#include <Queens.h>
Inheritance diagram for Constraint:

Public Types | |
|
typedef FastVector< Variable * >::const_iterator | variable_iterator |
Public Member Functions | |
| Constraint (int queens=0) | |
| virtual bool | check () const |
| Constraint (Problem &problem) | |
| Constraint (Problem &problem, const Constraint &constraint) | |
| double | weight () const |
| double | weight (const Variable &variable, const Value &value) const |
| double | minWeight () const |
| double | maxWeight () const |
| void | buildWrapper (const wstring &model, size_t nPairs, double probability, bool flawed) |
| void | buildEmpty () |
| Prepare an empty constraint (i.e. no allowed values). | |
| void | addPair (int value0, int value1) |
| Add a pair of allowed values to a constraint. | |
| virtual bool | check () const |
| bool | isFlawless () const |
| ulonglong | allowedTuples () const |
| Return the number of tuples allowed by the constraint. | |
| virtual wostream & | print (wostream &wos) const |
| Constraint () | |
| virtual | ~Constraint () |
| Destructor. | |
| variable_iterator | add (Variable &variable) |
| Add `variable' to the list of variables in this constraint. | |
| void | remove (Variable &variable, bool recursive=false) |
| Remove `variable' from the list of variables in this constraint. | |
| void | setId (id_t id) |
| Set the constraint's id. | |
| id_t | id () const |
| Return the constraint's id. | |
| virtual wstring | name () const |
| virtual wstring | color () const |
| virtual wstring | textColor () const |
| bool | isActive () const |
| void | activate () |
| Activate the constraint. | |
| void | deactivate () |
| Deactivate the constraint. | |
| bool | isComplete () const |
| bool | involves (const Variable &variable) const |
| Variable & | pair (const Variable &variable) const |
| size_t | variables () const |
| size_t | order () const |
| Same as `variables()'. Return the order of the constraint. | |
| const variable_iterator | beginVariables () const |
| Return an iterator to the first variable in this constraint. | |
| const variable_iterator | endVariables () const |
| Return an interator past the last variable in this constraint. | |
| const variable_iterator | secondVariable () const |
| Variable & | findVariable (bool instantiated=false) const |
| bool | isSatisfied () const |
| virtual bool | check () const =0 |
| virtual bool | propagate (Variable &) |
| bool | tryOut (Variable &variable0, Value &value0, Variable &variable1, Value &value1) const |
| virtual ulonglong | validTuples () const |
| ulonglong | maxTuples () const |
| long double | tightness () const |
| bool | isLoose () const |
| virtual ulonglong | invalidTuples () const |
| ulonglong | checks () const |
| Return the number of constraint checks for this constraint. | |
| ulonglong | failures () const |
| Return the number of constraint check failures for this constraint. | |
| virtual void | init () |
| virtual void | done () |
| Cleanup. Make sure you call this from derived classes. | |
| size_t | instantiatedVariables () const |
| size_t | uninstantiatedVariables () const |
| void | inc () |
| Increment the number of instantiated variables. | |
| void | dec () |
| Decrement the number of instantiated variables. | |
| void | incrementWeight () |
| Increment the constraint's weight. | |
| ulonglong | weight () const |
| Return the constraint's weight. | |
| virtual wostream & | print (wostream &wos) const |
Friends | |
| CSP_API wostream & | operator<< (wostream &wos, const Constraint &constraint) |
| The constraint's output operator. | |
Abstract super class for defining CSP constraints.
|
|
Create a new constraint object. |
|
|
Return `true' if the constraint is satisfied by the current assignment. |
|
|
Return the constraint's drawing color, if the derived class decided to assign it one. The default color is "black".
|
|
|
Return the first instantiated/uninstantiated variable in the constraint. At least one such variable should exist at the time of the call.
|
|
|
This performs a few initializations that are required before starting a new search. Make sure you call this from derived classes. |
|
|
Return the number of instantiated variables involved in this constraint. |
|
|
Return the number of tuples disallowed by the constraint. |
|
|
Return `true' if this constraint involves the given variable, `false' otherwise.
|
|
|
Return the constraint's active status.
|
|
|
A constraint is considered `complete' if all the variables involved have been instantiated.
|
|
|
Return `true' if every value in the variables involved in this constraint has a support in the other variable. |
|
|
Return `true' if the constraint's tightness is 0 (i.e. all tuples are valid), `false' otherwise. |
|
|
Check whether or not the constraint is satisfied by the current assignments of its variables and update the constraint check counters. The implementation should work if the variables involved have had their domain reduced to a single value, regardless of wether they have been instantiated or not. Calling this method is the proper way of verifying that a constraint is satisfied.
|
|
|
Return the maximum number of tuples allowed by the constraint, which is the product of the domain sizes of all the variables involved in the constraint. |
|
|
Return the constraint's name, if the derived class decided to assign it one. The default is to return the constraint's id as a string.
|
|
|
Given one variable involved in this (assumed binary) constraint, this method will return the other variable (the pair).
|
|
|
Print the constraint at the given stream.
|
|
|
Propagate this constraint. If you decide to overwrite this function, you can prune domains of other variables, provided that you make correct use of [save|restore|postpone|add]Diffs. This should work regardles of the arity of the constraint.
Reimplemented in AllDiff. |
|
|
This is for convenience only, since binary constraints are so common. Use this for binary constraints only!
|
|
|
Return the constraint's text color, if the derived class decided to assign it one. The default color is "black".
|
|
|
Return the constraint's tightness, i.e. 1-validTuples()/maxTuples(). |
|
||||||||||||||||||||
|
Check if the constraint is satisfied by the assignment of `value0' to `variable0' and `value1' to `variable1'. |
|
|
Return the number of uninstantiated variables involved in this constraint. |
|
|
Return the number of tuples allowed by the constraint. |
|
|
Return the number of variables involved in the constraint.
|
1.3.9.1