toulbar2
Public Member Functions | Static Public Member Functions | List of all members
WeightedCSP Class Referenceabstract

#include <toulbar2lib.hpp>

Public Member Functions

virtual int getIndex () const =0
 instantiation occurrence number of current WCSP object
 
virtual string getName () const =0
 get WCSP problem name (defaults to filename with no extension)
 
virtual void setName (const string &problem)=0
 set WCSP problem name
 
virtual void * getSolver () const =0
 special hook to access solver information
 
virtual Cost getLb () const =0
 gets internal dual lower bound
 
virtual Cost getUb () const =0
 gets internal primal upper bound
 
virtual Double getDPrimalBound () const =0
 gets problem primal bound as a Double representing a decimal cost (upper resp. lower bound for minimization resp. maximization)
 
virtual Double getDDualBound () const =0
 gets problem dual bound as a Double representing a decimal cost (lower resp. upper bound for minimization resp. maximization)
 
virtual Double getDLb () const =0
 gets problem lower bound as a Double representing a decimal cost
 
virtual Double getDUb () const =0
 gets problem upper bound as a Double representing a decimal cost
 
virtual void updateUb (Cost newUb)=0
 sets initial problem upper bound and each time a new solution is found
 
virtual void enforceUb ()=0
 enforces problem upper bound when exploring an alternative search node
 
virtual void increaseLb (Cost addLb)=0
 increases problem lower bound thanks to eg soft local consistencies More...
 
virtual void decreaseLb (Cost shift)=0
 shift problem optimum toward negative costs More...
 
virtual Cost getNegativeLb () const =0
 gets constant term used to subtract to the problem optimum when printing the solutions
 
virtual Cost finiteUb () const =0
 computes the worst-case assignment finite cost (sum of maximum finite cost over all cost functions plus one) More...
 
virtual void setInfiniteCost ()=0
 updates infinite costs in all cost functions accordingly to the problem global lower and upper bounds More...
 
virtual bool enumerated (int varIndex) const =0
 true if the variable has an enumerated domain
 
virtual string getName (int varIndex) const =0
 
virtual unsigned int getVarIndex (const string &s) const =0
 return variable index from its name, or numberOfVariables() if not found
 
virtual Value getInf (int varIndex) const =0
 minimum current domain value
 
virtual Value getSup (int varIndex) const =0
 maximum current domain value
 
virtual Value getValue (int varIndex) const =0
 current assigned value More...
 
virtual unsigned int getDomainSize (int varIndex) const =0
 current domain size
 
virtual vector< Value > getEnumDomain (int varIndex)=0
 gets current domain values in an array
 
virtual bool getEnumDomain (int varIndex, Value *array)=0
 
virtual vector< pair< Value, Cost > > getEnumDomainAndCost (int varIndex)=0
 gets current domain values and unary costs in an array
 
virtual bool getEnumDomainAndCost (int varIndex, ValueCost *array)=0
 
virtual unsigned int getDomainInitSize (int varIndex) const =0
 gets initial domain size (warning! assumes EnumeratedVariable)
 
virtual Value toValue (int varIndex, unsigned int idx)=0
 gets value from index (warning! assumes EnumeratedVariable)
 
virtual unsigned int toIndex (int varIndex, Value value)=0
 gets index from value (warning! assumes EnumeratedVariable)
 
virtual unsigned int toIndex (int varIndex, const string &valueName)=0
 gets index from value name (warning! assumes EnumeratedVariable with value names)
 
virtual int getDACOrder (int varIndex) const =0
 index of the variable in the DAC variable ordering
 
virtual Value nextValue (int varIndex, Value v) const =0
 first value after v in the current domain or v if there is no value
 
virtual void increase (int varIndex, Value newInf)=0
 changes domain lower bound
 
virtual void decrease (int varIndex, Value newSup)=0
 changes domain upper bound
 
virtual void assign (int varIndex, Value newValue)=0
 assigns a variable and immediately propagates this assignment
 
virtual void remove (int varIndex, Value remValue)=0
 removes a domain value (valid if done for an enumerated variable or on its domain bounds)
 
virtual void assignLS (vector< int > &varIndexes, vector< Value > &newValues, bool force=false)=0
 assigns a set of variables at once and propagates (used by Local Search methods such as Large Neighborhood Search) More...
 
virtual Cost getUnaryCost (int varIndex, Value v) const =0
 unary cost associated to a domain value
 
virtual Cost getMaxUnaryCost (int varIndex) const =0
 maximum unary cost in the domain
 
virtual Value getMaxUnaryCostValue (int varIndex) const =0
 a value having the maximum unary cost in the domain
 
virtual Value getSupport (int varIndex) const =0
 NC/EAC unary support value.
 
virtual Value getBestValue (int varIndex) const =0
 hint for some value ordering heuristics (only used by RDS)
 
virtual void setBestValue (int varIndex, Value v)=0
 hint for some value ordering heuristics (only used by RDS)
 
virtual bool getIsPartOfOptimalSolution ()=0
 special flag used for debugging purposes only
 
virtual void setIsPartOfOptimalSolution (bool v)=0
 special flag used for debugging purposes only
 
virtual int getDegree (int varIndex) const =0
 approximate degree of a variable (ie number of active cost functions, see Variable elimination)
 
virtual int getTrueDegree (int varIndex) const =0
 degree of a variable
 
virtual Long getWeightedDegree (int varIndex) const =0
 weighted degree heuristic
 
virtual void resetWeightedDegree (int varIndex)=0
 initialize weighted degree heuristic
 
virtual void preprocessing ()=0
 applies various preprocessing techniques to simplify the current problem
 
virtual void sortConstraints ()=0
 sorts the list of cost functions associated to each variable based on smallest problem variable indexes More...
 
virtual void whenContradiction ()=0
 after a contradiction, resets propagation queues
 
virtual void propagate ()=0
 propagates until a fix point is reached (or throws a contradiction)
 
virtual bool verify ()=0
 checks the propagation fix point is reached
 
virtual unsigned int numberOfVariables () const =0
 number of created variables
 
virtual unsigned int numberOfUnassignedVariables () const =0
 current number of unassigned variables
 
virtual unsigned int numberOfConstraints () const =0
 initial number of cost functions (before variable elimination)
 
virtual unsigned int numberOfConnectedConstraints () const =0
 current number of cost functions
 
virtual unsigned int numberOfConnectedBinaryConstraints () const =0
 current number of binary cost functions
 
virtual unsigned int medianDomainSize () const =0
 median current domain size of variables
 
virtual unsigned int medianDegree () const =0
 median current degree of variables
 
virtual unsigned int medianArity () const =0
 median arity of current cost functions
 
virtual int getMaxDomainSize () const =0
 maximum initial domain size found in all variables
 
virtual int getMaxCurrentDomainSize () const =0
 maximum current domain size found in all variables
 
virtual unsigned int getDomainSizeSum () const =0
 total sum of current domain sizes
 
virtual void cartProd (BigInteger &cartesianProduct)=0
 Cartesian product of current domain sizes. More...
 
virtual Long getNbDEE () const =0
 number of value removals due to dead-end elimination
 
virtual int makeEnumeratedVariable (string n, Value iinf, Value isup)=0
 create an enumerated variable with its domain bounds
 
virtual int makeEnumeratedVariable (string n, Value *d, int dsize)=0
 create an enumerated variable with its domain values
 
virtual void addValueName (int xIndex, const string &valuename)=0
 add next value name More...
 
virtual int makeIntervalVariable (string n, Value iinf, Value isup)=0
 create an interval variable with its domain bounds
 
virtual void postUnary (int xIndex, vector< Cost > &costs)=0
 
virtual int postNaryConstraintBegin (int *scope, int arity, Cost defval, Long nbtuples=0, bool forcenary=false)=0
 
virtual void postNaryConstraintTuple (int ctrindex, vector< Value > &tuple, Cost cost)=0
 
virtual void postNaryConstraintEnd (int ctrindex)=0
 
virtual int postUnary (int xIndex, Value *d, int dsize, Cost penalty)=0
 
virtual int postKnapsackConstraint (vector< int > &scope, const string &arguments)=0
 
virtual int postGlobalConstraint (int *scopeIndex, int arity, const string &gcname, istream &file, int *constrcounter=NULL, bool mult=true)=0
 
virtual int postWAmong (vector< int > &scope, const string &semantics, const string &propagator, Cost baseCost, const vector< Value > &values, int lb, int ub)=0
 post a soft among cost function More...
 
virtual int postWAmong (int *scopeIndex, int arity, const string &semantics, const string &propagator, Cost baseCost, const vector< Value > &values, int lb, int ub)=0
 
virtual void postWAmong (int *scopeIndex, int arity, string semantics, Cost baseCost, Value *values, int nbValues, int lb, int ub)=0
 
virtual void postWVarAmong (vector< int > &scope, const string &semantics, Cost baseCost, vector< Value > &values, int varIndex)=0
 post a weighted among cost function with the number of values encoded as a variable with index varIndex (network-based propagator only)
 
virtual void postWVarAmong (int *scopeIndex, int arity, const string &semantics, Cost baseCost, Value *values, int nbValues, int varIndex)=0
 
virtual int postWRegular (vector< int > &scope, const string &semantics, const string &propagator, Cost baseCost, int nbStates, const vector< WeightedObjInt > &initial_States, const vector< WeightedObjInt > &accepting_States, const vector< DFATransition > &Wtransitions)=0
 post a soft or weighted regular cost function More...
 
virtual int postWRegular (int *scopeIndex, int arity, const string &semantics, const string &propagator, Cost baseCost, int nbStates, const vector< WeightedObjInt > &initial_States, const vector< WeightedObjInt > &accepting_States, const vector< DFATransition > &Wtransitions)=0
 
virtual void postWRegular (int *scopeIndex, int arity, int nbStates, vector< pair< int, Cost > > initial_States, vector< pair< int, Cost > > accepting_States, int **Wtransitions, vector< Cost > transitionsCosts)=0
 
virtual int postWAllDiff (int *scopeIndex, int arity, const string &semantics, const string &propagator, Cost baseCost)=0
 post a soft alldifferent cost function More...
 
virtual void postWAllDiff (int *scopeIndex, int arity, string semantics, Cost baseCost)=0
 
virtual int postWGcc (int *scopeIndex, int arity, const string &semantics, const string &propagator, Cost baseCost, const vector< BoundedObjValue > &values)=0
 post a soft global cardinality cost function More...
 
virtual void postWGcc (int *scopeIndex, int arity, string semantics, Cost baseCost, Value *values, int nbValues, int *lb, int *ub)=0
 
virtual int postWSame (int *scopeIndexG1, int arityG1, int *scopeIndexG2, int arityG2, const string &semantics, const string &propagator, Cost baseCost)=0
 post a soft same cost function (a group of variables being a permutation of another group with the same size) More...
 
virtual void postWSame (int *scopeIndex, int arity, string semantics, Cost baseCost)=0
 
virtual void postWSameGcc (int *scopeIndex, int arity, string semantics, Cost baseCost, Value *values, int nbValues, int *lb, int *ub)=0
 post a combination of a same and gcc cost function decomposed as a cost function network
 
virtual int postWGrammarCNF (int *scopeIndex, int arity, const string &semantics, const string &propagator, Cost baseCost, int nbSymbols, int startSymbol, const vector< CFGProductionRule > WRuleToTerminal)=0
 post a soft/weighted grammar cost function with the dynamic programming propagator and grammar in Chomsky normal form More...
 
virtual int postMST (int *scopeIndex, int arity, const string &semantics, const string &propagator, Cost baseCost)=0
 post a Spanning Tree hard constraint More...
 
virtual int postMaxWeight (int *scopeIndex, int arity, const string &semantics, const string &propagator, Cost baseCost, const vector< WeightedVarValPair > weightFunction)=0
 post a weighted max cost function (maximum cost of a set of unary cost functions associated to a set of variables) More...
 
virtual void postWSum (int *scopeIndex, int arity, string semantics, Cost baseCost, string comparator, int rightRes)=0
 post a soft linear constraint with unit coefficients More...
 
virtual void postWVarSum (int *scopeIndex, int arity, string semantics, Cost baseCost, string comparator, int varIndex)=0
 post a soft linear constraint with unit coefficients and variable right-hand side
 
virtual void postWOverlap (int *scopeIndex, int arity, string semantics, Cost baseCost, string comparator, int rightRes)=0
 post a soft overlap cost function (a group of variables being point-wise equivalent – and not equal to zero – to another group with the same size) More...
 
virtual vector< vector< int > > * getListSuccessors ()=0
 generating additional variables vector created when berge decomposition are included in the WCSP
 
virtual bool isGlobal ()=0
 true if there are soft global constraints defined in the problem
 
virtual Cost read_wcsp (const char *fileName)=0
 load problem in all format supported by toulbar2. Returns the UB known to the solver before solving (file and command line).
 
virtual void read_legacy (const char *fileName)=0
 load problem in wcsp legacy format
 
virtual void read_uai2008 (const char *fileName)=0
 load problem in UAI 2008 format (see http://graphmod.ics.uci.edu/uai08/FileFormat and http://www.cs.huji.ac.il/project/UAI10/fileFormat.php) More...
 
virtual void read_random (int n, int m, vector< int > &p, int seed, bool forceSubModular=false, string globalname="")=0
 create a random WCSP with n variables, domain size m, array p where the first element is a percentage of tuples with a nonzero cost and next elements are the number of random cost functions for each different arity (starting with arity two), random seed, a flag to have a percentage (last element in the array p) of the binary cost functions being permutated submodular, and a string to use a specific global cost function instead of random cost functions in extension
 
virtual void read_wcnf (const char *fileName)=0
 load problem in (w)cnf format (see http://www.maxsat.udl.cat/08/index.php?disp=requirements)
 
virtual void read_qpbo (const char *fileName)=0
 load quadratic pseudo-Boolean optimization problem in unconstrained quadratic programming text format (first text line with n, number of variables and m, number of triplets, followed by the m triplets (x,y,cost) describing the sparse symmetric nXn cost matrix with variable indexes such that x <= y and any positive or negative real numbers for costs)
 
virtual void read_opb (const char *fileName)=0
 load pseudo-Boolean optimization problem
 
virtual const vector< Value > getSolution ()=0
 after solving the problem, return the optimal solution (warning! do not use it if doing solution counting or if there is no solution, see WeightedCSPSolver::solve output for that)
 
virtual Double getSolutionValue () const =0
 returns current best solution cost or MAX_COST if no solution found
 
virtual Cost getSolutionCost () const =0
 returns current best solution cost or MAX_COST if no solution found
 
virtual const vector< Value > getSolution (Cost *cost_ptr)=0
 returns current best solution and its cost More...
 
virtual void initSolutionCost ()=0
 returns all solutions found More...
 
virtual void setSolution (Cost cost, TAssign *sol=NULL)=0
 set best solution from current assigned values or from a given assignment (for BTD-like methods)
 
virtual void printSolution ()=0
 prints current best solution on standard output (using variable and value names if cfn format and ToulBar2::showSolution>1)
 
virtual void printSolution (ostream &os)=0
 prints current best solution (using variable and value names if cfn format and ToulBar2::writeSolution>1)
 
virtual void printSolution (FILE *f)=0
 prints current best solution (using variable and value names if cfn format and ToulBar2::writeSolution>1)
 
virtual void print (ostream &os)=0
 print current domains and active cost functions (see Output messages, verbosity options and debugging)
 
virtual void dump (ostream &os, bool original=true)=0
 output the current WCSP into a file in wcsp format More...
 
virtual void dump_CFN (ostream &os, bool original=true)=0
 output the current WCSP into a file in wcsp format More...
 
virtual const vector< Variable * > & getDivVariables ()=0
 returns all variables on which a diversity request exists
 

Static Public Member Functions

static WeightedCSPmakeWeightedCSP (Cost upperBound, void *solver=NULL)
 Weighted CSP factory.
 

Detailed Description

Abstract class WeightedCSP representing a weighted constraint satisfaction problem

Note
Variables are referenced by their lexicographic index number (as returned by eg WeightedCSP::makeEnumeratedVariable)
Cost functions are referenced by their lexicographic index number (as returned by eg WeightedCSP::postBinaryConstraint)

Member Function Documentation

◆ addValueName()

virtual void WeightedCSP::addValueName ( int  xIndex,
const string &  valuename 
)
pure virtual

add next value name

Warning
should be called on EnumeratedVariable object as many times as its number of initial domain values

◆ assignLS()

virtual void WeightedCSP::assignLS ( vector< int > &  varIndexes,
vector< Value > &  newValues,
bool  force = false 
)
pure virtual

assigns a set of variables at once and propagates (used by Local Search methods such as Large Neighborhood Search)

Parameters
varIndexesvector of variable indexes as returned by makeXXXVariable
newValuesvector of values to be assigned to the corresponding variables

◆ cartProd()

virtual void WeightedCSP::cartProd ( BigInteger &  cartesianProduct)
pure virtual

Cartesian product of current domain sizes.

Parameters
cartesianProductresult obtained by the GNU Multiple Precision Arithmetic Library GMP

◆ decreaseLb()

virtual void WeightedCSP::decreaseLb ( Cost  shift)
pure virtual

shift problem optimum toward negative costs

Parameters
shiftpositive shifting value to be subtracted to the problem optimum when printing the solutions

◆ dump()

virtual void WeightedCSP::dump ( ostream &  os,
bool  original = true 
)
pure virtual

output the current WCSP into a file in wcsp format

Parameters
osoutput file
originalif true then keeps all variables with their original domain size else uses unassigned variables and current domains recoding variable indexes

◆ dump_CFN()

virtual void WeightedCSP::dump_CFN ( ostream &  os,
bool  original = true 
)
pure virtual

output the current WCSP into a file in wcsp format

Parameters
osoutput file
originalif true then keeps all variables with their original domain size else uses unassigned variables and current domains recoding variable indexes

◆ finiteUb()

virtual Cost WeightedCSP::finiteUb ( ) const
pure virtual

computes the worst-case assignment finite cost (sum of maximum finite cost over all cost functions plus one)

Returns
the worst-case assignment finite cost
Warning
current problem should be completely loaded and propagated before calling this function

◆ getEnumDomain()

virtual bool WeightedCSP::getEnumDomain ( int  varIndex,
Value *  array 
)
pure virtual

◆ getEnumDomainAndCost()

virtual bool WeightedCSP::getEnumDomainAndCost ( int  varIndex,
ValueCost *  array 
)
pure virtual

◆ getName()

virtual string WeightedCSP::getName ( int  varIndex) const
pure virtual
Note
by default, variables names are integers, starting at zero

◆ getSolution()

virtual const vector< Value > WeightedCSP::getSolution ( Cost *  cost_ptr)
pure virtual

returns current best solution and its cost

◆ getValue()

virtual Value WeightedCSP::getValue ( int  varIndex) const
pure virtual

current assigned value

Warning
undefined if not assigned yet

◆ increaseLb()

virtual void WeightedCSP::increaseLb ( Cost  addLb)
pure virtual

increases problem lower bound thanks to eg soft local consistencies

Parameters
addLbincrement value to be added to the problem lower bound

◆ initSolutionCost()

virtual void WeightedCSP::initSolutionCost ( )
pure virtual

returns all solutions found

invalidate best solution by changing its cost to MAX_COST

◆ postGlobalConstraint()

virtual int WeightedCSP::postGlobalConstraint ( int *  scopeIndex,
int  arity,
const string &  gcname,
istream &  file,
int *  constrcounter = NULL,
bool  mult = true 
)
pure virtual

◆ postKnapsackConstraint()

virtual int WeightedCSP::postKnapsackConstraint ( vector< int > &  scope,
const string &  arguments 
)
pure virtual

◆ postMaxWeight()

virtual int WeightedCSP::postMaxWeight ( int *  scopeIndex,
int  arity,
const string &  semantics,
const string &  propagator,
Cost  baseCost,
const vector< WeightedVarValPair >  weightFunction 
)
pure virtual

post a weighted max cost function (maximum cost of a set of unary cost functions associated to a set of variables)

Parameters
scopeIndexan array of variable indexes as returned by WeightedCSP::makeEnumeratedVariable
aritythe size of scopeIndex
semanticsthe semantics of the global cost function: "val"
propagatorthe propagation method ("DAG" only)
baseCostif a variable-value pair does not exist in weightFunction, its weight will be mapped to baseCost.
weightFunctiona vector of WeightedVarValPair containing a mapping from variable-value pairs to their weights.

◆ postMST()

virtual int WeightedCSP::postMST ( int *  scopeIndex,
int  arity,
const string &  semantics,
const string &  propagator,
Cost  baseCost 
)
pure virtual

post a Spanning Tree hard constraint

Parameters
scopeIndexan array of variable indexes as returned by WeightedCSP::makeEnumeratedVariable
aritythe size of scopeIndex
semanticsthe semantics of the global cost function: "hard"
propagatorthe propagation method ("DAG" only)
baseCostunused in the current implementation (MAX_COST)

◆ postNaryConstraintBegin()

virtual int WeightedCSP::postNaryConstraintBegin ( int *  scope,
int  arity,
Cost  defval,
Long  nbtuples = 0,
bool  forcenary = false 
)
pure virtual
Warning
must call WeightedCSP::postNaryConstraintEnd after giving cost tuples

◆ postNaryConstraintEnd()

virtual void WeightedCSP::postNaryConstraintEnd ( int  ctrindex)
pure virtual

◆ postNaryConstraintTuple()

virtual void WeightedCSP::postNaryConstraintTuple ( int  ctrindex,
vector< Value > &  tuple,
Cost  cost 
)
pure virtual

◆ postUnary() [1/2]

virtual int WeightedCSP::postUnary ( int  xIndex,
Value *  d,
int  dsize,
Cost  penalty 
)
pure virtual
Warning
must call WeightedCSP::sortConstraints after all cost functions have been posted (see WeightedCSP::sortConstraints)

◆ postUnary() [2/2]

virtual void WeightedCSP::postUnary ( int  xIndex,
vector< Cost > &  costs 
)
pure virtual

◆ postWAllDiff() [1/2]

virtual int WeightedCSP::postWAllDiff ( int *  scopeIndex,
int  arity,
const string &  semantics,
const string &  propagator,
Cost  baseCost 
)
pure virtual

post a soft alldifferent cost function

Parameters
scopeIndexan array of variable indexes as returned by WeightedCSP::makeEnumeratedVariable
aritythe size of the array
semanticsthe semantics of the global cost function: for flow-based propagator: "var" or "dec" or "decbi" (decomposed into a binary cost function complete network), for DAG-based propagator: "var", for network-based propagator: "hard" or "lin" or "quad" (decomposed based on wamong)
propagatorthe propagation method ("flow", "DAG", "network")
baseCostthe scaling factor of the violation

◆ postWAllDiff() [2/2]

virtual void WeightedCSP::postWAllDiff ( int *  scopeIndex,
int  arity,
string  semantics,
Cost  baseCost 
)
pure virtual

◆ postWAmong() [1/3]

virtual int WeightedCSP::postWAmong ( int *  scopeIndex,
int  arity,
const string &  semantics,
const string &  propagator,
Cost  baseCost,
const vector< Value > &  values,
int  lb,
int  ub 
)
pure virtual

◆ postWAmong() [2/3]

virtual void WeightedCSP::postWAmong ( int *  scopeIndex,
int  arity,
string  semantics,
Cost  baseCost,
Value *  values,
int  nbValues,
int  lb,
int  ub 
)
pure virtual

◆ postWAmong() [3/3]

virtual int WeightedCSP::postWAmong ( vector< int > &  scope,
const string &  semantics,
const string &  propagator,
Cost  baseCost,
const vector< Value > &  values,
int  lb,
int  ub 
)
pure virtual

post a soft among cost function

Parameters
scopeIndexan array of variable indexes as returned by WeightedCSP::makeEnumeratedVariable
aritythe size of the array
semanticsthe semantics of the global cost function: "var" or – "hard" or "lin" or "quad" (network-based propagator only)–
propagatorthe propagation method (only "DAG" or "network")
baseCostthe scaling factor of the violation
valuesa vector of values to be restricted
lba fixed lower bound for the number variables to be assigned to the values in values
uba fixed upper bound for the number variables to be assigned to the values in values post a soft weighted among cost function

◆ postWGcc() [1/2]

virtual int WeightedCSP::postWGcc ( int *  scopeIndex,
int  arity,
const string &  semantics,
const string &  propagator,
Cost  baseCost,
const vector< BoundedObjValue > &  values 
)
pure virtual

post a soft global cardinality cost function

Parameters
scopeIndexan array of variable indexes as returned by WeightedCSP::makeEnumeratedVariable
aritythe size of the array
semanticsthe semantics of the global cost function: "var" (DAG-based propagator only) or – "var" or "dec" or "wdec" (flow-based propagator only) or – "hard" or "lin" or "quad" (network-based propagator only)–
propagatorthe propagation method ("flow", "DAG", "network")
baseCostthe scaling factor of the violation
valuesa vector of BoundedObjValue, specifying the lower and upper bounds of each value, restricting the number of variables can be assigned to them

◆ postWGcc() [2/2]

virtual void WeightedCSP::postWGcc ( int *  scopeIndex,
int  arity,
string  semantics,
Cost  baseCost,
Value *  values,
int  nbValues,
int *  lb,
int *  ub 
)
pure virtual

◆ postWGrammarCNF()

virtual int WeightedCSP::postWGrammarCNF ( int *  scopeIndex,
int  arity,
const string &  semantics,
const string &  propagator,
Cost  baseCost,
int  nbSymbols,
int  startSymbol,
const vector< CFGProductionRule >  WRuleToTerminal 
)
pure virtual

post a soft/weighted grammar cost function with the dynamic programming propagator and grammar in Chomsky normal form

Parameters
scopeIndexan array of the first group of variable indexes as returned by WeightedCSP::makeEnumeratedVariable
aritythe size of scopeIndex
semanticsthe semantics of the global cost function: "var" or "weight"
propagatorthe propagation method ("DAG" only)
baseCostthe scaling factor of the violation
nbSymbolsthe number of symbols in the corresponding grammar. Symbols are indexed as 0, 1, ..., nbSymbols-1
startSymbolthe index of the starting symbol
WRuleToTerminala vector of ::CFGProductionRule. Note that:
  • if order in CFGProductionRule is set to 0, it is classified as A -> v, where A is the index of the terminal symbol and v is the value.
  • if order in CFGProductionRule is set to 1, it is classified as A -> BC, where A,B,C the index of the nonterminal symbols.
  • if order in CFGProductionRule is set to 2, it is classified as weighted A -> v, where A is the index of the terminal symbol and v is the value.
  • if order in CFGProductionRule is set to 3, it is classified as weighted A -> BC, where A,B,C the index of the nonterminal symbols.
  • if order in CFGProductionRule is set to values greater than 3, it is ignored.

◆ postWOverlap()

virtual void WeightedCSP::postWOverlap ( int *  scopeIndex,
int  arity,
string  semantics,
Cost  baseCost,
string  comparator,
int  rightRes 
)
pure virtual

post a soft overlap cost function (a group of variables being point-wise equivalent – and not equal to zero – to another group with the same size)

Parameters
scopeIndexan array of variable indexes as returned by WeightedCSP::makeEnumeratedVariable
aritythe size of scopeIndex (should be an even value)
semanticsthe semantics of the global cost function: "hard" or "lin" or "quad" (network-based propagator only)
propagatorthe propagation method ("network" only)
baseCostthe scaling factor of the violation.
comparatorthe point-wise comparison operator applied to the number of equivalent variables ("==", "!=", "<", "<=", ">,", ">=")
rightResright-hand side value of the comparison

◆ postWRegular() [1/3]

virtual int WeightedCSP::postWRegular ( int *  scopeIndex,
int  arity,
const string &  semantics,
const string &  propagator,
Cost  baseCost,
int  nbStates,
const vector< WeightedObjInt > &  initial_States,
const vector< WeightedObjInt > &  accepting_States,
const vector< DFATransition > &  Wtransitions 
)
pure virtual

◆ postWRegular() [2/3]

virtual void WeightedCSP::postWRegular ( int *  scopeIndex,
int  arity,
int  nbStates,
vector< pair< int, Cost > >  initial_States,
vector< pair< int, Cost > >  accepting_States,
int **  Wtransitions,
vector< Cost >  transitionsCosts 
)
pure virtual

◆ postWRegular() [3/3]

virtual int WeightedCSP::postWRegular ( vector< int > &  scope,
const string &  semantics,
const string &  propagator,
Cost  baseCost,
int  nbStates,
const vector< WeightedObjInt > &  initial_States,
const vector< WeightedObjInt > &  accepting_States,
const vector< DFATransition > &  Wtransitions 
)
pure virtual

post a soft or weighted regular cost function

Parameters
scopeIndexan array of variable indexes as returned by WeightedCSP::makeEnumeratedVariable
aritythe size of the array
semanticsthe semantics of the soft global cost function: "var" or "edit" (flow-based propagator) or – "var" (DAG-based propagator)– (unused parameter for network-based propagator)
propagatorthe propagation method ("flow", "DAG", "network")
baseCostthe scaling factor of the violation ("flow", "DAG")
nbStatesthe number of the states in the corresponding DFA. The states are indexed as 0, 1, ..., nbStates-1
initial_Statesa vector of WeightedObjInt specifying the starting states with weight
accepting_Statesa vector of WeightedObjInt specifying the final states
Wtransitionsa vector of (weighted) transitions
Warning
Weights are ignored in the current implementation of DAG and flow-based propagators post a soft weighted regular cost function

◆ postWSame() [1/2]

virtual void WeightedCSP::postWSame ( int *  scopeIndex,
int  arity,
string  semantics,
Cost  baseCost 
)
pure virtual

◆ postWSame() [2/2]

virtual int WeightedCSP::postWSame ( int *  scopeIndexG1,
int  arityG1,
int *  scopeIndexG2,
int  arityG2,
const string &  semantics,
const string &  propagator,
Cost  baseCost 
)
pure virtual

post a soft same cost function (a group of variables being a permutation of another group with the same size)

Parameters
scopeIndexG1an array of the first group of variable indexes as returned by WeightedCSP::makeEnumeratedVariable
arityG1the size of scopeIndexG1
scopeIndexG2an array of the second group of variable indexes as returned by WeightedCSP::makeEnumeratedVariable
arityG2the size of scopeIndexG2
semanticsthe semantics of the global cost function: "var" or – "hard" or "lin" or "quad" (network-based propagator only)–
propagatorthe propagation method ("flow" or "network")
baseCostthe scaling factor of the violation.

◆ postWSum()

virtual void WeightedCSP::postWSum ( int *  scopeIndex,
int  arity,
string  semantics,
Cost  baseCost,
string  comparator,
int  rightRes 
)
pure virtual

post a soft linear constraint with unit coefficients

Parameters
scopeIndexan array of variable indexes as returned by WeightedCSP::makeEnumeratedVariable
aritythe size of scopeIndex
semanticsthe semantics of the global cost function: "hard" or "lin" or "quad" (network-based propagator only)
propagatorthe propagation method ("network" only)
baseCostthe scaling factor of the violation
comparatorthe comparison operator of the linear constraint ("==", "!=", "<", "<=", ">,", ">=")
rightResright-hand side value of the linear constraint

◆ postWVarAmong()

virtual void WeightedCSP::postWVarAmong ( int *  scopeIndex,
int  arity,
const string &  semantics,
Cost  baseCost,
Value *  values,
int  nbValues,
int  varIndex 
)
pure virtual

◆ read_uai2008()

virtual void WeightedCSP::read_uai2008 ( const char *  fileName)
pure virtual

load problem in UAI 2008 format (see http://graphmod.ics.uci.edu/uai08/FileFormat and http://www.cs.huji.ac.il/project/UAI10/fileFormat.php)

Warning
UAI10 evidence file format not recognized by toulbar2 as it does not allow multiple evidence (you should remove the first value in the file)

◆ setInfiniteCost()

virtual void WeightedCSP::setInfiniteCost ( )
pure virtual

updates infinite costs in all cost functions accordingly to the problem global lower and upper bounds

Warning
to be used in preprocessing only

◆ sortConstraints()

virtual void WeightedCSP::sortConstraints ( )
pure virtual

sorts the list of cost functions associated to each variable based on smallest problem variable indexes

Warning
side-effect: updates DAC order according to an existing variable elimination order
Note
must be called after creating all the cost functions and before solving the problem