53#include <unordered_set>
59 template<>
struct hash<
Gecode::TupleSet> {
68 template<>
struct hash<
Gecode::SharedArray<int> > {
72 size_t seed =
static_cast<size_t>(x.
size());
73 for (
int i=x.
size(); i--; )
80 template<>
struct hash<
Gecode::DFA> {
149 virtual size_t size(
void)
const {
163#ifdef GECODE_HAS_SET_VARS
167#ifdef GECODE_HAS_FLOAT_VARS
175 if (
done)
return false;
181#ifdef GECODE_HAS_SET_VARS
185#ifdef GECODE_HAS_FLOAT_VARS
199#ifdef GECODE_HAS_SET_VARS
202#ifdef GECODE_HAS_FLOAT_VARS
209 return new Choice(*
this,
false);
211 return new Choice(*
this,
true);
216 bool fail; e >> fail;
217 return new Choice(*
this, fail);
226 std::ostream& o)
const {
228 << (
static_cast<const Choice&
>(c).
fail ?
"fail" :
"ok")
264 return sizeof(*this);
273 std::vector<std::string> n;
274 BI(
void) : r0(
""), r1(
""), n(0) {}
275 BI(
const std::string& r00,
const std::string& r10,
276 const std::vector<std::string>& n0)
277 : r0(r00), r1(r10), n(n0) {}
289 const std::string& rel0,
290 const std::string& rel1,
291 const std::vector<std::string>& n) {
292 v.resize(std::max(
static_cast<unsigned int>(v.size()),bg.
id()+1));
293 v[bg.
id()] = BI(rel0,rel1,n);
297 unsigned int a,
int i,
int n, std::ostream& o)
const {
298 const BI& bi = v[b.group().id()];
299 o << bi.n[i] <<
" " << (a==0 ? bi.r0 : bi.r1) <<
" " << n;
301#ifdef GECODE_HAS_FLOAT_VARS
304 std::ostream& o)
const {
305 const BI& bi = v[b.group().id()];
307 << (((a == 0) == nl.
l) ?
"<=" :
">=") << nl.
n;
320 assert(
object() ==
nullptr);
326 const std::string& rel0,
327 const std::string& rel1,
328 const std::vector<std::string>& n) {
333 int n, std::ostream& o)
const {
336#ifdef GECODE_HAS_FLOAT_VARS
346 Var,
int i,
const int& n,
351#ifdef GECODE_HAS_FLOAT_VARS
369 int* newdom =
heap.alloc<
int>(
static_cast<unsigned long int>(sl->
s.size()));
370 for (
int i=sl->
s.size(); i--;)
371 newdom[i] = sl->
s[i];
372 IntSet ret(newdom, sl->
s.size());
373 heap.free(newdom,
static_cast<unsigned long int>(sl->
s.size()));
387 return std::min(1, std::max(0, sl->
min));
399 return std::max(0, std::min(1, sl->
max));
406 if (s->id ==
"input_order")
408 if (s->id ==
"first_fail")
410 if (s->id ==
"anti_first_fail")
412 if (s->id ==
"smallest")
414 if (s->id ==
"largest")
416 if (s->id ==
"occurrence")
418 if (s->id ==
"max_regret")
420 if (s->id ==
"most_constrained")
423 if (s->id ==
"random") {
426 if (s->id ==
"dom_w_deg") {
429 if (s->id ==
"afc_min")
431 if (s->id ==
"afc_max")
433 if (s->id ==
"afc_size_min")
435 if (s->id ==
"afc_size_max") {
438 if (s->id ==
"action_min")
440 if (s->id ==
"action_max")
442 if (s->id ==
"action_size_min")
444 if (s->id ==
"action_size_max")
447 std::cerr <<
"Warning, ignored search annotation: ";
448 ann->
print(std::cerr);
449 std::cerr << std::endl;
456 if (s->id ==
"indomain_min") {
460 if (s->id ==
"indomain_max") {
464 if (s->id ==
"indomain_median") {
468 if (s->id ==
"indomain_split") {
472 if (s->id ==
"indomain_reverse_split") {
476 if (s->id ==
"indomain_random") {
480 if (s->id ==
"indomain") {
484 if (s->id ==
"indomain_middle") {
485 std::cerr <<
"Warning, replacing unsupported annotation "
486 <<
"indomain_middle with indomain_median" << std::endl;
490 if (s->id ==
"indomain_interval") {
491 std::cerr <<
"Warning, replacing unsupported annotation "
492 <<
"indomain_interval with indomain_split" << std::endl;
497 std::cerr <<
"Warning, ignored search annotation: ";
498 ann->
print(std::cerr);
499 std::cerr << std::endl;
506 if (s->id ==
"indomain_min")
508 if (s->id ==
"indomain_max")
510 if (s->id ==
"indomain_median")
512 if (s->id ==
"indomain_random") {
516 std::cerr <<
"Warning, ignored search annotation: ";
517 ann->
print(std::cerr);
518 std::cerr << std::endl;
524 if ((s->id ==
"input_order") ||
525 (s->id ==
"first_fail") ||
526 (s->id ==
"anti_first_fail") ||
527 (s->id ==
"smallest") ||
528 (s->id ==
"largest") ||
529 (s->id ==
"max_regret"))
531 if ((s->id ==
"occurrence") ||
532 (s->id ==
"most_constrained"))
534 if (s->id ==
"random")
536 if ((s->id ==
"afc_min") ||
537 (s->id ==
"afc_size_min"))
539 if ((s->id ==
"afc_max") ||
540 (s->id ==
"afc_size_max") ||
541 (s->id ==
"dom_w_deg"))
543 if ((s->id ==
"action_min") &&
544 (s->id ==
"action_size_min"))
546 if ((s->id ==
"action_max") ||
547 (s->id ==
"action_size_max"))
550 std::cerr <<
"Warning, ignored search annotation: ";
551 ann->
print(std::cerr);
552 std::cerr << std::endl;
559 if (s->id ==
"indomain_min") {
563 if (s->id ==
"indomain_max") {
567 if (s->id ==
"indomain_median") {
571 if (s->id ==
"indomain_split") {
575 if (s->id ==
"indomain_reverse_split") {
579 if (s->id ==
"indomain_random") {
583 if (s->id ==
"indomain") {
587 if (s->id ==
"indomain_middle") {
588 std::cerr <<
"Warning, replacing unsupported annotation "
589 <<
"indomain_middle with indomain_median" << std::endl;
593 if (s->id ==
"indomain_interval") {
594 std::cerr <<
"Warning, replacing unsupported annotation "
595 <<
"indomain_interval with indomain_split" << std::endl;
600 std::cerr <<
"Warning, ignored search annotation: ";
601 ann->
print(std::cerr);
602 std::cerr << std::endl;
609 if ((s->id ==
"indomain_min") ||
610 (s->id ==
"indomain_median"))
612 if (s->id ==
"indomain_max")
614 if (s->id ==
"indomain_random") {
618 std::cerr <<
"Warning, ignored search annotation: ";
619 ann->
print(std::cerr);
620 std::cerr << std::endl;
624#ifdef GECODE_HAS_SET_VARS
627 if (s->id ==
"input_order")
629 if (s->id ==
"first_fail")
631 if (s->id ==
"anti_first_fail")
633 if (s->id ==
"smallest")
635 if (s->id ==
"largest")
637 if (s->id ==
"afc_min")
639 if (s->id ==
"afc_max")
641 if (s->id ==
"afc_size_min")
643 if (s->id ==
"afc_size_max")
645 if (s->id ==
"action_min")
647 if (s->id ==
"action_max")
649 if (s->id ==
"action_size_min")
651 if (s->id ==
"action_size_max")
653 if (s->id ==
"random") {
657 std::cerr <<
"Warning, ignored search annotation: ";
658 ann->
print(std::cerr);
659 std::cerr << std::endl;
667 if (s->id ==
"indomain_min") {
668 r0 =
"in"; r1 =
"not in";
671 if (s->id ==
"indomain_max") {
672 r0 =
"in"; r1 =
"not in";
675 if (s->id ==
"outdomain_min") {
676 r1 =
"in"; r0 =
"not in";
679 if (s->id ==
"outdomain_max") {
680 r1 =
"in"; r0 =
"not in";
684 std::cerr <<
"Warning, ignored search annotation: ";
685 ann->
print(std::cerr);
686 std::cerr << std::endl;
687 r0 =
"in"; r1 =
"not in";
692#ifdef GECODE_HAS_FLOAT_VARS
696 if (s->id ==
"input_order")
698 if (s->id ==
"first_fail")
700 if (s->id ==
"anti_first_fail")
702 if (s->id ==
"smallest")
704 if (s->id ==
"largest")
706 if (s->id ==
"occurrence")
708 if (s->id ==
"most_constrained")
711 if (s->id ==
"random") {
714 if (s->id ==
"afc_min")
716 if (s->id ==
"afc_max")
718 if (s->id ==
"afc_size_min")
720 if (s->id ==
"afc_size_max")
722 if (s->id ==
"action_min")
724 if (s->id ==
"action_max")
726 if (s->id ==
"action_size_min")
728 if (s->id ==
"action_size_max")
731 std::cerr <<
"Warning, ignored search annotation: ";
732 ann->
print(std::cerr);
733 std::cerr << std::endl;
739 if (s->id ==
"indomain_split") {
743 if (s->id ==
"indomain_reverse_split") {
748 std::cerr <<
"Warning, ignored search annotation: ";
749 ann->
print(std::cerr);
750 std::cerr << std::endl;
797 iv.update(*
this, f.iv);
798 iv_lns.update(*
this, f.iv_lns);
811 for (
int i=0; i<f.iv_aux.size(); i++) {
812 if (!f.iv_aux[i].assigned()) {
814 iva[iva.
size()-1].update(*
this, f.iv_aux[i]);
820 bv.update(*
this, f.bv);
824 for (
int i=0; i<f.bv_aux.size(); i++) {
825 if (!f.bv_aux[i].assigned()) {
827 bva[bva.
size()-1].update(*
this, f.bv_aux[i]);
833#ifdef GECODE_HAS_SET_VARS
834 sv.update(*
this, f.sv);
838 for (
int i=0; i<f.sv_aux.size(); i++) {
839 if (!f.sv_aux[i].assigned()) {
841 sva[sva.
size()-1].update(*
this, f.sv_aux[i]);
847#ifdef GECODE_HAS_FLOAT_VARS
848 fv.update(*
this, f.fv);
852 for (
int i=0; i<f.fv_aux.size(); i++) {
853 if (!f.fv_aux[i].assigned()) {
855 fva[fva.
size()-1].update(*
this, f.fv_aux[i]);
880 int setVars,
int floatVars) {
891#ifdef GECODE_HAS_SET_VARS
896#ifdef GECODE_HAS_FLOAT_VARS
941#ifdef GECODE_HAS_SET_VARS
953 int* is =
heap.alloc<
int>(
static_cast<unsigned long int>(vsv->
s.size()));
954 for (
int i=vsv->
s.size(); i--; )
957 heap.free(is,
static_cast<unsigned long int>(vsv->
s.size()));
966 int* is =
heap.alloc<
int>(
static_cast<unsigned long int>(vsv->
s.size()));
967 for (
int i=vsv->
s.size(); i--; )
970 heap.free(is,
static_cast<unsigned long int>(vsv->
s.size()));
988#ifdef GECODE_HAS_FLOAT_VARS
1019 struct ConExprOrder {
1020 bool operator() (ConExpr* ce0, ConExpr* ce1) {
1021 return ce0->args->a.size() < ce1->args->a.size();
1029 std::sort(ces.begin(), ces.end(), ceo);
1031 for (
unsigned int i=0; i<ces.
size(); i++) {
1046 for (
unsigned int i=0; i<ann->
a.size(); i++) {
1047 if (ann->
a[i]->isCall(
"seq_search")) {
1049 if (c->args->isArray())
1052 out.push_back(c->args);
1054 out.push_back(ann->
a[i]);
1062 std::ostream& err) {
1063 int seed = opt.
seed();
1064 double decay = opt.decay();
1065 Rnd rnd(
static_cast<unsigned int>(seed));
1069 std::string def_int_rel_left =
"=";
1070 std::string def_int_rel_right =
"!=";
1073 std::string def_bool_rel_left =
"=";
1074 std::string def_bool_rel_right =
"!=";
1075#ifdef GECODE_HAS_SET_VARS
1078 std::string def_set_rel_left =
"in";
1079 std::string def_set_rel_right =
"not in";
1081#ifdef GECODE_HAS_FLOAT_VARS
1084 std::string def_float_rel_left =
"<=";
1085 std::string def_float_rel_right =
">";
1088 std::vector<bool> iv_searched(
iv.size());
1089 for (
unsigned int i=
iv.size(); i--;)
1090 iv_searched[i] =
false;
1091 std::vector<bool> bv_searched(
bv.size());
1092 for (
unsigned int i=
bv.size(); i--;)
1093 bv_searched[i] =
false;
1094#ifdef GECODE_HAS_SET_VARS
1095 std::vector<bool> sv_searched(
sv.size());
1096 for (
unsigned int i=
sv.size(); i--;)
1097 sv_searched[i] =
false;
1099#ifdef GECODE_HAS_FLOAT_VARS
1100 std::vector<bool> fv_searched(
fv.size());
1101 for (
unsigned int i=
fv.size(); i--;)
1102 fv_searched[i] =
false;
1107 std::vector<AST::Node*> flatAnn;
1111 flatAnn.push_back(ann);
1114 for (
unsigned int i=0; i<flatAnn.
size(); i++) {
1115 if (flatAnn[i]->isCall(
"restart_geometric")) {
1119 opt.restart_base(args->
a[0]->getFloat());
1120 opt.restart_scale(args->
a[1]->getInt());
1121 }
else if (flatAnn[i]->isCall(
"restart_luby")) {
1125 }
else if (flatAnn[i]->isCall(
"restart_linear")) {
1129 }
else if (flatAnn[i]->isCall(
"restart_constant")) {
1133 }
else if (flatAnn[i]->isCall(
"restart_none")) {
1135 }
else if (flatAnn[i]->isCall(
"relax_and_reconstruct")) {
1138 "Only one relax_and_reconstruct annotation allowed");
1146 _lns = args->
a[1]->getInt();
1148 int k=vars->
a.size();
1149 for (
int i=vars->
a.size(); i--;)
1150 if (vars->
a[i]->isInt())
1154 for (
unsigned int i=0; i<vars->
a.size(); i++) {
1155 if (vars->
a[i]->isInt())
1157 iv_lns[k++] =
iv[vars->
a[i]->getIntVar()];
1159 if (args->
a.size()==3) {
1162 for (
unsigned int i=initial->
a.size(); i--;)
1165 }
else if (flatAnn[i]->isCall(
"gecode_search")) {
1167 branchWithPlugin(
c->args);
1168 }
else if (flatAnn[i]->isCall(
"int_search")) {
1172 int k=vars->
a.size();
1173 for (
int i=vars->
a.size(); i--;)
1174 if (vars->
a[i]->isInt())
1177 std::vector<std::string> names;
1179 for (
unsigned int i=0; i<vars->
a.size(); i++) {
1180 if (vars->
a[i]->isInt())
1182 va[k++] =
iv[vars->
a[i]->getIntVar()];
1183 iv_searched[vars->
a[i]->getIntVar()] =
true;
1184 names.push_back(vars->
a[i]->getVarName());
1196 }
else if (flatAnn[i]->isCall(
"int_assign")) {
1200 int k=vars->
a.size();
1201 for (
int i=vars->
a.size(); i--;)
1202 if (vars->
a[i]->isInt())
1206 for (
unsigned int i=0; i<vars->
a.size(); i++) {
1207 if (vars->
a[i]->isInt())
1209 va[k++] =
iv[vars->
a[i]->getIntVar()];
1210 iv_searched[vars->
a[i]->getIntVar()] =
true;
1214 }
else if (flatAnn[i]->isCall(
"bool_search")) {
1218 int k=vars->
a.size();
1219 for (
int i=vars->
a.size(); i--;)
1220 if (vars->
a[i]->isBool())
1224 std::vector<std::string> names;
1225 for (
unsigned int i=0; i<vars->
a.size(); i++) {
1226 if (vars->
a[i]->isBool())
1228 va[k++] =
bv[vars->
a[i]->getBoolVar()];
1229 bv_searched[vars->
a[i]->getBoolVar()] =
true;
1230 names.push_back(vars->
a[i]->getVarName());
1243 }
else if (flatAnn[i]->isCall(
"int_default_search")) {
1248 def_int_rel_left,def_int_rel_right,rnd);
1249 }
else if (flatAnn[i]->isCall(
"bool_default_search")) {
1254 def_bool_rel_left,def_bool_rel_right,
1256 }
else if (flatAnn[i]->isCall(
"set_search")) {
1257#ifdef GECODE_HAS_SET_VARS
1261 int k=vars->
a.size();
1262 for (
int i=vars->
a.size(); i--;)
1263 if (vars->
a[i]->isSet())
1267 std::vector<std::string> names;
1268 for (
unsigned int i=0; i<vars->
a.size(); i++) {
1269 if (vars->
a[i]->isSet())
1271 va[k++] =
sv[vars->
a[i]->getSetVar()];
1272 sv_searched[vars->
a[i]->getSetVar()] =
true;
1273 names.push_back(vars->
a[i]->getVarName());
1286 if (!ignoreUnknown) {
1287 err <<
"Warning, ignored search annotation: ";
1288 flatAnn[i]->print(err);
1292 }
else if (flatAnn[i]->isCall(
"set_default_search")) {
1293#ifdef GECODE_HAS_SET_VARS
1298 def_set_rel_left,def_set_rel_right,rnd);
1300 if (!ignoreUnknown) {
1301 err <<
"Warning, ignored search annotation: ";
1302 flatAnn[i]->print(err);
1306 }
else if (flatAnn[i]->isCall(
"float_default_search")) {
1307#ifdef GECODE_HAS_FLOAT_VARS
1312 def_float_rel_left,def_float_rel_right);
1314 if (!ignoreUnknown) {
1315 err <<
"Warning, ignored search annotation: ";
1316 flatAnn[i]->print(err);
1320 }
else if (flatAnn[i]->isCall(
"float_search")) {
1321#ifdef GECODE_HAS_FLOAT_VARS
1325 int k=vars->
a.size();
1326 for (
int i=vars->
a.size(); i--;)
1327 if (vars->
a[i]->isFloat())
1331 std::vector<std::string> names;
1332 for (
unsigned int i=0; i<vars->
a.size(); i++) {
1333 if (vars->
a[i]->isFloat())
1335 va[k++] =
fv[vars->
a[i]->getFloatVar()];
1336 fv_searched[vars->
a[i]->getFloatVar()] =
true;
1337 names.push_back(vars->
a[i]->getVarName());
1350 if (!ignoreUnknown) {
1351 err <<
"Warning, ignored search annotation: ";
1352 flatAnn[i]->print(err);
1357 if (!ignoreUnknown) {
1358 err <<
"Warning, ignored search annotation: ";
1359 flatAnn[i]->print(err);
1368 for (
int i=
iv.size(); i--;) {
1379 std::vector<std::string> iv_sol_names(
iv.size()-(introduced+funcdep+searched));
1380 IntVarArgs iv_sol(
iv.size()-(introduced+funcdep+searched));
1381 std::vector<std::string> iv_tmp_names(introduced);
1383 for (
int i=
iv.size(), j=0, k=0; i--;) {
1388 iv_tmp_names[j] =
p.intVarName(i);
1389 iv_tmp[j++] =
iv[i];
1392 iv_sol_names[k] =
p.intVarName(i);
1393 iv_sol[k++] =
iv[i];
1400 for (
int i=
bv.size(); i--;) {
1401 if (bv_searched[i]) {
1411 std::vector<std::string> bv_sol_names(
bv.size()-(introduced+funcdep+searched));
1412 BoolVarArgs bv_sol(
bv.size()-(introduced+funcdep+searched));
1414 std::vector<std::string> bv_tmp_names(introduced);
1415 for (
int i=
bv.size(), j=0, k=0; i--;) {
1420 bv_tmp_names[j] =
p.boolVarName(i);
1421 bv_tmp[j++] =
bv[i];
1424 bv_sol_names[k] =
p.boolVarName(i);
1425 bv_sol[k++] =
bv[i];
1429 if (iv_sol.
size() > 0 && bv_sol.
size() > 0) {
1430 branch(*
this, iv_sol, bv_sol, def_intbool_varsel, def_int_valsel);
1431 }
else if (iv_sol.
size() > 0) {
1433 branch(bg(*
this), iv_sol, def_int_varsel, def_int_valsel,
nullptr,
1435 branchInfo.add(bg,def_int_rel_left,def_int_rel_right,iv_sol_names);
1436 }
else if (bv_sol.
size() > 0) {
1438 branch(bg(*
this), bv_sol, def_bool_varsel, def_bool_valsel,
nullptr,
1440 branchInfo.add(bg,def_bool_rel_left,def_bool_rel_right,bv_sol_names);
1442#ifdef GECODE_HAS_FLOAT_VARS
1446 for (
int i=
fv.size(); i--;) {
1457 std::vector<std::string> fv_sol_names(
fv.size()-(introduced+funcdep+searched));
1460 std::vector<std::string> fv_tmp_names(introduced);
1461 for (
int i=
fv.size(), j=0, k=0; i--;) {
1466 fv_tmp_names[j] =
p.floatVarName(i);
1467 fv_tmp[j++] =
fv[i];
1470 fv_sol_names[k] =
p.floatVarName(i);
1471 fv_sol[k++] =
fv[i];
1475 if (fv_sol.
size() > 0) {
1477 branch(bg(*
this), fv_sol, def_float_varsel, def_float_valsel,
nullptr,
1479 branchInfo.add(bg,def_float_rel_left,def_float_rel_right,fv_sol_names);
1482#ifdef GECODE_HAS_SET_VARS
1486 for (
int i=
sv.size(); i--;) {
1487 if (sv_searched[i]) {
1497 std::vector<std::string> sv_sol_names(
sv.size()-(introduced+funcdep+searched));
1498 SetVarArgs sv_sol(
sv.size()-(introduced+funcdep+searched));
1500 std::vector<std::string> sv_tmp_names(introduced);
1501 for (
int i=
sv.size(), j=0, k=0; i--;) {
1506 sv_tmp_names[j] =
p.setVarName(i);
1507 sv_tmp[j++] =
sv[i];
1510 sv_sol_names[k] =
p.setVarName(i);
1511 sv_sol[k++] =
sv[i];
1515 if (sv_sol.
size() > 0) {
1517 branch(bg(*
this), sv_sol, def_set_varsel, def_set_valsel,
nullptr,
1519 branchInfo.add(bg,def_set_rel_left,def_set_rel_right,sv_sol_names);
1526#ifdef GECODE_HAS_SET_VARS
1530#ifdef GECODE_HAS_FLOAT_VARS
1538 def_bool_varsel, def_bool_valsel
1540 , def_set_varsel, def_set_valsel
1543 , def_float_varsel, def_float_valsel
1549 branch(bg(*
this),
iv_aux,def_int_varsel,def_int_valsel,
nullptr,
1551 branchInfo.add(bg,def_int_rel_left,def_int_rel_right,iv_tmp_names);
1555 branch(bg(*
this),
bv_aux,def_bool_varsel,def_bool_valsel,
nullptr,
1557 branchInfo.add(bg,def_bool_rel_left,def_bool_rel_right,bv_tmp_names);
1559 #ifdef GECODE_HAS_SET_VARS
1562 branch(bg(*
this),
sv_aux,def_set_varsel,def_set_valsel,
nullptr,
1564 branchInfo.add(bg,def_set_rel_left,def_set_rel_right,sv_tmp_names);
1567 #ifdef GECODE_HAS_FLOAT_VARS
1570 branch(bg(*
this),
fv_aux,def_float_varsel,def_float_valsel,
nullptr,
1572 branchInfo.add(bg,def_float_rel_left,def_float_rel_right,fv_tmp_names);
1581 std::vector<std::string> names(1);
1588#ifdef GECODE_HAS_FLOAT_VARS
1589 std::vector<std::string> names(1);
1590 names[0] =
p.floatVarName(
_optVar);
1599 std::vector<std::string> names(1);
1606#ifdef GECODE_HAS_FLOAT_VARS
1607 std::vector<std::string> names(1);
1608 names[0] =
p.floatVarName(
_optVar);
1651#ifdef GECODE_HAS_GIST
1656 template<
class Engine>
1661 template<
typename S>
1667 o.
c_d = opt.c_d(); o.
a_d = opt.a_d();
1675 template<
typename S>
1681 o.
c_d = opt.c_d(); o.
a_d = opt.a_d();
1743 dynamic_cast<const S&
>(s0).
compare(
dynamic_cast<const S&
>(s1),
1781 template<
template<
class>
class Engine>
1783 FlatZincSpace::runEngine(std::ostream& out,
const Printer& p,
1786 runMeta<Engine,Driver::EngineToMeta>(out,
p,opt,t_total);
1788 runMeta<Engine,RBS>(out,
p,opt,t_total);
1792#ifdef GECODE_HAS_CPPROFILER
1800 std::stringstream ss;
1802 ss <<
"{\n\t\"domains\": \"";
1803 ss << fz_space->getDomains(
p);
1814 os <<
"int: " << name <<
" = " << x.
val() <<
";";
1815 }
else if (x.
range()) {
1816 os << x.
min() <<
".." << x.
max() <<
": " << name <<
";";
1818 os <<
"array_union([";
1821 os << r.min() <<
".." << r.max();
1826 os <<
"]): " << name <<
";";
1831 os <<
"var bool: " << name;
1833 os <<
" = " << (b.val() ?
"true" :
"false");
1836#ifdef GECODE_HAS_FLOAT_VARS
1840 os <<
"float: " << name <<
" = " << f.med() <<
";";
1842 os << f.min() <<
".." << f.max() <<
": " << name <<
";";
1847 std::ostringstream oss;
1849 for (
int i = 0; i <
iv.size(); i++)
1852 for (
int i = 0; i <
bv.size(); i++)
1855#ifdef GECODE_HAS_FLOAT_VARS
1856 for (
int i = 0; i <
fv.size(); i++)
1859#ifdef GECODE_HAS_SET_VARS
1860 for (
int i = 0; i <
sv.size(); i++)
1861 oss <<
"var " <<
sv[i] <<
": " <<
p.setVarName(i) <<
";" << std::endl;
1869 template<
template<
class>
class Engine,
1870 template<
class,
template<
class>
class>
class Meta>
1873 const FlatZincOptions& opt, Support::Timer& t_total) {
1874#ifdef GECODE_HAS_GIST
1881 (void)
GistEngine<Engine<FlatZincSpace> >::explore(
this,opt,&
pi,&pc);
1887 unsigned int n_p = 0;
1893 BlackBoxContextHandle& black_box_context = BlackBoxAccess::context(*
this);
1894 black_box_context.rethrow();
1896 std::unique_ptr<Search::Stop> stop(
1897 Driver::CombinedStop::create(opt.node(), opt.fail(), opt.time(),
1898 opt.restart_limit(),
true));
1899 if (black_box_context) {
1900 stop.reset(
new FlatZincStop(stop.release(), black_box_context));
1902 o.stop =
stop.get();
1903 std::unique_ptr<SearchTracer> tracer;
1907#ifdef GECODE_HAS_CPPROFILER
1908 if (
opt.profiler_port()) {
1909 FlatZincGetInfo* getInfo =
nullptr;
1910 if (
opt.profiler_info())
1911 getInfo =
new FlatZincGetInfo(p);
1912 tracer.reset(
new CPProfilerSearchTracer(
opt.profiler_id(),
1913 opt.name(),
opt.profiler_port(),
1915 o.tracer = tracer.get();
1920#ifdef GECODE_HAS_FLOAT_VARS
1924 o.nogoods_limit =
opt.nogoods() ?
opt.nogoods_limit() : 0;
1925 o.cutoff =
new Search::CutoffAppend(
new Search::CutoffConstant(0), 1, Driver::createCutoff(opt));
1926 int noOfSolutions =
opt.solutions();
1927 if (noOfSolutions == -1) {
1928 noOfSolutions = (_method == SAT) ? 1 : 0;
1930 bool printAll = _method == SAT ||
opt.allSolutions() || noOfSolutions != 0;
1931 int findSol = noOfSolutions;
1932 bool solution_limit_reached =
false;
1933 bool engine_stopped =
false;
1934 Gecode::Search::Statistics stat;
1935 std::unique_ptr<FlatZincSpace> sol;
1937 InterruptHandlerGuard interrupt_handler(
opt.interrupt());
1938 Meta<FlatZincSpace,Engine> se(
this,o);
1939 while (FlatZincSpace* next = se.next()) {
1940 std::unique_ptr<FlatZincSpace> next_sol(next);
1941 if (black_box_context.failed()) {
1944 sol = std::move(next_sol);
1947 out <<
"----------" << std::endl;
1949 if (--findSol == 0) {
1950 solution_limit_reached =
true;
1954 engine_stopped = se.stopped();
1955 if (
opt.mode() == SM_STAT) {
1956 stat = se.statistics();
1959 if (black_box_context.failed()) {
1961 black_box_context.rethrow();
1963 if (sol && !printAll) {
1965 out <<
"----------" << std::endl;
1967 if (!solution_limit_reached) {
1968 if (!engine_stopped) {
1970 out <<
"==========" << std::endl;
1972 out <<
"=====UNSATISFIABLE=====" << std::endl;
1975 out <<
"=====UNKNOWN=====" << std::endl;
1978 if (
opt.mode() == SM_STAT) {
1979 double totalTime = (t_total.
stop() / 1000.0);
1980 double solveTime = (t_solve.
stop() / 1000.0);
1981 double initTime = totalTime - solveTime;
1983 <<
"%%%mzn-stat: initTime=" << initTime
1985 out <<
"%%%mzn-stat: solveTime=" << solveTime
1987 out <<
"%%%mzn-stat: solutions="
1988 << std::abs(noOfSolutions - findSol) << std::endl
1989 <<
"%%%mzn-stat: variables="
1990 << (intVarCount + boolVarCount + setVarCount) << std::endl
1991 <<
"%%%mzn-stat: propagators=" << n_p << std::endl
1993 <<
"%%%mzn-stat: nodes=" << stat.
node << std::endl
1994 <<
"%%%mzn-stat: failures=" << stat.
fail << std::endl
1995 <<
"%%%mzn-stat: restarts=" << stat.
restart << std::endl
1996 <<
"%%%mzn-stat: peakDepth=" << stat.
depth << std::endl
1997 <<
"%%%mzn-stat-end" << std::endl
2004 FlatZincSpace::branchWithPlugin(
AST::Node* ann) {
2005 if (AST::Call*
c =
dynamic_cast<AST::Call*
>(ann)) {
2006 QString pluginName(
c->id.c_str());
2007 if (QLibrary::isLibrary(pluginName+
".dll")) {
2008 pluginName +=
".dll";
2009 }
else if (QLibrary::isLibrary(pluginName+
".dylib")) {
2010 pluginName =
"lib" + pluginName +
".dylib";
2011 }
else if (QLibrary::isLibrary(pluginName+
".so")) {
2013 pluginName =
"lib" + pluginName +
".so";
2015 QPluginLoader pl(pluginName);
2016 QObject* plugin_o = pl.instance();
2018 throw FlatZinc::Error(
"FlatZinc",
2019 "Error loading plugin "+pluginName.toStdString()+
2020 ": "+pl.errorString().toStdString());
2022 BranchPlugin* pb = qobject_cast<BranchPlugin*>(plugin_o);
2024 throw FlatZinc::Error(
"FlatZinc",
2025 "Error loading plugin "+pluginName.toStdString()+
2026 ": does not contain valid PluginBrancher");
2028 pb->branch(*
this,
c);
2033 FlatZincSpace::branchWithPlugin(
AST::Node*) {
2034 throw FlatZinc::Error(
"FlatZinc",
2035 "Branching with plugins not supported (requires Qt support)");
2042#ifndef GECODE_HAS_GIST
2045 "Gist mode is unavailable in this build");
2050 runEngine<BAB>(out,
p,opt,t_total);
2053 runEngine<DFS>(out,
p,opt,t_total);
2068#ifdef GECODE_HAS_FLOAT_VARS
2096 for (
int i = 0; i <
restart_data().on_restart_iv_sol; ++i) {
2104 for (
size_t i = 0; i <
restart_data().last_val_int.size(); ++i) {
2110 for (
size_t i = 0; i <
restart_data().uniform_range_int.size(); ++i) {
2112 const unsigned long long int width =
2113 static_cast<unsigned long long int>(
2114 static_cast<long long int>(
range.second) -
2115 static_cast<long long int>(
range.first)) + 1ULL;
2117 static_cast<int>(
static_cast<long long int>(
range.first) +
2118 static_cast<long long int>(
_random(width)));
2150 for (
int i = 0; i <
restart_data().on_restart_iv_sol; ++i) {
2163 for (
int i = 0; i <
restart_data().on_restart_bv_sol; ++i) {
2171 for (
size_t i = 0; i <
restart_data().last_val_bool.size(); ++i) {
2179 for (
int i = 0; i <
restart_data().on_restart_bv_sol; ++i) {
2186#ifdef GECODE_HAS_SET_VARS
2193 for (
int i = 0; i <
restart_data().on_restart_sv_sol; ++i) {
2202 for (
size_t i = 0; i <
restart_data().last_val_set.size(); ++i) {
2210 for (
int i = 0; i <
restart_data().on_restart_sv_sol; ++i) {
2218#ifdef GECODE_HAS_FLOAT_VARS
2225 for (
int i = 0; i <
restart_data().on_restart_fv_sol; ++i) {
2233 for (
size_t i = 0; i <
restart_data().last_val_float.size(); ++i) {
2239 for (
size_t i = 0; i <
restart_data().uniform_range_float.size(); ++i) {
2244 static_cast<FloatVal>(INT_MAX - 1)) *
2253 for (
int i = 0; i <
restart_data().on_restart_fv_sol; ++i) {
2268 for (
unsigned int i=
iv_lns.size(); i--;) {
2278 for (
unsigned int i=
iv_lns.size(); i--;) {
2322 (void) s; (void) out;
2323#ifdef GECODE_HAS_GIST
2325 for (
int i = 0; i <
iv.size(); ++i) {
2326 std::stringstream ss;
2327 ss <<
"iv[" << i <<
"]";
2330 if (result.length() > 0) out << result << std::endl;
2332 for (
int i = 0; i <
bv.size(); ++i) {
2333 std::stringstream ss;
2334 ss <<
"bv[" << i <<
"]";
2337 if (result.length() > 0) out << result << std::endl;
2339#ifdef GECODE_HAS_SET_VARS
2340 for (
int i = 0; i <
sv.size(); ++i) {
2341 std::stringstream ss;
2342 ss <<
"sv[" << i <<
"]";
2345 if (result.length() > 0) out << result << std::endl;
2348#ifdef GECODE_HAS_FLOAT_VARS
2349 for (
int i = 0; i <
fv.size(); ++i) {
2350 std::stringstream ss;
2351 ss <<
"fv[" << i <<
"]";
2354 if (result.length() > 0) out << result << std::endl;
2389 for (
int i=offset; i--;)
2391 for (
int i=a->a.
size(); i--;)
2392 ia[i+offset] = a->a[i]->getInt();
2397 int noOfTuples = a.
size() == 0 ? 0 : (a.
size()/noOfVars);
2401 for (
int i=0; i<noOfTuples; i++) {
2403 for (
int j=0; j<noOfVars; j++) {
2404 t[j] = a[i*noOfVars+j];
2411 FlatZincSpaceInitData::TupleSetSet::iterator it =
_initData->tupleSetSet.find(ts);
2412 if (it !=
_initData->tupleSetSet.end()) {
2426 FlatZincSpaceInitData::IntSharedArraySet::iterator it =
_initData->intSharedArraySet.find(sia);
2427 if (it !=
_initData->intSharedArraySet.end()) {
2430 _initData->intSharedArraySet.insert(sia);
2439 for (
int i=offset; i--;)
2441 for (
int i=a->a.
size(); i--;)
2442 ia[i+offset] = a->a[i]->getBool();
2450 FlatZincSpaceInitData::IntSharedArraySet::iterator it =
_initData->intSharedArraySet.find(sia);
2451 if (it !=
_initData->intSharedArraySet.end()) {
2454 _initData->intSharedArraySet.insert(sia);
2467 int* is = re.
alloc<
int>(
static_cast<unsigned long int>(sl->
s.size()));
2468 for (
int i=sl->
s.size(); i--; )
2477 if (a->a.
size() == 0) {
2482 for (
int i=offset; i--;)
2484 for (
int i=a->a.
size(); i--;) {
2492 if (a->a.
size() == 0) {
2497 for (
int i=offset; i--;)
2498 ia[i] =
IntVar(*
this, 0, 0);
2499 for (
int i=a->a.
size(); i--;) {
2500 if (a->a[i]->isIntVar()) {
2501 ia[i+offset] =
iv[a->a[i]->getIntVar()];
2503 int value = a->a[i]->getInt();
2513 if (a->a.
size() == 0) {
2518 for (
int i=offset; i--;)
2520 for (
int i=0; i<static_cast<int>(a->a.
size()); i++) {
2523 if (a->a[i]->isBool()) {
2524 bool value = a->a[i]->getBool();
2527 }
else if (a->a[i]->isIntVar() &&
2531 ia[offset++] =
bv[a->a[i]->getBoolVar()];
2561 if (a->a.
size() == 0)
2563 for (
int i=a->a.
size(); i--;) {
2564 if (a->a[i]->isBoolVar() || a->a[i]->isBool()) {
2565 }
else if (a->a[i]->isIntVar()) {
2567 if (singleInt != -1) {
2576 return singleInt==-1 || a->a.
size() > 1;
2578#ifdef GECODE_HAS_SET_VARS
2584 x0 =
SetVar(*
this, d, d);
2595 for (
int i=offset; i--;) {
2597 ia[i] =
SetVar(*
this, d, d);
2599 for (
int i=a->a.
size(); i--;) {
2605#ifdef GECODE_HAS_FLOAT_VARS
2610 for (
int i=offset; i--;)
2612 for (
int i=a->a.
size(); i--;)
2613 fa[i+offset] = a->a[i]->getFloat();
2619 if (a->a.
size() == 0) {
2624 for (
int i=offset; i--;)
2626 for (
int i=a->a.
size(); i--;) {
2627 if (a->a[i]->isFloatVar()) {
2628 fa[i+offset] =
fv[a->a[i]->getFloatVar()];
2630 double value = a->a[i]->getFloat();
2653 if (ann->
hasAtom(
"domain") || ann->
hasAtom(
"domain_propagation"))
2656 ann->
hasAtom(
"bounds_propagation") ||
2668 FlatZincSpaceInitData::DFASet::iterator it =
_initData->dfaSet.find(a);
2683 Printer::printElem(std::ostream& out,
2703 }
else if (bv[ai->
getBoolVar()].max() == 0) {
2706 out <<
"false..true";
2708#ifdef GECODE_HAS_SET_VARS
2714 SetVarGlbRanges svr(sv[ai->
getSetVar()]);
2719 int min = svr.min();
2720 int max = svr.max();
2723 SetVarGlbValues svv(sv[ai->
getSetVar()]);
2727 for (; svv(); ++svv)
2728 out <<
", " << svv.val();
2731 out <<
min <<
".." <<
max;
2734#ifdef GECODE_HAS_FLOAT_VARS
2745 std::ostringstream oss;
2747 oss << std::setprecision(std::numeric_limits<double>::digits10);
2749 if (oss.str().find(
".") == std::string::npos)
2756 }
else if (ai->
isBool()) {
2757 out << (ai->
getBool() ?
"true" :
"false");
2758 }
else if (ai->
isSet()) {
2759 AST::SetLit* s = ai->
getSet();
2761 out << s->min <<
".." << s->max;
2764 for (
unsigned int i=0;
i<s->s.
size();
i++) {
2765 out << s->s[
i] << (
i < s->s.
size()-1 ?
", " :
"}");
2770 for (
unsigned int i=0;
i<s.
size();
i++) {
2771 if (s[i] ==
'\\' && i<s.size()-1) {
2773 case 'n': out <<
"\n";
break;
2774 case '\\': out <<
"\\";
break;
2775 case 't': out <<
"\t";
break;
2776 default: out <<
"\\" << s[
i+1];
2787 Printer::printElemDiff(std::ostream& out,
2789 const Gecode::IntVarArray& iv1,
2790 const Gecode::IntVarArray& iv2,
2791 const Gecode::BoolVarArray& bv1,
2792 const Gecode::BoolVarArray& bv2
2794 ,
const Gecode::SetVarArray& sv1,
2795 const Gecode::SetVarArray& sv2
2798 ,
const Gecode::FloatVarArray& fv1,
2799 const Gecode::FloatVarArray& fv2
2802#ifdef GECODE_HAS_GIST
2803 using namespace Gecode::Gist;
2807 }
else if (ai->isIntVar()) {
2808 std::string res(Comparator::compare(
"",iv1[ai->getIntVar()],
2809 iv2[ai->getIntVar()]));
2810 if (res.length() > 0) {
2814 out << iv1[ai->getIntVar()];
2816 }
else if (ai->isBoolVar()) {
2817 std::string res(Comparator::compare(
"",bv1[ai->getBoolVar()],
2818 bv2[ai->getBoolVar()]));
2819 if (res.length() > 0) {
2823 out << bv1[ai->getBoolVar()];
2825#ifdef GECODE_HAS_SET_VARS
2826 }
else if (ai->isSetVar()) {
2827 std::string res(Comparator::compare(
"",sv1[ai->getSetVar()],
2828 sv2[ai->getSetVar()]));
2829 if (res.length() > 0) {
2833 out << sv1[ai->getSetVar()];
2836#ifdef GECODE_HAS_FLOAT_VARS
2837 }
else if (ai->isFloatVar()) {
2838 std::string res(Comparator::compare(
"",fv1[ai->getFloatVar()],
2839 fv2[ai->getFloatVar()]));
2840 if (res.length() > 0) {
2844 out << fv1[ai->getFloatVar()];
2847 }
else if (ai->isBool()) {
2848 out << (ai->getBool() ?
"true" :
"false");
2849 }
else if (ai->isSet()) {
2850 AST::SetLit* s = ai->getSet();
2852 out << s->min <<
".." << s->max;
2855 for (
unsigned int i=0;
i<s->s.
size();
i++) {
2856 out << s->s[
i] << (
i < s->s.
size()-1 ?
", " :
"}");
2859 }
else if (ai->isString()) {
2860 std::string s = ai->getString();
2861 for (
unsigned int i=0;
i<s.
size();
i++) {
2862 if (s[i] ==
'\\' && i<s.size()-1) {
2864 case 'n': out <<
"\n";
break;
2865 case '\\': out <<
"\\";
break;
2866 case 't': out <<
"\t";
break;
2867 default: out <<
"\\" << s[
i+1];
2882#ifdef GECODE_HAS_SET_VARS
2886#ifdef GECODE_HAS_FLOAT_VARS
2907 if (_output ==
nullptr)
2909 for (
unsigned int i=0; i< _output->
a.size(); i++) {
2913 int size = aia->
a.size();
2915 for (
int j=0; j<size; j++) {
2916 printElem(out,aia->
a[j],iv,bv
2929 printElem(out,ai,iv,bv
2958 if (_output ==
nullptr)
2960 for (
unsigned int i=0; i< _output->
a.size(); i++) {
2964 int size = aia->
a.size();
2966 for (
int j=0; j<size; j++) {
2967 printElemDiff(out,aia->
a[j],iv1,iv2,bv1,bv2
2980 printElemDiff(out,ai,iv1,iv2,bv1,bv2
2994 iv_names.push_back(n);
2998 bv_names.push_back(n);
3000#ifdef GECODE_HAS_FLOAT_VARS
3003 fv_names.push_back(n);
3006#ifdef GECODE_HAS_SET_VARS
3009 sv_names.push_back(n);
3015 std::map<int,int>& iv, std::map<int,int>& bv,
3016 std::map<int,int>& sv, std::map<int,int>& fv) {
3019 if (iv.find(x->
i) == iv.end()) {
3020 int newi = iv.size();
3026 if (bv.find(x->
i) == bv.end()) {
3027 int newi = bv.size();
3033 if (sv.find(x->
i) == sv.end()) {
3034 int newi = sv.size();
3040 if (fv.find(x->
i) == fv.end()) {
3041 int newi = fv.size();
3050 int& optVar,
bool optVarIsInt,
3062 if (_output ==
nullptr) {
3063 if (optVarIsInt && optVar != -1) {
3072#ifdef GECODE_HAS_SET_VARS
3075#ifdef GECODE_HAS_FLOAT_VARS
3076 if (!optVarIsInt && optVar != -1) {
3087 std::map<int,int> iv_new;
3088 std::map<int,int> bv_new;
3089 std::map<int,int> sv_new;
3090 std::map<int,int> fv_new;
3100 for (
unsigned int i=0; i< _output->
a.size(); i++) {
3104 for (
unsigned int j=0; j<aia->
a.size(); j++) {
3113 std::vector<std::string> iv_names_new(iv_new.size());
3114 for (std::map<int,int>::iterator i=iv_new.begin(); i != iv_new.end(); ++i) {
3115 iva[(*i).second] = iv[(*i).first];
3116 iv_names_new[(*i).second] = iv_names[(*i).first];
3119 iv_names = iv_names_new;
3122 std::vector<std::string> bv_names_new(bv_new.size());
3123 for (std::map<int,int>::iterator i=bv_new.begin(); i != bv_new.end(); ++i) {
3124 bva[(*i).second] = bv[(*i).first];
3125 bv_names_new[(*i).second] = bv_names[(*i).first];
3128 bv_names = bv_names_new;
3130#ifdef GECODE_HAS_SET_VARS
3132 std::vector<std::string> sv_names_new(sv_new.size());
3133 for (std::map<int,int>::iterator i=sv_new.begin(); i != sv_new.end(); ++i) {
3134 sva[(*i).second] = sv[(*i).first];
3135 sv_names_new[(*i).second] = sv_names[(*i).first];
3138 sv_names = sv_names_new;
3141#ifdef GECODE_HAS_FLOAT_VARS
3143 std::vector<std::string> fv_names_new(fv_new.size());
3144 for (std::map<int,int>::iterator i=fv_new.begin(); i != fv_new.end(); ++i) {
3145 fva[(*i).second] = fv[(*i).first];
3146 fv_names_new[(*i).second] = fv_names[(*i).first];
3149 fv_names = fv_names_new;
void put(unsigned int i)
Add i to the contents.
int size(void) const
Return size of array (number of elements).
Depth-first branch-and-bound search engine.
Which values to select for assignment.
Which values to select for branching first.
Passing Boolean variables.
Boolean integer variables.
Base-class for branchers.
Brancher(Home home)
Constructor for creation.
Class to send solution information to CPProfiler.
Choice for performing commit
virtual void archive(Archive &e) const
Archive into e.
Deterministic finite automaton (DFA).
Depth-first search engine.
static void installCtrlHandler(bool install, bool force=false)
Install handler for catching Ctrl-C.
Exception: Base-class for exceptions
virtual const char * what(void) const noexcept
Return information.
Node representing an atom
Node representing a function call
Array * getArgs(unsigned int n)
A node in a FlatZinc abstract syntax tree.
bool isSetVar(void)
Test if node is a set variable node.
Array * getArray(void)
Cast this node to an array node.
bool isBool(void)
Test if node is a Boolean node.
bool isFloatVar(void)
Test if node is a float variable node.
bool isSet(void)
Test if node is a set literal node.
double getFloat(void)
Cast this node to a Float node.
int getFloatVar(void)
Cast this node to a Float variable node.
bool isArray(void)
Test if node is an array node.
SetLit * getSet(void)
Cast this node to a set literal node.
bool isString(void)
Test if node is a string node.
bool hasAtom(const std::string &id)
Test if node has atom with id.
bool isInt(int &i)
Test if node is int, if yes set i to the value.
int getInt(void)
Cast this node to an integer node.
bool isIntVar(void)
Test if node is an integer variable node.
int getIntVar(void)
Cast this node to an integer variable node.
bool isBoolVar(void)
Test if node is a Boolean variable node.
Call * getCall(void)
Return function call.
int getBoolVar(void)
Cast this node to a Boolean variable node.
virtual void print(std::ostream &)=0
Output string representation.
int getSetVar(void)
Cast this node to a set variable node.
bool getBool(void)
Cast this node to a Boolean node.
std::string getString(void)
Cast this node to a string node.
Exception signaling type error
Choice that only signals failure or success
bool fail
Whether brancher should fail.
virtual size_t size(void) const
Report size occupied.
Choice(const Brancher &b, bool fail0)
Initialize choice for brancher b.
virtual void archive(Archive &e) const
Archive into e.
virtual Choice * choice(const Space &, Archive &e)
Return choice.
FloatValBranch float_valsel
TieBreak< BoolVarBranch > bool_varsel
virtual void print(const Space &, const Gecode::Choice &c, unsigned int, std::ostream &o) const
Print explanation.
TieBreak< IntVarBranch > int_varsel
virtual bool status(const Space &_home) const
Check status of brancher, return true if alternatives left.
bool done
Flag whether brancher is done.
virtual Actor * copy(Space &home)
Copy brancher.
static void post(Home home, TieBreak< IntVarBranch > int_varsel, IntValBranch int_valsel, TieBreak< BoolVarBranch > bool_varsel, BoolValBranch bool_valsel, SetVarBranch set_varsel, SetValBranch set_valsel, TieBreak< FloatVarBranch > float_varsel, FloatValBranch float_valsel)
Post brancher.
TieBreak< FloatVarBranch > float_varsel
virtual Choice * choice(Space &home)
Return choice.
virtual ExecStatus commit(Space &, const Gecode::Choice &c, unsigned int)
Perform commit for choice c.
virtual size_t dispose(Space &)
Delete brancher and return its size.
BoolValBranch bool_valsel
AuxVarBrancher(Home home, TieBreak< IntVarBranch > int_varsel0, IntValBranch int_valsel0, TieBreak< BoolVarBranch > bool_varsel0, BoolValBranch bool_valsel0, SetVarBranch set_varsel0, SetValBranch set_valsel0, TieBreak< FloatVarBranch > float_varsel0, FloatValBranch float_valsel0)
Construct brancher.
AuxVarBrancher(Space &home, AuxVarBrancher &b)
Copy constructor.
static BlackBoxContextHandle & context(FlatZincSpace &s)
Model-local context shared by blackbox propagators and search support.
void rethrow(void) const
Rethrow the first recorded propagation exception.
Specification for Boolean variables.
Option< AST::SetLit * > domain
Abstract representation of a constraint.
AST::Array * ann
Constraint annotations.
Exception class for FlatZinc errors
virtual void compare(const Space &s0, const Space &s1)
Use the compare method of the template class S to compare two spaces.
FZPrintingComparator(const Printer &p0)
Constructor.
An inspector for printing simple text output.
virtual void finalize(void)
Finalize when Gist exits.
FZPrintingInspector(const Printer &p0)
Constructor.
virtual void inspect(const Space &node)
Use the print method of the template class S to print a space.
FlatZincGetInfo(const Printer &printer)
virtual std::string getInfo(const Space &space) const
Return info for a space.
Options for running FlatZinc models
std::unordered_set< TupleSet > TupleSetSet
Hash table of tuple sets.
BlackBoxContextHandle blackBoxContext
Opaque state shared by blackbox propagators in this model.
DFASet dfaSet
Hash table of DFAs.
std::unordered_set< DFA > DFASet
Hash table of DFAs.
FlatZincSpaceInitData(void)
Initialize.
IntSharedArraySet intSharedArraySet
Hash table of shared integer arrays.
TupleSetSet tupleSetSet
Hash table of tuple sets.
std::unordered_set< SharedArray< int > > IntSharedArraySet
Hash table of shared integer arrays.
A space that can be initialized with a FlatZinc model.
void createBranchers(Printer &p, AST::Node *ann, FlatZincOptions &opt, bool ignoreUnknown, std::ostream &err=std::cerr)
Create branchers corresponding to the solve item annotations.
Gecode::IntVarArray iv_lns
The integer variables used in LNS.
void shrinkArrays(Printer &p)
Remove all variables not needed for output.
unsigned int _lns
Percentage of variables to keep in LNS (or 0 for no LNS).
void maximize(int var, bool isInt, AST::Array *annotation)
Post that integer variable var should be maximized.
IntVarArgs arg2intvarargs(AST::Node *arg, int offset=0)
Convert arg to IntVarArgs.
Gecode::FloatVarArray fv
The float variables.
Rnd _random
Random number generator.
Gecode::FloatVarArray on_restart_fv
On Restart Tracked Floating Point Variables.
void newBoolVar(BoolVarSpec *vs)
Create new Boolean variable from specification.
FloatVar arg2FloatVar(AST::Node *n)
Convert n to FloatVar.
void print(std::ostream &out, const Printer &p) const
Produce output on out using p.
std::vector< bool > fv_introduced
Indicates whether a float variable is introduced by mzn2fzn.
AST::Array * _solveAnnotations
Annotations on the solve item.
int _optVar
Index of the variable to optimize.
BranchInformation branchInfo
Information for printing branches.
void run(std::ostream &out, const Printer &p, const FlatZincOptions &opt, Gecode::Support::Timer &t_total)
Run the search.
DFA getSharedDFA(DFA &a)
Share DFA a if possible.
void newFloatVar(FloatVarSpec *vs)
Create new float variable from specification.
SetVar arg2SetVar(AST::Node *n)
Convert n to SetVar.
int * iv_boolalias
Indicates whether an integer variable aliases a Boolean variable.
virtual bool slave(const MetaInfo &mi)
Slave function for restarts.
void postConstraints(std::vector< ConExpr * > &ces)
Post a constraint specified by ce.
SetVarArgs arg2setvarargs(AST::Node *arg, int offset=0, int doffset=0, const IntSet &od=IntSet::empty)
Convert n to SetVarArgs.
bool _optVarIsInt
Whether variable to optimize is integer (or float).
FlatZincSpace(FlatZincSpace &)
Copy constructor.
Gecode::BoolVarArray bv
The Boolean variables.
void newSetVar(SetVarSpec *vs)
Create new set variable from specification.
bool optVarIsInt(void) const
Return whether variable used for optimization is integer (or float).
Gecode::SetVarArray on_restart_sv
On Restart Tracked Set Variables.
std::vector< bool > iv_introduced
Indicates whether an integer variable is introduced by mzn2fzn.
IntVar arg2IntVar(AST::Node *n)
Convert n to IntVar.
std::string getDomains(const Printer &p) const
Get string representing the domains of variables (for cpprofiler).
FlatZincSpaceInitData * _initData
Initialisation data (only used for posting constraints).
Meth method(void) const
Return whether to solve a satisfaction or optimization problem.
std::vector< bool > sv_introduced
Indicates whether a set variable is introduced by mzn2fzn.
IntSet arg2intset(AST::Node *n)
Convert n to IntSet.
std::vector< bool > bv_introduced
Indicates whether a Boolean variable is introduced by mzn2fzn.
Gecode::FloatVarArray fv_aux
The introduced float variables.
void minimize(int var, bool isInt, AST::Array *annotation)
Post that integer variable var should be minimized.
virtual void constrain(const Space &s)
Implement optimization.
IntArgs arg2boolargs(AST::Node *arg, int offset=0)
Convert arg (array of Booleans) to IntArgs.
Gecode::SetVarArray sv_aux
The introduced set variables.
int floatVarCount
Number of float variables.
int boolVarCount
Number of Boolean variables.
Gecode::SetVarArray sv
The set variables.
int setVarCount
Number of set variables.
~FlatZincSpace(void)
Destructor.
OnRestartHandle restart_data
Gecode::IntVarArray on_restart_iv
On Restart Tracked Integer Variables.
int optVar(void) const
Return index of variable used for optimization.
FloatVarArgs arg2floatvarargs(AST::Node *arg, int offset=0)
Convert n to FloatVarArgs.
IntSharedArray arg2boolsharedarray(AST::Node *arg, int offset=0)
Convert arg (array of integers) to IntSharedArray.
void solve(AST::Array *annotation)
Post the solve item.
Gecode::FloatNum step
Step by which a next solution has to have lower cost.
IntSharedArray _lnsInitialSolution
Initial solution to start the LNS (or nullptr for no LNS).
Gecode::BoolVarArray bv_aux
The introduced Boolean variables.
IntSharedArray arg2intsharedarray(AST::Node *arg, int offset=0)
Convert arg (array of integers) to IntSharedArray.
BoolVarArgs arg2boolvarargs(AST::Node *arg, int offset=0, int siv=-1)
Convert arg to BoolVarArgs.
void aliasBool2Int(int iv, int bv)
Link integer variable iv to Boolean variable bv.
AST::Array * solveAnnotations(void) const
Return the solve item annotations.
Gecode::IntVarArray iv_aux
The introduced integer variables.
Gecode::IntVarArray iv
The integer variables.
virtual Gecode::Space * copy(void)
Copy function.
void init(int intVars, int boolVars, int setVars, int floatVars)
Initialize space with given number of variables.
Gecode::BoolVarArray on_restart_bv
On Restart Tracked Boolean Variables.
bool isBoolArray(AST::Node *b, int &singleInt)
Check if b is array of Booleans (or has a single integer).
IntPropLevel ann2ipl(AST::Node *ann)
Convert ann to integer propagation level.
void newIntVar(IntVarSpec *vs)
Create new integer variable from specification.
Meth _method
Whether to solve as satisfaction or optimization problem.
void compare(const Space &s, std::ostream &out) const
Compare this space with space s and print the differences on out.
int intVarCount
Number of integer variables.
BoolVar arg2BoolVar(AST::Node *n)
Convert n to BoolVar.
TupleSet arg2tupleset(const IntArgs &a, int noOfVars)
Convert a to TupleSet.
IntSetArgs arg2intsetargs(AST::Node *arg, int offset=0)
Convert arg to IntSetArgs.
FloatValArgs arg2floatargs(AST::Node *arg, int offset=0)
Convert n to FloatValArgs.
bool needAuxVars
Whether the introduced variables still need to be copied.
IntArgs arg2intargs(AST::Node *arg, int offset=0)
Convert arg (array of integers) to IntArgs.
std::unique_ptr< Search::Stop > stop_object
FlatZincStop(Search::Stop *stop_object0, const BlackBoxContextHandle &black_box_context0)
BlackBoxContextHandle black_box_context
bool stop(const Search::Statistics &s, const Search::Options &o) override
Stop search, if returns true.
Specification for floating point variables.
Option< std::pair< double, double > > domain
static void explore(S *root, const FlatZincOptions &opt, Gist::Inspector *i, Gist::Comparator *c)
static void explore(S *root, const FlatZincOptions &opt, Gist::Inspector *i, Gist::Comparator *c)
Traits class for search engines.
Which integer or Boolean variable to select for branching.
Specification for integer variables.
Option< AST::SetLit * > domain
InterruptHandlerGuard(bool install)
~InterruptHandlerGuard(void)
Output support class for FlatZinc interpreter.
void addFloatVarName(const std::string &n)
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
void addSetVarName(const std::string &n)
void init(AST::Array *output)
void print(std::ostream &out, const Gecode::IntVarArray &iv, const Gecode::BoolVarArray &bv, const Gecode::SetVarArray &sv, const Gecode::FloatVarArray &fv) const
void shrinkArrays(Space &home, int &optVar, bool optVarIsInt, Gecode::IntVarArray &iv, Gecode::BoolVarArray &bv, Gecode::SetVarArray &sv, Gecode::FloatVarArray &fv)
void addIntVarName(const std::string &n)
void addBoolVarName(const std::string &n)
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)
void post(FlatZincSpace &s, const ConExpr &ce)
Post constraint specified by ce.
Specification for set variables.
Option< AST::SetLit * > upperBound
bool introduced
Whether the variable was introduced in the mzn2fzn translation.
bool assigned
Whether the variable is assigned.
bool alias
Whether the variable aliases another variable.
bool funcDep
Whether the variable functionally depends on another variable.
Value description class for branching.
bool l
Whether to try the lower or upper half first.
FloatNum n
The middle value for branching.
Which values to select for branching first.
FloatNum size(void) const
Return size of float value (distance between maximum and minimum).
Float view for float variables.
Abstract base class for comparators.
virtual void compare(const Space &s0, const Space &s1)=0
Call-back function.
Abstract base class for inspectors.
void compare(Comparator *c)
Add comparator.
void click(Inspector *i)
Add inspector that reacts on node double clicks.
class Gecode::Gist::Options::I_ inspect
An window for simple text output.
void finalize(void)
Clean up when Gist exits.
TextOutput(const std::string &name)
Constructor.
std::ostream & getStream(void)
Get the stream that is used to output text.
void init(void)
Initialize the implementation object.
VarComparator(std::string name)
Constructor.
unsigned int id(void) const
Return a unique id for the group.
Home class for posting propagators
Passing integer arguments.
Which values to select for assignment.
static const IntSet empty
Empty set.
Which values to select for branching first.
Passing integer variables.
Integer view for integer variables.
int min(void) const
Return minimum of domain.
bool range(void) const
Test whether domain is a range.
int val(void) const
Return assigned value (only if assigned).
int max(void) const
Return maximum of domain.
Range iterator for integer views.
static PropagatorGroup all
Group of all propagators.
T * alloc(long unsigned int n)
Allocate block of n objects of type T from region.
unsigned int c_d
Create a clone after every c_d commits (commit distance).
unsigned int a_d
Create a clone during recomputation if distance is greater than a_d (adaptive distance).
unsigned long int restart
Number of restarts.
unsigned long int depth
Maximum depth of search stack.
unsigned long long int fail
Number of failed nodes in search tree.
unsigned long long int node
Number of nodes expanded.
Base-class for Stop-object.
Which values to select for branching first.
Which variable to select for branching.
Range iterator for the greatest lower bound.
Shared array with arbitrary number of elements.
int size(void) const
Return number of elements.
SharedHandle(void)
Create shared handle with no object pointing to.
SharedHandle::Object * object(void) const
Access to the shared object.
struct Gecode::Space::@055132133326276162005044145100211202071356247106::@275070317317120154232063063134255170030071110047 p
Data only available during propagation or branching.
struct Gecode::Space::@055132133326276162005044145100211202071356247106::@155123175027073262103111264343315000271204104107 c
Data available only during copying.
T * alloc(long unsigned int n)
Allocate block of n objects of type T from space heap.
friend class BrancherGroup
Statistics for execution of status
unsigned long long int propagate
Number of propagator executions.
double stop(void)
Get time since start of timer.
void start(void)
Start timer.
Combine variable selection criteria for tie-breaking.
Class representing a set of tuples.
TupleSet & add(const IntArgs &t)
Add tuple t to tuple set.
std::size_t hash(void) const
Return hash key.
void finalize(void)
Finalize tuple set with dense support data.
bool assigned(void) const
Test if all variables are assigned.
int size(void) const
Return size of array (number of elements).
bool assigned(void) const
Test whether view is assigned.
Base class for variables.
unsigned int seed
The random seed to be used.
unsigned int threads
Number of threads to use.
Heap heap
The single global heap.
void fail(void)
Fail space.
@ SM_GIST
Run script in Gist.
@ RM_CONSTANT
Restart with constant sequence.
@ RM_LINEAR
Restart with linear sequence.
@ RM_LUBY
Restart with Luby sequence.
@ RM_GEOMETRIC
Restart with geometric sequence.
int bab(Space *root, const Gist::Options &opt=Gist::Options::def)
Create a new stand-alone Gist for branch-and-bound search of root.
int dfs(Space *root, const Gist::Options &opt=Gist::Options::def)
Create a new stand-alone Gist for root.
void assign(Home home, const FloatVarArgs &x, FloatVarBranch vars, FloatAssign vals, FloatBranchFilter bf=nullptr, FloatVarValPrint vvp=nullptr)
Assign all x with variable selection vars and value selection vals.
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVar x1)
Post propagator for .
double FloatNum
Floating point number base type.
IntPropLevel
Propagation levels for integer propagators.
@ IPL_DOM
Domain propagation Options: basic versus advanced propagation.
@ IPL_VAL
Value propagation.
@ IPL_DEF
Simple propagation levels.
@ IPL_BND
Bounds propagation.
Space(void)
Default constructor.
Space * clone(void) const
Clone space.
@ SS_FAILED
Space is failed
void stop(Support::Timer &timer, std::ostream &os)
Get time since start of timer and print user friendly time information.
Interpreter for the FlatZinc language.
void printIntVar(std::ostream &os, const std::string name, const Int::IntView &x)
Registry & registry(void)
Return global registry object.
void varValPrintF(const Space &home, const Brancher &b, unsigned int a, FloatVar, int i, const FloatNumBranch &nl, std::ostream &o)
TieBreak< IntVarBranch > ann2ivarsel(AST::Node *ann, Rnd rnd, double decay)
void varValPrint(const Space &home, const Brancher &b, unsigned int a, Var, int i, const int &n, std::ostream &o)
BoolAssign ann2asnbvalsel(AST::Node *ann, Rnd rnd)
TieBreak< BoolVarBranch > ann2bvarsel(AST::Node *ann, Rnd rnd, double decay)
void printFloatVar(std::ostream &os, const std::string name, const Float::FloatView &f)
void printBoolVar(std::ostream &os, const std::string name, const BoolVar &b)
TieBreak< FloatVarBranch > ann2fvarsel(AST::Node *ann, Rnd rnd, double decay)
BoolValBranch ann2bvalsel(AST::Node *ann, std::string &r0, std::string &r1, Rnd rnd)
IntSet vs2is(IntVarSpec *vs)
FloatValBranch ann2fvalsel(AST::Node *ann, std::string r0, std::string r1)
int vs2bsl(BoolVarSpec *bs)
IntValBranch ann2ivalsel(AST::Node *ann, std::string &r0, std::string &r1, Rnd rnd)
IntBoolVarBranch INTBOOL_VAR_AFC_SIZE_MAX(double d=1.0)
Select variable with largest accumulated failure count divided by domain size.
GECODE_FLATZINC_EXPORT Rnd defrnd
Uninitialized default random number generator.
void branch(Home home, const IntVarArgs &x, const BoolVarArgs &y, IntBoolVarBranch vars, IntValBranch vals)
Branch function for integer and Boolean variables.
SetVarBranch ann2svarsel(AST::Node *ann, Rnd rnd, double decay)
SetValBranch ann2svalsel(AST::Node *ann, std::string r0, std::string r1, Rnd rnd)
int vs2bsh(BoolVarSpec *bs)
IntAssign ann2asnivalsel(AST::Node *ann, Rnd rnd)
void flattenAnnotations(AST::Array *ann, std::vector< AST::Node * > &out)
const FloatNum max
Largest allowed float value.
const FloatNum min
Smallest allowed float value.
The Gecode Interactive Search Tool.
const int min
Smallest allowed integer value.
const int max
Largest allowed integer value.
const int min
Smallest allowed integer in integer set.
const int max
Largest allowed integer in integer set.
void print(std::basic_ostream< Char, Traits > &s, bool assigned, IL &lb, IU &ub, unsigned int cardMin, unsigned int cardMax)
Print set view.
Gecode toplevel namespace
FloatVarBranch FLOAT_VAR_RND(Rnd r)
Select random variable (uniform distribution, for tie breaking).
FloatValBranch FLOAT_VAL_SPLIT_MAX(void)
Select values greater than mean of smallest and largest value.
ArgArray< IntSet > IntSetArgs
Passing set arguments.
SetVarBranch SET_VAR_ACTION_SIZE_MIN(double d=1.0, BranchTbl tbl=nullptr)
Select variable with smallest action divided by domain size with decay factor d.
IntAssign INT_ASSIGN_RND(Rnd r)
Select random value.
SetVarBranch SET_VAR_ACTION_SIZE_MAX(double d=1.0, BranchTbl tbl=nullptr)
Select variable with largest action divided by domain size with decay factor d.
IntValBranch INT_VAL_SPLIT_MIN(void)
Select values not greater than mean of smallest and largest value.
FloatVarBranch FLOAT_VAR_AFC_MIN(double d=1.0, BranchTbl tbl=nullptr)
Select variable with smallest accumulated failure count with decay factor d.
BoolAssign BOOL_ASSIGN_MAX(void)
Select largest value.
FloatVarBranch FLOAT_VAR_SIZE_MAX(BranchTbl tbl=nullptr)
Select variable with largest domain size.
IntVarBranch INT_VAR_AFC_SIZE_MAX(double d=1.0, BranchTbl tbl=nullptr)
Select variable with largest accumulated failure count divided by domain size with decay factor d.
FloatVarBranch FLOAT_VAR_MAX_MAX(BranchTbl tbl=nullptr)
Select variable with largest max.
SetVarBranch SET_VAR_NONE(void)
Select first unassigned variable.
IntVarBranch INT_VAR_DEGREE_MAX(BranchTbl tbl=nullptr)
Select variable with largest degree.
IntVarBranch INT_VAR_ACTION_MAX(double d=1.0, BranchTbl tbl=nullptr)
Select variable with highest action with decay factor d.
FloatVarBranch FLOAT_VAR_AFC_SIZE_MIN(double d=1.0, BranchTbl tbl=nullptr)
Select variable with smalllest accumulated failure count divided by domain size with decay factor d.
SharedArray< int > IntSharedArray
Arrays of integers that can be shared among several element constraints.
IntValBranch INT_VAL_MED(void)
Select greatest value not greater than the median.
IntVarBranch INT_VAR_REGRET_MIN_MAX(BranchTbl tbl=nullptr)
Select variable with largest min-regret.
IntVarBranch INT_VAR_ACTION_SIZE_MAX(double d=1.0, BranchTbl tbl=nullptr)
Select variable with largest action divided by domain size with decay factor d.
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
BoolValBranch BOOL_VAL_MIN(void)
Select smallest value.
IntVarBranch INT_VAR_NONE(void)
Select first unassigned variable.
void dom(Home home, FloatVar x, FloatVal n)
Propagates .
BoolVarBranch BOOL_VAR_NONE(void)
Select first unassigned variable.
IntVarBranch INT_VAR_AFC_MAX(double d=1.0, BranchTbl tbl=nullptr)
Select variable with largest accumulated failure count with decay factor d.
IntVarBranch INT_VAR_AFC_MIN(double d=1.0, BranchTbl tbl=nullptr)
Select variable with smallest accumulated failure count with decay factor d.
IntValBranch INT_VALUES_MIN(void)
Try all values starting from smallest.
SetVarBranch SET_VAR_SIZE_MIN(BranchTbl tbl=nullptr)
Select variable with smallest unknown set.
SetVarBranch SET_VAR_RND(Rnd r)
Select random variable (uniform distribution, for tie breaking).
void range(Home home, const IntVarArgs &x, SetVar y, SetVar z)
Post constraint .
void cmb_hash(std::size_t &seed, const T h)
Combine hash value h into seed.
SetVarBranch SET_VAR_MAX_MAX(BranchTbl tbl=nullptr)
Select variable with largest maximum unknown element.
IntValBranch INT_VAL_MAX(void)
Select largest value.
FloatVarBranch FLOAT_VAR_ACTION_MAX(double d=1.0, BranchTbl tbl=nullptr)
Select variable with highest action with decay factor d.
BoolValBranch BOOL_VAL_MAX(void)
Select largest value.
BoolVarBranch BOOL_VAR_RND(Rnd r)
Select random variable (uniform distribution, for tie breaking).
BoolVarBranch BOOL_VAR_ACTION_MIN(double d=1.0, BranchTbl tbl=nullptr)
Select variable with lowest action with decay factor d.
SetVarBranch SET_VAR_AFC_MAX(double d=1.0, BranchTbl tbl=nullptr)
Select variable with largest accumulated failure count with decay factor d.
FloatVarBranch FLOAT_VAR_MIN_MIN(BranchTbl tbl=nullptr)
Select variable with smallest min.
SetVarBranch SET_VAR_MIN_MIN(BranchTbl tbl=nullptr)
Select variable with smallest minimum unknown element.
FloatVarBranch FLOAT_VAR_ACTION_MIN(double d=1.0, BranchTbl tbl=nullptr)
Select variable with lowest action with decay factor d.
SetValBranch SET_VAL_MAX_INC(void)
Include largest element.
BoolAssign BOOL_ASSIGN_RND(Rnd r)
Select random value.
IntValBranch INT_VAL_SPLIT_MAX(void)
Select values greater than mean of smallest and largest value.
IntValBranch INT_VAL_MIN(void)
Select smallest value.
IntAssign INT_ASSIGN_MED(void)
Select greatest value not greater than the median.
SetVarBranch SET_VAR_AFC_MIN(double d=1.0, BranchTbl tbl=nullptr)
Select variable with smallest accumulated failure count with decay factor d.
BoolVarBranch BOOL_VAR_AFC_MIN(double d=1.0, BranchTbl tbl=nullptr)
Select variable with smallest accumulated failure count with decay factor d.
T * dfs(T *s, const Search::Options &o=Search::Options::def)
Invoke depth-first search engine for subclass T of space s with options o.
BoolVarBranch BOOL_VAR_AFC_MAX(double d=1.0, BranchTbl tbl=nullptr)
Select variable with largest accumulated failure count with decay factor d.
FloatVarBranch FLOAT_VAR_NONE(void)
Select first unassigned variable.
IntVarBranch INT_VAR_MAX_MAX(BranchTbl tbl=nullptr)
Select variable with largest max.
IntAssign INT_ASSIGN_MIN(void)
Select smallest value.
IntVarBranch INT_VAR_ACTION_MIN(double d=1.0, BranchTbl tbl=nullptr)
Select variable with lowest action with decay factor d.
IntVarBranch INT_VAR_RND(Rnd r)
Select random variable (uniform distribution, for tie breaking).
IntVarBranch INT_VAR_AFC_SIZE_MIN(double d=1.0, BranchTbl tbl=nullptr)
Select variable with smallest accumulated failure count divided by domain size with decay factor d.
SetValBranch SET_VAL_MIN_INC(void)
Include smallest element.
@ ES_OK
Execution is okay.
@ ES_FAILED
Execution has resulted in failure.
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
FloatVarBranch FLOAT_VAR_DEGREE_MAX(BranchTbl tbl=nullptr)
Select variable with largest degree.
SetVarBranch SET_VAR_AFC_SIZE_MIN(double d=1.0, BranchTbl tbl=nullptr)
Select variable with smallest accumulated failure count divided by domain size with decay factor d.
SetValBranch SET_VAL_MAX_EXC(void)
Exclude largest element.
FloatVarBranch FLOAT_VAR_ACTION_SIZE_MAX(double d=1.0, BranchTbl tbl=nullptr)
Select variable with largest action divided by domain size with decay factor d.
BoolValBranch BOOL_VAL_RND(Rnd r)
Select random value.
SetVarBranch SET_VAR_AFC_SIZE_MAX(double d=1.0, BranchTbl tbl=nullptr)
Select variable with largest accumulated failure count divided by domain size with decay factor d.
SetVarBranch SET_VAR_ACTION_MIN(double d=1.0, BranchTbl tbl=nullptr)
Select variable with lowest action with decay factor d.
IntVarBranch INT_VAR_SIZE_MIN(BranchTbl tbl=nullptr)
Select variable with smallest domain size.
BoolVarBranch BOOL_VAR_DEGREE_MAX(BranchTbl tbl=nullptr)
Select variable with largest degree.
FloatVarBranch FLOAT_VAR_AFC_SIZE_MAX(double d=1.0, BranchTbl tbl=nullptr)
Select variable with largest accumulated failure count divided by domain size with decay factor d.
IntVarBranch INT_VAR_ACTION_SIZE_MIN(double d=1.0, BranchTbl tbl=nullptr)
Select variable with smallest action divided by domain size with decay factor d.
BoolVarBranch BOOL_VAR_ACTION_MAX(double d=1.0, BranchTbl tbl=nullptr)
Select variable with highest action with decay factor d.
BoolAssign BOOL_ASSIGN_MIN(void)
Select smallest value.
FloatValBranch FLOAT_VAL_SPLIT_MIN(void)
Select values not greater than mean of smallest and largest value.
IntAssign INT_ASSIGN_MAX(void)
Select largest value.
FloatVarBranch FLOAT_VAR_SIZE_MIN(BranchTbl tbl=nullptr)
Select variable with smallest domain size.
IntVarBranch INT_VAR_MIN_MIN(BranchTbl tbl=nullptr)
Select variable with smallest min.
FloatVarBranch FLOAT_VAR_AFC_MAX(double d=1.0, BranchTbl tbl=nullptr)
Select variable with largest accumulated failure count with decay factor d.
SetValBranch SET_VAL_MIN_EXC(void)
Exclude smallest element.
IntVarBranch INT_VAR_SIZE_MAX(BranchTbl tbl=nullptr)
Select variable with largest domain size.
SetVarBranch SET_VAR_SIZE_MAX(BranchTbl tbl=nullptr)
Select variable with largest unknown set.
IntValBranch INT_VAL_RND(Rnd r)
Select random value.
SetVarBranch SET_VAR_ACTION_MAX(double d=1.0, BranchTbl tbl=nullptr)
Select variable with highest action with decay factor d.
FloatVarBranch FLOAT_VAR_ACTION_SIZE_MIN(double d=1.0, BranchTbl tbl=nullptr)
Select variable with smallest action divided by domain size with decay factor d.
const Gecode::FloatNum step
Gecode::IntArgs i({1, 2, 3, 4})
const Val & some(void) const
size_t operator()(const Gecode::DFA &d) const
Return hash key for d.
size_t operator()(const Gecode::SharedArray< int > &x) const
Return hash key for x.
size_t operator()(const Gecode::TupleSet &x) const
Return hash key for x.
#define GECODE_HAS_FLOAT_VARS
#define GECODE_HAS_SET_VARS