public class Variable<V extends Variable<V,T>,T extends Value<V,T>> extends Object implements Comparable<V>
Value
,
Model
,
Solver
Modifier and Type | Field and Description |
---|---|
protected long |
iId |
protected T |
iValue
Assigned value
|
Constructor and Description |
---|
Variable()
Constructor
|
Variable(T initialValue)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
addContstraint(Constraint<V,T> constraint)
Adds a constraint.
|
void |
addVariableListener(VariableListener<T> listener)
Adds variable listener
|
void |
assign(long iteration,
T value)
Assign value to this variable.
|
int |
compareTo(V variable) |
List<Constraint<V,T>> |
constraints()
Return the list of constraints associated with this variable
|
Map<V,List<Constraint<V,T>>> |
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) |
T |
getAssignment()
Returns current assignment
|
T |
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
|
T |
getInitialAssignment()
Returns initial assignment
|
Model<V,T> |
getModel()
Model, the variable belong to
|
String |
getName()
Variable's name -- for printing purposes
|
List<VariableListener<T>> |
getVariableListeners()
Return variable listeners
|
List<Constraint<V,T>> |
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<V,T> constraint)
Removes a constraint.
|
void |
removeInitialValue()
Permanently remove the initial value from the variable's domain -- for
testing MPP
|
void |
removeValue(long iteration,
T value)
Permanently remove a value from variables domain.
|
void |
removeVariableListener(VariableListener<T> listener)
Removes variable listener
|
void |
setBestAssignment(T 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(T initialValue)
Sets initial assignment
|
void |
setModel(Model<V,T> model)
Set the model to which the variable belongs to
|
protected void |
setValues(List<T> values)
Sets the domain
|
List<Constraint<V,T>> |
softConstraints()
Return the list of soft constraints associated with this variable
|
String |
toString() |
void |
unassign(long iteration)
Unassign value from this variable.
|
List<T> |
values()
Domain
|
public Variable()
public boolean hasValues()
public T getAssignment()
public boolean hasAssignment()
public T getInitialAssignment()
public void setInitialAssignment(T initialValue)
public boolean hasInitialAssignment()
public void assign(long iteration, T value)
iteration
- current iterationvalue
- the value to be assignedpublic void unassign(long iteration)
iteration
- current iterationpublic long countAssignments()
public void addContstraint(Constraint<V,T> constraint)
Model.addConstraint(Constraint)
is called.constraint
- added constraintpublic void removeContstraint(Constraint<V,T> constraint)
Model.removeConstraint(Constraint)
is
called.constraint
- added constraintpublic List<Constraint<V,T>> constraints()
public List<Constraint<V,T>> hardConstraints()
public List<Constraint<V,T>> softConstraints()
public long getId()
public String getDescription()
public void setBestAssignment(T value)
Model.saveBest()
is called.public T getBestAssignment()
public long getBestAssignmentIteration()
public long lastAssignmentIteration()
public long lastUnassignmentIteration()
public void addVariableListener(VariableListener<T> listener)
public void removeVariableListener(VariableListener<T> listener)
public List<VariableListener<T>> getVariableListeners()
public void setExtra(Object object)
Extension
).public Object getExtra()
Extension
).public void removeValue(long iteration, T value)
public Map<V,List<Constraint<V,T>>> constraintVariables()
public void removeInitialValue()