toulbar2
tb2sameconstr.hpp
1 
5 #ifndef TB2SAMECONSTR_HPP_
6 #define TB2SAMECONSTR_HPP_
7 
8 #include "tb2flowbasedconstr.hpp"
9 
10 class SameConstraint : public FlowBasedGlobalConstraint {
11 private:
12  //int def;
13  void buildIndex();
14  vector<int> group[2];
15  int nDistinctDomainValues;
16  pair<int, int> mapto(int varindex, Value val);
17  //void checkRemoved(Graph &graph, vector<int> &rmv);
18  size_t GetGraphAllocatedSize();
19  void buildGraph(Graph& g);
20  //void getDomainFromGraph(Graph &graph, int varindex, vector<int> &domain);
21  //void augmentGraph(Graph &graph, int &cost, int varindex);
22 public:
23  SameConstraint(WCSP* wcsp, EnumeratedVariable** scope_in, int
24  arity_in);
25 
26  ~SameConstraint() {}
27 
28  Cost evalOriginal(const String& s);
29  /*void addToGroup(int gp, Variable *var) {
30  for (int i=0;i<arity_;i++) {
31  if (getVar(i) == var) {
32  group[gp][size[gp]] = i;
33  size[gp]++;
34  break;
35  }
36  }
37  }
38  void addToGroupX(Variable *var) {addToGroup(0, var);}
39  void addToGroupY(Variable *var) {addToGroup(1, var);}
40  */
41  string getName() { return "ssame"; }
42  void read(istream& file, bool mult = true);
43  void addVariablesToGroup(EnumeratedVariable* variable, int groupID)
44  {
45 
46  for (int j = 0; j < arity_; j++) {
47  if (getVar(j) == variable) {
48  group[groupID].push_back(j);
49  break;
50  }
51  }
52  }
53  void organizeConfig()
54  {
55  for (int g = 0; g < 2; g++)
56  sort(group[g].begin(), group[g].end());
57  }
58 
59  // void print(ostream& os);
60  void dump(ostream& os, bool original = true);
61 };
62 
63 #endif
64 
65 /* Local Variables: */
66 /* c-basic-offset: 4 */
67 /* tab-width: 4 */
68 /* indent-tabs-mode: nil */
69 /* c-default-style: "k&r" */
70 /* End: */
WeightedCSPSolver::solve
virtual bool solve()=0
simplifies and solves to optimality the problem
INCOP::NaryConstraint::nbtuples
int nbtuples(vector< int > *tabdomaines)
Definition: narycsproblem.cpp:155
WeightedCSPSolver::dump_wcsp
virtual void dump_wcsp(const char *fileName, bool original=true)=0
output current problem in a file
WeightedCSPSolver::read_solution
virtual void read_solution(const char *fileName, bool updateValueHeuristic=true)=0
read a solution from a file
WeightedCSP::getUb
virtual Cost getUb() const =0
gets internal primal upper bound
WeightedCSPSolver::read_random
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
WeightedCSPSolver::getWCSP
virtual WeightedCSP * getWCSP()=0
access to its associated Weighted CSP
WeightedCSPSolver::read_wcsp
virtual Cost read_wcsp(const char *fileName)=0
reads a Cost function netwrok from a file (format as indicated by ToulBar2:: global variables)
WeightedCSPSolver::parse_solution
virtual void parse_solution(const char *certificate)=0
read a solution from a string (see ToulBar2 option -x)
WeightedCSPSolver::makeWeightedCSPSolver
static WeightedCSPSolver * makeWeightedCSPSolver(Cost initUpperBound)
WeightedCSP Solver factory.
Definition: tb2solver.cpp:29
WeightedCSPSolver
Definition: toulbar2lib.hpp:423