Class Constraint
- java.lang.Object
-
- com.google.ortools.constraintsolver.BaseObject
-
- com.google.ortools.constraintsolver.PropagationBaseObject
-
- com.google.ortools.constraintsolver.Constraint
-
- Direct Known Subclasses:
CastConstraint,DisjunctiveConstraint,GlobalVehicleBreaksConstraint,Pack,TypeRegulationsConstraint
public class Constraint extends PropagationBaseObject
A constraint is the main modeling object. It provides two methods:
- Post() is responsible for creating the demons and attaching them to
immediate demons().
- InitialPropagate() is called once just after Post and performs
the initial propagation. The subsequent propagations will be performed
by the demons Posted during the post() method.
-
-
Field Summary
-
Fields inherited from class com.google.ortools.constraintsolver.BaseObject
swigCMemOwn
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedConstraint(long cPtr, boolean cMemoryOwn)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(ModelVisitor visitor)Accepts the given visitor.voiddelete()protected voidfinalize()protected static longgetCPtr(Constraint obj)voidinitialPropagate()This method performs the initial propagation of the
constraint.booleanisCastConstraint()Is the constraint created by a cast from expression to integer variable?voidpost()This method is called when the constraint is processed by the
solver.voidpostAndPropagate()Calls Post and then Propagate to initialize the constraints.protected static longswigRelease(Constraint obj)java.lang.StringtoString()IntVarvar()Creates a Boolean variable representing the status of the constraint
(false = constraint is violated, true = constraint is satisfied).-
Methods inherited from class com.google.ortools.constraintsolver.PropagationBaseObject
baseName, enqueueDelayedDemon, enqueueVar, freezeQueue, getCPtr, hasName, name, reset_action_on_fail, set_variable_to_clean_on_fail, setName, solver, swigRelease, unfreezeQueue
-
Methods inherited from class com.google.ortools.constraintsolver.BaseObject
getCPtr, swigRelease
-
-
-
-
Method Detail
-
getCPtr
protected static long getCPtr(Constraint obj)
-
swigRelease
protected static long swigRelease(Constraint obj)
-
finalize
protected void finalize()
- Overrides:
finalizein classPropagationBaseObject
-
delete
public void delete()
- Overrides:
deletein classPropagationBaseObject
-
post
public void post()
This method is called when the constraint is processed by the
solver. Its main usage is to attach demons to variables.
-
initialPropagate
public void initialPropagate()
This method performs the initial propagation of the
constraint. It is called just after the post.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classPropagationBaseObject
-
postAndPropagate
public void postAndPropagate()
Calls Post and then Propagate to initialize the constraints. This
is usually done in the root node.
-
accept
public void accept(ModelVisitor visitor)
Accepts the given visitor.
-
isCastConstraint
public boolean isCastConstraint()
Is the constraint created by a cast from expression to integer variable?
-
var
public IntVar var()
Creates a Boolean variable representing the status of the constraint
(false = constraint is violated, true = constraint is satisfied). It
returns nullptr if the constraint does not support this API.
-
-