|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.cpsolver.ifs.model.Variable
public class Variable
Generic variable.
Besides a domain of values, a variable also contains information about assigned value,
the value assigned in the best ever found solution and also the initial value (minimal
perturbations problem). It also knows what constraints are associated with this variable and
has a unique id.
Value
,
Model
,
Solver
Field Summary | |
---|---|
protected long |
iId
|
protected Value |
iValue
Assigned value |
Constructor Summary | |
---|---|
Variable()
Constructor |
|
Variable(Value initialValue)
Constructor |
Method Summary | |
---|---|
void |
addContstraint(Constraint constraint)
Adds a constraint. |
void |
addVariableListener(VariableListener listener)
Adds variable listener |
void |
assign(long iteration,
Value value)
Assign value to this variable. |
int |
compareTo(Object o)
|
Vector |
constraints()
Return the list of constraints associated with this variable |
Hashtable |
constraintVariables()
Returns a table of all variables linked with this variable by a constraint. |
long |
countAssignments()
Return how many times was this variable assigned in the past. |
boolean |
equals(Object o)
|
Value |
getAssignment()
Returns current assignment |
Value |
getBestAssignment()
Returns the value from the best ever found soultion. |
long |
getBestAssignmentIteration()
Returns the iteration when the best value was assigned |
String |
getDescription()
Variable's description -- for printing purposes |
Object |
getExtra()
Extra information to which can be used by an extension (see Extension ). |
long |
getId()
Unique id |
Value |
getInitialAssignment()
Returns initial assignment |
Model |
getModel()
Model, the variable belong to |
String |
getName()
Variable's name -- for printing purposes |
Vector |
getVariableListeners()
Return variable listeners |
Vector |
hardConstraints()
Return the list of hard constraints associated with this variable |
boolean |
hasAssignment()
Returns true if the variable is assigned |
int |
hashCode()
|
boolean |
hasInitialAssignment()
Returns true if the variable has an initial assignment |
boolean |
hasValues()
True, if the variable's domain is not empty |
long |
lastAssignmentIteration()
Returns the iteration when the variable was assigned for the last time (-1 if never) |
long |
lastUnassignmentIteration()
Returns the iteration when the variable was unassigned for the last time (-1 if never) |
void |
removeContstraint(Constraint constraint)
Removes a constraint. |
void |
removeInitialValue()
Permanently remove the initial value from the variable's domain -- for testing MPP |
void |
removeValue(long iteration,
Value value)
Permanently remove a value from variables domain. |
void |
removeVariableListener(VariableListener listener)
Removes variable listener |
void |
setBestAssignment(Value value)
Sets variable's value of the best ever found solution. |
void |
setExtra(Object object)
Extra information to which can be used by an extension (see Extension ). |
void |
setInitialAssignment(Value initialValue)
Sets initial assignment |
void |
setModel(Model model)
Set the model to which the variable belongs to |
protected void |
setValues(Vector values)
Sets the domain |
Vector |
softConstraints()
Return the list of soft constraints associated with this variable |
String |
toString()
|
void |
unassign(long iteration)
Unassign value from this variable. |
Vector |
values()
Domain |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected long iId
protected Value iValue
Constructor Detail |
---|
public Variable()
public Variable(Value initialValue)
initialValue
- initial value (minimal-perturbation problem)Method Detail |
---|
public Model getModel()
public void setModel(Model model)
public Vector values()
protected void setValues(Vector values)
public boolean hasValues()
public Value getAssignment()
public boolean hasAssignment()
public Value getInitialAssignment()
public void setInitialAssignment(Value initialValue)
public boolean hasInitialAssignment()
public void assign(long iteration, Value value)
iteration
- current iterationvalue
- the value to be assignedpublic void unassign(long iteration)
iteration
- current iterationpublic long countAssignments()
public void addContstraint(Constraint constraint)
Model.addConstraint(Constraint)
is called.
constraint
- added constraintpublic void removeContstraint(Constraint constraint)
Model.removeConstraint(Constraint)
is called.
constraint
- added constraintpublic Vector constraints()
public Vector hardConstraints()
public Vector softConstraints()
public String toString()
toString
in class Object
public long getId()
public int hashCode()
hashCode
in class Object
public String getName()
public String getDescription()
public void setBestAssignment(Value value)
Model.saveBest()
is called.
public Value getBestAssignment()
public long getBestAssignmentIteration()
public long lastAssignmentIteration()
public long lastUnassignmentIteration()
public int compareTo(Object o)
compareTo
in interface Comparable
public boolean equals(Object o)
equals
in class Object
public void addVariableListener(VariableListener listener)
public void removeVariableListener(VariableListener listener)
public Vector getVariableListeners()
public void setExtra(Object object)
Extension
).
public Object getExtra()
Extension
).
public void removeValue(long iteration, Value value)
public Hashtable constraintVariables()
public void removeInitialValue()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |