toulbar2
toulbar2lib.hpp
1
59#ifndef TOULBAR2LIB_HPP_
60#define TOULBAR2LIB_HPP_
61
62#include "core/tb2types.hpp"
63
76public:
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;
104 virtual void decreaseLb(Cost shift) = 0;
105 virtual Cost getNegativeLb() const = 0;
109 virtual Cost finiteUb() const = 0;
112 virtual void setInfiniteCost() = 0;
113
114 virtual bool enumerated(int varIndex) const = 0;
115
116 virtual string getName(int varIndex) const = 0;
117 virtual unsigned int getVarIndex(const string& s) const = 0;
118 virtual Value getInf(int varIndex) const = 0;
119 virtual Value getSup(int varIndex) const = 0;
120 virtual Value getValue(int varIndex) const = 0;
121 virtual unsigned int getDomainSize(int varIndex) const = 0;
122 virtual vector<Value> getEnumDomain(int varIndex) = 0;
123 virtual bool getEnumDomain(int varIndex, Value* array) = 0;
124 virtual vector<pair<Value, Cost>> getEnumDomainAndCost(int varIndex) = 0;
125 virtual bool getEnumDomainAndCost(int varIndex, ValueCost* array) = 0;
126 virtual unsigned int getDomainInitSize(int varIndex) const = 0;
127 virtual Value toValue(int varIndex, unsigned int idx) = 0;
128 virtual unsigned int toIndex(int varIndex, Value value) = 0;
129 virtual unsigned int toIndex(int varIndex, const string& valueName) = 0;
130 virtual int getDACOrder(int varIndex) const = 0;
131
132 virtual bool assigned(int varIndex) const = 0;
133 virtual bool unassigned(int varIndex) const = 0;
134 virtual bool canbe(int varIndex, Value v) const = 0;
135 virtual bool cannotbe(int varIndex, Value v) const = 0;
136 virtual Value nextValue(int varIndex, Value v) const = 0;
137
138 virtual void increase(int varIndex, Value newInf) = 0;
139 virtual void decrease(int varIndex, Value newSup) = 0;
140 virtual void assign(int varIndex, Value newValue) = 0;
141 virtual void remove(int varIndex, Value remValue) = 0;
142
146 virtual void assignLS(vector<int>& varIndexes, vector<Value>& newValues, bool force = false) = 0;
147 virtual void assignLS(int* varIndexes, Value* newValues, unsigned int size, bool dopropagate, bool force = false) = 0;
148
149 virtual Cost getUnaryCost(int varIndex, Value v) const = 0;
150 virtual Cost getMaxUnaryCost(int varIndex) const = 0;
151 virtual Value getMaxUnaryCostValue(int varIndex) const = 0;
152 virtual Value getSupport(int varIndex) const = 0;
153 virtual Value getBestValue(int varIndex) const = 0;
154 virtual void setBestValue(int varIndex, Value v) = 0;
155 virtual bool getIsPartOfOptimalSolution() = 0;
156 virtual void setIsPartOfOptimalSolution(bool v) = 0;
157
158 virtual int getDegree(int varIndex) const = 0;
159 virtual int getTrueDegree(int varIndex) const = 0;
160 virtual Long getWeightedDegree(int varIndex) const = 0;
161 virtual void resetWeightedDegree(int varIndex) = 0;
162
163 virtual void preprocessing() = 0;
167 virtual void sortConstraints() = 0;
168
169 virtual void whenContradiction() = 0;
170 virtual void propagate() = 0;
171 virtual bool verify() = 0;
172
173 virtual unsigned int numberOfVariables() const = 0;
174 virtual unsigned int numberOfUnassignedVariables() const = 0;
175 virtual unsigned int numberOfConstraints() const = 0;
176 virtual unsigned int numberOfConnectedConstraints() const = 0;
177 virtual unsigned int numberOfConnectedBinaryConstraints() const = 0;
178 virtual unsigned int medianDomainSize() const = 0;
179 virtual unsigned int medianDegree() const = 0;
180 virtual unsigned int medianArity() const = 0;
181 virtual int getMaxDomainSize() const = 0;
182 virtual int getMaxCurrentDomainSize() const = 0;
183 virtual unsigned int getDomainSizeSum() const = 0;
186 virtual void cartProd(BigInteger& cartesianProduct) = 0;
187 virtual Long getNbDEE() const = 0;
188
197
222
223 virtual int makeEnumeratedVariable(string n, Value iinf, Value isup) = 0;
224 virtual int makeEnumeratedVariable(string n, Value* d, int dsize) = 0;
225 virtual void addValueName(int xIndex, const string& valuename) = 0;
226 virtual int makeIntervalVariable(string n, Value iinf, Value isup) = 0;
227 virtual void postNullaryConstraint(Double cost) = 0;
228 virtual void postNullaryConstraint(Cost cost) = 0;
229 virtual void postUnary(int xIndex, vector<Cost>& costs) = 0;
230 virtual void postUnaryConstraint(int xIndex, vector<Double>& costs, bool incremental = false) = 0;
231 virtual void postUnaryConstraint(int xIndex, vector<Cost>& costs) = 0;
232 virtual void postIncrementalUnaryConstraint(int xIndex, vector<Cost>& costs) = 0;
233 virtual int postBinaryConstraint(int xIndex, int yIndex, vector<Double>& costs, bool incremental = false) = 0;
234 virtual int postBinaryConstraint(int xIndex, int yIndex, vector<Cost>& costs) = 0;
235 virtual int postIncrementalBinaryConstraint(int xIndex, int yIndex, vector<Cost>& costs) = 0;
236 virtual int postTernaryConstraint(int xIndex, int yIndex, int zIndex, vector<Double>& costs, bool incremental = false) = 0;
237 virtual int postTernaryConstraint(int xIndex, int yIndex, int zIndex, vector<Cost>& costs) = 0;
238 virtual int postIncrementalTernaryConstraint(int xIndex, int yIndex, int zIndex, vector<Cost>& costs) = 0;
239 virtual int postNaryConstraintBegin(vector<int>& scope, Cost defval, Long nbtuples = 0, bool forcenary = false) = 0;
240 virtual int postNaryConstraintBegin(int* scope, int arity, Cost defval, Long nbtuples = 0, bool forcenary = false) = 0;
241 virtual void postNaryConstraintTuple(int ctrindex, vector<Value>& tuple, Cost cost) = 0;
242 virtual void postNaryConstraintTuple(int ctrindex, Value* tuple, int arity, Cost cost) = 0;
243 virtual void postNaryConstraintEnd(int ctrindex) = 0;
244 virtual int postUnary(int xIndex, Value* d, int dsize, Cost penalty) = 0;
245 virtual int postUnaryConstraint(int xIndex, Value* d, int dsize, Cost penalty) = 0;
246 virtual int postSupxyc(int xIndex, int yIndex, Value cst, Value deltamax = MAX_VAL - MIN_VAL) = 0;
247 virtual int postDisjunction(int xIndex, int yIndex, Value cstx, Value csty, Cost penalty) = 0;
248 virtual int postSpecialDisjunction(int xIndex, int yIndex, Value cstx, Value csty, Value xinfty, Value yinfty, Cost costx, Cost costy) = 0;
249 virtual int postCliqueConstraint(vector<int>& scope, const string& arguments) = 0;
250 virtual int postCliqueConstraint(int* scopeIndex, int arity, istream& file) = 0;
251 virtual int postKnapsackConstraint(vector<int>& scope, const string& arguments) = 0;
252 virtual int postKnapsackConstraint(int* scopeIndex, int arity, istream& file) = 0;
253 virtual int postGlobalConstraint(int* scopeIndex, int arity, const string& gcname, istream& file, int* constrcounter = NULL, bool mult = true) = 0;
254
264 virtual int postWAmong(vector<int>& scope, const string& semantics, const string& propagator, Cost baseCost, const vector<Value>& values, int lb, int ub) = 0;
265 virtual int postWAmong(int* scopeIndex, int arity, const string& semantics, const string& propagator, Cost baseCost, const vector<Value>& values, int lb, int ub) = 0;
266 virtual void postWAmong(int* scopeIndex, int arity, string semantics, Cost baseCost, Value* values, int nbValues, int lb, int ub) = 0;
267 virtual void postWVarAmong(vector<int>& scope, const string& semantics, Cost baseCost, vector<Value>& values, int varIndex) = 0;
268 virtual void postWVarAmong(int* scopeIndex, int arity, const string& semantics, Cost baseCost, Value* values, int nbValues, int varIndex) = 0;
269
281 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;
282 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;
283 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;
284
291 virtual int postWAllDiff(int* scopeIndex, int arity, const string& semantics, const string& propagator, Cost baseCost) = 0;
292 virtual void postWAllDiff(int* scopeIndex, int arity, string semantics, Cost baseCost) = 0;
293
301 virtual int postWGcc(int* scopeIndex, int arity, const string& semantics, const string& propagator, Cost baseCost,
302 const vector<BoundedObjValue>& values)
303 = 0;
304 virtual void postWGcc(int* scopeIndex, int arity, string semantics, Cost baseCost, Value* values, int nbValues, int* lb, int* ub) = 0;
305
314 virtual int postWSame(int* scopeIndexG1, int arityG1, int* scopeIndexG2, int arityG2, const string& semantics, const string& propagator, Cost baseCost) = 0;
315 virtual void postWSame(int* scopeIndex, int arity, string semantics, Cost baseCost) = 0;
316 virtual void postWSameGcc(int* scopeIndex, int arity, string semantics, Cost baseCost, Value* values, int nbValues, int* lb, int* ub) = 0;
317
332 virtual int postWGrammarCNF(int* scopeIndex, int arity, const string& semantics, const string& propagator, Cost baseCost,
333 int nbSymbols,
334 int startSymbol,
335 const vector<CFGProductionRule> WRuleToTerminal)
336 = 0;
337
344 virtual int postMST(int* scopeIndex, int arity, const string& semantics, const string& propagator, Cost baseCost) = 0;
345
353 virtual int postMaxWeight(int* scopeIndex, int arity, const string& semantics, const string& propagator, Cost baseCost,
354 const vector<WeightedVarValPair> weightFunction)
355 = 0;
356
365 virtual void postWSum(int* scopeIndex, int arity, string semantics, Cost baseCost, string comparator, int rightRes) = 0;
366 virtual void postWVarSum(int* scopeIndex, int arity, string semantics, Cost baseCost, string comparator, int varIndex) = 0;
367
376 virtual void postWOverlap(int* scopeIndex, int arity, string semantics, Cost baseCost, string comparator, int rightRes) = 0;
377
378 virtual vector<vector<int>>* getListSuccessors() = 0;
379
380 virtual bool isGlobal() = 0;
381
382 virtual Cost read_wcsp(const char* fileName) = 0;
383 virtual void read_legacy(const char* fileName) = 0;
384 virtual void read_uai2008(const char* fileName) = 0;
385 virtual void read_random(int n, int m, vector<int>& p, int seed, bool forceSubModular = false, string globalname = "") = 0;
386 virtual void read_wcnf(const char* fileName) = 0;
387 virtual void read_qpbo(const char* fileName) = 0;
388 virtual void read_opb(const char* fileName) = 0;
389
390 virtual const vector<Value> getSolution() = 0;
391 virtual Double getSolutionValue() const = 0;
392 virtual Cost getSolutionCost() const = 0;
393 virtual const vector<Value> getSolution(Cost* cost_ptr) = 0;
394 virtual vector<pair<Double, vector<Value>>> getSolutions() const = 0;
395 virtual void initSolutionCost() = 0;
396 virtual void setSolution(Cost cost, TAssign* sol = NULL) = 0;
397 virtual void printSolution() = 0;
398 virtual void printSolution(ostream& os) = 0;
399 virtual void printSolution(FILE* f) = 0;
400
401 virtual void print(ostream& os) = 0;
402 virtual void dump(ostream& os, bool original = true) = 0;
403 virtual void dump_CFN(ostream& os, bool original = true) = 0;
404
405 // -----------------------------------------------------------
406 // Functions dealing with all representations of Costs
407 // warning: ToulBar2::NormFactor has to be initialized
408
409 virtual Cost decimalToCost(const string& decimalToken, const unsigned int lineNumber) const = 0;
410 virtual Cost DoubletoCost(const Double& c) const = 0;
411 virtual Double Cost2ADCost(const Cost& c) const = 0;
412 virtual Double Cost2RDCost(const Cost& c) const = 0;
413 virtual Cost Prob2Cost(TProb p) const = 0;
414 virtual TProb Cost2Prob(Cost c) const = 0;
415 virtual TLogProb Cost2LogProb(Cost c) const = 0;
416 virtual Cost LogProb2Cost(TLogProb p) const = 0;
417 virtual Cost LogSumExp(Cost c1, Cost c2) const = 0;
418 virtual TLogProb LogSumExp(TLogProb logc1, Cost c2) const = 0;
419 virtual TLogProb LogSumExp(TLogProb logc1, TLogProb logc2) const = 0;
420
421 // -----------------------------------------------------------
422 // Internal WCSP functions DO NOT USE THEM
423
424 virtual void setLb(Cost newLb) = 0;
425 virtual void setUb(Cost newUb) = 0;
426 virtual void restoreSolution(Cluster* c = NULL) = 0;
427
428 virtual void buildTreeDecomposition() = 0;
429 virtual TreeDecomposition* getTreeDec() = 0;
430
431 virtual const vector<Variable*>& getDivVariables() = 0;
432 virtual void addDivConstraint(const vector<Value> solution, int sol_id, Cost cost) = 0;
433 virtual void addHDivConstraint(const vector<Value> solution, int sol_id, Cost cost) = 0;
434 virtual void addTDivConstraint(const vector<Value> solution, int sol_id, Cost cost) = 0;
435 virtual void addMDDConstraint(Mdd mdd, int relaxed) = 0;
436 virtual void addHMDDConstraint(Mdd mdd, int relaxed) = 0;
437 virtual void addTMDDConstraint(Mdd mdd, int relaxed) = 0;
438
439 virtual void iniSingleton() = 0;
440 virtual void updateSingleton() = 0;
441 virtual void removeSingleton() = 0;
442 virtual void printVACStat() = 0;
443};
444
445ostream& operator<<(ostream& os, WeightedCSP& wcsp);
446
459public:
460 static WeightedCSPSolver* makeWeightedCSPSolver(Cost initUpperBound);
461
462 virtual ~WeightedCSPSolver() {}
463
464 virtual WeightedCSP* getWCSP() = 0;
465
466 virtual Long getNbNodes() const = 0;
467 virtual Long getNbBacktracks() const = 0;
468
469 virtual void increase(int varIndex, Value value, bool reverse = false) = 0;
470 virtual void decrease(int varIndex, Value value, bool reverse = false) = 0;
471 virtual void assign(int varIndex, Value value, bool reverse = false) = 0;
472 virtual void remove(int varIndex, Value value, bool reverse = false) = 0;
473
526 virtual Cost read_wcsp(const char* fileName) = 0;
527 virtual void read_random(int n, int m, vector<int>& p, int seed, bool forceSubModular = false, string globalname = "") = 0;
528
533 virtual bool solve(bool first = true) = 0;
534
535 // internal methods called by solve, for advanced programmers only!!!
536 virtual void beginSolve(Cost ub) = 0;
537 virtual Cost preprocessing(Cost ub) = 0;
538 virtual void recursiveSolve(Cost lb = MIN_COST) = 0;
539 virtual void recursiveSolveLDS(int discrepancy) = 0;
540 virtual pair<Cost, Cost> hybridSolve() = 0;
541 virtual void endSolve(bool isSolution, Cost cost, bool isComplete) = 0;
542 // end of internal solve methods
543
550 virtual Cost narycsp(string cmd, vector<Value>& solution) = 0;
551
560 virtual bool solve_symmax2sat(int n, int m, int* posx, int* posy, double* cost, int* sol) = 0;
561
562 virtual void dump_wcsp(const char* fileName, bool original = true, ProblemFormat format = WCSP_FORMAT) = 0;
563 virtual void read_solution(const char* fileName, bool updateValueHeuristic = true) = 0;
564 virtual void parse_solution(const char* certificate, bool updateValueHeuristic = true) = 0;
565
566 virtual const vector<Value> getSolution() = 0;
567 virtual Double getSolutionValue() const = 0;
568 virtual Cost getSolutionCost() const = 0;
569 virtual Cost getSolution(vector<Value>& solution) const = 0;
570 virtual vector<pair<Double, vector<Value>>> getSolutions() const = 0;
571
572 // -----------------------------------------------------------
573 // Internal Solver functions DO NOT USE THEM
574
575 virtual set<int> getUnassignedVars() const = 0;
576 virtual unsigned int numberOfUnassignedVariables() const = 0;
577};
578
580extern void tb2init();
582extern void tb2checkOptions();
583#endif /*TOULBAR2LIB_HPP_*/
584
585/* Local Variables: */
586/* c-basic-offset: 4 */
587/* tab-width: 4 */
588/* indent-tabs-mode: nil */
589/* c-default-style: "k&r" */
590/* End: */
Definition toulbar2lib.hpp:458
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 Cost getSolutionCost() const =0
after solving the problem, return the optimal solution nonnegative integer cost (warning!...
virtual vector< pair< Double, vector< Value > > > getSolutions() const =0
after solving the problem, return all solutions found with their corresponding value
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 Cost read_wcsp(const char *fileName)=0
reads a Cost function network from a file (format as indicated by ToulBar2:: global variables)
virtual WeightedCSP * getWCSP()=0
access to its associated Weighted CSP
virtual void dump_wcsp(const char *fileName, bool original=true, ProblemFormat format=WCSP_FORMAT)=0
output current problem in a file
virtual Double getSolutionValue() const =0
after solving the problem, return the optimal solution value (can be an arbitrary real cost in minimi...
virtual Cost getSolution(vector< Value > &solution) const =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 vector< Value > getSolution()=0
after solving the problem, return the optimal solution (warning! do not use it if doing solution coun...
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 const vector< Value > getSolution(Cost *cost_ptr)=0
returns current best solution and its cost
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 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 * getSolver() const =0
special hook to access solver information
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 const vector< Variable * > & getDivVariables()=0
returns all variables on which a diversity request exists
virtual Cost getNegativeLb() const =0
gets constant term used to subtract to the problem optimum when printing the solutions
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 vector< pair< Value, Cost > > getEnumDomainAndCost(int varIndex)=0
gets current domain values and unary costs in an array
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 vector< vector< int > > * getListSuccessors()=0
generating additional variables vector created when berge decomposition are included in the WCSP
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 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 vector< Value > getEnumDomain(int varIndex)=0
gets current domain values in an array
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 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 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 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 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 const vector< Value > getSolution()=0
after solving the problem, return the optimal solution (warning! do not use it if doing solution coun...
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 Long getNbDEE() const =0
number of value removals due to dead-end elimination
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 Cost getSolutionCost() const =0
returns current best solution cost or MAX_COST if no solution found
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 unsigned int getVarIndex(const string &s) const =0
return variable index from its name, or numberOfVariables() if not found
virtual void decreaseLb(Cost shift)=0
shift problem optimum toward negative costs
virtual unsigned int numberOfVariables() const =0
number of created variables
virtual Double getSolutionValue() const =0
returns current best solution cost or MAX_COST if no solution found
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 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