Generated on Fri Mar 20 15:56:50 2015 for Gecode by doxygen 1.6.3

Gecode::FlatZinc::FlatZincSpace Class Reference

A space that can be initialized with a FlatZinc model. More...

#include <flatzinc.hh>

List of all members.

Public Types

enum  Meth { SAT, MIN, MAX }

Public Member Functions

 FlatZincSpace (FznRnd *random=NULL)
 Construct empty space.
 ~FlatZincSpace (void)
 Destructor.
void init (int intVars, int boolVars, int setVars, int floatVars)
 Initialize space with given number of variables.
void newIntVar (IntVarSpec *vs)
 Create new integer variable from specification.
void aliasBool2Int (int iv, int bv)
 Link integer variable iv to Boolean variable bv.
int aliasBool2Int (int iv)
 Return linked Boolean variable for integer variable iv.
void newBoolVar (BoolVarSpec *vs)
 Create new Boolean variable from specification.
void newSetVar (SetVarSpec *vs)
 Create new set variable from specification.
void newFloatVar (FloatVarSpec *vs)
 Create new float variable from specification.
void postConstraints (std::vector< ConExpr * > &ces)
 Post a constraint specified by ce.
void solve (AST::Array *annotation)
 Post the solve item.
void minimize (int var, bool isInt, AST::Array *annotation)
 Post that integer variable var should be minimized.
void maximize (int var, bool isInt, AST::Array *annotation)
 Post that integer variable var should be maximized.
void run (std::ostream &out, const Printer &p, const FlatZincOptions &opt, Gecode::Support::Timer &t_total)
 Run the search.
void print (std::ostream &out, const Printer &p) const
 Produce output on out using p.
void compare (const Space &s, std::ostream &out) const
 Compare this space with space s and print the differences on out.
void compare (const FlatZincSpace &s, std::ostream &out, const Printer &p) const
 Compare this space with space s and print the differences on out using p.
void shrinkArrays (Printer &p)
 Remove all variables not needed for output.
Meth method (void) const
 Return whether to solve a satisfaction or optimization problem.
int optVar (void) const
 Return index of variable used for optimization.
bool optVarIsInt (void) const
 Return whether variable used for optimization is integer (or float).
void createBranchers (AST::Node *ann, int seed, double decay, bool ignoreUnknown, std::ostream &err=std::cerr)
 Create branchers corresponding to the solve item annotations.
AST::ArraysolveAnnotations (void) const
 Return the solve item annotations.
virtual void constrain (const Space &s)
 Implement optimization.
virtual Gecode::Spacecopy (bool share)
 Copy function.
virtual bool slave (const CRI &cri)
 Slave configuration function for restart meta search engine.

Public Attributes

Gecode::IntVarArray iv
 The integer variables.
Gecode::IntVarArray iv_aux
 The introduced integer variables.
Gecode::IntVarArray iv_lns
 The integer variables used in LNS.
std::vector< bool > iv_introduced
 Indicates whether an integer variable is introduced by mzn2fzn.
int * iv_boolalias
 Indicates whether an integer variable aliases a Boolean variable.
Gecode::BoolVarArray bv
 The Boolean variables.
Gecode::BoolVarArray bv_aux
 The introduced Boolean variables.
std::vector< bool > bv_introduced
 Indicates whether a Boolean variable is introduced by mzn2fzn.
Gecode::SetVarArray sv
 The set variables.
Gecode::SetVarArray sv_aux
 The introduced set variables.
std::vector< bool > sv_introduced
 Indicates whether a set variable is introduced by mzn2fzn.
Gecode::FloatVarArray fv
 The float variables.
Gecode::FloatVarArray fv_aux
 The introduced float variables.
std::vector< bool > fv_introduced
 Indicates whether a float variable is introduced by mzn2fzn.
Gecode::FloatNum step
 Step by which a next solution has to have lower cost.
bool needAuxVars
 Whether the introduced variables still need to be copied.
BranchInformation branchInfo
 Information for printing branches.

Protected Member Functions

 FlatZincSpace (bool share, FlatZincSpace &)
 Copy constructor.

Protected Attributes

int intVarCount
 Number of integer variables.
int boolVarCount
 Number of Boolean variables.
int floatVarCount
 Number of float variables.
int setVarCount
 Number of set variables.
int _optVar
 Index of the variable to optimize.
bool _optVarIsInt
 Whether variable to optimize is integer (or float).
Meth _method
 Whether to solve as satisfaction or optimization problem.
unsigned int _lns
 Percentage of variables to keep in LNS (or 0 for no LNS).
FznRnd_random
 Random number generator.
AST::Array_solveAnnotations
 Annotations on the solve item.

AST to variable and value conversion



IntArgs arg2intargs (AST::Node *arg, int offset=0)
 Convert arg (array of integers) to IntArgs.
IntArgs arg2boolargs (AST::Node *arg, int offset=0)
 Convert arg (array of Booleans) to IntArgs.
IntSet arg2intset (AST::Node *n)
 Convert n to IntSet.
IntSetArgs arg2intsetargs (AST::Node *arg, int offset=0)
 Convert arg to IntSetArgs.
IntVarArgs arg2intvarargs (AST::Node *arg, int offset=0)
 Convert arg to IntVarArgs.
BoolVarArgs arg2boolvarargs (AST::Node *arg, int offset=0, int siv=-1)
 Convert arg to BoolVarArgs.
BoolVar arg2BoolVar (AST::Node *n)
 Convert n to BoolVar.
IntVar arg2IntVar (AST::Node *n)
 Convert n to IntVar.
bool isBoolArray (AST::Node *b, int &singleInt)
 Check if b is array of Booleans (or has a single integer).
SetVar arg2SetVar (AST::Node *n)
 Convert n to SetVar.
SetVarArgs arg2setvarargs (AST::Node *arg, int offset=0, int doffset=0, const IntSet &od=IntSet::empty)
 Convert n to SetVarArgs.
FloatValArgs arg2floatargs (AST::Node *arg, int offset=0)
 Convert n to FloatValArgs.
FloatVar arg2FloatVar (AST::Node *n)
 Convert n to FloatVar.
FloatVarArgs arg2floatvarargs (AST::Node *arg, int offset=0)
 Convert n to FloatVarArgs.
IntConLevel ann2icl (AST::Node *ann)
 Convert ann to IntConLevel.

Detailed Description

A space that can be initialized with a FlatZinc model.

Definition at line 375 of file flatzinc.hh.


Member Enumeration Documentation

Enumerator:
SAT 
MIN 
MAX 

Definition at line 377 of file flatzinc.hh.


Constructor & Destructor Documentation

Gecode::FlatZinc::FlatZincSpace::FlatZincSpace ( bool  share,
FlatZincSpace f 
) [protected]

Copy constructor.

Definition at line 623 of file flatzinc.cpp.

Gecode::FlatZinc::FlatZincSpace::FlatZincSpace ( FznRnd random = NULL  ) 

Construct empty space.

Definition at line 693 of file flatzinc.cpp.

Gecode::FlatZinc::FlatZincSpace::~FlatZincSpace ( void   ) 

Destructor.

Definition at line 1338 of file flatzinc.cpp.


Member Function Documentation

void Gecode::FlatZinc::FlatZincSpace::init ( int  intVars,
int  boolVars,
int  setVars,
int  floatVars 
)

Initialize space with given number of variables.

Definition at line 701 of file flatzinc.cpp.

void Gecode::FlatZinc::FlatZincSpace::newIntVar ( IntVarSpec vs  ) 

Create new integer variable from specification.

Definition at line 726 of file flatzinc.cpp.

void Gecode::FlatZinc::FlatZincSpace::aliasBool2Int ( int  iv,
int  bv 
)

Link integer variable iv to Boolean variable bv.

Definition at line 744 of file flatzinc.cpp.

int Gecode::FlatZinc::FlatZincSpace::aliasBool2Int ( int  iv  ) 

Return linked Boolean variable for integer variable iv.

Definition at line 748 of file flatzinc.cpp.

void Gecode::FlatZinc::FlatZincSpace::newBoolVar ( BoolVarSpec vs  ) 

Create new Boolean variable from specification.

Definition at line 753 of file flatzinc.cpp.

void Gecode::FlatZinc::FlatZincSpace::newSetVar ( SetVarSpec vs  ) 

Create new set variable from specification.

Definition at line 765 of file flatzinc.cpp.

void Gecode::FlatZinc::FlatZincSpace::newFloatVar ( FloatVarSpec vs  ) 

Create new float variable from specification.

Definition at line 812 of file flatzinc.cpp.

void Gecode::FlatZinc::FlatZincSpace::postConstraints ( std::vector< ConExpr * > &  ces  ) 

Post a constraint specified by ce.

Definition at line 849 of file flatzinc.cpp.

void Gecode::FlatZinc::FlatZincSpace::solve ( AST::Array annotation  ) 

Post the solve item.

Definition at line 1317 of file flatzinc.cpp.

void Gecode::FlatZinc::FlatZincSpace::minimize ( int  var,
bool  isInt,
AST::Array annotation 
)

Post that integer variable var should be minimized.

Definition at line 1323 of file flatzinc.cpp.

void Gecode::FlatZinc::FlatZincSpace::maximize ( int  var,
bool  isInt,
AST::Array annotation 
)

Post that integer variable var should be maximized.

Definition at line 1331 of file flatzinc.cpp.

void Gecode::FlatZinc::FlatZincSpace::run ( std::ostream &  out,
const Printer p,
const FlatZincOptions opt,
Gecode::Support::Timer t_total 
)

Run the search.

Definition at line 1586 of file flatzinc.cpp.

void Gecode::FlatZinc::FlatZincSpace::print ( std::ostream &  out,
const Printer p 
) const

Produce output on out using p.

Definition at line 1655 of file flatzinc.cpp.

void Gecode::FlatZinc::FlatZincSpace::compare ( const Space s,
std::ostream &  out 
) const

Compare this space with space s and print the differences on out.

Definition at line 1667 of file flatzinc.cpp.

void Gecode::FlatZinc::FlatZincSpace::compare ( const FlatZincSpace s,
std::ostream &  out,
const Printer p 
) const

Compare this space with space s and print the differences on out using p.

Definition at line 1707 of file flatzinc.cpp.

void Gecode::FlatZinc::FlatZincSpace::shrinkArrays ( Printer p  ) 

Remove all variables not needed for output.

After calling this function, no new constraints can be posted through FlatZinc variable references, and the createBranchers method must not be called again.

Definition at line 1720 of file flatzinc.cpp.

FlatZincSpace::Meth Gecode::FlatZinc::FlatZincSpace::method ( void   )  const

Return whether to solve a satisfaction or optimization problem.

Definition at line 1640 of file flatzinc.cpp.

int Gecode::FlatZinc::FlatZincSpace::optVar ( void   )  const

Return index of variable used for optimization.

Definition at line 1645 of file flatzinc.cpp.

bool Gecode::FlatZinc::FlatZincSpace::optVarIsInt ( void   )  const

Return whether variable used for optimization is integer (or float).

Definition at line 1650 of file flatzinc.cpp.

void Gecode::FlatZinc::FlatZincSpace::createBranchers ( AST::Node ann,
int  seed,
double  decay,
bool  ignoreUnknown,
std::ostream &  err = std::cerr 
)

Create branchers corresponding to the solve item annotations.

If ignoreUnknown is true, unknown solve item annotations will be ignored, otherwise a warning is written to err.

The seed for random branchers is given by the seed parameter.

Definition at line 882 of file flatzinc.cpp.

AST::Array * Gecode::FlatZinc::FlatZincSpace::solveAnnotations ( void   )  const

Return the solve item annotations.

Definition at line 1312 of file flatzinc.cpp.

void Gecode::FlatZinc::FlatZincSpace::constrain ( const Space s  )  [virtual]

Implement optimization.

Reimplemented from Gecode::Space.

Definition at line 1600 of file flatzinc.cpp.

Space * Gecode::FlatZinc::FlatZincSpace::copy ( bool  share  )  [virtual]

Copy function.

Implements Gecode::Space.

Definition at line 1635 of file flatzinc.cpp.

bool Gecode::FlatZinc::FlatZincSpace::slave ( const CRI cri  )  [virtual]

Slave configuration function for restart meta search engine.

A restart meta search engine calls this function on its slave space whenever it finds a solution or exploration restarts. cri contains information about the current restart.

If the function returns true, the search on the slave space is considered complete, i.e., if it fails or exhaustively explores the entire search space, the meta search engine finishes. If the function returns false, the search on the slave space is considered incomplete, and the meta engine will restart the search regardless of whether the search on the slave space finishes or times out.

The default function does nothing and returns true.

Reimplemented from Gecode::Space.

Definition at line 1621 of file flatzinc.cpp.

IntArgs Gecode::FlatZinc::FlatZincSpace::arg2intargs ( AST::Node arg,
int  offset = 0 
)

Convert arg (array of integers) to IntArgs.

Definition at line 1732 of file flatzinc.cpp.

IntArgs Gecode::FlatZinc::FlatZincSpace::arg2boolargs ( AST::Node arg,
int  offset = 0 
)

Convert arg (array of Booleans) to IntArgs.

Definition at line 1742 of file flatzinc.cpp.

IntSet Gecode::FlatZinc::FlatZincSpace::arg2intset ( AST::Node n  ) 

Convert n to IntSet.

Definition at line 1752 of file flatzinc.cpp.

IntSetArgs Gecode::FlatZinc::FlatZincSpace::arg2intsetargs ( AST::Node arg,
int  offset = 0 
)

Convert arg to IntSetArgs.

Definition at line 1767 of file flatzinc.cpp.

IntVarArgs Gecode::FlatZinc::FlatZincSpace::arg2intvarargs ( AST::Node arg,
int  offset = 0 
)

Convert arg to IntVarArgs.

Definition at line 1782 of file flatzinc.cpp.

BoolVarArgs Gecode::FlatZinc::FlatZincSpace::arg2boolvarargs ( AST::Node arg,
int  offset = 0,
int  siv = -1 
)

Convert arg to BoolVarArgs.

Definition at line 1803 of file flatzinc.cpp.

BoolVar Gecode::FlatZinc::FlatZincSpace::arg2BoolVar ( AST::Node n  ) 

Convert n to BoolVar.

Definition at line 1829 of file flatzinc.cpp.

IntVar Gecode::FlatZinc::FlatZincSpace::arg2IntVar ( AST::Node n  ) 

Convert n to IntVar.

Definition at line 1840 of file flatzinc.cpp.

bool Gecode::FlatZinc::FlatZincSpace::isBoolArray ( AST::Node b,
int &  singleInt 
)

Check if b is array of Booleans (or has a single integer).

Definition at line 1850 of file flatzinc.cpp.

SetVar Gecode::FlatZinc::FlatZincSpace::arg2SetVar ( AST::Node n  ) 

Convert n to SetVar.

Definition at line 1872 of file flatzinc.cpp.

SetVarArgs Gecode::FlatZinc::FlatZincSpace::arg2setvarargs ( AST::Node arg,
int  offset = 0,
int  doffset = 0,
const IntSet od = IntSet::empty 
)

Convert n to SetVarArgs.

Definition at line 1883 of file flatzinc.cpp.

FloatValArgs Gecode::FlatZinc::FlatZincSpace::arg2floatargs ( AST::Node arg,
int  offset = 0 
)

Convert n to FloatValArgs.

Definition at line 1899 of file flatzinc.cpp.

FloatVar Gecode::FlatZinc::FlatZincSpace::arg2FloatVar ( AST::Node n  ) 

Convert n to FloatVar.

Definition at line 1930 of file flatzinc.cpp.

FloatVarArgs Gecode::FlatZinc::FlatZincSpace::arg2floatvarargs ( AST::Node arg,
int  offset = 0 
)

Convert n to FloatVarArgs.

Definition at line 1909 of file flatzinc.cpp.

IntConLevel Gecode::FlatZinc::FlatZincSpace::ann2icl ( AST::Node ann  ) 

Convert ann to IntConLevel.

Definition at line 1941 of file flatzinc.cpp.


Member Data Documentation

Number of integer variables.

Definition at line 384 of file flatzinc.hh.

Number of Boolean variables.

Definition at line 386 of file flatzinc.hh.

Number of float variables.

Definition at line 388 of file flatzinc.hh.

Number of set variables.

Definition at line 390 of file flatzinc.hh.

Index of the variable to optimize.

Definition at line 393 of file flatzinc.hh.

Whether variable to optimize is integer (or float).

Definition at line 395 of file flatzinc.hh.

Whether to solve as satisfaction or optimization problem.

Definition at line 398 of file flatzinc.hh.

unsigned int Gecode::FlatZinc::FlatZincSpace::_lns [protected]

Percentage of variables to keep in LNS (or 0 for no LNS).

Definition at line 401 of file flatzinc.hh.

Random number generator.

Definition at line 404 of file flatzinc.hh.

Annotations on the solve item.

Definition at line 407 of file flatzinc.hh.

The integer variables.

Definition at line 427 of file flatzinc.hh.

The introduced integer variables.

Definition at line 429 of file flatzinc.hh.

The integer variables used in LNS.

Definition at line 432 of file flatzinc.hh.

Indicates whether an integer variable is introduced by mzn2fzn.

Definition at line 435 of file flatzinc.hh.

Indicates whether an integer variable aliases a Boolean variable.

Definition at line 437 of file flatzinc.hh.

The Boolean variables.

Definition at line 439 of file flatzinc.hh.

The introduced Boolean variables.

Definition at line 441 of file flatzinc.hh.

Indicates whether a Boolean variable is introduced by mzn2fzn.

Definition at line 443 of file flatzinc.hh.

The set variables.

Definition at line 446 of file flatzinc.hh.

The introduced set variables.

Definition at line 448 of file flatzinc.hh.

Indicates whether a set variable is introduced by mzn2fzn.

Definition at line 450 of file flatzinc.hh.

The float variables.

Definition at line 454 of file flatzinc.hh.

The introduced float variables.

Definition at line 456 of file flatzinc.hh.

Indicates whether a float variable is introduced by mzn2fzn.

Definition at line 458 of file flatzinc.hh.

Step by which a next solution has to have lower cost.

Definition at line 460 of file flatzinc.hh.

Whether the introduced variables still need to be copied.

Definition at line 463 of file flatzinc.hh.

Information for printing branches.

Definition at line 547 of file flatzinc.hh.


The documentation for this class was generated from the following files: