This class is used to iterate on all assignments that can be obtained by deliberately flipping 'n' variables from the reference solution, 'n' being smaller than or equal to max_num_decisions.
- Note
- one deliberate variable flip may lead to many other flips due to constraint propagation, those additional flips are not counted in 'n'.
Definition at line 531 of file bop_ls.h.
bool operations_research::bop::LocalSearchAssignmentIterator::NextAssignment |
( |
| ) |
|
Move to the next assignment. Returns false when the search is finished.
We only look for potential one flip repairs if we reached the end of the LS tree. I tried to do that at every level, but it didn't change the result much on the set-partitionning example I was using.
- Todo
- (user): Perform more experiments with this.
Temporarily apply the potential repair and see if it worked!
If possible, go deeper, i.e. take one more decision.
If not, backtrack to the first node that still has untried way to fix its associated constraint. Update it to the next untried way.
All nodes have been explored.
Apply the next decision, i.e. the literal of the flipped variable.
Definition at line 801 of file bop_ls.cc.
void operations_research::bop::LocalSearchAssignmentIterator::SynchronizeSatWrapper |
( |
| ) |
|
Synchronize the SatWrapper with our current search state. This needs to be called before calls to NextAssignment() if the underlying SatWrapper was used by someone else than this class.
In order to restore the synchronization from any state, we backtrack everything and retry to take the same decisions as before. We stop at the first one that can't be taken.
Note(user): at this stage, the sat trail contains the fixed variables. There will almost always be at the same value in the reference solution. However since the objective may be over-constrained in the sat_solver, it is possible that some variable where propagated to some other values.
Definition at line 762 of file bop_ls.cc.