#include <Variable.h>
Inheritance diagram for Variable:

Public Types | |
|
typedef FastVector< Constraint * >::const_iterator | constraint_iterator |
| Iterator through a vector of constraints. | |
Public Member Functions | |
| Variable (const Problem &problem, int min, int max, int index) | |
| int | index () const |
| Variable (const Problem &problem, int min, int max, int row, int column) | |
| Variable (const Problem &problem, const vector< csp::values::Int > &values, int row, int column) | |
| int | row () const |
| int | column () const |
| virtual wstring | color () const |
| virtual wstring | textColor () const |
| virtual wstring | shape () const |
| virtual void | setBackdoorStatus (bool status) |
| virtual void | setBackdoorKeyStatus (bool status) |
| virtual void | setBranchingStatus (bool status) |
| Variable (const Problem &problem, int min, int max, int index) | |
| int | index () const |
| virtual wstring | color () const |
| virtual wstring | textColor () const |
| virtual wstring | shape () const |
| virtual void | setBackdoorStatus (bool status) |
| virtual void | setBackdoorKeyStatus (bool status) |
| virtual void | setBranchingStatus (bool status) |
| Variable (const Problem &problem, const int min, const int max) | |
| double | weight () const |
| double | minWeight () const |
| double | maxWeight () const |
| Value & | value () const |
| virtual wostream & | print (wostream &wos) const |
| virtual wstring | color () const |
| virtual wstring | textColor () const |
| virtual wstring | shape () const |
| virtual void | setBackdoorStatus (bool status) |
| virtual void | setBackdoorKeyStatus (bool status) |
| virtual void | setBranchingStatus (bool status) |
| Variable (const Problem &problem, const vector< csp::values::Int > &array, const wstring &name) | |
| virtual wstring | name () const |
| int | index () const |
| void | setColor (const wstring &color) |
| virtual wstring | color () const |
| virtual wstring | textColor () const |
| virtual wstring | shape () const |
| virtual void | setBackdoorStatus (bool status) |
| virtual void | setBackdoorKeyStatus (bool status) |
| virtual void | setBranchingStatus (bool status) |
| Variable (const Problem &problem) | |
| virtual | ~Variable () |
| Destructor. | |
| id_t | id () const |
| Return the variable's id. | |
| virtual wstring | name () const |
| virtual wstring | color () const |
| virtual wstring | textColor () const |
| virtual wstring | shape () const |
| void | setId (id_t id) |
| Set the variable's id. | |
| virtual void | setBackdoorStatus (bool) |
| virtual void | setBackdoorKeyStatus (bool) |
| virtual void | setBranchingStatus (bool) |
| const Problem & | problem () const |
| Return the problem to which this variable belongs to. | |
| constraint_iterator | add (Constraint &constraint) |
| Add a new constraint to this variable. | |
| void | remove (Constraint &constraint, bool recursive=false) |
| Remove constraint `c' from this variable. | |
| size_t | values () const |
| Return the number of values in the domain of the variable. | |
| Value & | value () const |
| Value & | value (id_t id) const |
| Domain::iterator | beginValues () |
| Return an iterator to the first value. | |
| Domain::iterator | endValues () |
| Return an iterator past the last value. | |
| Domain::const_iterator | beginValues () const |
| Return an iterator to the first value. | |
| Domain::const_iterator | endValues () const |
| Return an iterator past the last value. | |
| constraint_iterator | beginConstraints () const |
| Return an iterator to the first active constraint. | |
| constraint_iterator | endConstraints () const |
| Return an iterator past the last active constraint. | |
| constraint_iterator | beginInactiveConstraints () const |
| Return an iterator to the first inactive constraint. | |
| constraint_iterator | endInactiveConstraints () const |
| Return an iterator past the last inactive constraint. | |
| Domain & | domain () |
| Get the domain of a variable. | |
| const Domain & | domain () const |
| Get the domain of a variable. | |
| size_t | constraints () const |
| Return the number of active constraints in this variable. | |
| size_t | inactiveConstraints () const |
| Return the number of inactive constraints in this variable. | |
| size_t | hiddenConstraints () const |
| Return the number of hidden constraints in this variable. | |
| size_t | degree () const |
| ulonglong | weightedDegree () const |
| void | incrementDomainWipeouts () |
| Increment the number of domain wipe-outs for this variable. | |
| ulonglong | domainWipeouts () const |
| Return the number of domain wipe-outs for this variable. | |
| bool | isPast () const |
| Return `true' if this is a `past' variable. | |
| bool | isCurrent () const |
| Return `true' if this is a `current' variable. | |
| bool | isFuture () const |
| Return `true' if this is a `future' variable. | |
| bool | isInstantiated () const |
| Return `true' if the variable is instantiated. | |
| int | instantiationDepth () const |
| Return the instantiation depth. | |
| const vector< Domain * > & | diffs () const |
| void | saveDiffs () |
| void | restoreDiffs () |
| void | postponeDiffs () |
| void | addDiffs (Domain &diffs) |
| Value * | findSupport (Value &value, const Constraint &constraint, Variable &pair) |
| size_t | prune (const Constraint &constraint, Domain &diffs, bool consistent=false) |
| void | sortDomain () |
| virtual wostream & | print (wostream &wos) const |
| Print the variable at the given stream. | |
Protected Member Functions | |
| void | add (Value &v) |
| Add a new value to this variable's domain. | |
| void | remove (Value &v) |
| Remove a value from this variable's domain. | |
Friends | |
| class | Decomposition |
| class | Problem |
| The Problem class needs access to some of the Variable's internals. | |
| CSP_API wostream & | operator<< (wostream &wos, const Variable &variable) |
| Print the variable at the given stream. | |
|
|
Create a variable object.
|
|
|
This method does the actual saving of the domain of the variable. It should be called only when the variable is actually modified, to avoid unnecessary save/restore operations. The `domain' passed as an argument contains the values that have been removed from the variable's domain in the current modification. We only save the difference between the old state of the domain and the new one, to keep memory usage within reasonable limits. `addDiffs()' can be called multiple times - the values are merged with the previously saved values. `addDiffs()' will _move_ the values from the domain specified as a parameter to its stack of removed values.
|
|
|
Return the variable's drawing color, if the derived class decided to assign it one. The default color is "gray".
|
|
|
Return the current degree of this variable. Note that this is the same as constraints(), since the degree of the variable is given by the number of active constraints related to it. |
|
|
Return the set of values that have been removed from the current variable (per depth). |
|
||||||||||||||||
|
Given a value from the domain of this variable and a constraint in which this variable is involved, this function looks for a support on that constraint. This is done by temporary setting the domain of this variable to `value' and the domain of its pair, in turn, to all its values.
|
|
|
Return the variable's name, if the derived class decided to assign it one. The default is to return the variable's id as a string.
|
|
|
Postpone the latest saved differences for the domain of this variable. This usually happens when the algorithm can succesfully propagate the constraints on a variable. The differencess are merged into the previous level differences on the stack of saved domain differences. |
|
||||||||||||||||
|
Move from the domain of the variable into `diffs' all the values that are `consistent' or `inconsistent' with the given constraint. Beware that it is possible for this method to empty the domain of the current variable. Such a situation is normal and should be taken care of by the calling method.
|
|
|
Restore the domain of the variable to the domain it had at the time `saveDiffs()' was called for it. |
|
|
This method doesn't actually save the current state of the variable, it just records the fact that the corresponding `restoreDiffs()' call should restore the domain of the variable to the state it was in at the time `saveDiffs()' was called. Note however that this should not be thought of as a general mechanism for saving/restoring variables - it is just a mechanism that allows the library to control the modifications done by filters to the domains of uninstantiated variables. The basic idea is this. In the decomposition algorithm a variable is selected according to the heuristics in place and instantiated, then the state of all the remaining (uninstantiated) variables is saved. The next thing to do is check whether or not the instantiation breaks any constraint, so the filter gets called. It saves the current state of all the uninstantiated variables and then attempts to restore consistency by trying to eliminate all the values that are no longer supported, potentially modifying the domains of the variables. If the filter fails to restore consistency, then it undoes all the changes to the domains of the variables. However, if the filter succeeds, the restauration of the domain of the variables has to be postponed until the resulting subproblem is solved because the subproblem has to be solved with the filter modifications in place. Note that the mechanism for saving/restoring/postponing the state of variables is capable of figuring out the exact state that needs to be restored. That is, a call to restoreDiffs() does not necessarily match a call to saveDiffs() - it can restore the changes performed by a number of addDiffs()s at different depths, such that the state matches the previous state at that depth. That's because a filter can modify a variable several times during a single call, since the values of a variable can be inconsistent with different constraints. |
|
|
Hook to allow the decomposition to mark this variable as a backdoor key. This can be used to change the variable's graphical attributes for more useful graphs. The Decomposition object calls this hook to update the variable's status whenever a new solution is found.
|
|
|
Hook to allow the decomposition to mark this variable as belonging to a backdoor. This can be used to change the variable's graphical attributes for more useful graphs. The Decomposition object calls this hook to update the variable's status whenever a new solution is found.
|
|
|
Hook to allow the decomposition to mark this variable as a branching variable. This can be used to change the variable's graphical attributes for more useful graphs. The Decomposition object calls this hook to update the variable's status whenever a new solution is found.
|
|
|
Return the variable's drawing shape, if the derived class decided to assign it one. The default color is "ellipse".
|
|
|
Sort the domain of the variable in increasing order of ID of the values. |
|
|
Return the variable's text color, if the derived class decided to assign it one. The default color is "black".
|
|
|
Return the value with the given id.
|
|
|
Return the value of the variable. Should only be used after the variable has been instantiated. |
|
|
Return the current weighted degree of this variable. The weight of a constraint is 1 plus the number of times that constraint has failed. The weighted degree of a variable is the sum of all the weights of all the constraints involving that variable and at least one other unassigned variable. |
|
|
We give the Decomposition class access to this, to simplify the interface. This used to be part of Decomposition anyway, and it is only used there. |
1.3.9.1