toulbar2
toulbar2lib.hpp
1 
59 #ifndef TOULBAR2LIB_HPP_
60 #define TOULBAR2LIB_HPP_
61 
62 #include "core/tb2types.hpp"
63 
75 class WeightedCSP {
76 public:
77  static WeightedCSP* makeWeightedCSP(Cost upperBound, void* solver = NULL);
78 
79  virtual ~WeightedCSP() {}
80 
81  virtual int getIndex() const = 0;
82  virtual string getName() const = 0;
83  virtual void setName(const string& problem) = 0;
84  virtual void* getSolver() const = 0;
85 
86  virtual Cost getLb() const = 0;
87  virtual Cost getUb() const = 0;
88 
89  virtual Double getDPrimalBound() const = 0;
90  virtual Double getDDualBound() const = 0;
91 
92  virtual Double getDLb() const = 0;
93  virtual Double getDUb() const = 0;
94 
96  virtual void updateUb(Cost newUb) = 0;
98  virtual void enforceUb() = 0;
101  virtual void increaseLb(Cost addLb) = 0;
105  virtual Cost finiteUb() const = 0;
108  virtual void setInfiniteCost() = 0;
109 
110  virtual bool enumerated(int varIndex) const = 0;
111 
112  virtual string getName(int varIndex) const = 0;
113  virtual int getVarIndex(const string& s) const = 0;
114  virtual Value getInf(int varIndex) const = 0;
115  virtual Value getSup(int varIndex) const = 0;
116  virtual Value getValue(int varIndex) const = 0;
117  virtual unsigned int getDomainSize(int varIndex) const = 0;
118  virtual vector<Value> getEnumDomain(int varIndex) = 0;
119  virtual bool getEnumDomain(int varIndex, Value* array) = 0;
120  virtual vector<pair<Value, Cost>> getEnumDomainAndCost(int varIndex) = 0;
121  virtual bool getEnumDomainAndCost(int varIndex, ValueCost* array) = 0;
122  virtual unsigned int getDomainInitSize(int varIndex) const = 0;
123  virtual Value toValue(int varIndex, unsigned int idx) = 0;
124  virtual unsigned int toIndex(int varIndex, Value value) = 0;
125  virtual unsigned int toIndex(int varIndex, const string& valueName) = 0;
126  virtual int getDACOrder(int varIndex) const = 0;
127 
128  virtual bool assigned(int varIndex) const = 0;
129  virtual bool unassigned(int varIndex) const = 0;
130  virtual bool canbe(int varIndex, Value v) const = 0;
131  virtual bool cannotbe(int varIndex, Value v) const = 0;
132  virtual Value nextValue(int varIndex, Value v) const = 0;
133 
134  virtual void increase(int varIndex, Value newInf) = 0;
135  virtual void decrease(int varIndex, Value newSup) = 0;
136  virtual void assign(int varIndex, Value newValue) = 0;
137  virtual void remove(int varIndex, Value remValue) = 0;
138 
142  virtual void assignLS(vector<int>& varIndexes, vector<Value>& newValues, bool force = false) = 0;
143  virtual void assignLS(int* varIndexes, Value* newValues, unsigned int size, bool dopropagate, bool force = false) = 0;
144 
145  virtual Cost getUnaryCost(int varIndex, Value v) const = 0;
146  virtual Cost getMaxUnaryCost(int varIndex) const = 0;
147  virtual Value getMaxUnaryCostValue(int varIndex) const = 0;
148  virtual Value getSupport(int varIndex) const = 0;
149  virtual Value getBestValue(int varIndex) const = 0;
150  virtual void setBestValue(int varIndex, Value v) = 0;
151  virtual bool getIsPartOfOptimalSolution() = 0;
152  virtual void setIsPartOfOptimalSolution(bool v) = 0;
153 
154  virtual int getDegree(int varIndex) const = 0;
155  virtual int getTrueDegree(int varIndex) const = 0;
156  virtual Long getWeightedDegree(int varIndex) const = 0;
157  virtual void resetWeightedDegree(int varIndex) = 0;
158 
159  virtual void preprocessing() = 0;
163  virtual void sortConstraints() = 0;
164 
165  virtual void whenContradiction() = 0;
166  virtual void propagate() = 0;
167  virtual bool verify() = 0;
168 
169  virtual unsigned int numberOfVariables() const = 0;
170  virtual unsigned int numberOfUnassignedVariables() const = 0;
171  virtual unsigned int numberOfConstraints() const = 0;
172  virtual unsigned int numberOfConnectedConstraints() const = 0;
173  virtual unsigned int numberOfConnectedBinaryConstraints() const = 0;
174  virtual unsigned int medianDomainSize() const = 0;
175  virtual unsigned int medianDegree() const = 0;
176  virtual unsigned int medianArity() const = 0;
177  virtual int getMaxDomainSize() const = 0;
178  virtual int getMaxCurrentDomainSize() const = 0;
179  virtual unsigned int getDomainSizeSum() const = 0;
182  virtual void cartProd(BigInteger& cartesianProduct) = 0;
183  virtual Long getNbDEE() const = 0;
184 
193 
218 
219  virtual int makeEnumeratedVariable(string n, Value iinf, Value isup) = 0;
220  virtual int makeEnumeratedVariable(string n, Value* d, int dsize) = 0;
221  virtual void addValueName(int xIndex, const string& valuename) = 0;
222  virtual int makeIntervalVariable(string n, Value iinf, Value isup) = 0;
223  virtual void postNullaryConstraint(Double cost) = 0;
224  virtual void postNullaryConstraint(Cost cost) = 0;
225  virtual void postUnary(int xIndex, vector<Cost>& costs) = 0;
226  virtual void postUnaryConstraint(int xIndex, vector<Double>& costs, bool incremental = false) = 0;
227  virtual void postUnaryConstraint(int xIndex, vector<Cost>& costs) = 0;
228  virtual void postIncrementalUnaryConstraint(int xIndex, vector<Cost>& costs) = 0;
229  virtual int postBinaryConstraint(int xIndex, int yIndex, vector<Double>& costs, bool incremental = false) = 0;
230  virtual int postBinaryConstraint(int xIndex, int yIndex, vector<Cost>& costs) = 0;
231  virtual int postIncrementalBinaryConstraint(int xIndex, int yIndex, vector<Cost>& costs) = 0;
232  virtual int postTernaryConstraint(int xIndex, int yIndex, int zIndex, vector<Double>& costs, bool incremental = false) = 0;
233  virtual int postTernaryConstraint(int xIndex, int yIndex, int zIndex, vector<Cost>& costs) = 0;
234  virtual int postIncrementalTernaryConstraint(int xIndex, int yIndex, int zIndex, vector<Cost>& costs) = 0;
235  virtual int postNaryConstraintBegin(vector<int>& scope, Cost defval, Long nbtuples = 0, bool forcenary = false) = 0;
236  virtual int postNaryConstraintBegin(int* scope, int arity, Cost defval, Long nbtuples = 0, bool forcenary = false) = 0;
237  virtual void postNaryConstraintTuple(int ctrindex, vector<Value>& tuple, Cost cost) = 0;
238  virtual void postNaryConstraintTuple(int ctrindex, Value* tuple, int arity, Cost cost) = 0;
239  virtual void postNaryConstraintEnd(int ctrindex) = 0;
240  virtual int postUnary(int xIndex, Value* d, int dsize, Cost penalty) = 0;
241  virtual int postUnaryConstraint(int xIndex, Value* d, int dsize, Cost penalty) = 0;
242  virtual int postSupxyc(int xIndex, int yIndex, Value cst, Value deltamax = MAX_VAL - MIN_VAL) = 0;
243  virtual int postDisjunction(int xIndex, int yIndex, Value cstx, Value csty, Cost penalty) = 0;
244  virtual int postSpecialDisjunction(int xIndex, int yIndex, Value cstx, Value csty, Value xinfty, Value yinfty, Cost costx, Cost costy) = 0;
245  virtual int postCliqueConstraint(vector<int>& scope, const string& arguments) = 0;
246  virtual int postCliqueConstraint(int* scopeIndex, int arity, istream& file) = 0;
247  virtual int postKnapsackConstraint(vector<int>& scope, const string& arguments) = 0;
248  virtual int postKnapsackConstraint(int* scopeIndex, int arity, istream& file) = 0;
249  virtual int postGlobalConstraint(int* scopeIndex, int arity, const string& gcname, istream& file, int* constrcounter = NULL, bool mult = true) = 0;
250 
260  virtual int postWAmong(vector<int>& scope, const string& semantics, const string& propagator, Cost baseCost, const vector<Value>& values, int lb, int ub) = 0;
261  virtual int postWAmong(int* scopeIndex, int arity, const string& semantics, const string& propagator, Cost baseCost, const vector<Value>& values, int lb, int ub) = 0;
262  virtual void postWAmong(int* scopeIndex, int arity, string semantics, Cost baseCost, Value* values, int nbValues, int lb, int ub) = 0;
263  virtual void postWVarAmong(vector<int>& scope, const string& semantics, Cost baseCost, vector<Value>& values, int varIndex) = 0;
264  virtual void postWVarAmong(int* scopeIndex, int arity, const string& semantics, Cost baseCost, Value* values, int nbValues, int varIndex) = 0;
265 
277  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;
278  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;
279  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;
280 
287  virtual int postWAllDiff(int* scopeIndex, int arity, const string& semantics, const string& propagator, Cost baseCost) = 0;
288  virtual void postWAllDiff(int* scopeIndex, int arity, string semantics, Cost baseCost) = 0;
289 
297  virtual int postWGcc(int* scopeIndex, int arity, const string& semantics, const string& propagator, Cost baseCost,
298  const vector<BoundedObjValue>& values)
299  = 0;
300  virtual void postWGcc(int* scopeIndex, int arity, string semantics, Cost baseCost, Value* values, int nbValues, int* lb, int* ub) = 0;
301 
310  virtual int postWSame(int* scopeIndexG1, int arityG1, int* scopeIndexG2, int arityG2, const string& semantics, const string& propagator, Cost baseCost) = 0;
311  virtual void postWSame(int* scopeIndex, int arity, string semantics, Cost baseCost) = 0;
312  virtual void postWSameGcc(int* scopeIndex, int arity, string semantics, Cost baseCost, Value* values, int nbValues, int* lb, int* ub) = 0;
313 
328  virtual int postWGrammarCNF(int* scopeIndex, int arity, const string& semantics, const string& propagator, Cost baseCost,
329  int nbSymbols,
330  int startSymbol,
331  const vector<CFGProductionRule> WRuleToTerminal)
332  = 0;
333 
340  virtual int postMST(int* scopeIndex, int arity, const string& semantics, const string& propagator, Cost baseCost) = 0;
341 
349  virtual int postMaxWeight(int* scopeIndex, int arity, const string& semantics, const string& propagator, Cost baseCost,
350  const vector<WeightedVarValPair> weightFunction)
351  = 0;
352 
361  virtual void postWSum(int* scopeIndex, int arity, string semantics, Cost baseCost, string comparator, int rightRes) = 0;
362  virtual void postWVarSum(int* scopeIndex, int arity, string semantics, Cost baseCost, string comparator, int varIndex) = 0;
363 
372  virtual void postWOverlap(int* scopeIndex, int arity, string semantics, Cost baseCost, string comparator, int rightRes) = 0;
373 
374  virtual vector<vector<int>>* getListSuccessors() = 0;
375 
376  virtual bool isGlobal() = 0;
377 
378  virtual Cost read_wcsp(const char* fileName) = 0;
379  virtual void read_legacy(const char* fileName) = 0;
380  virtual void read_uai2008(const char* fileName) = 0;
381  virtual void read_random(int n, int m, vector<int>& p, int seed, bool forceSubModular = false, string globalname = "") = 0;
382  virtual void read_wcnf(const char* fileName) = 0;
383  virtual void read_qpbo(const char* fileName) = 0;
384  virtual void read_opb(const char* fileName) = 0;
385 
386  virtual const vector<Value> getSolution() = 0;
387  virtual const Double getSolutionValue() = 0;
388  virtual const Cost getSolutionCost() = 0;
389  virtual const vector<Value> getSolution(Cost* cost_ptr) = 0;
390  virtual const vector<pair<Double, vector<Value>>> getSolutions() = 0;
391  virtual void initSolutionCost() = 0;
392  virtual void setSolution(Cost cost, TAssign* sol = NULL) = 0;
393  virtual void printSolution() = 0;
394  virtual void printSolution(ostream& os) = 0;
395  virtual void printSolution(FILE* f) = 0;
396 
397  virtual void print(ostream& os) = 0;
398  virtual void dump(ostream& os, bool original = true) = 0;
399  virtual void dump_CFN(ostream& os, bool original = true) = 0;
400 
401  // -----------------------------------------------------------
402  // Functions dealing with all representations of Costs
403  // warning: ToulBar2::NormFactor has to be initialized
404 
405  virtual Cost decimalToCost(const string& decimalToken, const unsigned int lineNumber) const = 0;
406  virtual Cost DoubletoCost(const Double& c) const = 0;
407  virtual Double Cost2ADCost(const Cost& c) const = 0;
408  virtual Double Cost2RDCost(const Cost& c) const = 0;
409  virtual Cost Prob2Cost(TProb p) const = 0;
410  virtual TProb Cost2Prob(Cost c) const = 0;
411  virtual TLogProb Cost2LogProb(Cost c) const = 0;
412  virtual Cost LogProb2Cost(TLogProb p) const = 0;
413  virtual Cost LogSumExp(Cost c1, Cost c2) const = 0;
414  virtual TLogProb LogSumExp(TLogProb logc1, Cost c2) const = 0;
415  virtual TLogProb LogSumExp(TLogProb logc1, TLogProb logc2) const = 0;
416 
417  // -----------------------------------------------------------
418  // Internal WCSP functions DO NOT USE THEM
419 
420  virtual void setLb(Cost newLb) = 0;
421  virtual void setUb(Cost newUb) = 0;
422  virtual Cost getNegativeLb() const = 0;
423  virtual void restoreSolution(Cluster* c = NULL) = 0;
424 
425  virtual void buildTreeDecomposition() = 0;
426  virtual TreeDecomposition* getTreeDec() = 0;
427 
428  virtual const vector<Variable*>& getDivVariables() = 0;
429  virtual void addDivConstraint(const vector<Value> solution, int sol_id, Cost cost) = 0;
430  virtual void addHDivConstraint(const vector<Value> solution, int sol_id, Cost cost) = 0;
431  virtual void addTDivConstraint(const vector<Value> solution, int sol_id, Cost cost) = 0;
432  virtual void addMDDConstraint(Mdd mdd, int relaxed) = 0;
433  virtual void addHMDDConstraint(Mdd mdd, int relaxed) = 0;
434  virtual void addTMDDConstraint(Mdd mdd, int relaxed) = 0;
435 
436  virtual void iniSingleton() = 0;
437  virtual void updateSingleton() = 0;
438  virtual void removeSingleton() = 0;
439  virtual void printVACStat() = 0;
440 };
441 
442 ostream& operator<<(ostream& os, WeightedCSP& wcsp);
443 
456 public:
457  static WeightedCSPSolver* makeWeightedCSPSolver(Cost initUpperBound);
458 
459  virtual ~WeightedCSPSolver() {}
460 
461  virtual WeightedCSP* getWCSP() = 0;
462 
463  virtual Long getNbNodes() const = 0;
464  virtual Long getNbBacktracks() const = 0;
465 
466  virtual void increase(int varIndex, Value value, bool reverse = false) = 0;
467  virtual void decrease(int varIndex, Value value, bool reverse = false) = 0;
468  virtual void assign(int varIndex, Value value, bool reverse = false) = 0;
469  virtual void remove(int varIndex, Value value, bool reverse = false) = 0;
470 
523  virtual Cost read_wcsp(const char* fileName) = 0;
524  virtual void read_random(int n, int m, vector<int>& p, int seed, bool forceSubModular = false, string globalname = "") = 0;
525 
530  virtual bool solve(bool first = true) = 0;
531 
532  // internal methods called by solve, for advanced programmers only!!!
533  virtual void beginSolve(Cost ub) = 0;
534  virtual Cost preprocessing(Cost ub) = 0;
535  virtual void recursiveSolve(Cost lb = MIN_COST) = 0;
536  virtual void recursiveSolveLDS(int discrepancy) = 0;
537  virtual pair<Cost, Cost> hybridSolve() = 0;
538  virtual void endSolve(bool isSolution, Cost cost, bool isComplete) = 0;
539  // end of internal solve methods
540 
547  virtual Cost narycsp(string cmd, vector<Value>& solution) = 0;
548 
557  virtual bool solve_symmax2sat(int n, int m, int* posx, int* posy, double* cost, int* sol) = 0;
558 
559  virtual void dump_wcsp(const char* fileName, bool original = true, ProblemFormat format = WCSP_FORMAT) = 0;
560  virtual void read_solution(const char* fileName, bool updateValueHeuristic = true) = 0;
561  virtual void parse_solution(const char* certificate, bool updateValueHeuristic = true) = 0;
562 
563  virtual const vector<Value> getSolution() = 0;
564  virtual const Double getSolutionValue() = 0;
565  virtual const Cost getSolutionCost() = 0;
566  virtual const Cost getSolution(vector<Value>& solution) = 0;
567  virtual const vector<pair<Double, vector<Value>>> getSolutions() = 0;
568 
569  // -----------------------------------------------------------
570  // Internal Solver functions DO NOT USE THEM
571 
572  virtual set<int> getUnassignedVars() const = 0;
573  virtual unsigned int numberOfUnassignedVariables() const = 0;
574 };
575 
577 extern void tb2init();
579 extern void tb2checkOptions();
580 #endif /*TOULBAR2LIB_HPP_*/
581 
582 /* Local Variables: */
583 /* c-basic-offset: 4 */
584 /* tab-width: 4 */
585 /* indent-tabs-mode: nil */
586 /* c-default-style: "k&r" */
587 /* End: */
Definition: toulbar2lib.hpp:455
virtual const vector< pair< Double, vector< Value > > > getSolutions()=0
after solving the problem, return all solutions found with their corresponding value
virtual void remove(int varIndex, Value value, bool reverse=false)=0
removes a domain value and propagates (valid if done for an enumerated variable or on its domain boun...
virtual bool solve_symmax2sat(int n, int m, int *posx, int *posy, double *cost, int *sol)=0
quadratic unconstrained pseudo-Boolean optimization Maximize where is expressed by all its non-zero...
virtual const Double getSolutionValue()=0
after solving the problem, return the optimal solution value (can be an arbitrary real cost in minimi...
virtual Cost read_wcsp(const char *fileName)=0
reads a Cost function network from a file (format as indicated by ToulBar2:: global variables)
virtual void dump_wcsp(const char *fileName, bool original=true, ProblemFormat format=WCSP_FORMAT)=0
output current problem in a file
virtual WeightedCSP * getWCSP()=0
access to its associated Weighted CSP
virtual const vector< Value > getSolution()=0
after solving the problem, return the optimal solution (warning! do not use it if doing solution coun...
virtual const Cost getSolution(vector< Value > &solution)=0
after solving the problem, add the optimal solution in the input/output vector and returns its optimu...
virtual Long getNbBacktracks() const =0
number of backtracks
virtual void decrease(int varIndex, Value value, bool reverse=false)=0
changes domain upper bound and propagates
virtual void read_random(int n, int m, vector< int > &p, int seed, bool forceSubModular=false, string globalname="")=0
create a random WCSP, see WeightedCSP::read_random
virtual void assign(int varIndex, Value value, bool reverse=false)=0
assigns a variable and propagates
static WeightedCSPSolver * makeWeightedCSPSolver(Cost initUpperBound)
WeightedCSP Solver factory.
Definition: tb2solver.cpp:30
virtual bool solve(bool first=true)=0
simplifies and solves to optimality the problem
virtual Long getNbNodes() const =0
number of search nodes (see WeightedCSPSolver::increase, WeightedCSPSolver::decrease,...
virtual const Cost getSolutionCost()=0
after solving the problem, return the optimal solution nonnegative integer cost (warning!...
virtual void parse_solution(const char *certificate, bool updateValueHeuristic=true)=0
read a solution from a string (see ToulBar2 option -x)
virtual Cost narycsp(string cmd, vector< Value > &solution)=0
solves the current problem using INCOP local search solver by Bertrand Neveu
virtual void increase(int varIndex, Value value, bool reverse=false)=0
changes domain lower bound and propagates
virtual void read_solution(const char *fileName, bool updateValueHeuristic=true)=0
read a solution from a file
Definition: toulbar2lib.hpp:75
virtual Double getDLb() const =0
gets problem lower bound as a Double representing a decimal cost
virtual void printSolution(ostream &os)=0
prints current best solution (using variable and value names if cfn format and ToulBar2::writeSolutio...
virtual string getName(int varIndex) const =0
virtual Value getValue(int varIndex) const =0
current assigned value
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 bool getIsPartOfOptimalSolution()=0
special flag used for debugging purposes only
virtual unsigned int getDomainInitSize(int varIndex) const =0
gets initial domain size (warning! assumes EnumeratedVariable)
virtual Value getBestValue(int varIndex) const =0
hint for some value ordering heuristics (only used by RDS)
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 unsigned int medianDomainSize() const =0
median current domain size of variables
virtual bool verify()=0
checks the propagation fix point is reached
virtual void setIsPartOfOptimalSolution(bool v)=0
special flag used for debugging purposes only
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 setName(const string &problem)=0
set WCSP problem name
virtual int makeEnumeratedVariable(string n, Value iinf, Value isup)=0
create an enumerated variable with its domain bounds
virtual void postNaryConstraintEnd(int ctrindex)=0
virtual Value toValue(int varIndex, unsigned int idx)=0
gets value from index (warning! assumes EnumeratedVariable)
virtual Cost getUnaryCost(int varIndex, Value v) const =0
unary cost associated to a domain value
virtual void read_qpbo(const char *fileName)=0
load quadratic pseudo-Boolean optimization problem in unconstrained quadratic programming text format...
virtual void postUnary(int xIndex, vector< Cost > &costs)=0
virtual void setInfiniteCost()=0
updates infinite costs in all cost functions accordingly to the problem global lower and upper bounds
virtual unsigned int numberOfConnectedConstraints() const =0
current number of cost functions
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)
static WeightedCSP * makeWeightedCSP(Cost upperBound, void *solver=NULL)
Weighted CSP factory.
Definition: tb2wcsp.cpp:657
virtual void decrease(int varIndex, Value newSup)=0
changes domain upper bound
virtual void addValueName(int xIndex, const string &valuename)=0
add next value name
virtual vector< pair< Value, Cost > > getEnumDomainAndCost(int varIndex)=0
gets current domain values and unary costs in an array
virtual void print(ostream &os)=0
print current domains and active cost functions (see Output messages, verbosity options and debugging...
virtual void sortConstraints()=0
sorts the list of cost functions associated to each variable based on smallest problem variable index...
virtual void preprocessing()=0
applies various preprocessing techniques to simplify the current problem
virtual void postWSum(int *scopeIndex, int arity, string semantics, Cost baseCost, string comparator, int rightRes)=0
post a soft linear constraint with unit coefficients
virtual int postKnapsackConstraint(vector< int > &scope, const string &arguments)=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 Long getWeightedDegree(int varIndex) const =0
weighted degree heuristic
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 Cho...
virtual unsigned int numberOfConnectedBinaryConstraints() const =0
current number of binary cost functions
virtual Value getInf(int varIndex) const =0
minimum current domain value
virtual void initSolutionCost()=0
returns all solutions found
virtual Cost finiteUb() const =0
computes the worst-case assignment finite cost (sum of maximum finite cost over all cost functions pl...
virtual void read_opb(const char *fileName)=0
load pseudo-Boolean optimization problem
virtual void postNaryConstraintTuple(int ctrindex, vector< Value > &tuple, Cost cost)=0
virtual Value getMaxUnaryCostValue(int varIndex) const =0
a value having the maximum unary cost in the domain
virtual int getTrueDegree(int varIndex) const =0
degree of a variable
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....
virtual void resetWeightedDegree(int varIndex)=0
initialize weighted degree heuristic
virtual void increase(int varIndex, Value newInf)=0
changes domain lower bound
virtual Cost getLb() const =0
gets internal dual lower bound
virtual void printSolution()=0
prints current best solution on standard output (using variable and value names if cfn format and Tou...
virtual void postWGcc(int *scopeIndex, int arity, string semantics, Cost baseCost, Value *values, int nbValues, int *lb, int *ub)=0
virtual bool getEnumDomainAndCost(int varIndex, ValueCost *array)=0
virtual void increaseLb(Cost addLb)=0
increases problem lower bound thanks to eg soft local consistencies
virtual void propagate()=0
propagates until a fix point is reached (or throws a contradiction)
virtual void printSolution(FILE *f)=0
prints current best solution (using variable and value names if cfn format and ToulBar2::writeSolutio...
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
virtual void enforceUb()=0
enforces problem upper bound when exploring an alternative search node
virtual vector< vector< int > > * getListSuccessors()=0
generating additional variables vector created when berge decomposition are included in the WCSP
virtual const vector< Value > getSolution(Cost *cost_ptr)=0
returns current best solution and its cost
virtual void postWAllDiff(int *scopeIndex, int arity, string semantics, Cost baseCost)=0
virtual void postWAmong(int *scopeIndex, int arity, string semantics, Cost baseCost, Value *values, int nbValues, int lb, int ub)=0
virtual unsigned int numberOfUnassignedVariables() const =0
current number of unassigned variables
virtual int postNaryConstraintBegin(int *scope, int arity, Cost defval, Long nbtuples=0, bool forcenary=false)=0
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 ...
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 varInd...
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 unsigned int medianArity() const =0
median arity of current cost functions
virtual bool enumerated(int varIndex) const =0
true if the variable has an enumerated domain
virtual void postWSame(int *scopeIndex, int arity, string semantics, Cost baseCost)=0
virtual int postGlobalConstraint(int *scopeIndex, int arity, const string &gcname, istream &file, int *constrcounter=NULL, bool mult=true)=0
virtual int postUnary(int xIndex, Value *d, int dsize, Cost penalty)=0
virtual int postWAllDiff(int *scopeIndex, int arity, const string &semantics, const string &propagator, Cost baseCost)=0
post a soft alldifferent cost function
virtual void postWVarAmong(int *scopeIndex, int arity, const string &semantics, Cost baseCost, Value *values, int nbValues, int varIndex)=0
virtual unsigned int getDomainSize(int varIndex) const =0
current domain size
virtual const vector< Value > getSolution()=0
after solving the problem, return the optimal solution (warning! do not use it if doing solution coun...
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
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 sa...
virtual void dump_CFN(ostream &os, bool original=true)=0
output the current WCSP into a file in wcsp format
virtual vector< Value > getEnumDomain(int varIndex)=0
gets current domain values in an array
virtual Value getSup(int varIndex) const =0
maximum current domain value
virtual unsigned int numberOfConstraints() const =0
initial number of cost functions (before variable elimination)
virtual int getIndex() const =0
instantiation occurrence number of current WCSP object
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...
virtual void * getSolver() const =0
special hook to access solver information
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
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 (...
virtual bool getEnumDomain(int varIndex, Value *array)=0
virtual Double getDPrimalBound() const =0
gets problem primal bound as a Double representing a decimal cost (upper resp. lower bound for minimi...
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 Neighbo...
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 Long getNbDEE() const =0
number of value removals due to dead-end elimination
virtual const Cost getSolutionCost()=0
returns current best solution cost or MAX_COST if no solution found
virtual unsigned int getDomainSizeSum() const =0
total sum of current domain sizes
virtual Cost getMaxUnaryCost(int varIndex) const =0
maximum unary cost in the domain
virtual int postMST(int *scopeIndex, int arity, const string &semantics, const string &propagator, Cost baseCost)=0
post a Spanning Tree hard constraint
virtual const vector< Variable * > & getDivVariables()=0
returns all variables on which a diversity request exists
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 Value getSupport(int varIndex) const =0
NC/EAC unary support value.
virtual const Double getSolutionValue()=0
returns current best solution cost or MAX_COST if no solution found
virtual unsigned int numberOfVariables() const =0
number of created variables
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 t...
virtual void dump(ostream &os, bool original=true)=0
output the current WCSP into a file in wcsp format
virtual int getVarIndex(const string &s) const =0
return variable index from its name, or numberOfVariables() if not found
virtual unsigned int medianDegree() const =0
median current degree of variables
virtual void updateUb(Cost newUb)=0
sets initial problem upper bound and each time a new solution is found
virtual int getDegree(int varIndex) const =0
approximate degree of a variable (ie number of active cost functions, see Variable elimination)
virtual void setBestValue(int varIndex, Value v)=0
hint for some value ordering heuristics (only used by RDS)
virtual Double getDDualBound() const =0
gets problem dual bound as a Double representing a decimal cost (lower resp. upper bound for minimiza...
virtual void assign(int varIndex, Value newValue)=0
assigns a variable and immediately propagates this assignment
virtual unsigned int toIndex(int varIndex, Value value)=0
gets index from value (warning! assumes EnumeratedVariable)
virtual Double getDUb() const =0
gets problem upper bound as a Double representing a decimal cost
virtual void read_legacy(const char *fileName)=0
load problem in wcsp legacy format
virtual void cartProd(BigInteger &cartesianProduct)=0
Cartesian product of current domain sizes.
virtual bool isGlobal()=0
true if there are soft global constraints defined in the problem
virtual unsigned int toIndex(int varIndex, const string &valueName)=0
gets index from value name (warning! assumes EnumeratedVariable with value names)
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 Cost getUb() const =0
gets internal primal upper bound
virtual void whenContradiction()=0
after a contradiction, resets propagation queues
virtual string getName() const =0
get WCSP problem name (defaults to filename with no extension)
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 int makeIntervalVariable(string n, Value iinf, Value isup)=0
create an interval variable with its domain bounds
virtual int makeEnumeratedVariable(string n, Value *d, int dsize)=0
create an enumerated variable with its domain values
virtual int getDACOrder(int varIndex) const =0
index of the variable in the DAC variable ordering