|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectchoco.cp.model.CPModel
public class CPModel
A model is a global structure containing variables bound by listeners as well as solutions or strategy parameters
Field Summary | |
---|---|
protected TIHIterator<Constraint> |
_iterator
|
protected ComponentConstraintWithSubConstraints |
clausesStore
|
protected DeterministicIndicedList<Variable> |
constantVars
All the constant vars in the model |
protected DeterministicIndicedList<Constraint> |
constraints
All the constraint of the model |
protected Boolean |
defDecExp
Decomposed expression |
protected DeterministicIndicedList<IntegerExpressionVariable> |
expVars
All the search intVars in the model. |
protected DeterministicIndicedList<RealVariable> |
floatVars
All the float vars in the model. |
protected DeterministicIndicedList<IntegerVariable> |
intVars
All the search intVars in the model. |
protected static Logger |
LOGGER
|
protected int |
nbBoolVar
|
static Properties |
properties
Properties file |
protected DeterministicIndicedList<SetVariable> |
setVars
All the set intVars in the model. |
protected DeterministicIndicedList<MultipleVariables> |
storedMultipleVariables
|
Constructor Summary | |
---|---|
CPModel()
Constructor. |
|
CPModel(int nbCstrs,
int nbIntVars,
int nbSetVars,
int nbRealVars,
int nbCsts,
int nbExpVars,
int nbMultVars)
Constructor. |
Method Summary | ||
---|---|---|
void |
addConstraint(Constraint... c)
Deprecated. |
|
void |
addConstraint(Constraint c)
Add one constraint to the model. |
|
void |
addConstraint(String options,
Constraint... c)
Deprecated. |
|
void |
addConstraint(String options,
Constraint c)
Add one constraint to the model. |
|
void |
addConstraints(Constraint... c)
Add one or more constraint to the model. |
|
void |
addConstraints(String options,
Constraint... tabc)
Add constraints to the model |
|
void |
addOptions(String options,
IOptions... element)
|
|
void |
addVariable(String options,
Variable... v)
Deprecated. |
|
void |
addVariable(String options,
Variable v)
Add one variable with options to the model |
|
void |
addVariable(Variable... v)
Deprecated. |
|
void |
addVariable(Variable v)
Add a variable to the model |
|
void |
addVariables(String options,
Variable... tabv)
Add variables to CPModel. |
|
void |
addVariables(Variable... tabv)
Add variables to the model. |
|
String |
constraintsToString()
Create and return a string representation of the constraints of the Model |
|
boolean |
contains(Constraint c)
|
|
IntegerConstantVariable |
getConstantVar(int i)
Returns a constant variable. |
|
Constraint |
getConstraint(int i)
Network management: Retrieve a constraint by its index. |
|
DisposableIterator<Constraint> |
getConstraintByType(ConstraintType t)
Return an iterator over constraint of a certain type |
|
Iterator<Constraint> |
getConstraintIterator()
Return an iterator over the constraints of the model |
|
Iterator<Variable> |
getConstVarIterator()
Retrieves an iterator over constantes variables of the model |
|
Boolean |
getDefaultExpressionDecomposition()
Return the default expression decomposition |
|
Iterator<IntegerExpressionVariable> |
getExprVarIterator()
|
|
Iterator<Constraint> |
getIntConstraintIterator()
Deprecated. |
|
IntegerVariable |
getIntVar(int i)
Network management: Retrieve a variable by its index (all integer variables of the model are numbered in sequence from 0 on) |
|
int |
getIntVarIndex(IntDomainVar c)
Deprecated. |
|
int |
getIntVarIndex(IntVar c)
Deprecated. |
|
Iterator<IntegerVariable> |
getIntVarIterator()
Retrieves an iterator over IntegerVariables of the model |
|
Iterator<MultipleVariables> |
getMultipleVarIterator()
Retrieves an iterator over MultipleVariables of the model (if stored) |
|
int |
getNbBoolVar()
return the number of boolean variable (with binary domain) of the model |
|
int |
getNbConstantVars()
Returns the number of variables modelling constant. |
|
int |
getNbConstraintByType(ConstraintType t)
Return the number of constraint of a certain type |
|
int |
getNbConstraints()
retrieving the total number of constraint |
|
int |
getNbIntVars()
retrieving the total number of variables |
|
int |
getNbRealVars()
Returns the number of variables modelling real numbers. |
|
int |
getNbSetVars()
Returns the number of variables modelling real numbers. |
|
int |
getNbStoredMultipleVars()
Returns the number of stored multiple variables. |
|
int |
getNbTotVars()
Return the total numbers of variables of the model |
|
RealVariable |
getRealVar(int i)
Returns a real variable. |
|
Iterator<RealVariable> |
getRealVarIterator()
Retrieves an iterator over RealVariables of the model |
|
SetVariable |
getSetVar(int i)
Returns a set variable. |
|
Iterator<SetVariable> |
getSetVarIterator()
Retrieves an iterator over SetVariables of the model |
|
MultipleVariables |
getStoredMultipleVar(int i)
Returns a multiple variable. |
|
String |
pretty()
pretty printing of the object. |
|
static CPModel |
readFromFile(File file)
Restore flatten CPModel from the given file . |
|
void |
remove(Object ob)
|
|
void |
removeConstraint(Constraint c)
Remove a constraint from the model. |
|
void |
removeConstraints()
Empty this by removing everry added constraints. |
|
protected
|
removeVariable(E v,
DeterministicIndicedList<E> vars)
Deprecated. |
|
void |
removeVariable(Variable... v)
Deprecated. |
|
void |
removeVariable(Variable v)
Remove one variable from the model (also remove constraints linked to the variable) |
|
void |
removeVariables(Variable... v)
Remove one or more variables from the model (also remove constraints linked to the variables) |
|
protected
|
remVariable(E v)
|
|
void |
setDefaultExpressionDecomposition(Boolean defDecExp)
Set the default expression decomposition (BEWARE : it only concerns expression without particular decomposition option) If decomposedExp is set to false: Every expression is then used to check a tuple in a dynamic way just like a nary relation that is defined without listing all the possible tuples. |
|
String |
solutionToString()
Return a string representation of a solution. !! |
|
String |
varsToString()
Create and return a string representation of the variables of the Model |
|
static File |
writeInFile(CPModel model)
Kicks off the serialization mechanism and flatten the model into a file
in the default temporary-file directory. |
|
static void |
writeInFile(CPModel model,
File file)
Kicks off the serialization mechanism and flatten the model into the given file . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final Logger LOGGER
protected final DeterministicIndicedList<Constraint> constraints
protected final DeterministicIndicedList<IntegerVariable> intVars
protected int nbBoolVar
protected final DeterministicIndicedList<SetVariable> setVars
protected final DeterministicIndicedList<RealVariable> floatVars
protected final DeterministicIndicedList<Variable> constantVars
protected final DeterministicIndicedList<IntegerExpressionVariable> expVars
protected final DeterministicIndicedList<MultipleVariables> storedMultipleVariables
protected Boolean defDecExp
protected ComponentConstraintWithSubConstraints clausesStore
protected TIHIterator<Constraint> _iterator
public static final Properties properties
Constructor Detail |
---|
public CPModel()
public CPModel(int nbCstrs, int nbIntVars, int nbSetVars, int nbRealVars, int nbCsts, int nbExpVars, int nbMultVars)
nbCstrs
- estimated number of constraintsnbIntVars
- estimated number of integer variablesnbSetVars
- estimated number of set variablesnbRealVars
- estimated number of real variablesnbCsts
- estimated number of constantsnbExpVars
- estimated number of expression variablesnbMultVars
- estimated number of multiples variablesMethod Detail |
---|
public void removeConstraints()
this
by removing everry added constraints. A consequence is that every variables declared
will also be removed properly.
this
becomes obsolet and variables or constraints are shared
between mutliple models. This prevents from alive references of useless constraints within variables which
consequences can be slowing down execution and large memory usage with useless calls to gc.
public String pretty()
IPretty
pretty
in interface IPretty
public String varsToString()
Model
varsToString
in interface Model
public String constraintsToString()
Model
constraintsToString
in interface Model
public String solutionToString()
Model
solutionToString
in interface Model
IPretty.pretty()
@Deprecated public int getIntVarIndex(IntDomainVar c)
Model
getIntVarIndex
in interface Model
c
- Solver variable
@Deprecated public int getIntVarIndex(IntVar c)
Model
getIntVarIndex
in interface Model
c
- the int var
public Boolean getDefaultExpressionDecomposition()
Model
getDefaultExpressionDecomposition
in interface Model
public void setDefaultExpressionDecomposition(Boolean defDecExp)
Model
setDefaultExpressionDecomposition
in interface Model
defDecExp
- the new default expression decompositionpublic final IntegerVariable getIntVar(int i)
getIntVar
in interface Model
i
- index of the variable in the model
public final int getNbIntVars()
getNbIntVars
in interface Model
public final RealVariable getRealVar(int i)
getRealVar
in interface Model
i
- index of the variable
public final int getNbRealVars()
getNbRealVars
in interface Model
public final SetVariable getSetVar(int i)
getSetVar
in interface Model
i
- index of the variable
public final int getNbSetVars()
getNbSetVars
in interface Model
public int getNbTotVars()
Model
getNbTotVars
in interface Model
Model.getNbTotVars()
public IntegerConstantVariable getConstantVar(int i)
getConstantVar
in interface Model
i
- index of the variable
public int getNbConstantVars()
getNbConstantVars
in interface Model
public int getNbStoredMultipleVars()
Model
getNbStoredMultipleVars
in interface Model
public MultipleVariables getStoredMultipleVar(int i)
Model
getStoredMultipleVar
in interface Model
i
- index of the variable
public final int getNbConstraints()
getNbConstraints
in interface Model
public final Constraint getConstraint(int i)
getConstraint
in interface Model
i
- index of the constraint in the model
@Deprecated public Iterator<Constraint> getIntConstraintIterator()
getIntConstraintIterator
in interface Model
getConstraintIterator()
public Iterator<Constraint> getConstraintIterator()
getConstraintIterator
in interface Model
public DisposableIterator<Constraint> getConstraintByType(ConstraintType t)
Model
getConstraintByType
in interface Model
t
- type
public int getNbConstraintByType(ConstraintType t)
Model
getNbConstraintByType
in interface Model
t
- the type of constraint
public void addOptions(String options, IOptions... element)
addOptions
in interface Model
public void addVariable(Variable v)
addVariable
in interface Model
v
- a variable
This method use default options.
But User can define its own one.
See CPModel.addVariable(String options, Variable... tabv) for more details.public void addVariable(String options, Variable v)
addVariable
in interface Model
options
- define options of the variables
This method use default options.
But User can define its own one.
See CPModel.addVariable(String options, Variable... tabv) for more details.v
- one or more variables@Deprecated public void addVariable(Variable... v)
addVariable
in interface Model
v
- one or more variablesModel.addVariables(choco.kernel.model.variables.Variable[])
@Deprecated public void addVariable(String options, Variable... v)
addVariable
in interface Model
options
- defines options of the variablesv
- one or more variablesModel.addVariables(String, choco.kernel.model.variables.Variable[])
public void addVariables(Variable... tabv)
addVariables
in interface Model
tabv
- : variables to add
This method use default options.
But User can define its own one.
See CPModel.addVariable(String options, Variable... tabv) for more details.public void addVariables(String options, Variable... tabv)
addVariables
in interface Model
options
- : String that allows user to precise som parameters to the model concerning the variable tabvtabv
- : variables to add
For IntegerVariable, available options are :
choco.Options.V_ENUM
to force Solver to create enumerated domain variables (default options if options is empty)choco.Options.V_BOUND
to force Solver to create bounded domain variableschoco.Options.V_BTREE
to force Solver to create binary tree domain variableschoco.Options.V_BLIST
to force Solver to create bipartite list domain variableschoco.Options.V_LINK
to force Solver to create linked list domain variableschoco.Options.V_ENUM
to force Solver to create set variables with enumerated caridinality (default options if options is empty)choco.Options.V_BOUND
to force Solver to create set variables with bounded cardinalitychoco.Options.V_DECISION
to force variable to be a decisional onechoco.Options.V_NO_DECISION
to force variable to be removed from the pool of decisionnal variableschoco.Options.V_OBJECTIVE
to define the variable to optimizepublic int getNbBoolVar()
@Deprecated protected <E extends Variable> void removeVariable(E v, DeterministicIndicedList<E> vars)
protected <E extends Variable> void remVariable(E v)
public void remove(Object ob)
public void removeConstraint(Constraint c)
Model
removeConstraint
in interface Model
c
- the constraint to remove@Deprecated public void removeVariable(Variable... v)
removeVariable
in interface Model
v
- variables to removeModel.removeVariables(choco.kernel.model.variables.Variable[])
public void removeVariable(Variable v)
removeVariable
in interface Model
v
- the variable to removepublic void removeVariables(Variable... v)
removeVariables
in interface Model
v
- variables to remove@Deprecated public void addConstraint(Constraint... c)
addConstraint
in interface Model
c
- one or more constraintModel.addConstraints(choco.kernel.model.constraints.Constraint[])
@Deprecated public void addConstraint(String options, Constraint... c)
addConstraint
in interface Model
options
- defines options of the constraintc
- one or more constraintModel.addConstraints(choco.kernel.model.constraints.Constraint[])
public void addConstraint(Constraint c)
addConstraint
in interface Model
c
- one constraintpublic void addConstraints(Constraint... c)
addConstraints
in interface Model
c
- one or more constraintpublic void addConstraint(String options, Constraint c)
addConstraint
in interface Model
options
- defines options of the constraintc
- one constraintpublic void addConstraints(String options, Constraint... tabc)
addConstraints
in interface Model
options
- : options of constrainttabc
- : constraints to add
Options of CPModel must be prefixed with cp.
The following options are available:
public Iterator<IntegerVariable> getIntVarIterator()
Model
getIntVarIterator
in interface Model
public Iterator<RealVariable> getRealVarIterator()
Model
getRealVarIterator
in interface Model
public Iterator<SetVariable> getSetVarIterator()
Model
getSetVarIterator
in interface Model
public Iterator<Variable> getConstVarIterator()
Model
getConstVarIterator
in interface Model
public Iterator<IntegerExpressionVariable> getExprVarIterator()
public Iterator<MultipleVariables> getMultipleVarIterator()
Model
getMultipleVarIterator
in interface Model
public boolean contains(Constraint c)
contains
in interface Model
public static void writeInFile(CPModel model, File file) throws IOException
model
into the given file
.
model
- to flattenfile
- scope file
IOException
- if an I/O exception occurs.public static File writeInFile(CPModel model) throws IOException
model
into a file
in the default temporary-file directory.
model
- to flattenfile
- scope file
IOException
- if an I/O exception occurs.public static CPModel readFromFile(File file) throws IOException, ClassNotFoundException
CPModel
from the given file
.
file
- input file
CPModel
IOException
- if an I/O exception occurs.
ClassNotFoundException
- if wrong flattened object.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |