Main Page | Class Hierarchy | Class List | File List | Class Members

Problem Class Reference

#include <Problem.h>

List of all members.

Public Types

typedef vhash_type::const_iterator variable_iterator
typedef chash_type::const_iterator constraint_iterator
typedef shash_type::const_iterator solution_iterator

Public Member Functions

 Problem (csp::RandomSequence &randomSequence)
 Problem (const Problem &problem)
virtual wstring name () const
void addNonConsecutiveConstraint (int index0, int index1)
void addDifferentConstraint (int index0, int index1)
virtual wostream & printSolution (wostream &wos) const
virtual wostream & print (wostream &wos) const
 Problem (csp::RandomSequence &randomSequence, int order, bool idempotency=false, bool symmetry=true, int holes=0, bool balanced=true)
 Problem (const Problem &problem)
 Problem (csp::RandomSequence &randomSequence, wifstream &wifs)
virtual wstring name () const
Variablevariable (int row, int column) const
int order () const
virtual bool isSolution () const
virtual void save (wofstream &wofs) const
virtual wostream & printSolution (wostream &wos) const
virtual wostream & print (wostream &wos) const
 Problem (csp::RandomSequence &randomSequence, int queens, bool compact=false, bool symmetry=true)
 Problem (const Problem &problem)
virtual wstring name () const
virtual wostream & printSolution (wostream &wos) const
virtual wostream & print (wostream &wos) const
 Problem (csp::RandomSequence &randomSequence, const wstring &model, bool flawed, bool weightSearch, size_t nVariables, size_t domainSize, double density, double tightness, bool nonStandardDensity=true, size_t weakSpots=0, size_t weakSpotConstraints=5)
 Problem (const Problem &problem)
 Problem (csp::RandomSequence &randomSequence, wifstream &wifs)
virtual wstring name () const
bool weightSearch () const
double weight () const
double minWeight () const
double maxWeight () const
double currentWeight () const
double minAcceptableWeight () const
double maxAcceptableWeight () const
void setMinAcceptableWeight (double minAcceptableWeight)
void setMaxAcceptableWeight (double maxAcceptableWeight)
double minFutureWeight () const
double maxFutureWeight () const
double idealWeight () const
void computeConstraintAcceptableWeightRange ()
virtual void save (wofstream &wofs) const
void loadSolutions (wifstream &wifs)
 Load solutions from a given file.
void saveSolution (wofstream &wofs) const
 Save the current solution to the given output stream.
virtual wostream & printSolution (wostream &wos) const
virtual wostream & print (wostream &wos) const
 Problem (csp::RandomSequence &randomSequence, const wstring &domainsFileName, const wstring &variablesFileName, const wstring &constraintsFileName)
 Problem (const Problem &problem)
virtual wstring name () const
void addDistanceConstraint (int index0, int index1, int distance)
void addEqualityConstraint (int index0, int index1, int distance)
virtual wostream & printSolution (wostream &wos) const
virtual wostream & print (wostream &wos) const
 Problem (RandomSequence &randomSequence)
 Default constructor.
virtual ~Problem ()
 Destructor.
virtual wstring name () const
virtual wstring signature () const
size_t variables () const
size_t constraints () const
size_t solutions () const
const variable_iterator beginVariables () const
 Return an iterator to the first variable in the problem.
const variable_iterator endVariables () const
 Return an iterator past the last variable in the problem.
const constraint_iterator beginConstraints () const
 Return an iterator to the first constraint in the problem.
const constraint_iterator endConstraints () const
 Return an iterator past the last constraint in the problem.
const solution_iterator beginSolutions () const
 Return an iterator to the first precomputed solution to the problem.
const solution_iterator endSolutions () const
 Return an iterator past the last precomputed solution to the problem.
Variablevariable (id_t id)
 Return the variable with the given id.
const Variablevariable (id_t id) const
 Return the variable with the given id.
Constraintconstraint (id_t id)
 Return the constraint with the given id.
const Constraintconstraint (id_t id) const
 Return the constraint with the given id.
virtual bool isSolution () const
bool isInternallyConsistent () const
bool isArcConsistent () const
virtual wostream & printSolution (wostream &wos) const
 Print the problem's solution to an output stream.
virtual void init ()
virtual void done ()
size_t maxDomainSize () const
RandomSequencerandomSequence () const
 Return the RandomSequence object used by this problem instance.
virtual wostream & print (wostream &wos) const
virtual void generateGraph (wostream &wos) const
virtual void save (wofstream &wofs) const
virtual void saveSolution (wofstream &wofs) const
variable_iterator add (Variable &variable)
void remove (Variable &variable)
constraint_iterator add (Constraint &constraint)
void remove (Constraint &constraint)
ulonglong totalCCKS () const
ulonglong failedCCKS () const
 Return the current number of constraint failures.

Protected Member Functions

void addConstraint (csp::Variable &variable0, csp::Variable &variable1, int queens)
void addVerticalConstraint (csp::Variable &variable0, csp::Variable &variable1)
void addDiagonalConstraint (csp::Variable &variable0, csp::Variable &variable1)
void addSymmetryConstraint (csp::Variable &variable0, csp::Variable &variable1, int queens)
 Problem (const Problem &problem)
void add (Solution &solution)
int nextRandomNumber (int limit)

Friends

CSP_API wostream & operator<< (wostream &wos, const Problem &problem)


Detailed Description

The super class of all the CSPs.


Constructor & Destructor Documentation

Problem::Problem const Problem problem  )  [protected]
 

Copy constructor. Only copies the predefined random number sequence so that the problem could be properly reproduced when random numbers are used. No other fields are copied. Remember to call nextRandomNumber() in the derived constructor.

Parameters:
problem the problem to be copied.


Member Function Documentation

void Problem::add Solution solution  )  [protected]
 

Add a precomputed solution to the problem's list of known solutions.

Problem::constraint_iterator Problem::add Constraint constraint  ) 
 

Add a new constraint to the problem.

Parameters:
constraint the constraint to be added.
Returns:
an iterator pointing to the new constraint.

Problem::variable_iterator Problem::add Variable variable  ) 
 

Add a new variable to the problem.

Parameters:
variable the variable to be added.
Returns:
an iterator pointing to the new variable.

size_t Problem::constraints  )  const [inline]
 

Return the number of constraints in the problem.

Returns:
the number of constraints in the problem.

void Problem::done  )  [virtual]
 

Clean up the problem after a search.

void Problem::generateGraph wostream &  wos  )  const [virtual]
 

Generate the problem's graph in AT&T's Graphviz DOT format.

Parameters:
wos an output stream to output the graph to.

void Problem::init  )  [virtual]
 

This function should be called whenever a new search is started. It resets the constraint check counters in all the constraints, and resets the temporal flags in all the variables.

bool Problem::isArcConsistent  )  const
 

Check if the problem is in an arc consistent state. This is useful mainly during debugging, as we can independently check whether a filter that claims to fully restore arc consistency does so.

bool Problem::isInternallyConsistent  )  const
 

Check that the problem is internally consistent, i.e. there are no inactive constraints connecting active variables.

virtual bool Problem::isSolution  )  const [virtual]
 

Check that the current assignment of variables in this problem is a solution. This is a default implementation that checks to see that all the variables are instantiated and all the constraints satisfied. If some other checks are needed to ensure that we have a solution, this method should be overwritten, although it is a good idea to call this anyway.

Returns:
`true' if we have a solution, `false' otherwise.

size_t Problem::maxDomainSize  )  const
 

Return the size of the largest domain among the variables in the problem.

double Problem::maxFutureWeight  )  const
 

Return the sum of the maximum weights of all the active constraints.

double Problem::minFutureWeight  )  const
 

Return the sum of the minimum weights of all the active constraints.

virtual wstring Problem::name  )  const [inline, virtual]
 

Return the problem's name, if the derived class decided to assign it one. The default is to return the string L"Problem".

Returns:
the problem's name.

int Problem::nextRandomNumber int  limit  )  [protected]
 

Generate a new random number. For copy constructors this takes numbers from the m_predefinedRandomSequence member and makes sure that the limits match.

virtual wostream& Problem::print wostream &  wos  )  const [virtual]
 

Print problem information at the given stream.

Parameters:
wos the output stream to print to.

void Problem::remove Constraint constraint  ) 
 

Remove a constraint from the problem.

Parameters:
constraint the constraint to be removed.

void Problem::remove Variable variable  ) 
 

Remove a variable from the problem.

Parameters:
variable the variable to be removed.

virtual void Problem::save wofstream &  wofs  )  const [virtual]
 

Dump the problem in text format at the given stream.

Parameters:
wofs the stream to dump the problem to

virtual void Problem::save wofstream &  wofs  )  const [virtual]
 

Dump the problem in text format at the given stream.

Parameters:
wofs the stream to dump the problem to

void Problem::save wofstream &  wofs  )  const [virtual]
 

Dump the problem in text format at the given stream.

Parameters:
wofs the stream to dump the problem to

virtual void Problem::saveSolution wofstream &  wofs  )  const [virtual]
 

Save the current solution to the given stream.

Parameters:
wofs the stream to write the solution to.

wstring Problem::signature  )  const [virtual]
 

Compute the problem's signature. Useful to compare outputs and make sure we're running different algorithms against the same problem.

size_t Problem::solutions  )  const [inline]
 

Return the number of precomputed solutions known to the problem.

Returns:
the number of solutions known to the problem.

ulonglong Problem::totalCCKS  )  const
 

Return the number of constraint checks performed so far on this problem instance by the decomposition using it.

size_t Problem::variables  )  const [inline]
 

Return the number of variables in the problem.

Returns:
the number of variables in the problem.


The documentation for this class was generated from the following files:
Generated on Wed May 25 12:21:21 2005 for csp.kdevelop by  doxygen 1.3.9.1