54 namespace Gecode {
namespace FlatZinc {
89 int_varsel(int_varsel0), int_valsel(int_valsel0),
90 bool_varsel(bool_varsel0), bool_valsel(bool_valsel0)
91 #ifdef GECODE_HAS_SET_VARS
92 , set_varsel(set_varsel0), set_valsel(set_valsel0)
94 #ifdef GECODE_HAS_FLOAT_VARS
95 , float_varsel(float_varsel0), float_valsel(float_valsel0)
100 :
Brancher(home, share, b), done(b.done) {}
111 virtual size_t size(
void)
const {
125 #ifdef GECODE_HAS_SET_VARS 129 #ifdef GECODE_HAS_FLOAT_VARS 137 if (done)
return false;
143 #ifdef GECODE_HAS_SET_VARS 147 #ifdef GECODE_HAS_FLOAT_VARS 161 #ifdef GECODE_HAS_SET_VARS 164 #ifdef GECODE_HAS_FLOAT_VARS 171 return new Choice(*
this,
false);
173 return new Choice(*
this,
true);
178 bool fail; e >> fail;
179 return new Choice(*
this, fail);
188 std::ostream& o)
const {
190 << (
static_cast<const Choice&
>(
c).fail ?
"fail" :
"ok")
215 bool_varsel, bool_valsel
216 #ifdef GECODE_HAS_SET_VARS
217 , set_varsel, set_valsel
219 #ifdef GECODE_HAS_FLOAT_VARS
220 , float_varsel, float_valsel
226 return sizeof(*this);
236 BI(
void) : r0(
""), r1(
""),
n(0) {}
237 BI(
const string& r00,
const string& r10,
const vector<string>& n0)
238 : r0(r00), r1(r10),
n(n0) {}
252 const vector<string>&
n) {
253 v.resize(
std::max(static_cast<unsigned int>(v.size()),bg.
id()+1));
254 v[bg.
id()] = BI(rel0,rel1,n);
258 unsigned int a,
int i,
int n, ostream& o)
const {
260 o << bi.n[
i] <<
" " << (a==0 ? bi.r0 : bi.r1) <<
" " << n;
262 #ifdef GECODE_HAS_FLOAT_VARS 268 << (((a == 0) == nl.
l) ?
"<=" :
">=") << nl.
n;
273 BranchInformation::BranchInformation(
void)
281 assert(
object() == NULL);
287 const std::string& rel0,
288 const std::string& rel1,
289 const std::vector<std::string>&
n) {
294 int n, std::ostream& o)
const {
297 #ifdef GECODE_HAS_FLOAT_VARS 307 Var,
int i,
const int&
n,
312 #ifdef GECODE_HAS_FLOAT_VARS 338 int* newdom =
heap.
alloc<
int>(
static_cast<unsigned long int>(sl->
s.size()));
339 for (
int i=sl->
s.size();
i--;)
340 newdom[
i] = sl->
s[
i];
341 IntSet ret(newdom, sl->
s.size());
342 heap.
free(newdom, static_cast<unsigned long int>(sl->
s.size()));
374 if (
AST::Atom* s = dynamic_cast<AST::Atom*>(ann)) {
375 if (s->id ==
"input_order")
377 if (s->id ==
"first_fail")
379 if (s->id ==
"anti_first_fail")
381 if (s->id ==
"smallest")
383 if (s->id ==
"largest")
385 if (s->id ==
"occurrence")
387 if (s->id ==
"max_regret")
389 if (s->id ==
"most_constrained")
392 if (s->id ==
"random") {
395 if (s->id ==
"dom_w_deg") {
398 if (s->id ==
"afc_min")
400 if (s->id ==
"afc_max")
402 if (s->id ==
"afc_size_min")
404 if (s->id ==
"afc_size_max") {
407 if (s->id ==
"activity_min")
409 if (s->id ==
"activity_max")
411 if (s->id ==
"activity_size_min")
413 if (s->id ==
"activity_size_max")
416 std::cerr <<
"Warning, ignored search annotation: ";
417 ann->
print(std::cerr);
418 std::cerr << std::endl;
424 if (
AST::Atom* s = dynamic_cast<AST::Atom*>(ann)) {
425 if (s->id ==
"indomain_min") {
429 if (s->id ==
"indomain_max") {
433 if (s->id ==
"indomain_median") {
437 if (s->id ==
"indomain_split") {
441 if (s->id ==
"indomain_reverse_split") {
445 if (s->id ==
"indomain_random") {
449 if (s->id ==
"indomain") {
453 if (s->id ==
"indomain_middle") {
454 std::cerr <<
"Warning, replacing unsupported annotation " 455 <<
"indomain_middle with indomain_median" << std::endl;
459 if (s->id ==
"indomain_interval") {
460 std::cerr <<
"Warning, replacing unsupported annotation " 461 <<
"indomain_interval with indomain_split" << std::endl;
466 std::cerr <<
"Warning, ignored search annotation: ";
467 ann->
print(std::cerr);
468 std::cerr << std::endl;
474 if (
AST::Atom* s = dynamic_cast<AST::Atom*>(ann)) {
475 if (s->id ==
"indomain_min")
477 if (s->id ==
"indomain_max")
479 if (s->id ==
"indomain_median")
481 if (s->id ==
"indomain_random") {
485 std::cerr <<
"Warning, ignored search annotation: ";
486 ann->
print(std::cerr);
487 std::cerr << std::endl;
491 #ifdef GECODE_HAS_SET_VARS 493 if (
AST::Atom* s = dynamic_cast<AST::Atom*>(ann)) {
494 if (s->id ==
"input_order")
496 if (s->id ==
"first_fail")
498 if (s->id ==
"anti_first_fail")
500 if (s->id ==
"smallest")
502 if (s->id ==
"largest")
504 if (s->id ==
"afc_min")
506 if (s->id ==
"afc_max")
508 if (s->id ==
"afc_size_min")
510 if (s->id ==
"afc_size_max")
512 if (s->id ==
"activity_min")
514 if (s->id ==
"activity_max")
516 if (s->id ==
"activity_size_min")
518 if (s->id ==
"activity_size_max")
520 if (s->id ==
"random") {
524 std::cerr <<
"Warning, ignored search annotation: ";
525 ann->
print(std::cerr);
526 std::cerr << std::endl;
533 if (
AST::Atom* s = dynamic_cast<AST::Atom*>(ann)) {
534 if (s->id ==
"indomain_min") {
535 r0 =
"in"; r1 =
"not in";
538 if (s->id ==
"indomain_max") {
539 r0 =
"in"; r1 =
"not in";
542 if (s->id ==
"outdomain_min") {
543 r1 =
"in"; r0 =
"not in";
546 if (s->id ==
"outdomain_max") {
547 r1 =
"in"; r0 =
"not in";
551 std::cerr <<
"Warning, ignored search annotation: ";
552 ann->
print(std::cerr);
553 std::cerr << std::endl;
554 r0 =
"in"; r1 =
"not in";
559 #ifdef GECODE_HAS_FLOAT_VARS 562 if (
AST::Atom* s = dynamic_cast<AST::Atom*>(ann)) {
563 if (s->id ==
"input_order")
565 if (s->id ==
"first_fail")
567 if (s->id ==
"anti_first_fail")
569 if (s->id ==
"smallest")
571 if (s->id ==
"largest")
573 if (s->id ==
"occurrence")
575 if (s->id ==
"most_constrained")
578 if (s->id ==
"random") {
581 if (s->id ==
"afc_min")
583 if (s->id ==
"afc_max")
585 if (s->id ==
"afc_size_min")
587 if (s->id ==
"afc_size_max")
589 if (s->id ==
"activity_min")
591 if (s->id ==
"activity_max")
593 if (s->id ==
"activity_size_min")
595 if (s->id ==
"activity_size_max")
598 std::cerr <<
"Warning, ignored search annotation: ";
599 ann->
print(std::cerr);
600 std::cerr << std::endl;
605 if (
AST::Atom* s = dynamic_cast<AST::Atom*>(ann)) {
606 if (s->id ==
"indomain_split") {
610 if (s->id ==
"indomain_reverse_split") {
615 std::cerr <<
"Warning, ignored search annotation: ";
616 ann->
print(std::cerr);
617 std::cerr << std::endl;
625 :
Space(share, f), _random(f._random),
626 _solveAnnotations(NULL), iv_boolalias(NULL),
630 needAuxVars(f.needAuxVars) {
646 iva[iva.
size()-1].update(*
this, share, f.
iv_aux[
i]);
659 bva[bva.
size()-1].update(*
this, share, f.
bv_aux[
i]);
665 #ifdef GECODE_HAS_SET_VARS 673 sva[sva.
size()-1].update(*
this, share, f.
sv_aux[
i]);
679 #ifdef GECODE_HAS_FLOAT_VARS 687 fva[fva.
size()-1].update(*
this, share, f.
fv_aux[
i]);
705 int setVars,
int floatVars) {
716 #ifdef GECODE_HAS_SET_VARS 721 #ifdef GECODE_HAS_FLOAT_VARS 766 #ifdef GECODE_HAS_SET_VARS 778 int* is =
heap.
alloc<
int>(
static_cast<unsigned long int>(vsv->s.size()));
779 for (
int i=vsv->s.
size();
i--; )
782 heap.
free(is,static_cast<unsigned long int>(vsv->s.size()));
791 int* is =
heap.
alloc<
int>(
static_cast<unsigned long int>(vsv->
s.size()));
792 for (
int i=vsv->
s.size();
i--; )
795 heap.
free(is,static_cast<unsigned long int>(vsv->
s.size()));
813 #ifdef GECODE_HAS_FLOAT_VARS 844 struct ConExprOrder {
846 return ce0->
args->
a.size() < ce1->
args->
a.size();
856 for (
unsigned int i=0;
i<ces.
size();
i++) {
871 for (
unsigned int i=0;
i<ann->
a.size();
i++) {
872 if (ann->
a[
i]->isCall(
"seq_search")) {
877 out.push_back(c->
args);
879 out.push_back(ann->
a[
i]);
889 Rnd rnd(static_cast<unsigned int>(seed));
892 std::string def_int_rel_left =
"=";
893 std::string def_int_rel_right =
"!=";
896 std::string def_bool_rel_left =
"=";
897 std::string def_bool_rel_right =
"!=";
898 #ifdef GECODE_HAS_SET_VARS 901 std::string def_set_rel_left =
"in";
902 std::string def_set_rel_right =
"not in";
904 #ifdef GECODE_HAS_FLOAT_VARS 907 std::string def_float_rel_left =
"<=";
908 std::string def_float_rel_right =
">";
911 std::vector<bool> iv_searched(
iv.
size());
912 for (
unsigned int i=
iv.
size();
i--;)
913 iv_searched[
i] =
false;
914 std::vector<bool> bv_searched(
bv.
size());
915 for (
unsigned int i=
bv.
size();
i--;)
916 bv_searched[
i] =
false;
917 #ifdef GECODE_HAS_SET_VARS 918 std::vector<bool> sv_searched(
sv.
size());
919 for (
unsigned int i=
sv.
size();
i--;)
920 sv_searched[
i] =
false;
922 #ifdef GECODE_HAS_FLOAT_VARS 923 std::vector<bool> fv_searched(
fv.
size());
924 for (
unsigned int i=
fv.
size();
i--;)
925 fv_searched[
i] =
false;
930 std::vector<AST::Node*> flatAnn;
934 flatAnn.push_back(ann);
937 for (
unsigned int i=0;
i<flatAnn.
size();
i++) {
938 if (flatAnn[
i]->isCall(
"relax_and_reconstruct")) {
941 "Only one relax_and_reconstruct annotation allowed");
949 _lns = args->
a[1]->getInt();
951 int k=vars->
a.size();
952 for (
int i=vars->
a.size();
i--;)
953 if (vars->
a[
i]->isInt())
957 for (
unsigned int i=0;
i<vars->
a.size();
i++) {
958 if (vars->
a[
i]->isInt())
962 if (args->
a.size()==3) {
965 for (
unsigned int i=initial->
a.size();
i--;)
968 }
else if (flatAnn[
i]->isCall(
"gecode_search")) {
970 branchWithPlugin(c->
args);
971 }
else if (flatAnn[
i]->isCall(
"int_search")) {
975 int k=vars->
a.size();
976 for (
int i=vars->
a.size();
i--;)
977 if (vars->
a[
i]->isInt())
980 vector<string> names;
982 for (
unsigned int i=0;
i<vars->
a.size();
i++) {
983 if (vars->
a[
i]->isInt())
985 va[k++] =
iv[vars->
a[
i]->getIntVar()];
986 iv_searched[vars->
a[
i]->getIntVar()] =
true;
987 names.push_back(vars->
a[
i]->getVarName());
996 &varValPrint<IntVar>);
999 }
else if (flatAnn[
i]->isCall(
"int_assign")) {
1003 int k=vars->
a.size();
1004 for (
int i=vars->
a.size();
i--;)
1005 if (vars->
a[
i]->isInt())
1009 for (
unsigned int i=0;
i<vars->
a.size();
i++) {
1010 if (vars->
a[
i]->isInt())
1012 va[k++] =
iv[vars->
a[
i]->getIntVar()];
1013 iv_searched[vars->
a[
i]->getIntVar()] =
true;
1016 &varValPrint<IntVar>);
1017 }
else if (flatAnn[
i]->isCall(
"bool_search")) {
1021 int k=vars->
a.size();
1022 for (
int i=vars->
a.size();
i--;)
1023 if (vars->
a[
i]->isBool())
1027 vector<string> names;
1028 for (
unsigned int i=0;
i<vars->
a.size();
i++) {
1029 if (vars->
a[
i]->isBool())
1031 va[k++] =
bv[vars->
a[
i]->getBoolVar()];
1032 bv_searched[vars->
a[
i]->getBoolVar()] =
true;
1033 names.push_back(vars->
a[
i]->getVarName());
1042 &varValPrint<BoolVar>);
1045 }
else if (flatAnn[
i]->isCall(
"int_default_search")) {
1050 def_int_rel_left,def_int_rel_right,rnd);
1051 }
else if (flatAnn[
i]->isCall(
"bool_default_search")) {
1056 def_bool_rel_left,def_bool_rel_right,
1058 }
else if (flatAnn[
i]->isCall(
"set_search")) {
1059 #ifdef GECODE_HAS_SET_VARS 1063 int k=vars->
a.size();
1064 for (
int i=vars->
a.size();
i--;)
1065 if (vars->
a[
i]->isSet())
1069 vector<string> names;
1070 for (
unsigned int i=0;
i<vars->
a.size();
i++) {
1071 if (vars->
a[
i]->isSet())
1073 va[k++] =
sv[vars->
a[
i]->getSetVar()];
1074 sv_searched[vars->
a[
i]->getSetVar()] =
true;
1075 names.push_back(vars->
a[
i]->getVarName());
1084 &varValPrint<SetVar>);
1088 if (!ignoreUnknown) {
1089 err <<
"Warning, ignored search annotation: ";
1090 flatAnn[
i]->print(err);
1094 }
else if (flatAnn[
i]->isCall(
"set_default_search")) {
1095 #ifdef GECODE_HAS_SET_VARS 1100 def_set_rel_left,def_set_rel_right,rnd);
1102 if (!ignoreUnknown) {
1103 err <<
"Warning, ignored search annotation: ";
1104 flatAnn[
i]->print(err);
1108 }
else if (flatAnn[
i]->isCall(
"float_default_search")) {
1109 #ifdef GECODE_HAS_FLOAT_VARS 1114 def_float_rel_left,def_float_rel_right);
1116 if (!ignoreUnknown) {
1117 err <<
"Warning, ignored search annotation: ";
1118 flatAnn[
i]->print(err);
1122 }
else if (flatAnn[
i]->isCall(
"float_search")) {
1123 #ifdef GECODE_HAS_FLOAT_VARS 1127 int k=vars->
a.size();
1128 for (
int i=vars->
a.size();
i--;)
1129 if (vars->
a[
i]->isFloat())
1133 vector<string> names;
1134 for (
unsigned int i=0;
i<vars->
a.size();
i++) {
1135 if (vars->
a[
i]->isFloat())
1137 va[k++] =
fv[vars->
a[
i]->getFloatVar()];
1138 fv_searched[vars->
a[
i]->getFloatVar()] =
true;
1139 names.push_back(vars->
a[
i]->getVarName());
1152 if (!ignoreUnknown) {
1153 err <<
"Warning, ignored search annotation: ";
1154 flatAnn[
i]->print(err);
1159 if (!ignoreUnknown) {
1160 err <<
"Warning, ignored search annotation: ";
1161 flatAnn[
i]->print(err);
1181 std::vector<std::string> iv_sol_names(
iv.
size()-(introduced+funcdep+searched));
1183 std::vector<std::string> iv_tmp_names(introduced);
1185 for (
int i=
iv.
size(), j=0, k=0;
i--;) {
1191 iv_tmp[j++] =
iv[
i];
1195 iv_sol[k++] =
iv[
i];
1203 if (bv_searched[
i]) {
1213 std::vector<std::string> bv_sol_names(
bv.
size()-(introduced+funcdep+searched));
1216 std::vector<std::string> bv_tmp_names(introduced);
1217 for (
int i=
bv.
size(), j=0, k=0;
i--;) {
1223 bv_tmp[j++] =
bv[
i];
1227 bv_sol[k++] =
bv[
i];
1231 if (iv_sol.
size() > 0) {
1233 branch(bg(*
this), iv_sol, def_int_varsel, def_int_valsel,
1234 NULL, &varValPrint<IntVar>);
1235 branchInfo.
add(bg,def_int_rel_left,def_int_rel_right,iv_sol_names);
1237 if (bv_sol.
size() > 0) {
1239 branch(bg(*
this), bv_sol, def_bool_varsel, def_bool_valsel,
1240 NULL, &varValPrint<BoolVar>);
1241 branchInfo.
add(bg,def_bool_rel_left,def_bool_rel_right,bv_sol_names);
1243 #ifdef GECODE_HAS_FLOAT_VARS 1258 std::vector<std::string> fv_sol_names(
fv.
size()-(introduced+funcdep+searched));
1261 std::vector<std::string> fv_tmp_names(introduced);
1262 for (
int i=
fv.
size(), j=0, k=0;
i--;) {
1268 fv_tmp[j++] =
fv[
i];
1272 fv_sol[k++] =
fv[
i];
1276 if (fv_sol.
size() > 0) {
1278 branch(bg(*
this), fv_sol, def_float_varsel, def_float_valsel,
1280 branchInfo.
add(bg,def_float_rel_left,def_float_rel_right,fv_sol_names);
1283 #ifdef GECODE_HAS_SET_VARS 1288 if (sv_searched[
i]) {
1298 std::vector<std::string> sv_sol_names(
sv.
size()-(introduced+funcdep+searched));
1301 std::vector<std::string> sv_tmp_names(introduced);
1302 for (
int i=
sv.
size(), j=0, k=0;
i--;) {
1308 sv_tmp[j++] =
sv[
i];
1312 sv_sol[k++] =
sv[
i];
1316 if (sv_sol.
size() > 0) {
1318 branch(bg(*
this), sv_sol, def_set_varsel, def_set_valsel,
1319 NULL, &varValPrint<SetVar>);
1320 branchInfo.
add(bg,def_set_rel_left,def_set_rel_right,sv_sol_names);
1327 #ifdef GECODE_HAS_SET_VARS 1331 #ifdef GECODE_HAS_FLOAT_VARS 1338 std::vector<std::string> names(1);
1344 #ifdef GECODE_HAS_FLOAT_VARS 1345 std::vector<std::string> names(1);
1354 std::vector<std::string> names(1);
1360 #ifdef GECODE_HAS_FLOAT_VARS 1361 std::vector<std::string> names(1);
1373 def_bool_varsel, def_bool_valsel
1375 , def_set_varsel, def_set_valsel
1378 , def_float_varsel, def_float_valsel
1385 NULL, &varValPrint<IntVar>);
1386 branchInfo.
add(bg,def_int_rel_left,def_int_rel_right,iv_tmp_names);
1390 branch(bg(*
this),
bv_aux,def_bool_varsel,def_bool_valsel,
1391 NULL, &varValPrint<BoolVar>);
1392 branchInfo.
add(bg,def_bool_rel_left,def_bool_rel_right,bv_tmp_names);
1394 #ifdef GECODE_HAS_SET_VARS 1398 NULL, &varValPrint<SetVar>);
1399 branchInfo.
add(bg,def_set_rel_left,def_set_rel_right,sv_tmp_names);
1402 #ifdef GECODE_HAS_FLOAT_VARS 1405 branch(bg(*
this),
fv_aux,def_float_varsel,def_float_valsel,
1407 branchInfo.
add(bg,def_float_rel_left,def_float_rel_right,fv_tmp_names);
1446 #ifdef GECODE_HAS_GIST 1451 template<
class Engine>
1456 template<
typename S>
1470 template<
typename S>
1493 virtual void inspect(
const Space& node);
1495 virtual void finalize(
void);
1500 : TextOutput(
"Gecode/FlatZinc"),
p(p0) {}
1531 :
Gecode::Gist::VarComparator<S>(
"Gecode/FlatZinc"),
p(p0) {}
1538 dynamic_cast<const S&
>(s0).
compare(dynamic_cast<const S&>(s1),
1549 template<
template<
class>
class Engine>
1551 FlatZincSpace::runEngine(std::ostream& out,
const Printer& p,
1554 runMeta<Engine,Driver::EngineToMeta>(out,p,
opt,t_total);
1556 runMeta<Engine,RBS>(out,p,
opt,t_total);
1560 template<
template<
class>
class Engine,
1561 template<
class,
template<
class>
class>
class Meta>
1563 FlatZincSpace::runMeta(std::ostream& out, const Printer& p,
1564 const FlatZincOptions& opt, Support::Timer& t_total) {
1565 #ifdef GECODE_HAS_GIST 1574 unsigned int n_p = 0;
1585 #ifdef GECODE_HAS_FLOAT_VARS 1593 Meta<FlatZincSpace,Engine> se(
this,o);
1595 if (noOfSolutions == -1) {
1596 noOfSolutions = (_method == SAT) ? 1 : 0;
1598 bool printAll = _method == SAT || opt.
allSolutions() || noOfSolutions != 0;
1599 int findSol = noOfSolutions;
1600 FlatZincSpace* sol = NULL;
1601 while (FlatZincSpace* next_sol = se.next()) {
1606 out <<
"----------" << std::endl;
1611 if (sol && !printAll) {
1613 out <<
"----------" << std::endl;
1615 if (!se.stopped()) {
1617 out <<
"==========" << endl;
1619 out <<
"=====UNSATISFIABLE=====" << endl;
1622 out <<
"=====UNKNOWN=====" << endl;
1634 <<
"%% solvetime: ";
1638 <<
std::abs(noOfSolutions - findSol) << endl
1640 << (intVarCount + boolVarCount + setVarCount) << endl
1641 <<
"%% propagators: " << n_p << endl
1643 <<
"%% nodes: " << stat.
node << endl
1644 <<
"%% failures: " << stat.
fail << endl
1645 <<
"%% restarts: " << stat.
restart << endl
1646 <<
"%% peak depth: " << stat.
depth << endl
1652 #ifdef GECODE_HAS_QT 1654 FlatZincSpace::branchWithPlugin(
AST::Node* ann) {
1655 if (
AST::Call*
c = dynamic_cast<AST::Call*>(ann)) {
1656 QString pluginName(
c->id.c_str());
1657 if (QLibrary::isLibrary(pluginName+
".dll")) {
1658 pluginName +=
".dll";
1659 }
else if (QLibrary::isLibrary(pluginName+
".dylib")) {
1660 pluginName =
"lib" + pluginName +
".dylib";
1661 }
else if (QLibrary::isLibrary(pluginName+
".so")) {
1663 pluginName =
"lib" + pluginName +
".so";
1665 QPluginLoader pl(pluginName);
1666 QObject* plugin_o = pl.instance();
1669 "Error loading plugin "+pluginName.toStdString()+
1670 ": "+pl.errorString().toStdString());
1672 BranchPlugin* pb = qobject_cast<BranchPlugin*>(plugin_o);
1675 "Error loading plugin "+pluginName.toStdString()+
1676 ": does not contain valid PluginBrancher");
1678 pb->branch(*
this,
c);
1683 FlatZincSpace::branchWithPlugin(
AST::Node*) {
1685 "Branching with plugins not supported (requires Qt support)");
1695 runEngine<BAB>(out,p,
opt,t_total);
1698 runEngine<DFS>(out,p,
opt,t_total);
1708 static_cast<const FlatZincSpace*>(&s)->iv[_optVar].val());
1709 else if (_method == MAX)
1711 static_cast<const FlatZincSpace*>(&s)->iv[_optVar].val());
1713 #ifdef GECODE_HAS_FLOAT_VARS 1716 static_cast<const FlatZincSpace*>(&s)->fv[_optVar].val()-
step);
1717 else if (_method == MAX)
1719 static_cast<const FlatZincSpace*>(&s)->fv[_optVar].val()+
step);
1727 (_lns > 0) && (mi.
last()==NULL) && (_lnsInitialSolution.size()>0)) {
1728 for (
unsigned int i=iv_lns.
size();
i--;) {
1729 if ((*_random)(99) <= _lns) {
1730 rel(*
this, iv_lns[
i],
IRT_EQ, _lnsInitialSolution[i]);
1735 (_lns > 0) && mi.
last()) {
1736 const FlatZincSpace& last =
1737 static_cast<const FlatZincSpace&
>(*mi.
last());
1738 for (
unsigned int i=iv_lns.
size();
i--;) {
1739 if ((*_random)(99) <= _lns) {
1750 return new FlatZincSpace(share, *
this);
1765 return _optVarIsInt;
1782 (void) s; (void) out;
1783 #ifdef GECODE_HAS_GIST 1784 const FlatZincSpace& fs =
dynamic_cast<const FlatZincSpace&
>(s);
1785 for (
int i = 0;
i < iv.
size(); ++
i) {
1786 std::stringstream ss;
1787 ss <<
"iv[" <<
i <<
"]";
1790 if (result.length() > 0) out << result << std::endl;
1792 for (
int i = 0;
i < bv.
size(); ++
i) {
1793 std::stringstream ss;
1794 ss <<
"bv[" <<
i <<
"]";
1797 if (result.length() > 0) out << result << std::endl;
1799 #ifdef GECODE_HAS_SET_VARS 1800 for (
int i = 0;
i < sv.
size(); ++
i) {
1801 std::stringstream ss;
1802 ss <<
"sv[" <<
i <<
"]";
1805 if (result.length() > 0) out << result << std::endl;
1808 #ifdef GECODE_HAS_FLOAT_VARS 1809 for (
int i = 0;
i < fv.
size(); ++
i) {
1810 std::stringstream ss;
1811 ss <<
"fv[" <<
i <<
"]";
1814 if (result.length() > 0) out << result << std::endl;
1849 for (
int i=offset;
i--;)
1851 for (
int i=a->
a.size();
i--;)
1852 ia[
i+offset] = a->
a[
i]->getInt();
1859 for (
int i=offset;
i--;)
1861 for (
int i=a->
a.size();
i--;)
1862 ia[
i+offset] = a->
a[
i]->getBool();
1873 int* is = re.
alloc<
int>(
static_cast<unsigned long int>(sl->
s.size()));
1874 for (
int i=sl->
s.size();
i--; )
1883 if (a->
a.size() == 0) {
1888 for (
int i=offset;
i--;)
1890 for (
int i=a->
a.size();
i--;) {
1891 ia[
i+offset] = arg2intset(a->
a[
i]);
1898 if (a->
a.size() == 0) {
1903 for (
int i=offset;
i--;)
1905 for (
int i=a->
a.size();
i--;) {
1906 if (a->
a[
i]->isIntVar()) {
1907 ia[
i+offset] = iv[a->
a[
i]->getIntVar()];
1909 int value = a->
a[
i]->getInt();
1910 IntVar iv(*
this, value, value);
1919 if (a->
a.size() == 0) {
1924 for (
int i=offset;
i--;)
1926 for (
int i=0; i<static_cast<int>(a->
a.size());
i++) {
1929 if (a->
a[
i]->isBool()) {
1930 bool value = a->
a[
i]->getBool();
1931 BoolVar iv(*
this, value, value);
1933 }
else if (a->
a[
i]->isIntVar() &&
1934 aliasBool2Int(a->
a[
i]->getIntVar()) != -1) {
1935 ia[offset++] = bv[aliasBool2Int(a->
a[
i]->getIntVar())];
1937 ia[offset++] = bv[a->
a[
i]->getBoolVar()];
1967 if (a->
a.size() == 0)
1969 for (
int i=a->
a.size();
i--;) {
1970 if (a->
a[
i]->isBoolVar() || a->
a[
i]->isBool()) {
1971 }
else if (a->
a[
i]->isIntVar()) {
1972 if (aliasBool2Int(a->
a[
i]->getIntVar()) == -1) {
1973 if (singleInt != -1) {
1982 return singleInt==-1 || a->
a.size() > 1;
1984 #ifdef GECODE_HAS_SET_VARS 1990 x0 =
SetVar(*
this, d, d);
2001 for (
int i=offset;
i--;) {
2005 for (
int i=a->
a.size();
i--;) {
2006 ia[
i+offset] = arg2SetVar(a->
a[
i]);
2011 #ifdef GECODE_HAS_FLOAT_VARS 2016 for (
int i=offset;
i--;)
2018 for (
int i=a->
a.size();
i--;)
2019 fa[
i+offset] = a->
a[
i]->getFloat();
2025 if (a->
a.size() == 0) {
2030 for (
int i=offset;
i--;)
2032 for (
int i=a->
a.size();
i--;) {
2033 if (a->
a[
i]->isFloatVar()) {
2034 fa[
i+offset] = fv[a->
a[
i]->getFloatVar()];
2036 double value = a->
a[
i]->getFloat();
2077 Printer::printElem(std::ostream& out,
2097 }
else if (bv[ai->
getBoolVar()].max() == 0) {
2100 out <<
"false..true";
2102 #ifdef GECODE_HAS_SET_VARS 2113 int min = svr.min();
2114 int max = svr.max();
2121 for (; svv(); ++svv)
2122 out <<
", " << svv.val();
2125 out << min <<
".." <<
max;
2128 #ifdef GECODE_HAS_FLOAT_VARS 2139 std::ostringstream oss;
2141 oss << std::setprecision(std::numeric_limits<double>::digits10);
2143 if (oss.str().find(
".") == std::string::npos)
2150 }
else if (ai->
isBool()) {
2151 out << (ai->
getBool() ?
"true" :
"false");
2152 }
else if (ai->
isSet()) {
2155 out << s->
min <<
".." << s->
max;
2158 for (
unsigned int i=0;
i<s->
s.size();
i++) {
2159 out << s->
s[
i] << (
i < s->
s.size()-1 ?
", " :
"}");
2164 for (
unsigned int i=0;
i<s.
size();
i++) {
2165 if (s[
i] ==
'\\' &&
i<s.
size()-1) {
2167 case 'n': out <<
"\n";
break;
2168 case '\\': out <<
"\\";
break;
2169 case 't': out <<
"\t";
break;
2170 default: out <<
"\\" << s[
i+1];
2181 Printer::printElemDiff(std::ostream& out,
2187 #ifdef GECODE_HAS_SET_VARS
2191 #ifdef GECODE_HAS_FLOAT_VARS
2196 #ifdef GECODE_HAS_GIST 2204 if (res.length() > 0) {
2213 if (res.length() > 0) {
2219 #ifdef GECODE_HAS_SET_VARS 2223 if (res.length() > 0) {
2230 #ifdef GECODE_HAS_FLOAT_VARS 2234 if (res.length() > 0) {
2241 }
else if (ai->
isBool()) {
2242 out << (ai->
getBool() ?
"true" :
"false");
2243 }
else if (ai->
isSet()) {
2246 out << s->
min <<
".." << s->
max;
2249 for (
unsigned int i=0;
i<s->
s.size();
i++) {
2250 out << s->
s[
i] << (
i < s->
s.size()-1 ?
", " :
"}");
2255 for (
unsigned int i=0;
i<s.
size();
i++) {
2256 if (s[
i] ==
'\\' &&
i<s.
size()-1) {
2258 case 'n': out <<
"\n";
break;
2259 case '\\': out <<
"\\";
break;
2260 case 't': out <<
"\t";
break;
2261 default: out <<
"\\" << s[
i+1];
2276 #ifdef GECODE_HAS_SET_VARS 2280 #ifdef GECODE_HAS_FLOAT_VARS 2292 #ifdef GECODE_HAS_SET_VARS
2296 #ifdef GECODE_HAS_FLOAT_VARS
2301 if (_output == NULL)
2303 for (
unsigned int i=0;
i< _output->
a.size();
i++) {
2307 int size = aia->
a.size();
2309 for (
int j=0; j<
size; j++) {
2310 printElem(out,aia->
a[j],iv,bv
2311 #ifdef GECODE_HAS_SET_VARS
2314 #ifdef GECODE_HAS_FLOAT_VARS
2323 printElem(out,ai,iv,bv
2324 #ifdef GECODE_HAS_SET_VARS
2327 #ifdef GECODE_HAS_FLOAT_VARS
2341 #ifdef GECODE_HAS_SET_VARS
2346 #ifdef GECODE_HAS_FLOAT_VARS
2352 if (_output == NULL)
2354 for (
unsigned int i=0;
i< _output->
a.size();
i++) {
2358 int size = aia->
a.size();
2360 for (
int j=0; j<
size; j++) {
2361 printElemDiff(out,aia->
a[j],iv1,iv2,bv1,bv2
2362 #ifdef GECODE_HAS_SET_VARS
2365 #ifdef GECODE_HAS_FLOAT_VARS
2374 printElemDiff(out,ai,iv1,iv2,bv1,bv2
2375 #ifdef GECODE_HAS_SET_VARS
2378 #ifdef GECODE_HAS_FLOAT_VARS
2388 iv_names.push_back(n);
2392 bv_names.push_back(n);
2394 #ifdef GECODE_HAS_FLOAT_VARS 2397 fv_names.push_back(n);
2400 #ifdef GECODE_HAS_SET_VARS 2403 sv_names.push_back(n);
2409 std::map<int,int>& iv, std::map<int,int>& bv,
2410 std::map<int,int>& sv, std::map<int,int>& fv) {
2413 if (iv.find(x->
i) == iv.end()) {
2414 int newi = iv.size();
2420 if (bv.find(x->
i) == bv.end()) {
2421 int newi = bv.size();
2427 if (sv.find(x->
i) == sv.end()) {
2428 int newi = sv.size();
2434 if (fv.find(x->
i) == fv.end()) {
2435 int newi = fv.size();
2444 int& optVar,
bool optVarIsInt,
2447 #ifdef GECODE_HAS_SET_VARS
2451 #ifdef GECODE_HAS_FLOAT_VARS
2456 if (_output == NULL) {
2457 if (optVarIsInt && optVar != -1) {
2466 #ifdef GECODE_HAS_SET_VARS 2469 #ifdef GECODE_HAS_FLOAT_VARS 2470 if (!optVarIsInt && optVar != -1) {
2481 std::map<int,int> iv_new;
2482 std::map<int,int> bv_new;
2483 std::map<int,int> sv_new;
2484 std::map<int,int> fv_new;
2494 for (
unsigned int i=0;
i< _output->
a.size();
i++) {
2498 for (
unsigned int j=0; j<aia->
a.size(); j++) {
2499 shrinkElement(aia->
a[j],iv_new,bv_new,sv_new,fv_new);
2502 shrinkElement(ai,iv_new,bv_new,sv_new,fv_new);
2507 for (map<int,int>::iterator
i=iv_new.
begin();
i != iv_new.
end(); ++
i) {
2508 iva[(*i).second] = iv[(*i).first];
2513 for (map<int,int>::iterator
i=bv_new.
begin();
i != bv_new.
end(); ++
i) {
2514 bva[(*i).second] = bv[(*i).first];
2518 #ifdef GECODE_HAS_SET_VARS 2520 for (map<int,int>::iterator
i=sv_new.
begin();
i != sv_new.
end(); ++
i) {
2521 sva[(*i).second] = sv[(*i).first];
2526 #ifdef GECODE_HAS_FLOAT_VARS 2528 for (map<int,int>::iterator
i=fv_new.
begin();
i != fv_new.
end(); ++
i) {
2529 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) ...
int solutions(void) const
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
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.
RestartMode restart(void) const
Combine variable selection criteria for tie-breaking.
IntSet vs2is(IntVarSpec *vs)
virtual void print(const Space &, const Gecode::Choice &c, unsigned int, std::ostream &o) const
Print explanation.
Gecode::Support::RandomGenerator random
The actual random number generator.
Which values to select for branching first.
std::ostream & getStream(void)
Get the stream that is used to output text.
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.
int size(void) const
Return size of array (number of elements)
Traits class for search engines.
SetVarBranch SET_VAR_NONE(void)
Select first unassigned variable.
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.
int size(void) const
Return size of array (number of elements)
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.
Meth _method
Whether to solve as satisfaction or optimization problem.
unsigned int c_d
Create a clone after every c_d commits (commit distance)
Cutoff generator appending two cutoff generators.
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 .
int getFloatVar(void)
Cast this node to a Float variable node.
Gecode::ScriptMode mode(void) const
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 .
static PropagatorGroup all
Group of all propagators.
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.
virtual void compare(const Space &s0, const Space &s1)
Use the compare method of the template class S to compare two spaces.
BranchInformation branchInfo
Information for printing branches.
void compare(const Space &s, std::ostream &out) const
Compare this space with space s and print the differences on out.
int boolVarCount
Number of Boolean variables.
bool assigned(void) const
Test if all variables are assigned.
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.
bool singleton(void) const
Test whether float is a singleton.
void dom(Home home, FloatVar x, FloatVal n)
Propagates .
bool optVarIsInt(void) const
Return whether variable used for optimization is integer (or float)
IntVarBranch INT_VAR_SIZE_MIN(BranchTbl tbl)
Select variable with smallest domain size.
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.
bool isSetVar(void)
Test if node is a set variable node.
bool isBoolVar(void)
Test if node is a Boolean variable node.
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)
bool allSolutions(void) const
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)
Space * clone(bool share_data=true, bool share_info=true, CloneStatistics &stat=unused_clone) const
Clone space.
void init(int intVars, int boolVars, int setVars, int floatVars)
Initialize space with given number of variables.
static void explore(S *root, const FlatZincOptions &opt, Gist::Inspector *i, Gist::Comparator *c)
void varValPrint(const Space &home, const Brancher &b, unsigned int a, Var, int i, const int &n, std::ostream &o)
AuxVarBrancher(Space &home, bool share, AuxVarBrancher &b)
Copy constructor.
Meth method(void) const
Return whether to solve a satisfaction or optimization problem.
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.
unsigned int id(void) const
Return a unique id for the group.
A thread-safe random number generator.
const int max
Largest allowed integer value.
int vs2bsl(BoolVarSpec *bs)
An inspector for printing simple text output.
Abstract base class for inspectors.
FloatVarBranch FLOAT_VAR_NONE(void)
Select first unassigned variable.
unsigned int size(Space &home) const
Return number of propagators in a group.
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.
virtual size_t size(void) const
Report size occupied.
SetVarBranch SET_VAR_SIZE_MAX(BranchTbl tbl)
Select variable with largest unknown set.
Statistics for execution of status
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.
std::vector< bool > iv_introduced
Indicates whether an integer variable is introduced by mzn2fzn.
TieBreak< IntVarBranch > bool_varsel
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)
void start(void)
Start timer.
SetVar arg2SetVar(AST::Node *n)
Convert n to SetVar.
unsigned int nogoods_limit(void) const
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 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.
Cutoff * cutoff
Cutoff for restart-based search.
int optVar(void) const
Return index of variable used for optimization.
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...
struct Gecode::@554::NNF::@60::@62 a
For atomic nodes.
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.
void assign(Home home, const FloatVarArgs &x, FloatAssign fa, FloatBranchFilter bf, FloatVarValPrint vvp)
Assign all x with value selection vals.
virtual bool status(const Space &_home) const
Check status of brancher, return true if alternatives left.
int n
Number of negative literals for node type.
BrancherGroup group(void) const
Return group brancher belongs to.
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.
IntPropLevel ann2ipl(AST::Node *ann)
Convert ann to integer propagation level.
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 or branching.
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.
Depth-first branch-and-bound search engine.
void createBranchers(Printer &p, AST::Node *ann, int seed, double decay, bool ignoreUnknown, std::ostream &err=std::cerr)
Create branchers corresponding to the solve item annotations.
Execution has resulted in failure.
Specification for Boolean variables.
Value description class for branching.
double threads(void) const
Node representing an atom
A lock as a scoped frontend for a mutex.
SharedHandle::Object * object(void) const
Access to the shared object.
int _optVar
Index of the variable to optimize.
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.
FZPrintingInspector(const Printer &p0)
Constructor.
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)
Simple propagation levels.
int getBoolVar(void)
Cast this node to a Boolean variable node.
The Gecode Interactive Search Tool.
virtual const char * what(void) const
Return information.
virtual void archive(Archive &e) const
Archive into e.
bool isSet(void)
Test if node is a set literal node.
void fail(void)
Fail space.
FznRnd * _random
Random number generator.
unsigned int size(void) const
Return size (cardinality) of set.
BoolVarArgs arg2boolvarargs(AST::Node *arg, int offset=0, int siv=-1)
Convert arg to BoolVarArgs.
IntValBranch INT_VAL_MIN(void)
Select smallest value.
const std::string & floatVarName(int i) const
std::string what(void) const
unsigned int size(I &i)
Size of all ranges of range iterator i.
void newFloatVar(FloatVarSpec *vs)
Create new float variable from specification.
static void explore(S *root, const FlatZincOptions &opt, Gist::Inspector *i, Gist::Comparator *c)
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.
IntVarBranch INT_VAR_RND(Rnd r)
Select random variable (uniform distribution, for tie breaking)
iterator begin(void)
Return an iterator at the beginning of the array.
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. ...
Iterator for the greatest lower bound ranges of a set variable.
Gecode::BoolVarArray bv_aux
The introduced Boolean variables.
bool clone
Whether engines create a clone when being initialized.
void print(std::ostream &out, const Gecode::IntVarArray &iv, const Gecode::BoolVarArray &bv, const Gecode::SetVarArray &sv, const Gecode::FloatVarArray &fv) const
FznRnd(unsigned int s=1)
Constructor.
Array * getArgs(unsigned int n)
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.
void addSetVarName(const std::string &n)
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...
unsigned int node(void) const
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.
bool isIntVar(void)
Test if node is an integer variable node.
const std::string & intVarName(int i) const
FloatVarBranch FLOAT_VAR_RND(Rnd r)
Select random variable (uniform distribution, for tie breaking)
Passing integer variables.
bool isBoolArray(AST::Node *b, int &singleInt)
Check if b is array of Booleans (or has a single integer)
std::vector< bool > bv_introduced
Indicates whether a Boolean variable is introduced by mzn2fzn.
SharedArray< int > IntSharedArray
Arrays of integers that can be shared among several element constraints.
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.
virtual bool slave(const MetaInfo &mi)
Slave function for restarts.
void init(void)
Initialize the implementation object.
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.
IntPropLevel
Propagation levels for integer propagators.
Cutoff generator for constant sequence.
AST::Array * args
Constraint arguments.
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.
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 postConstraints(std::vector< ConExpr *> &ces)
Post a constraint specified by ce.
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.
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.
Home operator()(Propagator &p)
Return a home for this space with the information that p is being rewritten.
void print(std::ostream &out, const Printer &p) const
Produce output on out using p.
virtual void archive(Archive &e) const
Archive into e.
Choice for performing commit
unsigned int fail(void) const
struct Gecode::Space::@55::@57 c
Data available only during copying.
bool hasAtom(const std::string &id)
Test if node has atom with id.
bool isFloatVar(void)
Test if node is a float variable node.
void flattenAnnotations(AST::Array *ann, std::vector< AST::Node *> &out)
Heap heap
The single global heap.
Iterator for the values in the greatest lower bound of a set variable.
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.
Domain propagation Preferences: prefer speed or memory.
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...
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.
virtual void inspect(const Space &node)
Use the print method of the template class S to print a space.
unsigned int c_d(void) const
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.
void solve(AST::Array *annotation)
Post the solve item.
unsigned int time(void) const
unsigned long int restart
Number of restarts.
AST::Array * solveAnnotations(void) const
Return the solve item annotations.
#define GECODE_HAS_FLOAT_VARS
TieBreak< FloatVarBranch > float_varsel
bool isArray(void)
Test if node is an array node.
bool interrupt(void) const
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 addBoolVarName(const std::string &n)
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.
Stop * stop
Stop object for stopping search.
class Gecode::Gist::Options::_I inspect
const std::string & setVarName(int i) const
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.
Gecode toplevel namespace
void addIntVarName(const std::string &n)
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.
unsigned int a_d(void) const
FZPrintingComparator(const Printer &p0)
Constructor.
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.
SetVarBranch SET_VAR_ACTIVITY_SIZE_MAX(double d, BranchTbl tbl)
Select variable with largest activity divided by domain size with decay factor d. ...
IntArgs arg2boolargs(AST::Node *arg, int offset=0)
Convert arg (array of Booleans) to IntArgs.
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.
void addFloatVarName(const std::string &n)
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.
friend FloatVal max(const FloatVal &x, const FloatVal &y)
iterator end(void)
Return an iterator past the end of the array.
struct Gecode::@554::NNF::@60::@61 b
For binary nodes (and, or, eqv)
void varValPrintF(const Space &home, const Brancher &b, unsigned int a, FloatVar, int i, const FloatNumBranch &nl, std::ostream &o)
friend FloatVal min(const FloatVal &x, const FloatVal &y)
Gecode::SetVarArray sv
The set variables.
Home class for posting propagators
double FloatNum
Floating point number base type.
Specification for integer variables.
void compare(Comparator *c)
Add comparator.
const std::string & boolVarName(int i) const
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.
virtual void finalize(void)
Finalize when Gist exits.
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.
Depth-first search engine.
Branching on the introduced variables.
const Val & some(void) const
IntVarBranch INT_VAR_SIZE_MAX(BranchTbl tbl)
Select variable with largest domain size.
IntSharedArray _lnsInitialSolution
Initial solution to start the LNS (or NULL for no LNS)
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.
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.