V
- VariableT
- Valuepublic 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 int |
iIndex |
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(int iteration,
T value)
Deprecated.
|
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.
|
boolean |
equals(Object o) |
T |
getAssignment()
Deprecated.
|
T |
getAssignment(Assignment<V,T> assignment)
Returns current assignment
|
Value<V,T>[] |
getAssignments()
Deprecated.
|
T |
getBestAssignment()
Returns the value from the best ever found solution.
|
long |
getBestAssignmentIteration()
Returns the iteration when the best value was assigned
|
String |
getDescription()
Variable's description -- for printing purposes
|
<X> X |
getExtra()
Extra information to which can be used by an extension (see
Extension ). |
long |
getId()
Unique id
|
int |
getIndex()
Unique index of a variable that was assigned by
Model.addVariable(Variable) . |
T |
getInitialAssignment()
Returns initial assignment
|
long |
getLastIteration()
Deprecated.
|
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()
Deprecated.
|
boolean |
hasAssignment(Assignment<V,T> assignment)
Returns true if the variable is assigned
|
int |
hashCode() |
boolean |
hasInitialAssignment()
Returns true if the variable has an initial assignment
|
boolean |
hasValues()
Deprecated.
|
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 variable's domain.
|
void |
removeVariableListener(VariableListener<T> listener)
Removes variable listener
|
void |
setAssignment(T value)
Deprecated.
|
void |
setBestAssignment(T value,
long iteration)
Sets variable's value of the best ever found solution.
|
<X> void |
setExtra(X object)
Extra information to which can be used by an extension (see
Extension ). |
void |
setIndex(int index)
Unique index of a variable, only to be assigned by
Model.addVariable(Variable) . |
void |
setInitialAssignment(T initialValue)
Sets initial assignment
|
void |
setLastIteration(long iteration)
Deprecated.
|
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(int iteration)
Deprecated.
|
List<T> |
values()
Deprecated.
|
List<T> |
values(Assignment<V,T> assignment)
Variable's domain
|
void |
variableAssigned(Assignment<V,T> assignment,
long iteration,
T value)
A value was assigned to this variable
|
void |
variableUnassigned(Assignment<V,T> assignment,
long iteration,
T oldValue)
A value was unassigned from this variable
|
public Variable()
public void setModel(Model<V,T> model)
model
- problem model@Deprecated public List<T> values()
values(Assignment)
instead.public List<T> values(Assignment<V,T> assignment)
assignment
- current assignment (if the domain is dependent on the current assignment)protected void setValues(List<T> values)
values
- variable's domain to cache@Deprecated public boolean hasValues()
@Deprecated public T getAssignment()
Assignment.getValue(Variable)
or getAssignment(Assignment)
instead.@Deprecated public boolean hasAssignment()
hasAssignment(Assignment)
instead.public T getAssignment(Assignment<V,T> assignment)
assignment
- current assignmentpublic boolean hasAssignment(Assignment<V,T> assignment)
assignment
- current assignment@Deprecated public void setAssignment(T value)
DefaultSingleAssignment
.value
- current assignment@Deprecated public Value<V,T>[] getAssignments()
DefaultParallelAssignment
.public T getInitialAssignment()
public void setInitialAssignment(T initialValue)
initialValue
- initial assignmentpublic boolean hasInitialAssignment()
@Deprecated public void assign(int iteration, T value)
Assignment.assign(long, Value)
instead.iteration
- current iterationvalue
- the value to be assigned@Deprecated public void unassign(int iteration)
Assignment.unassign(long, Variable)
instead.iteration
- current iteration@Deprecated public long getLastIteration()
Assignment.getIteration(Variable)
instead.@Deprecated public void setLastIteration(long iteration)
DefaultSingleAssignment
.iteration
- current iterationpublic void variableAssigned(Assignment<V,T> assignment, long iteration, T value)
assignment
- current assignmentiteration
- current iterationvalue
- assigned valuepublic void variableUnassigned(Assignment<V,T> assignment, long iteration, T oldValue)
assignment
- current assignmentiteration
- current iterationoldValue
- unassigned valuepublic 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, long iteration)
Model.saveBest(Assignment)
is called.value
- a valueiteration
- value's assignment iterationpublic T getBestAssignment()
public long getBestAssignmentIteration()
public void addVariableListener(VariableListener<T> listener)
listener
- a variable listenerpublic void removeVariableListener(VariableListener<T> listener)
listener
- a variable listenerpublic List<VariableListener<T>> getVariableListeners()
public <X> void setExtra(X object)
Extension
).object
- extra objectpublic <X> X getExtra()
Extension
).public void removeValue(long iteration, T value)
iteration
- current iterationvalue
- value to be removed from this variable's domainpublic Map<V,List<Constraint<V,T>>> constraintVariables()
public void removeInitialValue()
public void setIndex(int index)
Model.addVariable(Variable)
.index
- an indexpublic int getIndex()
Model.addVariable(Variable)
.