Package org.jacop.satwrapper
Class SatChangesListener
java.lang.Object
org.jacop.satwrapper.SatChangesListener
- All Implemented Interfaces:
SolverComponent,AssertionListener,BackjumpListener,PropagateListener
public final class SatChangesListener
extends Object
implements AssertionListener, PropagateListener, BackjumpListener
this class listens to changes in literals in SAT solver, and reminds
what changes this implies for CP variables
- Version:
- 4.10
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Set<BooleanVar> private Coreprivate BitSetprivate Integer[]private Integer[]private SatWrapper -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()clears all sets, so that elements occurring in them later result only from later eventsvoidensureAccess(IntVar cpVar) gets sure we won't have a NullPointerExceptionvoidinitialize(Core core) initializes the component with the given solver.voidinitialize(SatWrapper wrapper) private voidonAssertion(int literal) this should be called every time a new boolean variable representing a CP proposition is asserted, but preferably only once per variable, so that it can later update the CP variables domainsvoidonAssertion(int literal, int level) Called when a variable is setvoidonBackjump(int oldLevel, int newLevel) clear on backjumpvoidonPropagate(int literal, int clauseId) called when a propagation occursvoidonRestart(int oldLevel) called when the solver restarts.toString()voidupdateCpVariables(int storeLevel) Using all data accumulated since last clear(), update the domain of the given CP variable
-
Field Details
-
wrapper
-
core
-
excludedValues
-
upperBounds
-
lowerBounds
-
intVarsToUpdate
-
booleanVarsToUpdate
-
-
Constructor Details
-
SatChangesListener
public SatChangesListener()
-
-
Method Details
-
clear
public void clear()clears all sets, so that elements occurring in them later result only from later events -
onPropagate
public void onPropagate(int literal, int clauseId) Description copied from interface:PropagateListenercalled when a propagation occurs- Specified by:
onPropagatein interfacePropagateListener- Parameters:
literal- the literal propagatedclauseId- the unique ID of the unit clause
-
onAssertion
public void onAssertion(int literal, int level) Description copied from interface:AssertionListenerCalled when a variable is set- Specified by:
onAssertionin interfaceAssertionListener- Parameters:
literal- the literal that is set propagation, false otherwiselevel- the search level
-
onBackjump
public void onBackjump(int oldLevel, int newLevel) clear on backjump- Specified by:
onBackjumpin interfaceBackjumpListener- Parameters:
oldLevel- the level at which the solver was before backtrackingnewLevel- the level to which the solver backtracks
-
onRestart
public void onRestart(int oldLevel) Description copied from interface:BackjumpListenercalled when the solver restarts.components that want to be warned about restarts should put themselves in Core.restartModules.
- Specified by:
onRestartin interfaceBackjumpListener- Parameters:
oldLevel- the level at which the solver was before restarting
-
onAssertion
private void onAssertion(int literal) this should be called every time a new boolean variable representing a CP proposition is asserted, but preferably only once per variable, so that it can later update the CP variables domains- Parameters:
literal- the boolean literal that has been asserted
-
updateCpVariables
public void updateCpVariables(int storeLevel) Using all data accumulated since last clear(), update the domain of the given CP variable- Parameters:
storeLevel- the current level of the store
-
ensureAccess
gets sure we won't have a NullPointerException- Parameters:
cpVar- the CP variable we are about to access
-
toString
-
initialize
Description copied from interface:SolverComponentinitializes the component with the given solver. May be called only once. This method must register the component to the solver for the run.- Specified by:
initializein interfaceSolverComponent- Parameters:
core- core component to initialize
-
initialize
-