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) {}
109 : Gecode::
Choice(b,1), fail(fail0) {}
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),
629 needAuxVars(f.needAuxVars) {
644 iva[iva.
size()-1].update(*
this, share, f.
iv_aux[
i]);
657 bva[bva.
size()-1].update(*
this, share, f.
bv_aux[
i]);
663 #ifdef GECODE_HAS_SET_VARS
671 sva[sva.
size()-1].update(*
this, share, f.
sv_aux[
i]);
677 #ifdef GECODE_HAS_FLOAT_VARS
685 fva[fva.
size()-1].update(*
this, share, f.
fv_aux[
i]);
694 : intVarCount(-1), boolVarCount(-1), floatVarCount(-1), setVarCount(-1),
695 _optVar(-1), _optVarIsInt(true), _lns(0), _random(random),
696 _solveAnnotations(NULL), needAuxVars(true) {
702 int setVars,
int floatVars) {
713 #ifdef GECODE_HAS_SET_VARS
718 #ifdef GECODE_HAS_FLOAT_VARS
763 #ifdef GECODE_HAS_SET_VARS
775 int* is =
heap.
alloc<
int>(
static_cast<unsigned long int>(vsv->s.size()));
776 for (
int i=vsv->s.
size();
i--; )
779 heap.
free(is,static_cast<unsigned long int>(vsv->s.size()));
788 int* is =
heap.
alloc<
int>(
static_cast<unsigned long int>(vsv->
s.size()));
789 for (
int i=vsv->
s.size();
i--; )
792 heap.
free(is,static_cast<unsigned long int>(vsv->
s.size()));
810 #ifdef GECODE_HAS_FLOAT_VARS
841 struct ConExprOrder {
842 bool operator() (ConExpr* ce0, ConExpr* ce1) {
843 return ce0->args->a.size() < ce1->args->a.size();
853 for (
unsigned int i=0;
i<ces.
size();
i++) {
868 for (
unsigned int i=0;
i<ann->
a.size();
i++) {
869 if (ann->
a[
i]->isCall(
"seq_search")) {
874 out.push_back(c->
args);
876 out.push_back(ann->
a[
i]);
885 Rnd rnd(static_cast<unsigned int>(seed));
890 #ifdef GECODE_HAS_SET_VARS
894 #ifdef GECODE_HAS_FLOAT_VARS
899 std::vector<bool> iv_searched(
iv.
size());
900 for (
unsigned int i=
iv.
size();
i--;)
901 iv_searched[
i] =
false;
902 std::vector<bool> bv_searched(
bv.
size());
903 for (
unsigned int i=
bv.
size();
i--;)
904 bv_searched[
i] =
false;
905 #ifdef GECODE_HAS_SET_VARS
906 std::vector<bool> sv_searched(
sv.
size());
907 for (
unsigned int i=
sv.
size();
i--;)
908 sv_searched[
i] =
false;
910 #ifdef GECODE_HAS_FLOAT_VARS
911 std::vector<bool> fv_searched(
fv.
size());
912 for (
unsigned int i=
fv.
size();
i--;)
913 fv_searched[
i] =
false;
918 std::vector<AST::Node*> flatAnn;
922 flatAnn.push_back(ann);
925 for (
unsigned int i=0;
i<flatAnn.
size();
i++) {
926 if (flatAnn[
i]->isCall(
"relax_and_reconstruct")) {
929 "Only one relax_and_reconstruct annotation allowed");
932 _lns = args->
a[1]->getInt();
934 int k=vars->
a.size();
935 for (
int i=vars->
a.size();
i--;)
936 if (vars->
a[
i]->isInt())
940 for (
unsigned int i=0;
i<vars->
a.size();
i++) {
941 if (vars->
a[
i]->isInt())
945 }
else if (flatAnn[
i]->isCall(
"gecode_search")) {
947 branchWithPlugin(c->
args);
948 }
else if (flatAnn[
i]->isCall(
"int_search")) {
952 int k=vars->
a.size();
953 for (
int i=vars->
a.size();
i--;)
954 if (vars->
a[
i]->isInt())
957 vector<string> names;
959 for (
unsigned int i=0;
i<vars->
a.size();
i++) {
960 if (vars->
a[
i]->isInt())
962 va[k++] =
iv[vars->
a[
i]->getIntVar()];
963 iv_searched[vars->
a[
i]->getIntVar()] =
true;
964 names.push_back(vars->
a[
i]->getVarName());
971 &varValPrint<IntVar>);
973 }
else if (flatAnn[
i]->isCall(
"int_assign")) {
977 int k=vars->
a.size();
978 for (
int i=vars->
a.size();
i--;)
979 if (vars->
a[
i]->isInt())
983 for (
unsigned int i=0;
i<vars->
a.size();
i++) {
984 if (vars->
a[
i]->isInt())
986 va[k++] =
iv[vars->
a[
i]->getIntVar()];
987 iv_searched[vars->
a[
i]->getIntVar()] =
true;
990 &varValPrint<IntVar>);
991 }
else if (flatAnn[
i]->isCall(
"bool_search")) {
995 int k=vars->
a.size();
996 for (
int i=vars->
a.size();
i--;)
997 if (vars->
a[
i]->isBool())
1001 vector<string> names;
1002 for (
unsigned int i=0;
i<vars->
a.size();
i++) {
1003 if (vars->
a[
i]->isBool())
1005 va[k++] =
bv[vars->
a[
i]->getBoolVar()];
1006 bv_searched[vars->
a[
i]->getBoolVar()] =
true;
1007 names.push_back(vars->
a[
i]->getVarName());
1014 &varValPrint<BoolVar>);
1016 }
else if (flatAnn[
i]->isCall(
"int_default_search")) {
1022 }
else if (flatAnn[
i]->isCall(
"bool_default_search")) {
1028 }
else if (flatAnn[
i]->isCall(
"set_search")) {
1029 #ifdef GECODE_HAS_SET_VARS
1033 int k=vars->
a.size();
1034 for (
int i=vars->
a.size();
i--;)
1035 if (vars->
a[
i]->isSet())
1039 vector<string> names;
1040 for (
unsigned int i=0;
i<vars->
a.size();
i++) {
1041 if (vars->
a[
i]->isSet())
1043 va[k++] =
sv[vars->
a[
i]->getSetVar()];
1044 sv_searched[vars->
a[
i]->getSetVar()] =
true;
1045 names.push_back(vars->
a[
i]->getVarName());
1052 &varValPrint<SetVar>);
1055 if (!ignoreUnknown) {
1056 err <<
"Warning, ignored search annotation: ";
1057 flatAnn[
i]->print(err);
1061 }
else if (flatAnn[
i]->isCall(
"set_default_search")) {
1062 #ifdef GECODE_HAS_SET_VARS
1069 if (!ignoreUnknown) {
1070 err <<
"Warning, ignored search annotation: ";
1071 flatAnn[
i]->print(err);
1075 }
else if (flatAnn[
i]->isCall(
"float_default_search")) {
1076 #ifdef GECODE_HAS_FLOAT_VARS
1083 if (!ignoreUnknown) {
1084 err <<
"Warning, ignored search annotation: ";
1085 flatAnn[
i]->print(err);
1089 }
else if (flatAnn[
i]->isCall(
"float_search")) {
1090 #ifdef GECODE_HAS_FLOAT_VARS
1094 int k=vars->
a.size();
1095 for (
int i=vars->
a.size();
i--;)
1096 if (vars->
a[
i]->isFloat())
1100 vector<string> names;
1101 for (
unsigned int i=0;
i<vars->
a.size();
i++) {
1102 if (vars->
a[
i]->isFloat())
1104 va[k++] =
fv[vars->
a[
i]->getFloatVar()];
1105 fv_searched[vars->
a[
i]->getFloatVar()] =
true;
1106 names.push_back(vars->
a[
i]->getVarName());
1116 if (!ignoreUnknown) {
1117 err <<
"Warning, ignored search annotation: ";
1118 flatAnn[
i]->print(err);
1123 if (!ignoreUnknown) {
1124 err <<
"Warning, ignored search annotation: ";
1125 flatAnn[
i]->print(err);
1147 for (
int i=
iv.
size(), j=0, k=0;
i--;) {
1152 iv_tmp[j++] =
iv[
i];
1155 iv_sol[k++] =
iv[
i];
1163 if (bv_searched[
i]) {
1175 for (
int i=
bv.
size(), j=0, k=0;
i--;) {
1180 bv_tmp[j++] =
bv[
i];
1183 bv_sol[k++] =
bv[
i];
1187 if (iv_sol.
size() > 0) {
1188 branch(*
this, iv_sol, def_int_varsel, def_int_valsel);
1190 if (bv_sol.
size() > 0)
1191 branch(*
this, bv_sol, def_bool_varsel, def_bool_valsel);
1192 #ifdef GECODE_HAS_FLOAT_VARS
1209 for (
int i=
fv.
size(), j=0, k=0;
i--;) {
1214 fv_tmp[j++] =
fv[
i];
1217 fv_sol[k++] =
fv[
i];
1221 if (fv_sol.
size() > 0)
1222 branch(*
this, fv_sol, def_float_varsel, def_float_valsel);
1224 #ifdef GECODE_HAS_SET_VARS
1229 if (sv_searched[
i]) {
1241 for (
int i=
sv.
size(), j=0, k=0;
i--;) {
1246 sv_tmp[j++] =
sv[
i];
1249 sv_sol[k++] =
sv[
i];
1253 if (sv_sol.
size() > 0)
1254 branch(*
this, sv_sol, def_set_varsel, def_set_valsel);
1259 #ifdef GECODE_HAS_SET_VARS
1263 #ifdef GECODE_HAS_FLOAT_VARS
1272 #ifdef GECODE_HAS_FLOAT_VARS
1280 #ifdef GECODE_HAS_FLOAT_VARS
1289 def_bool_varsel, def_bool_valsel
1291 , def_set_varsel, def_set_valsel
1294 , def_float_varsel, def_float_valsel
1300 #ifdef GECODE_HAS_SET_VARS
1303 #ifdef GECODE_HAS_FLOAT_VARS
1304 branch(*
this,
fv_aux,def_float_varsel,def_float_valsel);
1342 #ifdef GECODE_HAS_GIST
1347 template<
class Engine>
1352 template<
typename S>
1353 class GistEngine<
DFS<S> > {
1355 static void explore(S* root,
const FlatZincOptions&
opt,
1358 o.
c_d = opt.c_d(); o.
a_d = opt.a_d();
1366 template<
typename S>
1367 class GistEngine<BAB<S> > {
1369 static void explore(S* root,
const FlatZincOptions& opt,
1370 Gist::Inspector* i, Gist::Comparator* c) {
1372 o.
c_d = opt.c_d(); o.
a_d = opt.a_d();
1381 class FZPrintingInspector
1387 FZPrintingInspector(
const Printer& p0);
1389 virtual void inspect(
const Space& node);
1391 virtual void finalize(
void);
1395 FZPrintingInspector<S>::FZPrintingInspector(
const Printer& p0)
1396 : TextOutput(
"Gecode/FlatZinc"),
p(p0) {}
1400 FZPrintingInspector<S>::inspect(
const Space& node) {
1402 dynamic_cast<const S&
>(node).
print(getStream(),
p);
1403 getStream() << std::endl;
1408 FZPrintingInspector<S>::finalize(
void) {
1413 class FZPrintingComparator
1419 FZPrintingComparator(
const Printer& p0);
1422 virtual void compare(
const Space& s0,
const Space& s1);
1426 FZPrintingComparator<S>::FZPrintingComparator(
const Printer& p0)
1427 : Gecode::Gist::VarComparator<S>(
"Gecode/FlatZinc"),
p(p0) {}
1434 dynamic_cast<const S&
>(s0).
compare(dynamic_cast<const S&>(s1),
1435 this->getStream(),
p);
1436 }
catch (Exception& e) {
1437 this->getStream() <<
"Exception: " << e.what();
1439 this->getStream() << std::endl;
1445 template<
template<
class>
class Engine>
1447 FlatZincSpace::runEngine(std::ostream& out,
const Printer&
p,
1448 const FlatZincOptions& opt, Support::Timer& t_total) {
1450 runMeta<Engine,Driver::EngineToMeta>(out,
p,
opt,t_total);
1452 runMeta<Engine,RBS>(out,
p,
opt,t_total);
1456 template<
template<
class>
class Engine,
1457 template<
template<
class>
class,
class>
class Meta>
1459 FlatZincSpace::runMeta(std::ostream& out, const Printer& p,
1460 const FlatZincOptions& opt, Support::Timer& t_total) {
1461 #ifdef GECODE_HAS_GIST
1463 FZPrintingInspector<FlatZincSpace> pi(p);
1464 FZPrintingComparator<FlatZincSpace> pc(p);
1465 (void) GistEngine<Engine<FlatZincSpace> >::
explore(
this,opt,&pi,&pc);
1469 StatusStatistics sstat;
1470 unsigned int n_p = 0;
1471 Support::Timer t_solve;
1474 n_p = propagators();
1481 #ifdef GECODE_HAS_FLOAT_VARS
1487 if (opt.interrupt())
1489 Meta<Engine,FlatZincSpace> se(
this,o);
1490 int noOfSolutions = opt.solutions();
1491 if (noOfSolutions == -1) {
1492 noOfSolutions = (_method == SAT) ? 1 : 0;
1494 bool printAll = _method == SAT || opt.allSolutions() || noOfSolutions != 0;
1495 int findSol = noOfSolutions;
1496 FlatZincSpace* sol = NULL;
1497 while (FlatZincSpace* next_sol = se.next()) {
1502 out <<
"----------" << std::endl;
1507 if (sol && !printAll) {
1509 out <<
"----------" << std::endl;
1511 if (!se.stopped()) {
1513 out <<
"==========" << endl;
1515 out <<
"=====UNSATISFIABLE=====" << endl;
1518 out <<
"=====UNKNOWN=====" << endl;
1522 if (opt.interrupt())
1530 <<
"%% solvetime: ";
1534 <<
std::abs(noOfSolutions - findSol) << endl
1536 << (intVarCount + boolVarCount + setVarCount) << endl
1537 <<
"%% propagators: " << n_p << endl
1538 <<
"%% propagations: " << sstat.propagate+stat.
propagate << endl
1539 <<
"%% nodes: " << stat.
node << endl
1540 <<
"%% failures: " << stat.
fail << endl
1541 <<
"%% restarts: " << stat.
restart << endl
1542 <<
"%% peak depth: " << stat.
depth << endl
1548 #ifdef GECODE_HAS_QT
1550 FlatZincSpace::branchWithPlugin(AST::Node* ann) {
1551 if (AST::Call* c = dynamic_cast<AST::Call*>(ann)) {
1552 QString pluginName(c->id.c_str());
1553 if (QLibrary::isLibrary(pluginName+
".dll")) {
1554 pluginName +=
".dll";
1555 }
else if (QLibrary::isLibrary(pluginName+
".dylib")) {
1556 pluginName =
"lib" + pluginName +
".dylib";
1557 }
else if (QLibrary::isLibrary(pluginName+
".so")) {
1559 pluginName =
"lib" + pluginName +
".so";
1561 QPluginLoader pl(pluginName);
1562 QObject* plugin_o = pl.instance();
1564 throw FlatZinc::Error(
"FlatZinc",
1565 "Error loading plugin "+pluginName.toStdString()+
1566 ": "+pl.errorString().toStdString());
1568 BranchPlugin* pb = qobject_cast<BranchPlugin*>(plugin_o);
1570 throw FlatZinc::Error(
"FlatZinc",
1571 "Error loading plugin "+pluginName.toStdString()+
1572 ": does not contain valid PluginBrancher");
1574 pb->branch(*
this, c);
1579 FlatZincSpace::branchWithPlugin(AST::Node*) {
1580 throw FlatZinc::Error(
"FlatZinc",
1581 "Branching with plugins not supported (requires Qt support)");
1591 runEngine<BAB>(out,
p,
opt,t_total);
1594 runEngine<DFS>(out,
p,
opt,t_total);
1604 static_cast<const FlatZincSpace*>(&s)->
iv[_optVar].val());
1607 static_cast<const FlatZincSpace*>(&s)->
iv[_optVar].val());
1609 #ifdef GECODE_HAS_FLOAT_VARS
1612 static_cast<const FlatZincSpace*>(&s)->
fv[_optVar].val()-
step);
1615 static_cast<const FlatZincSpace*>(&s)->
fv[_optVar].val()+
step);
1668 (void) s; (void) out;
1669 #ifdef GECODE_HAS_GIST
1671 for (
int i = 0; i <
iv.
size(); ++
i) {
1672 std::stringstream ss;
1673 ss <<
"iv[" << i <<
"]";
1676 if (result.length() > 0) out << result << std::endl;
1678 for (
int i = 0; i <
bv.
size(); ++
i) {
1679 std::stringstream ss;
1680 ss <<
"bv[" << i <<
"]";
1683 if (result.length() > 0) out << result << std::endl;
1685 #ifdef GECODE_HAS_SET_VARS
1686 for (
int i = 0; i <
sv.
size(); ++
i) {
1687 std::stringstream ss;
1688 ss <<
"sv[" << i <<
"]";
1691 if (result.length() > 0) out << result << std::endl;
1694 #ifdef GECODE_HAS_FLOAT_VARS
1695 for (
int i = 0; i <
fv.
size(); ++
i) {
1696 std::stringstream ss;
1697 ss <<
"fv[" << i <<
"]";
1700 if (result.length() > 0) out << result << std::endl;
1735 for (
int i=offset; i--;)
1737 for (
int i=a->
a.size(); i--;)
1738 ia[i+offset] = a->
a[i]->getInt();
1745 for (
int i=offset; i--;)
1747 for (
int i=a->
a.size(); i--;)
1748 ia[i+offset] = a->
a[i]->getBool();
1759 int* is = re.
alloc<
int>(
static_cast<unsigned long int>(sl->
s.size()));
1760 for (
int i=sl->
s.size(); i--; )
1769 if (a->
a.size() == 0) {
1774 for (
int i=offset; i--;)
1776 for (
int i=a->
a.size(); i--;) {
1784 if (a->
a.size() == 0) {
1789 for (
int i=offset; i--;)
1790 ia[i] =
IntVar(*
this, 0, 0);
1791 for (
int i=a->
a.size(); i--;) {
1792 if (a->
a[i]->isIntVar()) {
1793 ia[i+offset] =
iv[a->
a[
i]->getIntVar()];
1795 int value = a->
a[
i]->getInt();
1805 if (a->
a.size() == 0) {
1810 for (
int i=offset; i--;)
1812 for (
int i=0; i<static_cast<int>(a->
a.size()); i++) {
1815 if (a->
a[i]->isBool()) {
1816 bool value = a->
a[
i]->getBool();
1819 }
else if (a->
a[i]->isIntVar() &&
1823 ia[offset++] =
bv[a->
a[
i]->getBoolVar()];
1853 if (a->
a.size() == 0)
1855 for (
int i=a->
a.size(); i--;) {
1856 if (a->
a[i]->isBoolVar() || a->
a[
i]->isBool()) {
1857 }
else if (a->
a[i]->isIntVar()) {
1859 if (singleInt != -1) {
1868 return singleInt==-1 || a->
a.size() > 1;
1870 #ifdef GECODE_HAS_SET_VARS
1876 x0 =
SetVar(*
this, d, d);
1887 for (
int i=offset; i--;) {
1891 for (
int i=a->
a.size(); i--;) {
1897 #ifdef GECODE_HAS_FLOAT_VARS
1902 for (
int i=offset; i--;)
1904 for (
int i=a->
a.size(); i--;)
1905 fa[i+offset] = a->
a[i]->getFloat();
1911 if (a->
a.size() == 0) {
1916 for (
int i=offset; i--;)
1918 for (
int i=a->
a.size(); i--;) {
1919 if (a->
a[i]->isFloatVar()) {
1920 fa[i+offset] =
fv[a->
a[
i]->getFloatVar()];
1922 double value = a->
a[
i]->getFloat();
1963 Printer::printElem(std::ostream& out,
1983 }
else if (bv[ai->
getBoolVar()].max() == 0) {
1986 out <<
"false..true";
1988 #ifdef GECODE_HAS_SET_VARS
1994 SetVarGlbRanges svr(sv[ai->
getSetVar()]);
1999 int min = svr.min();
2000 int max = svr.max();
2003 SetVarGlbValues svv(sv[ai->
getSetVar()]);
2007 for (; svv(); ++svv)
2008 out <<
", " << svv.val();
2011 out << min <<
".." <<
max;
2014 #ifdef GECODE_HAS_FLOAT_VARS
2025 std::ostringstream oss;
2027 oss << std::setprecision(std::numeric_limits<double>::digits10);
2029 if (oss.str().find(
".") == std::string::npos)
2036 }
else if (ai->
isBool()) {
2037 out << (ai->
getBool() ?
"true" :
"false");
2038 }
else if (ai->
isSet()) {
2039 AST::SetLit* s = ai->
getSet();
2041 out << s->
min <<
".." << s->max;
2044 for (
unsigned int i=0; i<s->s.size(); i++) {
2045 out << s->s[
i] << (i < s->s.size()-1 ?
", " :
"}");
2050 for (
unsigned int i=0; i<s.size(); i++) {
2051 if (s[i] ==
'\\' && i<s.size()-1) {
2053 case 'n': out <<
"\n";
break;
2054 case '\\': out <<
"\\";
break;
2055 case 't': out <<
"\t";
break;
2056 default: out <<
"\\" << s[i+1];
2067 Printer::printElemDiff(std::ostream& out,
2073 #ifdef GECODE_HAS_SET_VARS
2077 #ifdef GECODE_HAS_FLOAT_VARS
2082 #ifdef GECODE_HAS_GIST
2083 using namespace Gecode::Gist;
2087 }
else if (ai->isIntVar()) {
2089 iv2[ai->getIntVar()]));
2090 if (res.length() > 0) {
2094 out << iv1[ai->getIntVar()];
2096 }
else if (ai->isBoolVar()) {
2098 bv2[ai->getBoolVar()]));
2099 if (res.length() > 0) {
2103 out << bv1[ai->getBoolVar()];
2105 #ifdef GECODE_HAS_SET_VARS
2106 }
else if (ai->isSetVar()) {
2108 sv2[ai->getSetVar()]));
2109 if (res.length() > 0) {
2113 out << sv1[ai->getSetVar()];
2116 #ifdef GECODE_HAS_FLOAT_VARS
2117 }
else if (ai->isFloatVar()) {
2119 fv2[ai->getFloatVar()]));
2120 if (res.length() > 0) {
2124 out << fv1[ai->getFloatVar()];
2127 }
else if (ai->isBool()) {
2128 out << (ai->getBool() ?
"true" :
"false");
2129 }
else if (ai->isSet()) {
2130 AST::SetLit* s = ai->getSet();
2132 out << s->min <<
".." << s->max;
2135 for (
unsigned int i=0; i<s->s.size(); i++) {
2136 out << s->s[
i] << (i < s->s.size()-1 ?
", " :
"}");
2139 }
else if (ai->isString()) {
2140 std::string s = ai->getString();
2141 for (
unsigned int i=0; i<s.size(); i++) {
2142 if (s[i] ==
'\\' && i<s.size()-1) {
2144 case 'n': out <<
"\n";
break;
2145 case '\\': out <<
"\\";
break;
2146 case 't': out <<
"\t";
break;
2147 default: out <<
"\\" << s[i+1];
2162 #ifdef GECODE_HAS_SET_VARS
2166 #ifdef GECODE_HAS_FLOAT_VARS
2178 #ifdef GECODE_HAS_SET_VARS
2182 #ifdef GECODE_HAS_FLOAT_VARS
2187 if (_output == NULL)
2189 for (
unsigned int i=0; i< _output->
a.size(); i++) {
2193 int size = aia->
a.size();
2195 for (
int j=0; j<
size; j++) {
2196 printElem(out,aia->
a[j],iv,bv
2197 #ifdef GECODE_HAS_SET_VARS
2200 #ifdef GECODE_HAS_FLOAT_VARS
2209 printElem(out,ai,iv,bv
2210 #ifdef GECODE_HAS_SET_VARS
2213 #ifdef GECODE_HAS_FLOAT_VARS
2227 #ifdef GECODE_HAS_SET_VARS
2232 #ifdef GECODE_HAS_FLOAT_VARS
2238 if (_output == NULL)
2240 for (
unsigned int i=0; i< _output->
a.size(); i++) {
2244 int size = aia->
a.size();
2246 for (
int j=0; j<
size; j++) {
2247 printElemDiff(out,aia->
a[j],iv1,iv2,bv1,bv2
2248 #ifdef GECODE_HAS_SET_VARS
2251 #ifdef GECODE_HAS_FLOAT_VARS
2260 printElemDiff(out,ai,iv1,iv2,bv1,bv2
2261 #ifdef GECODE_HAS_SET_VARS
2264 #ifdef GECODE_HAS_FLOAT_VARS
2274 std::map<int,int>& iv, std::map<int,int>& bv,
2275 std::map<int,int>& sv, std::map<int,int>& fv) {
2278 if (iv.find(x->
i) == iv.end()) {
2279 int newi = iv.size();
2285 if (bv.find(x->
i) == bv.end()) {
2286 int newi = bv.size();
2292 if (sv.find(x->
i) == sv.end()) {
2293 int newi = sv.size();
2299 if (fv.find(x->
i) == fv.end()) {
2300 int newi = fv.size();
2309 int& optVar,
bool optVarIsInt,
2312 #ifdef GECODE_HAS_SET_VARS
2316 #ifdef GECODE_HAS_FLOAT_VARS
2321 if (_output == NULL) {
2322 if (optVarIsInt && optVar != -1) {
2331 #ifdef GECODE_HAS_SET_VARS
2334 #ifdef GECODE_HAS_FLOAT_VARS
2335 if (!optVarIsInt && optVar != -1) {
2346 std::map<int,int> iv_new;
2347 std::map<int,int> bv_new;
2348 std::map<int,int> sv_new;
2349 std::map<int,int> fv_new;
2359 for (
unsigned int i=0; i< _output->
a.size(); i++) {
2363 for (
unsigned int j=0; j<aia->
a.size(); j++) {
2372 for (map<int,int>::iterator i=iv_new.begin(); i != iv_new.end(); ++
i) {
2373 iva[(*i).second] = iv[(*i).first];
2378 for (map<int,int>::iterator i=bv_new.begin(); i != bv_new.end(); ++
i) {
2379 bva[(*i).second] = bv[(*i).first];
2383 #ifdef GECODE_HAS_SET_VARS
2385 for (map<int,int>::iterator i=sv_new.begin(); i != sv_new.end(); ++
i) {
2386 sva[(*i).second] = sv[(*i).first];
2391 #ifdef GECODE_HAS_FLOAT_VARS
2393 for (map<int,int>::iterator i=fv_new.begin(); i != fv_new.end(); ++
i) {
2394 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.
const Gecode::FloatNum step
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.
unsigned int nogoods_limit
Depth limit for extraction of no-goods.
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
Cutoff * cutoff
Cutoff for restart-based search.
double threads
Number of threads to use.
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.
struct Gecode::Space::@55::@56 p
Data only available during propagation.
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.
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.
struct Gecode::@519::NNF::@60::@62 a
For atomic nodes.
SetValBranch SET_VAL_MAX_INC(void)
Include largest element.
SetVarBranch SET_VAR_MAX_MAX(BranchTbl tbl)
Select variable with largest maximum unknown element.
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.
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.
struct Gecode::@519::NNF::@60::@61 b
For binary nodes (and, or, eqv)
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
struct Gecode::Space::@55::@57 c
Data available only during copying.
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.
void run(std::ostream &out, const Printer &p, const FlatZincOptions &opt, Gecode::Support::Timer &t_total)
Run the search.
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.
Gecode::FloatNum step
Step by which a next solution has to have lower cost.
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.
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.