lib/gecoder/interface/search.rb in gecoder-0.6.1 vs lib/gecoder/interface/search.rb in gecoder-0.7.0
- old
+ new
@@ -2,13 +2,11 @@
class Model
# Finds the first solution to the modelled problem and updates the variables
# to that solution. Returns the model if a solution was found, nil
# otherwise.
def solve!
- GC.disable
space = dfs_engine.next
- GC.enable
return nil if space.nil?
@active_space = space
return self
end
@@ -30,15 +28,13 @@
end
# Yields each solution that the model has.
def each_solution(&block)
dfs = dfs_engine
- GC.disable
while not (@active_space = dfs.next).nil?
yield self
end
- GC.enable
self.reset!
end
# Finds the optimal solution. Optimality is defined by the provided block
# which is given one parameter, a solution to the problem. The block should
@@ -66,15 +62,13 @@
perform_queued_gecode_interactions
end
# Perform the search.
- GC.disable
result = Gecode::Raw::bab(selected_space,
Gecode::Raw::Search::Config::MINIMAL_DISTANCE,
Gecode::Raw::Search::Config::ADAPTIVE_DISTANCE,
nil)
- GC.enable
# Reset the method used constrain calls and return the result.
Model.constrain_proc = nil
return nil if result.nil?