56 Graph(
const int n_v0,
const int n_e0,
const int* e0)
57 : n_v(n_v0), n_e(n_e0), e(e0) {}
60 const int e_20_10[] = {
61 0, 4, 2,12, 12,14, 18,19, 7,10,
62 9,12, 5,11, 6,15, 3,18, 7,16
65 const Graph g_20_10(20,10,e_20_10);
67 const int e_40_20[] = {
68 21,30, 11,30, 19,38, 20,25, 11,24,
69 20,33, 8,39, 4, 5, 6,16, 5,32,
70 0, 9, 5,24, 25,28, 36,38, 14,20,
71 19,25, 11,22, 13,30, 7,36, 15,33
74 const Graph g_40_20(40, 20, e_40_20);
95 : g(opt.
size() == 0 ? g_20_10 : g_40_20),
96 v(*this,g.n_v,0,1), k(*this,0,g.n_v) {
98 for (
int i = g.
n_e;
i--; ) {
99 const int* e1 = e++;
const int* e2 = e++;
114 return new IndSet(share,*
this);
119 os <<
"\tk = " << k << std::endl
120 <<
"\tv[] = " << v << std::endl;
138 opt.
parse(argc,argv);
139 IntMaximizeScript::run<IndSet,BAB,SizeOptions>(
opt);
void size(unsigned int s)
Set default size.
Options for scripts with additional size parameter
IntVarBranch INT_VAR_NONE(void)
Select first unassigned variable.
void linear(Home home, const FloatVarArgs &x, FloatRelType frt, FloatNum c)
Post propagator for .
virtual void print(std::ostream &os) const
Print solution.
void update(Space &home, bool share, VarImpVar< VarImp > &y)
Update this variable to be a clone of variable y.
void parse(int &argc, char *argv[])
Parse options from arguments argv (number is argc)
const int n_v
Number of vertices.
IndSet(bool share, IndSet &s)
Constructor for cloning s.
virtual Space * copy(bool share)
Copy during cloning.
Parametric base-class for scripts.
void iterations(unsigned int i)
Set default number of iterations.
void update(Space &, bool share, VarArray< Var > &a)
Update array to be a clone of array a.
Gecode::IntArgs i(4, 1, 2, 3, 4)
IntValBranch INT_VAL_MIN(void)
Select smallest value.
unsigned int size(I &i)
Size of all ranges of range iterator i.
const int n_e
Number of edges.
IntVar k
How many elements has indipendent set.
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
Example: Independent sets in a graph
IndSet(const SizeOptions &opt)
Actual model.
void solutions(unsigned int n)
Set default number of solutions to search for.
const Graph & g
Graph used
BoolVarArray v
Whether vertex included in independent set.
Gecode toplevel namespace
virtual IntVar cost(void) const
Return solution cost.
BrancherHandle branch(Home home, const FloatVarArgs &x, FloatVarBranch vars, FloatValBranch vals, FloatBranchFilter bf, FloatVarValPrint vvp)
Branch over x with variable selection vars and value selection vals.
Graph(const int n_v0, const int n_e0, const int *e0)
const int * e
Arrays of edges (as vertex pairs)
int main(int argc, char *argv[])
Main-function.