52 Graph(
const int n_v0,
const int n_e0,
const int* e0)
53 :
n_v(n_v0),
n_e(n_e0),
e(e0) {}
56const int e_20_10[] = {
57 0, 4, 2,12, 12,14, 18,19, 7,10,
58 9,12, 5,11, 6,15, 3,18, 7,16
63const int e_40_20[] = {
64 21,30, 11,30, 19,38, 20,25, 11,24,
65 20,33, 8,39, 4, 5, 6,16, 5,32,
66 0, 9, 5,24, 25,28, 36,38, 14,20,
67 19,25, 11,22, 13,30, 7,36, 15,33
93 v(*this,
g.n_v,0,1),
k(*this,0,
g.n_v) {
95 for (
int i =
g.
n_e; i--; ) {
96 const int* e1 = e++; const int* e2 = e++;
97 rel(*this, v[*e1], BOT_AND, v[*e2], 0);
116 os <<
"\tk = " <<
k << std::endl
117 <<
"\tv[] = " <<
v << std::endl;
134 opt.iterations(2000);
135 opt.
parse(argc,argv);
Parametric base-class for scripts.
static void run(const Options &opt, Script *s=NULL)
Options for scripts with additional size parameter
void update(Space &home, VarArray< Var > &a)
Update array to be a clone of array a.
void update(Space &home, VarImpVar< VarImp > &y)
Update this variable to be a clone of variable y.
Graph(const int n_v0, const int n_e0, const int *e0)
const int * e
Arrays of edges (as vertex pairs)
const int n_e
Number of edges.
const int n_v
Number of vertices.
Example: Independent sets in a graph
int main(int argc, char *argv[])
Main-function.
IndSet(IndSet &s)
Constructor for cloning s.
virtual Space * copy(void)
Copy during cloning.
const Graph g_20_10(20, 10, e_20_10)
Main-function.
const Graph g_40_20(40, 20, e_40_20)
Main-function.
IntVar k
How many elements has indipendent set.
BoolVarArray v
Whether vertex included in independent set.
virtual void print(std::ostream &os) const
Print solution.
const Graph & g
Graph used
virtual IntVar cost(void) const
Return solution cost.
IndSet(const SizeOptions &opt)
Actual model.
void parse(int argc, char *argv[])
Parse commandline arguments.
void branch(Home home, const FloatVarArgs &x, FloatVarBranch vars, FloatValBranch vals, FloatBranchFilter bf=nullptr, FloatVarValPrint vvp=nullptr)
Branch over x with variable selection vars and value selection vals.
void linear(Home home, const FloatVarArgs &x, FloatRelType frt, FloatVal c)
Post propagator for .
Gecode toplevel namespace
BoolValBranch BOOL_VAL_MIN(void)
Select smallest value.
BoolVarBranch BOOL_VAR_NONE(void)
Select first unassigned variable.