public abstract class IloCustomConstraint extends java.lang.Object implements IloPropagator
This is the base class for custom constraint. You need to subclass this to implement your own constraint.
The IloCustomConstraint class has a simple interface and requires you to define one abstract method
execute which will perform the required propagation. In addition, you must explicitly state which
variables are involved in the constraint. Whenever one of the variables that you stated changes its domain, the
propagator is called.
| Modifier | Constructor and Description |
|---|---|
protected |
IloCustomConstraint(IloCP cp)
This constructor is used in the constructor of your subclass as follows:
super(cp) |
| Modifier and Type | Method and Description |
|---|---|
void |
addVar(IloNumVar var)
This function should be called in the constructor of your subclass for each variable involved in the custom
constraint you are defining.
|
abstract void |
execute()
When subclassing the
IloCustomConstraint class to create your own custom constraint, it is the
execute function that you define. |
protected IloCP |
getCP()
Returns the embedded
IloCP. |
int |
getDomainSize(IloNumVar var)
The member function returns the number of domain elements of variable
var. |
double |
getMax(IloNumVar var)
The member function returns the maximum value of the domain of variable
var. |
double |
getMin(IloNumVar var)
The member function returns the minimum value of the domain of variable
var. |
java.lang.String |
getName()
Accesses the name assigned to the invoking modeling object.
|
double |
getValue(IloNumVar var)
The member function returns the value of the variable
var. |
boolean |
isFixed(IloNumVar var)
The member function determines if the variable
var is fixed to a value. |
boolean |
isInDomain(IloNumVar var,
int value)
The member function determines if the value
value is in the current domain of the variable var. |
ilog.cp.IloCPEngine.IntVarIterator |
iterator(IloIntVar var)
This member function creates an iterator which iterates over the elements of the domain of
var. |
void |
removeValue(IloIntVar var,
int value)
This function can be called from the
execute member function of your subclass. |
void |
setMax(IloNumVar var,
double max)
This function can be called from the
execute member function of your subclass. |
void |
setMin(IloNumVar var,
double min)
This function can be called from the
execute member function of your subclass. |
void |
setName(java.lang.String name)
Sets the name of the invoking addable object.
|
void |
setRange(IloNumVar var,
double min,
double max)
This function can be called from the
execute member function of your subclass. |
void |
setValue(IloNumVar var,
double value)
This function can be called from the
execute member function of your subclass. |
void |
violate()
This function can be called from the
execute member function of your subclass. |
protected IloCustomConstraint(IloCP cp) throws IloException
super(cp)IloExceptionprotected IloCP getCP()
IloCP.public void addVar(IloNumVar var)
This function should be called in the constructor of your subclass for each variable involved in the custom constraint you are defining.
public void violate()
This function can be called from the execute member function of your subclass. It
indicates that the constraint is violated.
public void setMax(IloNumVar var, double max)
This function can be called from the execute member function of your subclass. It sets the
maximum value of var to max. Note that this modification is buffered. See
the interface documentation for an explanation of this.
public void setMin(IloNumVar var, double min)
This function can be called from the execute member function of your subclass. It sets the
minimum value of var to min. Note that this modification is buffered. See
the interface documentation for an explanation of this.
public void setRange(IloNumVar var, double min, double max)
This function can be called from the execute member function of your subclass. It sets the
minimum value of var to min and the maximum value to max. Note that that
this modification is buffered. See the interface documentation for an explanation of this.
public void setValue(IloNumVar var, double value)
This function can be called from the execute member function of your subclass. It sets the
value of var to value. Note that that this modification is buffered. See the
interface documentation for an explanation of this.
public void removeValue(IloIntVar var, int value)
This function can be called from the execute member function of your subclass. It removes
value value from the domain of variable var. Note that that this modification is
buffered. See the interface documentation for an explanation of this.
public double getMin(IloNumVar var)
var.
Note that as domain modifications are buffered inside propagators, this value does not include the domain modifications
made since the execute method of the propagator was entered.public double getMax(IloNumVar var)
var.
Note that as domain modifications are buffered inside propagators, this value does not include the domain modifications
made since the execute method of the propagator was entered.public double getValue(IloNumVar var)
var. If the var was not fixed
on entry to the execute function, an exception is raised.public int getDomainSize(IloNumVar var)
var. Note that as domain modifications
are buffered inside propagators, this value does not include the domain modifications made since the execute method
of the propagator was entered.public boolean isInDomain(IloNumVar var, int value)
value is in the current domain of the variable var.
Note that as domain modifications are buffered inside propagators, this function will return true if var
had value in its domain on entry to the execute method of the propagator. This is the case
even if that value has subsequently been removed from var during the current execution of execute.public boolean isFixed(IloNumVar var)
var is fixed to a value.
Note that as domain modifications are buffered inside propagators, this function will only return true if var
was fixed on entry to the execute method of the propagator.public ilog.cp.IloCPEngine.IntVarIterator iterator(IloIntVar var)
This member function creates an iterator which iterates over the elements of the domain of var.
Note that as modifications are buffered inside a propagator, this iteration will scan all values in the domain of
var as they were when the execute member function was entered.
public java.lang.String getName()
IloAddablenull is
returned.getName in interface IloAddablepublic void setName(java.lang.String name)
IloAddablenull as the argument.setName in interface IloAddablename - The name assigned to the invoking modeling object.
null can be passed as argument to remove an assigned
name from the invoking modeling object.public abstract void execute()
IloCustomConstraint class to create your own custom constraint, it is the
execute function that you define. When you overload this function in your subclass, this function should update
the domains of the variables of the constraint to make them consistent.execute in interface IloPropagator