54 namespace Gecode {
namespace FlatZinc {
89 int_varsel(int_varsel0), int_valsel(int_valsel0),
90 bool_varsel(bool_varsel0), bool_valsel(bool_valsel0)
91 #ifdef GECODE_HAS_SET_VARS
92 , set_varsel(set_varsel0), set_valsel(set_valsel0)
94 #ifdef GECODE_HAS_FLOAT_VARS
95 , float_varsel(float_varsel0), float_valsel(float_valsel0)
100 :
Brancher(home, share, b), done(b.done) {}
111 virtual size_t size(
void)
const {
125 #ifdef GECODE_HAS_SET_VARS
129 #ifdef GECODE_HAS_FLOAT_VARS
137 if (done)
return false;
143 #ifdef GECODE_HAS_SET_VARS
147 #ifdef GECODE_HAS_FLOAT_VARS
161 #ifdef GECODE_HAS_SET_VARS
164 #ifdef GECODE_HAS_FLOAT_VARS
171 return new Choice(*
this,
false);
173 return new Choice(*
this,
true);
178 bool fail; e >> fail;
179 return new Choice(*
this, fail);
188 std::ostream& o)
const {
190 << (
static_cast<const Choice&
>(
c).fail ?
"fail" :
"ok")
215 bool_varsel, bool_valsel
216 #ifdef GECODE_HAS_SET_VARS
217 , set_varsel, set_valsel
219 #ifdef GECODE_HAS_FLOAT_VARS
220 , float_varsel, float_valsel
226 return sizeof(*this);
236 BI(
void) : r0(
""), r1(
""),
n(0) {}
237 BI(
const string& r00,
const string& r10,
const vector<string>& n0)
238 : r0(r00), r1(r10),
n(n0) {}
252 const vector<string>&
n) {
253 v.resize(
std::max(static_cast<unsigned int>(v.size()),bh.
id()+1));
254 v[bh.
id()] = BI(rel0,rel1,n);
258 int a,
int i,
int n, ostream& o)
const {
259 const BI&
bi = v[bh.
id()];
260 o << bi.n[
i] <<
" " << (a==0 ? bi.r0 : bi.r1) <<
" " << n;
262 #ifdef GECODE_HAS_FLOAT_VARS
265 const BI&
bi = v[bh.
id()];
267 << (((a == 0) == nl.
l) ?
"<=" :
">=") << nl.
n;
272 BranchInformation::BranchInformation(
void)
280 assert(
object() == NULL);
286 const std::string& rel0,
287 const std::string& rel1,
288 const std::vector<std::string>&
n) {
293 int n, std::ostream& o)
const {
296 #ifdef GECODE_HAS_FLOAT_VARS
306 Var,
int i,
const int&
n,
311 #ifdef GECODE_HAS_FLOAT_VARS
337 int* newdom =
heap.
alloc<
int>(
static_cast<unsigned long int>(sl->
s.size()));
338 for (
int i=sl->
s.size();
i--;)
339 newdom[
i] = sl->
s[
i];
340 IntSet ret(newdom, sl->
s.size());
341 heap.
free(newdom, static_cast<unsigned long int>(sl->
s.size()));
373 if (
AST::Atom* s = dynamic_cast<AST::Atom*>(ann)) {
374 if (s->id ==
"input_order")
376 if (s->id ==
"first_fail")
378 if (s->id ==
"anti_first_fail")
380 if (s->id ==
"smallest")
382 if (s->id ==
"largest")
384 if (s->id ==
"occurrence")
386 if (s->id ==
"max_regret")
388 if (s->id ==
"most_constrained")
391 if (s->id ==
"random") {
394 if (s->id ==
"dom_w_deg") {
397 if (s->id ==
"afc_min")
399 if (s->id ==
"afc_max")
401 if (s->id ==
"afc_size_min")
403 if (s->id ==
"afc_size_max") {
406 if (s->id ==
"activity_min")
408 if (s->id ==
"activity_max")
410 if (s->id ==
"activity_size_min")
412 if (s->id ==
"activity_size_max")
415 std::cerr <<
"Warning, ignored search annotation: ";
416 ann->
print(std::cerr);
417 std::cerr << std::endl;
423 if (
AST::Atom* s = dynamic_cast<AST::Atom*>(ann)) {
424 if (s->id ==
"indomain_min") {
428 if (s->id ==
"indomain_max") {
432 if (s->id ==
"indomain_median") {
436 if (s->id ==
"indomain_split") {
440 if (s->id ==
"indomain_reverse_split") {
444 if (s->id ==
"indomain_random") {
448 if (s->id ==
"indomain") {
452 if (s->id ==
"indomain_middle") {
453 std::cerr <<
"Warning, replacing unsupported annotation "
454 <<
"indomain_middle with indomain_median" << std::endl;
458 if (s->id ==
"indomain_interval") {
459 std::cerr <<
"Warning, replacing unsupported annotation "
460 <<
"indomain_interval with indomain_split" << std::endl;
465 std::cerr <<
"Warning, ignored search annotation: ";
466 ann->
print(std::cerr);
467 std::cerr << std::endl;
473 if (
AST::Atom* s = dynamic_cast<AST::Atom*>(ann)) {
474 if (s->id ==
"indomain_min")
476 if (s->id ==
"indomain_max")
478 if (s->id ==
"indomain_median")
480 if (s->id ==
"indomain_random") {
484 std::cerr <<
"Warning, ignored search annotation: ";
485 ann->
print(std::cerr);
486 std::cerr << std::endl;
490 #ifdef GECODE_HAS_SET_VARS
492 if (
AST::Atom* s = dynamic_cast<AST::Atom*>(ann)) {
493 if (s->id ==
"input_order")
495 if (s->id ==
"first_fail")
497 if (s->id ==
"anti_first_fail")
499 if (s->id ==
"smallest")
501 if (s->id ==
"largest")
503 if (s->id ==
"afc_min")
505 if (s->id ==
"afc_max")
507 if (s->id ==
"afc_size_min")
509 if (s->id ==
"afc_size_max")
511 if (s->id ==
"activity_min")
513 if (s->id ==
"activity_max")
515 if (s->id ==
"activity_size_min")
517 if (s->id ==
"activity_size_max")
519 if (s->id ==
"random") {
523 std::cerr <<
"Warning, ignored search annotation: ";
524 ann->
print(std::cerr);
525 std::cerr << std::endl;
532 if (
AST::Atom* s = dynamic_cast<AST::Atom*>(ann)) {
533 if (s->id ==
"indomain_min") {
534 r0 =
"in"; r1 =
"not in";
537 if (s->id ==
"indomain_max") {
538 r0 =
"in"; r1 =
"not in";
541 if (s->id ==
"outdomain_min") {
542 r1 =
"in"; r0 =
"not in";
545 if (s->id ==
"outdomain_max") {
546 r1 =
"in"; r0 =
"not in";
550 std::cerr <<
"Warning, ignored search annotation: ";
551 ann->
print(std::cerr);
552 std::cerr << std::endl;
553 r0 =
"in"; r1 =
"not in";
558 #ifdef GECODE_HAS_FLOAT_VARS
561 if (
AST::Atom* s = dynamic_cast<AST::Atom*>(ann)) {
562 if (s->id ==
"input_order")
564 if (s->id ==
"first_fail")
566 if (s->id ==
"anti_first_fail")
568 if (s->id ==
"smallest")
570 if (s->id ==
"largest")
572 if (s->id ==
"occurrence")
574 if (s->id ==
"most_constrained")
577 if (s->id ==
"random") {
580 if (s->id ==
"afc_min")
582 if (s->id ==
"afc_max")
584 if (s->id ==
"afc_size_min")
586 if (s->id ==
"afc_size_max")
588 if (s->id ==
"activity_min")
590 if (s->id ==
"activity_max")
592 if (s->id ==
"activity_size_min")
594 if (s->id ==
"activity_size_max")
597 std::cerr <<
"Warning, ignored search annotation: ";
598 ann->
print(std::cerr);
599 std::cerr << std::endl;
604 if (
AST::Atom* s = dynamic_cast<AST::Atom*>(ann)) {
605 if (s->id ==
"indomain_split") {
609 if (s->id ==
"indomain_reverse_split") {
614 std::cerr <<
"Warning, ignored search annotation: ";
615 ann->
print(std::cerr);
616 std::cerr << std::endl;
624 :
Space(share, f), _random(f._random),
625 _solveAnnotations(NULL), iv_boolalias(NULL),
626 needAuxVars(f.needAuxVars) {
641 iva[iva.
size()-1].update(*
this, share, f.
iv_aux[
i]);
654 bva[bva.
size()-1].update(*
this, share, f.
bv_aux[
i]);
660 #ifdef GECODE_HAS_SET_VARS
668 sva[sva.
size()-1].update(*
this, share, f.
sv_aux[
i]);
674 #ifdef GECODE_HAS_FLOAT_VARS
682 fva[fva.
size()-1].update(*
this, share, f.
fv_aux[
i]);
691 : intVarCount(-1), boolVarCount(-1), floatVarCount(-1), setVarCount(-1),
692 _optVar(-1), _optVarIsInt(true), _lns(0), _random(random),
693 _solveAnnotations(NULL), needAuxVars(true) {
699 int setVars,
int floatVars) {
710 #ifdef GECODE_HAS_SET_VARS
715 #ifdef GECODE_HAS_FLOAT_VARS
760 #ifdef GECODE_HAS_SET_VARS
772 int* is =
heap.
alloc<
int>(
static_cast<unsigned long int>(vsv->s.size()));
773 for (
int i=vsv->s.
size();
i--; )
776 heap.
free(is,static_cast<unsigned long int>(vsv->s.size()));
785 int* is =
heap.
alloc<
int>(
static_cast<unsigned long int>(vsv->
s.size()));
786 for (
int i=vsv->
s.size();
i--; )
789 heap.
free(is,static_cast<unsigned long int>(vsv->
s.size()));
807 #ifdef GECODE_HAS_FLOAT_VARS
838 struct ConExprOrder {
839 bool operator() (ConExpr* ce0, ConExpr* ce1) {
840 return ce0->args->a.size() < ce1->args->a.size();
850 for (
unsigned int i=0;
i<ces.
size();
i++) {
865 for (
unsigned int i=0;
i<ann->
a.size();
i++) {
866 if (ann->
a[
i]->isCall(
"seq_search")) {
871 out.push_back(c->
args);
873 out.push_back(ann->
a[
i]);
882 Rnd rnd(static_cast<unsigned int>(seed));
887 #ifdef GECODE_HAS_SET_VARS
891 #ifdef GECODE_HAS_FLOAT_VARS
896 std::vector<bool> iv_searched(
iv.
size());
897 for (
unsigned int i=
iv.
size();
i--;)
898 iv_searched[
i] =
false;
899 std::vector<bool> bv_searched(
bv.
size());
900 for (
unsigned int i=
bv.
size();
i--;)
901 bv_searched[
i] =
false;
902 #ifdef GECODE_HAS_SET_VARS
903 std::vector<bool> sv_searched(
sv.
size());
904 for (
unsigned int i=
sv.
size();
i--;)
905 sv_searched[
i] =
false;
907 #ifdef GECODE_HAS_FLOAT_VARS
908 std::vector<bool> fv_searched(
fv.
size());
909 for (
unsigned int i=
fv.
size();
i--;)
910 fv_searched[
i] =
false;
915 std::vector<AST::Node*> flatAnn;
919 flatAnn.push_back(ann);
922 for (
unsigned int i=0;
i<flatAnn.
size();
i++) {
923 if (flatAnn[
i]->isCall(
"relax_and_reconstruct")) {
926 "Only one relax_and_reconstruct annotation allowed");
929 _lns = args->
a[1]->getInt();
931 int k=vars->
a.size();
932 for (
int i=vars->
a.size();
i--;)
933 if (vars->
a[
i]->isInt())
937 for (
unsigned int i=0;
i<vars->
a.size();
i++) {
938 if (vars->
a[
i]->isInt())
942 }
else if (flatAnn[
i]->isCall(
"gecode_search")) {
944 branchWithPlugin(c->
args);
945 }
else if (flatAnn[
i]->isCall(
"int_search")) {
949 int k=vars->
a.size();
950 for (
int i=vars->
a.size();
i--;)
951 if (vars->
a[
i]->isInt())
954 vector<string> names;
956 for (
unsigned int i=0;
i<vars->
a.size();
i++) {
957 if (vars->
a[
i]->isInt())
959 va[k++] =
iv[vars->
a[
i]->getIntVar()];
960 iv_searched[vars->
a[
i]->getIntVar()] =
true;
961 names.push_back(vars->
a[
i]->getVarName());
968 &varValPrint<IntVar>);
970 }
else if (flatAnn[
i]->isCall(
"int_assign")) {
974 int k=vars->
a.size();
975 for (
int i=vars->
a.size();
i--;)
976 if (vars->
a[
i]->isInt())
980 for (
unsigned int i=0;
i<vars->
a.size();
i++) {
981 if (vars->
a[
i]->isInt())
983 va[k++] =
iv[vars->
a[
i]->getIntVar()];
984 iv_searched[vars->
a[
i]->getIntVar()] =
true;
987 &varValPrint<IntVar>);
988 }
else if (flatAnn[
i]->isCall(
"bool_search")) {
992 int k=vars->
a.size();
993 for (
int i=vars->
a.size();
i--;)
994 if (vars->
a[
i]->isBool())
998 vector<string> names;
999 for (
unsigned int i=0;
i<vars->
a.size();
i++) {
1000 if (vars->
a[
i]->isBool())
1002 va[k++] =
bv[vars->
a[
i]->getBoolVar()];
1003 bv_searched[vars->
a[
i]->getBoolVar()] =
true;
1004 names.push_back(vars->
a[
i]->getVarName());
1011 &varValPrint<BoolVar>);
1013 }
else if (flatAnn[
i]->isCall(
"int_default_search")) {
1019 }
else if (flatAnn[
i]->isCall(
"bool_default_search")) {
1025 }
else if (flatAnn[
i]->isCall(
"set_search")) {
1026 #ifdef GECODE_HAS_SET_VARS
1030 int k=vars->
a.size();
1031 for (
int i=vars->
a.size();
i--;)
1032 if (vars->
a[
i]->isSet())
1036 vector<string> names;
1037 for (
unsigned int i=0;
i<vars->
a.size();
i++) {
1038 if (vars->
a[
i]->isSet())
1040 va[k++] =
sv[vars->
a[
i]->getSetVar()];
1041 sv_searched[vars->
a[
i]->getSetVar()] =
true;
1042 names.push_back(vars->
a[
i]->getVarName());
1049 &varValPrint<SetVar>);
1052 if (!ignoreUnknown) {
1053 err <<
"Warning, ignored search annotation: ";
1054 flatAnn[
i]->print(err);
1058 }
else if (flatAnn[
i]->isCall(
"set_default_search")) {
1059 #ifdef GECODE_HAS_SET_VARS
1066 if (!ignoreUnknown) {
1067 err <<
"Warning, ignored search annotation: ";
1068 flatAnn[
i]->print(err);
1072 }
else if (flatAnn[
i]->isCall(
"float_default_search")) {
1073 #ifdef GECODE_HAS_FLOAT_VARS
1080 if (!ignoreUnknown) {
1081 err <<
"Warning, ignored search annotation: ";
1082 flatAnn[
i]->print(err);
1086 }
else if (flatAnn[
i]->isCall(
"float_search")) {
1087 #ifdef GECODE_HAS_FLOAT_VARS
1091 int k=vars->
a.size();
1092 for (
int i=vars->
a.size();
i--;)
1093 if (vars->
a[
i]->isFloat())
1097 vector<string> names;
1098 for (
unsigned int i=0;
i<vars->
a.size();
i++) {
1099 if (vars->
a[
i]->isFloat())
1101 va[k++] =
fv[vars->
a[
i]->getFloatVar()];
1102 fv_searched[vars->
a[
i]->getFloatVar()] =
true;
1103 names.push_back(vars->
a[
i]->getVarName());
1113 if (!ignoreUnknown) {
1114 err <<
"Warning, ignored search annotation: ";
1115 flatAnn[
i]->print(err);
1120 if (!ignoreUnknown) {
1121 err <<
"Warning, ignored search annotation: ";
1122 flatAnn[
i]->print(err);
1144 for (
int i=
iv.
size(), j=0, k=0;
i--;) {
1149 iv_tmp[j++] =
iv[
i];
1152 iv_sol[k++] =
iv[
i];
1160 if (bv_searched[
i]) {
1172 for (
int i=
bv.
size(), j=0, k=0;
i--;) {
1177 bv_tmp[j++] =
bv[
i];
1180 bv_sol[k++] =
bv[
i];
1184 if (iv_sol.
size() > 0) {
1185 branch(*
this, iv_sol, def_int_varsel, def_int_valsel);
1187 if (bv_sol.
size() > 0)
1188 branch(*
this, bv_sol, def_bool_varsel, def_bool_valsel);
1189 #ifdef GECODE_HAS_FLOAT_VARS
1206 for (
int i=
fv.
size(), j=0, k=0;
i--;) {
1211 fv_tmp[j++] =
fv[
i];
1214 fv_sol[k++] =
fv[
i];
1218 if (fv_sol.
size() > 0)
1219 branch(*
this, fv_sol, def_float_varsel, def_float_valsel);
1221 #ifdef GECODE_HAS_SET_VARS
1226 if (sv_searched[
i]) {
1238 for (
int i=
sv.
size(), j=0, k=0;
i--;) {
1243 sv_tmp[j++] =
sv[
i];
1246 sv_sol[k++] =
sv[
i];
1250 if (sv_sol.
size() > 0)
1251 branch(*
this, sv_sol, def_set_varsel, def_set_valsel);
1256 #ifdef GECODE_HAS_SET_VARS
1260 #ifdef GECODE_HAS_FLOAT_VARS
1269 #ifdef GECODE_HAS_FLOAT_VARS
1277 #ifdef GECODE_HAS_FLOAT_VARS
1286 def_bool_varsel, def_bool_valsel
1288 , def_set_varsel, def_set_valsel
1291 , def_float_varsel, def_float_valsel
1297 #ifdef GECODE_HAS_SET_VARS
1300 #ifdef GECODE_HAS_FLOAT_VARS
1301 branch(*
this,
fv_aux,def_float_varsel,def_float_valsel);
1339 #ifdef GECODE_HAS_GIST
1344 template<
class Engine>
1349 template<
typename S>
1350 class GistEngine<
DFS<S> > {
1352 static void explore(S* root,
const FlatZincOptions&
opt,
1355 o.
c_d = opt.c_d(); o.
a_d = opt.a_d();
1363 template<
typename S>
1364 class GistEngine<BAB<S> > {
1366 static void explore(S* root,
const FlatZincOptions& opt,
1367 Gist::Inspector* i, Gist::Comparator* c) {
1369 o.
c_d = opt.c_d(); o.
a_d = opt.a_d();
1378 class FZPrintingInspector
1384 FZPrintingInspector(
const Printer& p0);
1386 virtual void inspect(
const Space& node);
1388 virtual void finalize(
void);
1392 FZPrintingInspector<S>::FZPrintingInspector(
const Printer& p0)
1393 : TextOutput(
"Gecode/FlatZinc"),
p(p0) {}
1397 FZPrintingInspector<S>::inspect(
const Space& node) {
1399 dynamic_cast<const S&
>(node).
print(getStream(),
p);
1400 getStream() << std::endl;
1405 FZPrintingInspector<S>::finalize(
void) {
1410 class FZPrintingComparator
1416 FZPrintingComparator(
const Printer& p0);
1419 virtual void compare(
const Space& s0,
const Space& s1);
1423 FZPrintingComparator<S>::FZPrintingComparator(
const Printer& p0)
1424 :
Gecode::Gist::VarComparator<S>(
"Gecode/FlatZinc"),
p(p0) {}
1431 dynamic_cast<const S&
>(s0).
compare(dynamic_cast<const S&>(s1),
1432 this->getStream(),
p);
1433 }
catch (Exception& e) {
1434 this->getStream() <<
"Exception: " << e.what();
1436 this->getStream() << std::endl;
1442 template<
template<
class>
class Engine>
1444 FlatZincSpace::runEngine(std::ostream& out,
const Printer&
p,
1445 const FlatZincOptions& opt, Support::Timer& t_total) {
1447 runMeta<Engine,Driver::EngineToMeta>(out,
p,
opt,t_total);
1449 runMeta<Engine,RBS>(out,
p,
opt,t_total);
1453 template<
template<
class>
class Engine,
1454 template<
template<
class>
class,
class>
class Meta>
1456 FlatZincSpace::runMeta(std::ostream& out, const Printer& p,
1457 const FlatZincOptions& opt, Support::Timer& t_total) {
1458 #ifdef GECODE_HAS_GIST
1460 FZPrintingInspector<FlatZincSpace> pi(p);
1461 FZPrintingComparator<FlatZincSpace> pc(p);
1462 (void) GistEngine<Engine<FlatZincSpace> >::
explore(
this,opt,&pi,&pc);
1466 StatusStatistics sstat;
1467 unsigned int n_p = 0;
1468 Support::Timer t_solve;
1471 n_p = propagators();
1478 o.threads = opt.threads();
1479 o.nogoods_limit = opt.nogoods() ? opt.nogoods_limit() : 0;
1481 if (opt.interrupt())
1483 Meta<Engine,FlatZincSpace> se(
this,o);
1484 int noOfSolutions = opt.solutions();
1485 if (noOfSolutions == -1) {
1486 noOfSolutions = (_method == SAT) ? 1 : 0;
1488 bool printAll = _method == SAT || opt.allSolutions() || noOfSolutions != 0;
1489 int findSol = noOfSolutions;
1490 FlatZincSpace* sol = NULL;
1491 while (FlatZincSpace* next_sol = se.next()) {
1496 out <<
"----------" << std::endl;
1501 if (sol && !printAll) {
1503 out <<
"----------" << std::endl;
1505 if (!se.stopped()) {
1507 out <<
"==========" << endl;
1509 out <<
"=====UNSATISFIABLE=====" << endl;
1512 out <<
"=====UNKNOWN=====" << endl;
1516 if (opt.interrupt())
1524 <<
"%% solvetime: ";
1528 <<
std::abs(noOfSolutions - findSol) << endl
1530 << (intVarCount + boolVarCount + setVarCount) << endl
1531 <<
"%% propagators: " << n_p << endl
1532 <<
"%% propagations: " << sstat.propagate+stat.
propagate << endl
1533 <<
"%% nodes: " << stat.
node << endl
1534 <<
"%% failures: " << stat.
fail << endl
1535 <<
"%% restarts: " << stat.
restart << endl
1536 <<
"%% peak depth: " << stat.
depth << endl
1542 #ifdef GECODE_HAS_QT
1544 FlatZincSpace::branchWithPlugin(AST::Node* ann) {
1545 if (AST::Call* c = dynamic_cast<AST::Call*>(ann)) {
1546 QString pluginName(c->id.c_str());
1547 if (QLibrary::isLibrary(pluginName+
".dll")) {
1548 pluginName +=
".dll";
1549 }
else if (QLibrary::isLibrary(pluginName+
".dylib")) {
1550 pluginName =
"lib" + pluginName +
".dylib";
1551 }
else if (QLibrary::isLibrary(pluginName+
".so")) {
1553 pluginName =
"lib" + pluginName +
".so";
1555 QPluginLoader pl(pluginName);
1556 QObject* plugin_o = pl.instance();
1558 throw FlatZinc::Error(
"FlatZinc",
1559 "Error loading plugin "+pluginName.toStdString()+
1560 ": "+pl.errorString().toStdString());
1562 BranchPlugin* pb = qobject_cast<BranchPlugin*>(plugin_o);
1564 throw FlatZinc::Error(
"FlatZinc",
1565 "Error loading plugin "+pluginName.toStdString()+
1566 ": does not contain valid PluginBrancher");
1568 pb->branch(*
this, c);
1573 FlatZincSpace::branchWithPlugin(AST::Node*) {
1574 throw FlatZinc::Error(
"FlatZinc",
1575 "Branching with plugins not supported (requires Qt support)");
1585 runEngine<BAB>(out,
p,
opt,t_total);
1588 runEngine<DFS>(out,
p,
opt,t_total);
1598 static_cast<const FlatZincSpace*>(&s)->
iv[_optVar].val());
1601 static_cast<const FlatZincSpace*>(&s)->
iv[_optVar].val());
1603 #ifdef GECODE_HAS_FLOAT_VARS
1606 static_cast<const FlatZincSpace*>(&s)->
fv[_optVar].val());
1609 static_cast<const FlatZincSpace*>(&s)->
fv[_optVar].val());
1662 (void) s; (void) out;
1663 #ifdef GECODE_HAS_GIST
1665 for (
int i = 0; i <
iv.
size(); ++
i) {
1666 std::stringstream ss;
1667 ss <<
"iv[" << i <<
"]";
1670 if (result.length() > 0) out << result << std::endl;
1672 for (
int i = 0; i <
bv.
size(); ++
i) {
1673 std::stringstream ss;
1674 ss <<
"bv[" << i <<
"]";
1677 if (result.length() > 0) out << result << std::endl;
1679 #ifdef GECODE_HAS_SET_VARS
1680 for (
int i = 0; i <
sv.
size(); ++
i) {
1681 std::stringstream ss;
1682 ss <<
"sv[" << i <<
"]";
1685 if (result.length() > 0) out << result << std::endl;
1688 #ifdef GECODE_HAS_FLOAT_VARS
1689 for (
int i = 0; i <
fv.
size(); ++
i) {
1690 std::stringstream ss;
1691 ss <<
"fv[" << i <<
"]";
1694 if (result.length() > 0) out << result << std::endl;
1729 for (
int i=offset; i--;)
1731 for (
int i=a->
a.size(); i--;)
1732 ia[i+offset] = a->
a[i]->getInt();
1739 for (
int i=offset; i--;)
1741 for (
int i=a->
a.size(); i--;)
1742 ia[i+offset] = a->
a[i]->getBool();
1753 int* is = re.
alloc<
int>(
static_cast<unsigned long int>(sl->
s.size()));
1754 for (
int i=sl->
s.size(); i--; )
1763 if (a->
a.size() == 0) {
1768 for (
int i=offset; i--;)
1770 for (
int i=a->
a.size(); i--;) {
1778 if (a->
a.size() == 0) {
1783 for (
int i=offset; i--;)
1784 ia[i] =
IntVar(*
this, 0, 0);
1785 for (
int i=a->
a.size(); i--;) {
1786 if (a->
a[i]->isIntVar()) {
1787 ia[i+offset] =
iv[a->
a[
i]->getIntVar()];
1789 int value = a->
a[
i]->getInt();
1799 if (a->
a.size() == 0) {
1804 for (
int i=offset; i--;)
1806 for (
int i=0; i<static_cast<int>(a->
a.size()); i++) {
1809 if (a->
a[i]->isBool()) {
1810 bool value = a->
a[
i]->getBool();
1813 }
else if (a->
a[i]->isIntVar() &&
1817 ia[offset++] =
bv[a->
a[
i]->getBoolVar()];
1847 if (a->
a.size() == 0)
1849 for (
int i=a->
a.size(); i--;) {
1850 if (a->
a[i]->isBoolVar() || a->
a[
i]->isBool()) {
1851 }
else if (a->
a[i]->isIntVar()) {
1853 if (singleInt != -1) {
1862 return singleInt==-1 || a->
a.size() > 1;
1864 #ifdef GECODE_HAS_SET_VARS
1870 x0 =
SetVar(*
this, d, d);
1881 for (
int i=offset; i--;) {
1885 for (
int i=a->
a.size(); i--;) {
1891 #ifdef GECODE_HAS_FLOAT_VARS
1896 for (
int i=offset; i--;)
1898 for (
int i=a->
a.size(); i--;)
1899 fa[i+offset] = a->
a[i]->getFloat();
1905 if (a->
a.size() == 0) {
1910 for (
int i=offset; i--;)
1912 for (
int i=a->
a.size(); i--;) {
1913 if (a->
a[i]->isFloatVar()) {
1914 fa[i+offset] =
fv[a->
a[
i]->getFloatVar()];
1916 double value = a->
a[
i]->getFloat();
1957 Printer::printElem(std::ostream& out,
1977 }
else if (bv[ai->
getBoolVar()].max() == 0) {
1980 out <<
"false..true";
1982 #ifdef GECODE_HAS_SET_VARS
1988 SetVarGlbRanges svr(sv[ai->
getSetVar()]);
1993 int min = svr.min();
1994 int max = svr.max();
1997 SetVarGlbValues svv(sv[ai->
getSetVar()]);
2001 for (; svv(); ++svv)
2002 out <<
", " << svv.val();
2005 out << min <<
".." <<
max;
2008 #ifdef GECODE_HAS_FLOAT_VARS
2019 std::ostringstream oss;
2021 oss << std::setprecision(std::numeric_limits<double>::digits10);
2023 if (oss.str().find(
".") == std::string::npos)
2030 }
else if (ai->
isBool()) {
2031 out << (ai->
getBool() ?
"true" :
"false");
2032 }
else if (ai->
isSet()) {
2033 AST::SetLit* s = ai->
getSet();
2035 out << s->
min <<
".." << s->max;
2038 for (
unsigned int i=0; i<s->s.size(); i++) {
2039 out << s->s[
i] << (i < s->s.size()-1 ?
", " :
"}");
2044 for (
unsigned int i=0; i<s.size(); i++) {
2045 if (s[i] ==
'\\' && i<s.size()-1) {
2047 case 'n': out <<
"\n";
break;
2048 case '\\': out <<
"\\";
break;
2049 case 't': out <<
"\t";
break;
2050 default: out <<
"\\" << s[i+1];
2061 Printer::printElemDiff(std::ostream& out,
2067 #ifdef GECODE_HAS_SET_VARS
2071 #ifdef GECODE_HAS_FLOAT_VARS
2076 #ifdef GECODE_HAS_GIST
2081 }
else if (ai->isIntVar()) {
2083 iv2[ai->getIntVar()]));
2084 if (res.length() > 0) {
2088 out << iv1[ai->getIntVar()];
2090 }
else if (ai->isBoolVar()) {
2092 bv2[ai->getBoolVar()]));
2093 if (res.length() > 0) {
2097 out << bv1[ai->getBoolVar()];
2099 #ifdef GECODE_HAS_SET_VARS
2100 }
else if (ai->isSetVar()) {
2102 sv2[ai->getSetVar()]));
2103 if (res.length() > 0) {
2107 out << sv1[ai->getSetVar()];
2110 #ifdef GECODE_HAS_FLOAT_VARS
2111 }
else if (ai->isFloatVar()) {
2113 fv2[ai->getFloatVar()]));
2114 if (res.length() > 0) {
2118 out << fv1[ai->getFloatVar()];
2121 }
else if (ai->isBool()) {
2122 out << (ai->getBool() ?
"true" :
"false");
2123 }
else if (ai->isSet()) {
2124 AST::SetLit* s = ai->getSet();
2126 out << s->min <<
".." << s->max;
2129 for (
unsigned int i=0; i<s->s.size(); i++) {
2130 out << s->s[
i] << (i < s->s.size()-1 ?
", " :
"}");
2133 }
else if (ai->isString()) {
2134 std::string s = ai->getString();
2135 for (
unsigned int i=0; i<s.size(); i++) {
2136 if (s[i] ==
'\\' && i<s.size()-1) {
2138 case 'n': out <<
"\n";
break;
2139 case '\\': out <<
"\\";
break;
2140 case 't': out <<
"\t";
break;
2141 default: out <<
"\\" << s[i+1];
2156 #ifdef GECODE_HAS_SET_VARS
2160 #ifdef GECODE_HAS_FLOAT_VARS
2172 #ifdef GECODE_HAS_SET_VARS
2176 #ifdef GECODE_HAS_FLOAT_VARS
2181 if (_output == NULL)
2183 for (
unsigned int i=0; i< _output->
a.size(); i++) {
2187 int size = aia->
a.size();
2189 for (
int j=0; j<
size; j++) {
2190 printElem(out,aia->
a[j],iv,bv
2191 #ifdef GECODE_HAS_SET_VARS
2194 #ifdef GECODE_HAS_FLOAT_VARS
2203 printElem(out,ai,iv,bv
2204 #ifdef GECODE_HAS_SET_VARS
2207 #ifdef GECODE_HAS_FLOAT_VARS
2221 #ifdef GECODE_HAS_SET_VARS
2226 #ifdef GECODE_HAS_FLOAT_VARS
2232 if (_output == NULL)
2234 for (
unsigned int i=0; i< _output->
a.size(); i++) {
2238 int size = aia->
a.size();
2240 for (
int j=0; j<
size; j++) {
2241 printElemDiff(out,aia->
a[j],iv1,iv2,bv1,bv2
2242 #ifdef GECODE_HAS_SET_VARS
2245 #ifdef GECODE_HAS_FLOAT_VARS
2254 printElemDiff(out,ai,iv1,iv2,bv1,bv2
2255 #ifdef GECODE_HAS_SET_VARS
2258 #ifdef GECODE_HAS_FLOAT_VARS
2268 std::map<int,int>& iv, std::map<int,int>& bv,
2269 std::map<int,int>& sv, std::map<int,int>& fv) {
2272 if (iv.find(x->
i) == iv.end()) {
2273 int newi = iv.size();
2279 if (bv.find(x->
i) == bv.end()) {
2280 int newi = bv.size();
2286 if (sv.find(x->
i) == sv.end()) {
2287 int newi = sv.size();
2293 if (fv.find(x->
i) == fv.end()) {
2294 int newi = fv.size();
2303 int& optVar,
bool optVarIsInt,
2306 #ifdef GECODE_HAS_SET_VARS
2310 #ifdef GECODE_HAS_FLOAT_VARS
2315 if (_output == NULL) {
2316 if (optVarIsInt && optVar != -1) {
2325 #ifdef GECODE_HAS_SET_VARS
2328 #ifdef GECODE_HAS_FLOAT_VARS
2329 if (!optVarIsInt && optVar != -1) {
2340 std::map<int,int> iv_new;
2341 std::map<int,int> bv_new;
2342 std::map<int,int> sv_new;
2343 std::map<int,int> fv_new;
2353 for (
unsigned int i=0; i< _output->
a.size(); i++) {
2357 for (
unsigned int j=0; j<aia->
a.size(); j++) {
2366 for (map<int,int>::iterator i=iv_new.begin(); i != iv_new.end(); ++
i) {
2367 iva[(*i).second] = iv[(*i).first];
2372 for (map<int,int>::iterator i=bv_new.begin(); i != bv_new.end(); ++
i) {
2373 bva[(*i).second] = bv[(*i).first];
2377 #ifdef GECODE_HAS_SET_VARS
2379 for (map<int,int>::iterator i=sv_new.begin(); i != sv_new.end(); ++
i) {
2380 sva[(*i).second] = sv[(*i).first];
2385 #ifdef GECODE_HAS_FLOAT_VARS
2387 for (map<int,int>::iterator i=fv_new.begin(); i != fv_new.end(); ++
i) {
2388 fva[(*i).second] = fv[(*i).first];
void click(Inspector *i)
Add inspector that reacts on node double clicks.
SetVarBranch SET_VAR_SIZE_MIN(BranchTbl tbl)
Select variable with smallest unknown set.
void shrinkArrays(Printer &p)
Remove all variables not needed for output.
static void post(Home home, TieBreak< IntVarBranch > int_varsel, IntValBranch int_valsel, TieBreak< IntVarBranch > bool_varsel, IntValBranch bool_valsel, SetVarBranch set_varsel, SetValBranch set_valsel, TieBreak< FloatVarBranch > float_varsel, FloatValBranch float_valsel)
Post brancher.
unsigned int a_d
Create a clone during recomputation if distance is greater than a_d (adaptive distance) ...
Which values to select for branching first.
Gecode::SetVarArray sv_aux
The introduced set variables.
SetVarBranch SET_VAR_AFC_MIN(double d, BranchTbl tbl)
Select variable with smallest accumulated failure count with decay factor d.
int floatVarCount
Number of float variables.
void varValPrintF(const Space &home, const BrancherHandle &bh, unsigned int a, FloatVar, int i, const FloatNumBranch &nl, std::ostream &o)
Option< AST::SetLit * > domain
Options for running FlatZinc models
FloatVarBranch FLOAT_VAR_DEGREE_MAX(BranchTbl tbl)
Select variable with largest degree.
virtual Choice * choice(Space &home)
Return choice.
IntVarBranch INT_VAR_NONE(void)
Select first unassigned variable.
Combine variable selection criteria for tie-breaking.
IntSet vs2is(IntVarSpec *vs)
Gecode::Support::RandomGenerator random
The actual random number generator.
Which values to select for branching first.
void printDiff(std::ostream &out, const Gecode::IntVarArray &iv1, const Gecode::IntVarArray &iv2, const Gecode::BoolVarArray &bv1, const Gecode::BoolVarArray &bv2, const Gecode::SetVarArray &sv1, const Gecode::SetVarArray &sv2, const Gecode::FloatVarArray &fv1, const Gecode::FloatVarArray &fv2) const
IntConLevel
Consistency levels for integer propagators.
IntArgs arg2intargs(AST::Node *arg, int offset=0)
Convert arg (array of integers) to IntArgs.
void post(FlatZincSpace &s, const ConExpr &ce)
Post constraint specified by ce.
FloatValBranch FLOAT_VAL_SPLIT_MAX(void)
Select values greater than mean of smallest and largest value.
SetVarBranch SET_VAR_NONE(void)
Select first unassigned variable.
void createBranchers(AST::Node *ann, int seed, double decay, bool ignoreUnknown, std::ostream &err=std::cerr)
Create branchers corresponding to the solve item annotations.
std::string what(void) const
const int min
Smallest allowed integer in integer set.
FloatVarArgs arg2floatvarargs(AST::Node *arg, int offset=0)
Convert n to FloatVarArgs.
bool isBool(void)
Test if node is a Boolean node.
virtual Gecode::Space * copy(bool share)
Copy function.
std::vector< bool > sv_introduced
Indicates whether a set variable is introduced by mzn2fzn.
bool getBool(void)
Cast this node to a Boolean node.
const FloatNum max
Largest allowed float value.
#define GECODE_HAS_SET_VARS
Gecode::BoolVarArray bv
The Boolean variables.
void put(unsigned int i)
Add i to the contents.
int size(void) const
Return size of array (number of elements)
Meth _method
Whether to solve as satisfaction or optimization problem.
unsigned int c_d
Create a clone after every c_d commits (commit distance)
Space * clone(bool share=true, CloneStatistics &stat=unused_clone) const
Clone space.
T * alloc(long unsigned int n)
Allocate block of n objects of type T from region.
SetValBranch ann2svalsel(AST::Node *ann, std::string r0, std::string r1, Rnd rnd)
Which values to select for branching first.
SetLit * getSet(void)
Cast this node to a set literal node.
void newIntVar(IntVarSpec *vs)
Create new integer variable from specification.
Abstract base class for comparators.
Call * getCall(void)
Return function call.
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Value propagation or consistency (naive)
int getFloatVar(void)
Cast this node to a Float variable node.
Gecode::IntVarArray iv
The integer variables.
SetVarBranch SET_VAR_ACTIVITY_MIN(double d, BranchTbl tbl)
Select variable with lowest activity with decay factor d.
void abs(Home home, FloatVar x0, FloatVar x1)
Post propagator for .
void stop(Support::Timer &timer, std::ostream &os)
Get time since start of timer and print user friendly time information.
IntAssign INT_ASSIGN_MED(void)
Select greatest value not greater than the median.
Specification for set variables.
BranchInformation branchInfo
Information for printing branches.
int boolVarCount
Number of Boolean variables.
SetValBranch SET_VAL_MIN_INC(void)
Include smallest element.
SetVarBranch SET_VAR_ACTIVITY_SIZE_MIN(double d, BranchTbl tbl)
Select variable with smallest activity divided by domain size with decay factor d.
virtual const char * what(void) const
Return information.
void dom(Home home, FloatVar x, FloatVal n)
Propagates .
IntVarBranch INT_VAR_SIZE_MIN(BranchTbl tbl)
Select variable with smallest domain size.
void postConstraints(std::vector< ConExpr * > &ces)
Post a constraint specified by ce.
void minimize(int var, bool isInt, AST::Array *annotation)
Post that integer variable var should be minimized.
IntVarBranch INT_VAR_MIN_MIN(BranchTbl tbl)
Select variable with smallest min.
unsigned long int fail
Number of failed nodes in search tree.
const Val & some(void) const
bool isSetVar(void)
Test if node is a set variable node.
bool isBoolVar(void)
Test if node is a Boolean variable node.
void compare(const Space &s, std::ostream &out) const
Compare this space with space s and print the differences on out.
unsigned long int depth
Maximum depth of search stack.
TieBreak< IntVarBranch > ann2ivarsel(AST::Node *ann, Rnd rnd, double decay)
FloatVarBranch FLOAT_VAR_AFC_MIN(double d, BranchTbl tbl)
Select variable with smallest accumulated failure count with decay factor d.
FloatValBranch ann2fvalsel(AST::Node *ann, std::string r0, std::string r1)
FloatVarBranch FLOAT_VAR_ACTIVITY_SIZE_MAX(double d, BranchTbl tbl)
Select variable with largest activity divided by domain size with decay factor d. ...
IntVarBranch INT_VAR_ACTIVITY_MAX(double d, BranchTbl tbl)
Select variable with highest activity with decay factor d.
int vs2bsh(BoolVarSpec *bs)
void init(int intVars, int boolVars, int setVars, int floatVars)
Initialize space with given number of variables.
AuxVarBrancher(Space &home, bool share, AuxVarBrancher &b)
Copy constructor.
FloatVarBranch FLOAT_VAR_ACTIVITY_MAX(double d, BranchTbl tbl)
Select variable with highest activity with decay factor d.
unsigned long int propagate
Number of propagator executions.
Search::Cutoff * createCutoff(const Options &o)
Create cutoff object from options.
const int max
Largest allowed integer in integer set.
Array * getArray(void)
Cast this node to an array node.
A thread-safe random number generator.
const int max
Largest allowed integer value.
int vs2bsl(BoolVarSpec *bs)
Current restart information during search.
Abstract base class for inspectors.
FloatVarBranch FLOAT_VAR_NONE(void)
Select first unassigned variable.
const int min
Smallest allowed integer value.
IntVarBranch INT_VAR_REGRET_MIN_MAX(BranchTbl tbl)
Select variable with largest min-regret.
Base-class for both propagators and branchers.
SetVarBranch SET_VAR_SIZE_MAX(BranchTbl tbl)
Select variable with largest unknown set.
IntConLevel ann2icl(AST::Node *ann)
Convert ann to IntConLevel.
void newSetVar(SetVarSpec *vs)
Create new set variable from specification.
IntAssign INT_ASSIGN_MIN(void)
Select smallest value.
IntValBranch INT_VAL_RND(Rnd r)
Select random value.
virtual Choice * choice(const Space &, Archive &e)
Return choice.
Heap heap
The single global heap.
std::vector< bool > iv_introduced
Indicates whether an integer variable is introduced by mzn2fzn.
TieBreak< IntVarBranch > bool_varsel
unsigned int id(void) const
Return brancher id.
void newBoolVar(BoolVarSpec *vs)
Create new Boolean variable from specification.
Gecode::Support::Mutex mutex
A mutex for the random number generator.
void update(Space &, bool share, VarArray< Var > &a)
Update array to be a clone of array a.
bool alias
Whether the variable aliases another variable.
SetVarBranch ann2svarsel(AST::Node *ann, Rnd rnd, double decay)
SetVar arg2SetVar(AST::Node *n)
Convert n to SetVar.
int optVar(void) const
Return index of variable used for optimization.
int getSetVar(void)
Cast this node to a set variable node.
double getFloat(void)
Cast this node to a Float node.
Gecode::FloatVal c(-8, 8)
void print(std::ostream &out, const Gecode::IntVarArray &iv, const Gecode::BoolVarArray &bv, const Gecode::SetVarArray &sv, const Gecode::FloatVarArray &fv) const
void sort(TaskViewArray< TaskView > &t)
Sort task view array t according to sto and inc (increasing or decreasing)
FloatVarBranch FLOAT_VAR_AFC_SIZE_MAX(double d, BranchTbl tbl)
Select variable with largest accumulated failure count divided by domain size with decay factor d...
int p
Number of positive literals for node type.
T * alloc(long unsigned int n)
Allocate block of n objects of type T from heap.
IntVarBranch INT_VAR_AFC_MAX(double d, BranchTbl tbl)
Select variable with largest accumulated failure count with decay factor d.
Gecode::FloatVarArray fv
The float variables.
const FloatNum min
Smallest allowed float value.
Gecode::IntArgs i(4, 1, 2, 3, 4)
IntAssign ann2asnivalsel(AST::Node *ann, Rnd rnd)
Base-class for branchers.
FloatNum n
The middle value for branching.
const Space * last(void) const
Return last solution found (possibly NULL)
int n
Number of negative literals for node type.
IntVarBranch INT_VAR_DEGREE_MAX(BranchTbl tbl)
Select variable with largest degree.
std::vector< bool > fv_introduced
Indicates whether a float variable is introduced by mzn2fzn.
Argument array for non-primitive types.
Option< std::pair< double, double > > domain
IntVarBranch INT_VAR_ACTIVITY_MIN(double d, BranchTbl tbl)
Select variable with lowest activity with decay factor d.
int dfs(Space *root, const Gist::Options &opt)
Create a new stand-alone Gist for root.
FloatVarBranch FLOAT_VAR_AFC_SIZE_MIN(double d, BranchTbl tbl)
Select variable with smalllest accumulated failure count divided by domain size with decay factor d...
IntAssign INT_ASSIGN_RND(Rnd r)
Select random value.
Execution has resulted in failure.
Specification for Boolean variables.
Value description class for branching.
Node representing an atom
A lock as a scoped frontend for a mutex.
int _optVar
Index of the variable to optimize.
virtual void archive(Archive &e) const
Archive into e.
int getIntVar(void)
Cast this node to an integer variable node.
void finalize(void)
Clean up when Gist exits.
Output support class for FlatZinc interpreter.
IntVar arg2IntVar(AST::Node *n)
Convert n to IntVar.
Choice(const Brancher &b, bool fail0)
Initialize choice for brancher b.
static void installCtrlHandler(bool install, bool force=false)
Install handler for catching Ctrl-C.
static Search::Stop * create(unsigned int node, unsigned int fail, unsigned int time, bool intr)
Create appropriate stop-object.
IntAssign INT_ASSIGN_MAX(void)
Select largest value.
SetVarBranch SET_VAR_ACTIVITY_MAX(double d, BranchTbl tbl)
Select variable with highest activity with decay factor d.
unsigned int operator()(unsigned int n)
Returns a random integer from the interval [0..n)
int getBoolVar(void)
Cast this node to a Boolean variable node.
The Gecode Interactive Search Tool.
bool isSet(void)
Test if node is a set literal node.
void fail(void)
Fail space.
FznRnd * _random
Random number generator.
BoolVarArgs arg2boolvarargs(AST::Node *arg, int offset=0, int siv=-1)
Convert arg to BoolVarArgs.
IntValBranch INT_VAL_MIN(void)
Select smallest value.
virtual void archive(Archive &e) const
Archive into e.
unsigned int size(I &i)
Size of all ranges of range iterator i.
void newFloatVar(FloatVarSpec *vs)
Create new float variable from specification.
virtual ExecStatus commit(Space &, const Gecode::Choice &c, unsigned int)
Perform commit for choice c.
IntValBranch INT_VAL_SPLIT_MAX(void)
Select values greater than mean of smallest and largest value.
IntVarBranch INT_VAR_MAX_MAX(BranchTbl tbl)
Select variable with largest max.
void shrinkElement(AST::Node *node, std::map< int, int > &iv, std::map< int, int > &bv, std::map< int, int > &sv, std::map< int, int > &fv)
bool l
Whether to try the lower or upper half first.
bool optVarIsInt(void) const
Return whether variable used for optimization is integer (or float)
IntVarBranch INT_VAR_RND(Rnd r)
Select random variable (uniform distribution, for tie breaking)
IntVarBranch INT_VAR_AFC_MIN(double d, BranchTbl tbl)
Select variable with smallest accumulated failure count with decay factor d.
SetValBranch SET_VAL_MAX_EXC(void)
Exclude largest element.
IntVarBranch INT_VAR_ACTIVITY_SIZE_MAX(double d, BranchTbl tbl)
Select variable with largest activity divided by domain size with decay factor d. ...
Gecode::BoolVarArray bv_aux
The introduced Boolean variables.
bool clone
Whether engines create a clone when being initialized.
FznRnd(unsigned int s=1)
Constructor.
Array * getArgs(unsigned int n)
void print(std::ostream &out, const Printer &p) const
Produce output on out using p.
SetValBranch SET_VAL_MAX_INC(void)
Include largest element.
SetVarBranch SET_VAR_MAX_MAX(BranchTbl tbl)
Select variable with largest maximum unknown element.
struct Gecode::Space::@52::@53 p
Data only available during propagation.
FloatValBranch FLOAT_VAL_SPLIT_MIN(void)
Select values not greater than mean of smallest and largest value.
bool funcDep
Whether the variable functionally depends on another variable.
virtual void compare(const Space &s0, const Space &s1)=0
Call-back function.
Choice that only signals failure or success
SetVarBranch SET_VAR_AFC_SIZE_MIN(double d, BranchTbl tbl)
Select variable with smallest accumulated failure count divided by domain size with decay factor d...
Option< AST::SetLit * > domain
FlatZincSpace(bool share, FlatZincSpace &)
Copy constructor.
FloatVarBranch FLOAT_VAR_MAX_MAX(BranchTbl tbl)
Select variable with largest max.
IntVarArgs arg2intvarargs(AST::Node *arg, int offset=0)
Convert arg to IntVarArgs.
virtual void constrain(const Space &s)
Implement optimization.
unsigned long int restart(void) const
Return number of restarts.
bool isIntVar(void)
Test if node is an integer variable node.
FloatVarBranch FLOAT_VAR_RND(Rnd r)
Select random variable (uniform distribution, for tie breaking)
unsigned int size(void) const
Return size (cardinality) of set.
Passing integer variables.
bool isBoolArray(AST::Node *b, int &singleInt)
Check if b is array of Booleans (or has a single integer)
virtual void print(const Space &, const Gecode::Choice &c, unsigned int, std::ostream &o) const
Print explanation.
std::vector< bool > bv_introduced
Indicates whether a Boolean variable is introduced by mzn2fzn.
bool done
Flag whether brancher is done.
Passing integer arguments.
Passing Boolean variables.
struct Gecode::Space::@52::@54 c
Data available only during copying.
static const IntSet empty
Empty set.
FloatValBranch float_valsel
IntVarBranch INT_VAR_AFC_SIZE_MIN(double d, BranchTbl tbl)
Select variable with smallest accumulated failure count divided by domain size with decay factor d...
bool isInt(int &i)
Test if node is int, if yes set i to the value.
bool _optVarIsInt
Whether variable to optimize is integer (or float)
IntSet arg2intset(AST::Node *n)
Convert n to IntSet.
Gecode::FloatVarArray fv_aux
The introduced float variables.
SetValBranch SET_VAL_MIN_EXC(void)
Exclude smallest element.
SetVarBranch SET_VAR_AFC_SIZE_MAX(double d, BranchTbl tbl)
Select variable with largest accumulated failure count divided by domain size with decay factor d...
Boolean integer variables.
bool isString(void)
Test if node is a string node.
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
bool assigned
Whether the variable is assigned.
AuxVarBrancher(Home home, TieBreak< IntVarBranch > int_varsel0, IntValBranch int_valsel0, TieBreak< IntVarBranch > bool_varsel0, IntValBranch bool_valsel0, SetVarBranch set_varsel0, SetValBranch set_valsel0, TieBreak< FloatVarBranch > float_varsel0, FloatValBranch float_valsel0)
Construct brancher.
void update(Space &home, bool share, SharedHandle &sh)
Updating during cloning.
IntValBranch INT_VAL_MAX(void)
Select largest value.
int getInt(void)
Cast this node to an integer node.
void print(std::basic_ostream< Char, Traits > &s, bool assigned, IL &lb, IU &ub, unsigned int cardMin, unsigned int cardMax)
Print set view.
virtual size_t size(void) const
Report size occupied.
Exception: Base-class for exceptions
Print statistics for script.
SetVarBranch SET_VAR_RND(Rnd r)
Select random variable (uniform distribution, for tie breaking)
Base class for variables.
IntValBranch INT_VALUES_MIN(void)
Try all values starting from smallest.
void free(T *b, long unsigned int n)
Delete n objects starting at b.
BrancherHandle assign(Home home, const FloatVarArgs &x, FloatAssign fa, FloatBranchFilter bf, FloatVarValPrint vvp)
Assign all x with value selection vals.
virtual void print(std::ostream &)=0
Output string representation.
Exception signaling type error
Node * x
Pointer to corresponding Boolean expression node.
FloatVarBranch FLOAT_VAR_MIN_MIN(BranchTbl tbl)
Select variable with smallest min.
Choice for performing commit
bool hasAtom(const std::string &id)
Test if node has atom with id.
SharedHandle::Object * object(void) const
Access to the shared object.
bool isFloatVar(void)
Test if node is a float variable node.
Which values to select for assignment.
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
Exception class for FlatZinc errors
Specification for floating point variables.
TieBreak< FloatVarBranch > ann2fvarsel(AST::Node *ann, Rnd rnd, double decay)
IntVarBranch INT_VAR_AFC_SIZE_MAX(double d, BranchTbl tbl)
Select variable with largest accumulated failure count divided by domain size with decay factor d...
void flattenAnnotations(AST::Array *ann, std::vector< AST::Node * > &out)
The default consistency for a constraint.
int bab(Space *root, const Gist::Options &opt)
Create a new stand-alone Gist for branch-and-bound search of root.
AST::Array * _solveAnnotations
Annotations on the solve item.
IntValBranch INT_VAL_MED(void)
Select greatest value not greater than the median.
IntVarBranch INT_VAR_ACTIVITY_SIZE_MIN(double d, BranchTbl tbl)
Select variable with smallest activity divided by domain size with decay factor d.
~FlatZincSpace(void)
Destructor.
An window for simple text output.
bool needAuxVars
Whether the introduced variables still need to be copied.
virtual bool status(const Space &_home) const
Check status of brancher, return true if alternatives left.
void solve(AST::Array *annotation)
Post the solve item.
unsigned long int restart
Number of restarts.
#define GECODE_HAS_FLOAT_VARS
void varValPrint(const Space &home, const BrancherHandle &bh, unsigned int a, Var, int i, const int &n, std::ostream &o)
TieBreak< FloatVarBranch > float_varsel
bool isArray(void)
Test if node is an array node.
virtual Actor * copy(Space &home, bool share)
Copy brancher.
void aliasBool2Int(int iv, int bv)
Link integer variable iv to Boolean variable bv.
A space that can be initialized with a FlatZinc model.
Gecode::IntVarArray iv_aux
The introduced integer variables.
void shrinkArrays(Space &home, int &optVar, bool optVarIsInt, Gecode::IntVarArray &iv, Gecode::BoolVarArray &bv, Gecode::SetVarArray &sv, Gecode::FloatVarArray &fv)
CompareStatus compare(I &i, J &j)
Check whether range iterator i is a subset of j, or whether they are disjoint.
Bounds propagation or consistency.
Stop * stop
Stop object for stopping search.
class Gecode::Gist::Options::_I inspect
IntValBranch INT_VAL_SPLIT_MIN(void)
Select values not greater than mean of smallest and largest value.
int explore(Space *root, bool bab, const Options &opt)
Create a new stand-alone Gist for root using bab.
struct Gecode::@518::NNF::@57::@58 b
For binary nodes (and, or, eqv)
void run(std::ostream &out, const Printer &p, const FlatZincOptions &opt, Gecode::Support::Timer &t_total)
Run the search.
Gecode toplevel namespace
int * iv_boolalias
Indicates whether an integer variable aliases a Boolean variable.
unsigned long int node
Number of nodes expanded.
void maximize(int var, bool isInt, AST::Array *annotation)
Post that integer variable var should be maximized.
int setVarCount
Number of set variables.
Node representing a function call
int intVarCount
Number of integer variables.
IntValBranch ann2ivalsel(AST::Node *ann, std::string &r0, std::string &r1, Rnd rnd)
SetVarArgs arg2setvarargs(AST::Node *arg, int offset=0, int doffset=0, const IntSet &od=IntSet::empty)
Convert n to SetVarArgs.
A node in a FlatZinc abstract syntax tree.
virtual bool slave(const CRI &cri)
Slave configuration function for restart meta search engine.
SetVarBranch SET_VAR_ACTIVITY_SIZE_MAX(double d, BranchTbl tbl)
Select variable with largest activity divided by domain size with decay factor d. ...
bool assigned(void) const
Test if all variables are assigned.
IntArgs arg2boolargs(AST::Node *arg, int offset=0)
Convert arg (array of Booleans) to IntArgs.
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.
Which variable to select for branching.
FloatVarBranch FLOAT_VAR_ACTIVITY_MIN(double d, BranchTbl tbl)
Select variable with lowest activity with decay factor d.
SetVarBranch SET_VAR_MIN_MIN(BranchTbl tbl)
Select variable with smallest minimum unknown element.
FloatVarBranch FLOAT_VAR_ACTIVITY_SIZE_MIN(double d, BranchTbl tbl)
Select variable with smallest activity divided by domain size with decay factor d.
unsigned int _lns
Percentage of variables to keep in LNS (or 0 for no LNS)
FloatVarBranch FLOAT_VAR_SIZE_MAX(BranchTbl tbl)
Select variable with largest domain size.
Gecode::SetVarArray sv
The set variables.
Home class for posting propagators
int size(void) const
Return size of array (number of elements)
double FloatNum
Floating point number base type.
Specification for integer variables.
void compare(Comparator *c)
Add comparator.
SetVarBranch SET_VAR_AFC_MAX(double d, BranchTbl tbl)
Select variable with largest accumulated failure count with decay factor d.
bool introduced
Whether the variable was introduced in the mzn2fzn translation.
std::string getString(void)
Cast this node to a string node.
struct Gecode::@518::NNF::@57::@59 a
For atomic nodes.
FloatVarBranch FLOAT_VAR_AFC_MAX(double d, BranchTbl tbl)
Select variable with largest accumulated failure count with decay factor d.
Gecode::IntVarArray iv_lns
The integer variables used in LNS.
FloatVar arg2FloatVar(AST::Node *n)
Convert n to FloatVar.
Domain propagation or consistency.
Depth-first search engine.
Branching on the introduced variables.
IntVarBranch INT_VAR_SIZE_MAX(BranchTbl tbl)
Select variable with largest domain size.
Meth method(void) const
Return whether to solve a satisfaction or optimization problem.
Registry & registry(void)
Return global registry object.
FloatValArgs arg2floatargs(AST::Node *arg, int offset=0)
Convert n to FloatValArgs.
Option< AST::SetLit * > upperBound
virtual size_t dispose(Space &)
Delete brancher and return its size.
AST::Array * solveAnnotations(void) const
Return the solve item annotations.
bool fail
Whether brancher should fail.
TieBreak< IntVarBranch > int_varsel
FloatVarBranch FLOAT_VAR_SIZE_MIN(BranchTbl tbl)
Select variable with smallest domain size.
void init(AST::Array *output)
BoolVar arg2BoolVar(AST::Node *n)
Convert n to BoolVar.
IntSetArgs arg2intsetargs(AST::Node *arg, int offset=0)
Convert arg to IntSetArgs.
Abstract representation of a constraint.