54 namespace Gecode {
namespace FlatZinc {
89 int_varsel(int_varsel0), int_valsel(int_valsel0),
90 bool_varsel(bool_varsel0), bool_valsel(bool_valsel0)
91 #ifdef GECODE_HAS_SET_VARS
92 , set_varsel(set_varsel0), set_valsel(set_valsel0)
94 #ifdef GECODE_HAS_FLOAT_VARS
95 , float_varsel(float_varsel0), float_valsel(float_valsel0)
100 :
Brancher(home, share, b), done(b.done) {}
111 virtual size_t size(
void)
const {
125 #ifdef GECODE_HAS_SET_VARS
129 #ifdef GECODE_HAS_FLOAT_VARS
137 if (done)
return false;
143 #ifdef GECODE_HAS_SET_VARS
147 #ifdef GECODE_HAS_FLOAT_VARS
161 #ifdef GECODE_HAS_SET_VARS
164 #ifdef GECODE_HAS_FLOAT_VARS
171 return new Choice(*
this,
false);
173 return new Choice(*
this,
true);
178 bool fail; e >> fail;
179 return new Choice(*
this, fail);
188 std::ostream& o)
const {
190 << (
static_cast<const Choice&
>(
c).fail ?
"fail" :
"ok")
215 bool_varsel, bool_valsel
216 #ifdef GECODE_HAS_SET_VARS
217 , set_varsel, set_valsel
219 #ifdef GECODE_HAS_FLOAT_VARS
220 , float_varsel, float_valsel
226 return sizeof(*this);
236 BI(
void) : r0(
""), r1(
""),
n(0) {}
237 BI(
const string& r00,
const string& r10,
const vector<string>& n0)
238 : r0(r00), r1(r10),
n(n0) {}
252 const vector<string>&
n) {
253 v.resize(
std::max(static_cast<unsigned int>(v.size()),bh.
id()+1));
254 v[bh.
id()] = BI(rel0,rel1,n);
258 int a,
int i,
int n, ostream& o)
const {
259 const BI&
bi = v[bh.
id()];
260 o << bi.n[
i] <<
" " << (a==0 ? bi.r0 : bi.r1) <<
" " << n;
262 #ifdef GECODE_HAS_FLOAT_VARS
265 const BI&
bi = v[bh.
id()];
267 << (((a == 0) == nl.
l) ?
"<=" :
">=") << nl.
n;
272 BranchInformation::BranchInformation(
void)
280 assert(
object() ==
false);
286 const std::string& rel0,
287 const std::string& rel1,
288 const std::vector<std::string>&
n) {
293 int n, std::ostream& o)
const {
296 #ifdef GECODE_HAS_FLOAT_VARS
306 Var,
int i,
const int&
n,
311 #ifdef GECODE_HAS_FLOAT_VARS
329 int* newdom =
heap.
alloc<
int>(
static_cast<unsigned long int>(sl->
s.size()));
330 for (
int i=sl->
s.size();
i--;)
331 newdom[
i] = sl->
s[
i];
332 IntSet ret(newdom, sl->
s.size());
333 heap.
free(newdom, static_cast<unsigned long int>(sl->
s.size()));
365 if (
AST::Atom* s = dynamic_cast<AST::Atom*>(ann)) {
366 if (s->id ==
"input_order")
368 if (s->id ==
"first_fail")
370 if (s->id ==
"anti_first_fail")
372 if (s->id ==
"smallest")
374 if (s->id ==
"largest")
376 if (s->id ==
"occurrence")
378 if (s->id ==
"max_regret")
380 if (s->id ==
"most_constrained")
383 if (s->id ==
"random") {
386 if (s->id ==
"afc_min")
388 if (s->id ==
"afc_max")
390 if (s->id ==
"afc_size_min")
392 if (s->id ==
"afc_size_max") {
395 if (s->id ==
"activity_min")
397 if (s->id ==
"activity_max")
399 if (s->id ==
"activity_size_min")
401 if (s->id ==
"activity_size_max")
404 std::cerr <<
"Warning, ignored search annotation: ";
405 ann->
print(std::cerr);
406 std::cerr << std::endl;
412 if (
AST::Atom* s = dynamic_cast<AST::Atom*>(ann)) {
413 if (s->id ==
"indomain_min") {
417 if (s->id ==
"indomain_max") {
421 if (s->id ==
"indomain_median") {
425 if (s->id ==
"indomain_split") {
429 if (s->id ==
"indomain_reverse_split") {
433 if (s->id ==
"indomain_random") {
437 if (s->id ==
"indomain") {
441 if (s->id ==
"indomain_middle") {
442 std::cerr <<
"Warning, replacing unsupported annotation "
443 <<
"indomain_middle with indomain_median" << std::endl;
447 if (s->id ==
"indomain_interval") {
448 std::cerr <<
"Warning, replacing unsupported annotation "
449 <<
"indomain_interval with indomain_split" << std::endl;
454 std::cerr <<
"Warning, ignored search annotation: ";
455 ann->
print(std::cerr);
456 std::cerr << std::endl;
462 if (
AST::Atom* s = dynamic_cast<AST::Atom*>(ann)) {
463 if (s->id ==
"indomain_min")
465 if (s->id ==
"indomain_max")
467 if (s->id ==
"indomain_median")
469 if (s->id ==
"indomain_random") {
473 std::cerr <<
"Warning, ignored search annotation: ";
474 ann->
print(std::cerr);
475 std::cerr << std::endl;
479 #ifdef GECODE_HAS_SET_VARS
481 if (
AST::Atom* s = dynamic_cast<AST::Atom*>(ann)) {
482 if (s->id ==
"input_order")
484 if (s->id ==
"first_fail")
486 if (s->id ==
"anti_first_fail")
488 if (s->id ==
"smallest")
490 if (s->id ==
"largest")
492 if (s->id ==
"afc_min")
494 if (s->id ==
"afc_max")
496 if (s->id ==
"afc_size_min")
498 if (s->id ==
"afc_size_max")
500 if (s->id ==
"activity_min")
502 if (s->id ==
"activity_max")
504 if (s->id ==
"activity_size_min")
506 if (s->id ==
"activity_size_max")
508 if (s->id ==
"random") {
512 std::cerr <<
"Warning, ignored search annotation: ";
513 ann->
print(std::cerr);
514 std::cerr << std::endl;
521 if (
AST::Atom* s = dynamic_cast<AST::Atom*>(ann)) {
522 if (s->id ==
"indomain_min") {
523 r0 =
"in"; r1 =
"not in";
526 if (s->id ==
"indomain_max") {
527 r0 =
"in"; r1 =
"not in";
530 if (s->id ==
"outdomain_min") {
531 r1 =
"in"; r0 =
"not in";
534 if (s->id ==
"outdomain_max") {
535 r1 =
"in"; r0 =
"not in";
539 std::cerr <<
"Warning, ignored search annotation: ";
540 ann->
print(std::cerr);
541 std::cerr << std::endl;
542 r0 =
"in"; r1 =
"not in";
547 #ifdef GECODE_HAS_FLOAT_VARS
550 if (
AST::Atom* s = dynamic_cast<AST::Atom*>(ann)) {
551 if (s->id ==
"input_order")
553 if (s->id ==
"first_fail")
555 if (s->id ==
"anti_first_fail")
557 if (s->id ==
"smallest")
559 if (s->id ==
"largest")
561 if (s->id ==
"occurrence")
563 if (s->id ==
"most_constrained")
566 if (s->id ==
"random") {
569 if (s->id ==
"afc_min")
571 if (s->id ==
"afc_max")
573 if (s->id ==
"afc_size_min")
575 if (s->id ==
"afc_size_max")
577 if (s->id ==
"activity_min")
579 if (s->id ==
"activity_max")
581 if (s->id ==
"activity_size_min")
583 if (s->id ==
"activity_size_max")
586 std::cerr <<
"Warning, ignored search annotation: ";
587 ann->
print(std::cerr);
588 std::cerr << std::endl;
593 if (
AST::Atom* s = dynamic_cast<AST::Atom*>(ann)) {
594 if (s->id ==
"indomain_split") {
598 if (s->id ==
"indomain_reverse_split") {
603 std::cerr <<
"Warning, ignored search annotation: ";
604 ann->
print(std::cerr);
605 std::cerr << std::endl;
613 :
Space(share, f), _solveAnnotations(NULL), iv_boolalias(NULL),
614 needAuxVars(f.needAuxVars) {
627 iva[iva.
size()-1].update(*
this, share, f.
iv_aux[
i]);
640 bva[bva.
size()-1].update(*
this, share, f.
bv_aux[
i]);
646 #ifdef GECODE_HAS_SET_VARS
654 sva[sva.
size()-1].update(*
this, share, f.
sv_aux[
i]);
660 #ifdef GECODE_HAS_FLOAT_VARS
668 fva[fva.
size()-1].update(*
this, share, f.
fv_aux[
i]);
677 : intVarCount(-1), boolVarCount(-1), floatVarCount(-1), setVarCount(-1),
678 _optVar(-1), _optVarIsInt(true),
679 _solveAnnotations(NULL), needAuxVars(true) {
685 int setVars,
int floatVars) {
696 #ifdef GECODE_HAS_SET_VARS
701 #ifdef GECODE_HAS_FLOAT_VARS
746 #ifdef GECODE_HAS_SET_VARS
758 int* is =
heap.
alloc<
int>(
static_cast<unsigned long int>(vsv->s.size()));
759 for (
int i=vsv->s.
size();
i--; )
762 heap.
free(is,static_cast<unsigned long int>(vsv->s.size()));
771 int* is =
heap.
alloc<
int>(
static_cast<unsigned long int>(vsv->
s.size()));
772 for (
int i=vsv->
s.size();
i--; )
775 heap.
free(is,static_cast<unsigned long int>(vsv->
s.size()));
793 #ifdef GECODE_HAS_FLOAT_VARS
835 for (
unsigned int i=0;
i<ann->
a.size();
i++) {
836 if (ann->
a[
i]->isCall(
"seq_search")) {
841 out.push_back(c->
args);
843 out.push_back(ann->
a[
i]);
852 Rnd rnd(static_cast<unsigned int>(seed));
857 #ifdef GECODE_HAS_SET_VARS
861 #ifdef GECODE_HAS_FLOAT_VARS
866 std::vector<bool> iv_searched(
iv.
size());
867 for (
unsigned int i=
iv.
size();
i--;)
868 iv_searched[
i] =
false;
869 std::vector<bool> bv_searched(
bv.
size());
870 for (
unsigned int i=
bv.
size();
i--;)
871 bv_searched[
i] =
false;
872 #ifdef GECODE_HAS_SET_VARS
873 std::vector<bool> sv_searched(
sv.
size());
874 for (
unsigned int i=
sv.
size();
i--;)
875 sv_searched[
i] =
false;
877 #ifdef GECODE_HAS_FLOAT_VARS
878 std::vector<bool> fv_searched(
fv.
size());
879 for (
unsigned int i=
fv.
size();
i--;)
880 fv_searched[
i] =
false;
884 std::vector<AST::Node*> flatAnn;
888 flatAnn.push_back(ann);
891 for (
unsigned int i=0;
i<flatAnn.
size();
i++) {
892 if (flatAnn[
i]->isCall(
"gecode_search")) {
894 branchWithPlugin(c->
args);
895 }
else if (flatAnn[
i]->isCall(
"int_search")) {
899 int k=vars->
a.size();
900 for (
int i=vars->
a.size();
i--;)
901 if (vars->
a[
i]->isInt())
904 vector<string> names;
906 for (
unsigned int i=0;
i<vars->
a.size();
i++) {
907 if (vars->
a[
i]->isInt())
909 va[k++] =
iv[vars->
a[
i]->getIntVar()];
910 iv_searched[vars->
a[
i]->getIntVar()] =
true;
911 names.push_back(vars->
a[
i]->getVarName());
918 &varValPrint<IntVar>);
920 }
else if (flatAnn[
i]->isCall(
"int_assign")) {
924 int k=vars->
a.size();
925 for (
int i=vars->
a.size();
i--;)
926 if (vars->
a[
i]->isInt())
930 for (
unsigned int i=0;
i<vars->
a.size();
i++) {
931 if (vars->
a[
i]->isInt())
933 va[k++] =
iv[vars->
a[
i]->getIntVar()];
934 iv_searched[vars->
a[
i]->getIntVar()] =
true;
937 &varValPrint<IntVar>);
938 }
else if (flatAnn[
i]->isCall(
"bool_search")) {
942 int k=vars->
a.size();
943 for (
int i=vars->
a.size();
i--;)
944 if (vars->
a[
i]->isBool())
948 vector<string> names;
949 for (
unsigned int i=0;
i<vars->
a.size();
i++) {
950 if (vars->
a[
i]->isBool())
952 va[k++] =
bv[vars->
a[
i]->getBoolVar()];
953 bv_searched[vars->
a[
i]->getBoolVar()] =
true;
954 names.push_back(vars->
a[
i]->getVarName());
961 &varValPrint<BoolVar>);
963 }
else if (flatAnn[
i]->isCall(
"int_default_search")) {
969 }
else if (flatAnn[
i]->isCall(
"bool_default_search")) {
975 }
else if (flatAnn[
i]->isCall(
"set_search")) {
976 #ifdef GECODE_HAS_SET_VARS
980 int k=vars->
a.size();
981 for (
int i=vars->
a.size();
i--;)
982 if (vars->
a[
i]->isSet())
986 vector<string> names;
987 for (
unsigned int i=0;
i<vars->
a.size();
i++) {
988 if (vars->
a[
i]->isSet())
990 va[k++] =
sv[vars->
a[
i]->getSetVar()];
991 sv_searched[vars->
a[
i]->getSetVar()] =
true;
992 names.push_back(vars->
a[
i]->getVarName());
999 &varValPrint<SetVar>);
1002 if (!ignoreUnknown) {
1003 err <<
"Warning, ignored search annotation: ";
1004 flatAnn[
i]->print(err);
1008 }
else if (flatAnn[
i]->isCall(
"set_default_search")) {
1009 #ifdef GECODE_HAS_SET_VARS
1016 if (!ignoreUnknown) {
1017 err <<
"Warning, ignored search annotation: ";
1018 flatAnn[
i]->print(err);
1022 }
else if (flatAnn[
i]->isCall(
"float_default_search")) {
1023 #ifdef GECODE_HAS_FLOAT_VARS
1030 if (!ignoreUnknown) {
1031 err <<
"Warning, ignored search annotation: ";
1032 flatAnn[
i]->print(err);
1036 }
else if (flatAnn[
i]->isCall(
"float_search")) {
1037 #ifdef GECODE_HAS_FLOAT_VARS
1041 int k=vars->
a.size();
1042 for (
int i=vars->
a.size();
i--;)
1043 if (vars->
a[
i]->isFloat())
1047 vector<string> names;
1048 for (
unsigned int i=0;
i<vars->
a.size();
i++) {
1049 if (vars->
a[
i]->isFloat())
1051 va[k++] =
fv[vars->
a[
i]->getFloatVar()];
1052 fv_searched[vars->
a[
i]->getFloatVar()] =
true;
1053 names.push_back(vars->
a[
i]->getVarName());
1063 if (!ignoreUnknown) {
1064 err <<
"Warning, ignored search annotation: ";
1065 flatAnn[
i]->print(err);
1070 if (!ignoreUnknown) {
1071 err <<
"Warning, ignored search annotation: ";
1072 flatAnn[
i]->print(err);
1082 if (iv_searched[
i]) {
1094 for (
int i=
iv.
size(), j=0, k=0;
i--;) {
1099 iv_tmp[j++] =
iv[
i];
1102 iv_sol[k++] =
iv[
i];
1110 if (bv_searched[
i]) {
1122 for (
int i=
bv.
size(), j=0, k=0;
i--;) {
1127 bv_tmp[j++] =
bv[
i];
1130 bv_sol[k++] =
bv[
i];
1134 if (iv_sol.
size() > 0)
1135 branch(*
this, iv_sol, def_int_varsel, def_int_valsel);
1136 if (bv_sol.
size() > 0)
1137 branch(*
this, bv_sol, def_bool_varsel, def_bool_valsel);
1138 #ifdef GECODE_HAS_FLOAT_VARS
1143 if (fv_searched[
i]) {
1155 for (
int i=
fv.
size(), j=0, k=0;
i--;) {
1160 fv_tmp[j++] =
fv[
i];
1163 fv_sol[k++] =
fv[
i];
1167 if (fv_sol.
size() > 0)
1168 branch(*
this, fv_sol, def_float_varsel, def_float_valsel);
1170 #ifdef GECODE_HAS_SET_VARS
1175 if (sv_searched[
i]) {
1187 for (
int i=
sv.
size(), j=0, k=0;
i--;) {
1192 sv_tmp[j++] =
sv[
i];
1195 sv_sol[k++] =
sv[
i];
1199 if (sv_sol.
size() > 0)
1200 branch(*
this, sv_sol, def_set_varsel, def_set_valsel);
1205 #ifdef GECODE_HAS_SET_VARS
1209 #ifdef GECODE_HAS_FLOAT_VARS
1215 def_bool_varsel, def_bool_valsel
1217 , def_set_varsel, def_set_valsel
1220 , def_float_varsel, def_float_valsel
1256 args->
a[3] =
new AST::Atom(
"indomain_split");
1258 c =
new AST::Call(
"float_search", args);
1263 ann->
a.push_back(c);
1286 args->
a[3] =
new AST::Atom(
"indomain_split_reverse");
1288 c =
new AST::Call(
"float_search", args);
1293 ann->
a.push_back(c);
1301 #ifdef GECODE_HAS_GIST
1306 template<
class Engine>
1311 template<
typename S>
1312 class GistEngine<
DFS<S> > {
1314 static void explore(S* root,
const FlatZincOptions&
opt,
1317 o.
c_d = opt.c_d(); o.
a_d = opt.a_d();
1325 template<
typename S>
1326 class GistEngine<BAB<S> > {
1328 static void explore(S* root,
const FlatZincOptions& opt,
1329 Gist::Inspector* i, Gist::Comparator* c) {
1331 o.
c_d = opt.c_d(); o.
a_d = opt.a_d();
1340 class FZPrintingInspector
1346 FZPrintingInspector(
const Printer& p0);
1348 virtual void inspect(
const Space& node);
1350 virtual void finalize(
void);
1354 FZPrintingInspector<S>::FZPrintingInspector(
const Printer& p0)
1355 : TextOutput(
"Gecode/FlatZinc"),
p(p0) {}
1359 FZPrintingInspector<S>::inspect(
const Space& node) {
1361 dynamic_cast<const S&
>(node).
print(getStream(),
p);
1362 getStream() << std::endl;
1367 FZPrintingInspector<S>::finalize(
void) {
1372 class FZPrintingComparator
1378 FZPrintingComparator(
const Printer& p0);
1381 virtual void compare(
const Space& s0,
const Space& s1);
1385 FZPrintingComparator<S>::FZPrintingComparator(
const Printer& p0)
1386 :
Gecode::Gist::VarComparator<S>(
"Gecode/FlatZinc"),
p(p0) {}
1393 dynamic_cast<const S&
>(s0).
compare(dynamic_cast<const S&>(s1),
1394 this->getStream(),
p);
1395 }
catch (Exception& e) {
1396 this->getStream() <<
"Exception: " << e.what();
1398 this->getStream() << std::endl;
1404 template<
template<
class>
class Engine>
1406 FlatZincSpace::runEngine(std::ostream& out,
const Printer&
p,
1407 const FlatZincOptions& opt, Support::Timer& t_total) {
1409 runMeta<Engine,Driver::EngineToMeta>(out,
p,
opt,t_total);
1411 runMeta<Engine,RBS>(out,
p,
opt,t_total);
1415 template<
template<
class>
class Engine,
1416 template<
template<
class>
class,
class>
class Meta>
1418 FlatZincSpace::runMeta(std::ostream& out, const Printer& p,
1419 const FlatZincOptions& opt, Support::Timer& t_total) {
1420 #ifdef GECODE_HAS_GIST
1422 FZPrintingInspector<FlatZincSpace> pi(p);
1423 FZPrintingComparator<FlatZincSpace> pc(p);
1424 (void) GistEngine<Engine<FlatZincSpace> >::
explore(
this,opt,&pi,&pc);
1428 StatusStatistics sstat;
1429 unsigned int n_p = 0;
1430 Support::Timer t_solve;
1433 n_p = propagators();
1440 o.threads = opt.threads();
1441 o.nogoods_limit = opt.nogoods() ? opt.nogoods_limit() : 0;
1443 if (opt.interrupt())
1445 Meta<Engine,FlatZincSpace> se(
this,o);
1446 int noOfSolutions = _method == SAT ? opt.solutions() : 0;
1447 bool printAll = _method == SAT || opt.allSolutions();
1448 int findSol = noOfSolutions;
1449 FlatZincSpace* sol = NULL;
1450 while (FlatZincSpace* next_sol = se.next()) {
1455 out <<
"----------" << std::endl;
1460 if (sol && !printAll) {
1462 out <<
"----------" << std::endl;
1464 if (!se.stopped()) {
1466 out <<
"==========" << endl;
1468 out <<
"=====UNSATISFIABLE=====" << endl;
1471 out <<
"=====UNKNOWN=====" << endl;
1475 if (opt.interrupt())
1483 <<
"%% solvetime: ";
1487 <<
std::abs(noOfSolutions - findSol) << endl
1489 << (intVarCount + boolVarCount + setVarCount) << endl
1490 <<
"%% propagators: " << n_p << endl
1491 <<
"%% propagations: " << sstat.propagate+stat.
propagate << endl
1492 <<
"%% nodes: " << stat.
node << endl
1493 <<
"%% failures: " << stat.
fail << endl
1494 <<
"%% restarts: " << stat.
restart << endl
1495 <<
"%% peak depth: " << stat.
depth << endl
1501 #ifdef GECODE_HAS_QT
1503 FlatZincSpace::branchWithPlugin(AST::Node* ann) {
1504 if (AST::Call* c = dynamic_cast<AST::Call*>(ann)) {
1505 QString pluginName(c->id.c_str());
1506 if (QLibrary::isLibrary(pluginName+
".dll")) {
1507 pluginName +=
".dll";
1508 }
else if (QLibrary::isLibrary(pluginName+
".dylib")) {
1509 pluginName =
"lib" + pluginName +
".dylib";
1510 }
else if (QLibrary::isLibrary(pluginName+
".so")) {
1512 pluginName =
"lib" + pluginName +
".so";
1514 QPluginLoader pl(pluginName);
1515 QObject* plugin_o = pl.instance();
1517 throw FlatZinc::Error(
"FlatZinc",
1518 "Error loading plugin "+pluginName.toStdString()+
1519 ": "+pl.errorString().toStdString());
1521 BranchPlugin* pb = qobject_cast<BranchPlugin*>(plugin_o);
1523 throw FlatZinc::Error(
"FlatZinc",
1524 "Error loading plugin "+pluginName.toStdString()+
1525 ": does not contain valid PluginBrancher");
1527 pb->branch(*
this, c);
1532 FlatZincSpace::branchWithPlugin(AST::Node*) {
1533 throw FlatZinc::Error(
"FlatZinc",
1534 "Branching with plugins not supported (requires Qt support)");
1544 runEngine<BAB>(out,
p,
opt,t_total);
1547 runEngine<DFS>(out,
p,
opt,t_total);
1557 static_cast<const FlatZincSpace*>(&s)->
iv[_optVar].val());
1560 static_cast<const FlatZincSpace*>(&s)->
iv[_optVar].val());
1562 #ifdef GECODE_HAS_FLOAT_VARS
1565 static_cast<const FlatZincSpace*>(&s)->
fv[_optVar].val());
1568 static_cast<const FlatZincSpace*>(&s)->
fv[_optVar].val());
1607 (void) s; (void) out;
1608 #ifdef GECODE_HAS_GIST
1610 for (
int i = 0; i <
iv.
size(); ++
i) {
1611 std::stringstream ss;
1612 ss <<
"iv[" << i <<
"]";
1615 if (result.length() > 0) out << result << std::endl;
1617 for (
int i = 0; i <
bv.
size(); ++
i) {
1618 std::stringstream ss;
1619 ss <<
"bv[" << i <<
"]";
1622 if (result.length() > 0) out << result << std::endl;
1624 #ifdef GECODE_HAS_SET_VARS
1625 for (
int i = 0; i <
sv.
size(); ++
i) {
1626 std::stringstream ss;
1627 ss <<
"sv[" << i <<
"]";
1630 if (result.length() > 0) out << result << std::endl;
1633 #ifdef GECODE_HAS_FLOAT_VARS
1634 for (
int i = 0; i <
fv.
size(); ++
i) {
1635 std::stringstream ss;
1636 ss <<
"fv[" << i <<
"]";
1639 if (result.length() > 0) out << result << std::endl;
1674 for (
int i=offset; i--;)
1676 for (
int i=a->
a.size(); i--;)
1677 ia[i+offset] = a->
a[i]->getInt();
1684 for (
int i=offset; i--;)
1686 for (
int i=a->
a.size(); i--;)
1687 ia[i+offset] = a->
a[i]->getBool();
1698 int* is = re.
alloc<
int>(
static_cast<unsigned long int>(sl->
s.size()));
1699 for (
int i=sl->
s.size(); i--; )
1708 if (a->
a.size() == 0) {
1713 for (
int i=offset; i--;)
1715 for (
int i=a->
a.size(); i--;) {
1723 if (a->
a.size() == 0) {
1728 for (
int i=offset; i--;)
1729 ia[i] =
IntVar(*
this, 0, 0);
1730 for (
int i=a->
a.size(); i--;) {
1731 if (a->
a[i]->isIntVar()) {
1732 ia[i+offset] =
iv[a->
a[
i]->getIntVar()];
1734 int value = a->
a[
i]->getInt();
1744 if (a->
a.size() == 0) {
1749 for (
int i=offset; i--;)
1751 for (
int i=0; i<static_cast<int>(a->
a.size()); i++) {
1754 if (a->
a[i]->isBool()) {
1755 bool value = a->
a[
i]->getBool();
1758 }
else if (a->
a[i]->isIntVar() &&
1762 ia[offset++] =
bv[a->
a[
i]->getBoolVar()];
1792 if (a->
a.size() == 0)
1794 for (
int i=a->
a.size(); i--;) {
1795 if (a->
a[i]->isBoolVar() || a->
a[
i]->isBool()) {
1796 }
else if (a->
a[i]->isIntVar()) {
1798 if (singleInt != -1) {
1807 return singleInt==-1 || a->
a.size() > 1;
1809 #ifdef GECODE_HAS_SET_VARS
1815 x0 =
SetVar(*
this, d, d);
1826 for (
int i=offset; i--;) {
1830 for (
int i=a->
a.size(); i--;) {
1836 #ifdef GECODE_HAS_FLOAT_VARS
1841 for (
int i=offset; i--;)
1843 for (
int i=a->
a.size(); i--;)
1844 fa[i+offset] = a->
a[i]->getFloat();
1850 if (a->
a.size() == 0) {
1855 for (
int i=offset; i--;)
1857 for (
int i=a->
a.size(); i--;) {
1858 if (a->
a[i]->isFloatVar()) {
1859 fa[i+offset] =
fv[a->
a[
i]->getFloatVar()];
1861 double value = a->
a[
i]->getFloat();
1902 Printer::printElem(std::ostream& out,
1922 }
else if (bv[ai->
getBoolVar()].max() == 0) {
1925 out <<
"false..true";
1927 #ifdef GECODE_HAS_SET_VARS
1933 SetVarGlbRanges svr(sv[ai->
getSetVar()]);
1938 int min = svr.min();
1939 int max = svr.max();
1942 SetVarGlbValues svv(sv[ai->
getSetVar()]);
1946 for (; svv(); ++svv)
1947 out <<
", " << svv.val();
1950 out << min <<
".." <<
max;
1953 #ifdef GECODE_HAS_FLOAT_VARS
1964 std::ostringstream oss;
1966 oss << std::setprecision(std::numeric_limits<double>::digits10);
1968 if (oss.str().find(
".") == std::string::npos)
1975 }
else if (ai->
isBool()) {
1976 out << (ai->
getBool() ?
"true" :
"false");
1977 }
else if (ai->
isSet()) {
1978 AST::SetLit* s = ai->
getSet();
1980 out << s->
min <<
".." << s->max;
1983 for (
unsigned int i=0; i<s->s.size(); i++) {
1984 out << s->s[
i] << (i < s->s.size()-1 ?
", " :
"}");
1989 for (
unsigned int i=0; i<s.size(); i++) {
1990 if (s[i] ==
'\\' && i<s.size()-1) {
1992 case 'n': out <<
"\n";
break;
1993 case '\\': out <<
"\\";
break;
1994 case 't': out <<
"\t";
break;
1995 default: out <<
"\\" << s[i+1];
2006 Printer::printElemDiff(std::ostream& out,
2012 #ifdef GECODE_HAS_SET_VARS
2016 #ifdef GECODE_HAS_FLOAT_VARS
2021 #ifdef GECODE_HAS_GIST
2026 }
else if (ai->isIntVar()) {
2028 iv2[ai->getIntVar()]));
2029 if (res.length() > 0) {
2033 out << iv1[ai->getIntVar()];
2035 }
else if (ai->isBoolVar()) {
2037 bv2[ai->getBoolVar()]));
2038 if (res.length() > 0) {
2042 out << bv1[ai->getBoolVar()];
2044 #ifdef GECODE_HAS_SET_VARS
2045 }
else if (ai->isSetVar()) {
2047 sv2[ai->getSetVar()]));
2048 if (res.length() > 0) {
2052 out << sv1[ai->getSetVar()];
2055 #ifdef GECODE_HAS_FLOAT_VARS
2056 }
else if (ai->isFloatVar()) {
2058 fv2[ai->getFloatVar()]));
2059 if (res.length() > 0) {
2063 out << fv1[ai->getFloatVar()];
2066 }
else if (ai->isBool()) {
2067 out << (ai->getBool() ?
"true" :
"false");
2068 }
else if (ai->isSet()) {
2069 AST::SetLit* s = ai->getSet();
2071 out << s->min <<
".." << s->max;
2074 for (
unsigned int i=0; i<s->s.size(); i++) {
2075 out << s->s[
i] << (i < s->s.size()-1 ?
", " :
"}");
2078 }
else if (ai->isString()) {
2079 std::string s = ai->getString();
2080 for (
unsigned int i=0; i<s.size(); i++) {
2081 if (s[i] ==
'\\' && i<s.size()-1) {
2083 case 'n': out <<
"\n";
break;
2084 case '\\': out <<
"\\";
break;
2085 case 't': out <<
"\t";
break;
2086 default: out <<
"\\" << s[i+1];
2101 #ifdef GECODE_HAS_SET_VARS
2105 #ifdef GECODE_HAS_FLOAT_VARS
2110 if (_output == NULL)
2112 for (
unsigned int i=0; i< _output->
a.size(); i++) {
2116 int size = aia->
a.size();
2118 for (
int j=0; j<
size; j++) {
2119 printElem(out,aia->
a[j],iv,bv
2120 #ifdef GECODE_HAS_SET_VARS
2123 #ifdef GECODE_HAS_FLOAT_VARS
2132 printElem(out,ai,iv,bv
2133 #ifdef GECODE_HAS_SET_VARS
2136 #ifdef GECODE_HAS_FLOAT_VARS
2150 #ifdef GECODE_HAS_SET_VARS
2155 #ifdef GECODE_HAS_FLOAT_VARS
2161 if (_output == NULL)
2163 for (
unsigned int i=0; i< _output->
a.size(); i++) {
2167 int size = aia->
a.size();
2169 for (
int j=0; j<
size; j++) {
2170 printElemDiff(out,aia->
a[j],iv1,iv2,bv1,bv2
2171 #ifdef GECODE_HAS_SET_VARS
2174 #ifdef GECODE_HAS_FLOAT_VARS
2183 printElemDiff(out,ai,iv1,iv2,bv1,bv2
2184 #ifdef GECODE_HAS_SET_VARS
2187 #ifdef GECODE_HAS_FLOAT_VARS
2197 std::map<int,int>& iv, std::map<int,int>& bv,
2198 std::map<int,int>& sv, std::map<int,int>& fv) {
2201 if (iv.find(x->
i) == iv.end()) {
2202 int newi = iv.size();
2208 if (bv.find(x->
i) == bv.end()) {
2209 int newi = bv.size();
2215 if (sv.find(x->
i) == sv.end()) {
2216 int newi = sv.size();
2222 if (fv.find(x->
i) == fv.end()) {
2223 int newi = fv.size();
2232 int& optVar,
bool optVarIsInt,
2235 #ifdef GECODE_HAS_SET_VARS
2239 #ifdef GECODE_HAS_FLOAT_VARS
2244 if (_output == NULL) {
2245 if (optVarIsInt && optVar != -1) {
2254 #ifdef GECODE_HAS_SET_VARS
2257 #ifdef GECODE_HAS_FLOAT_VARS
2258 if (!optVarIsInt && optVar != -1) {
2269 std::map<int,int> iv_new;
2270 std::map<int,int> bv_new;
2271 std::map<int,int> sv_new;
2272 std::map<int,int> fv_new;
2282 for (
unsigned int i=0; i< _output->
a.size(); i++) {
2286 for (
unsigned int j=0; j<aia->
a.size(); j++) {
2295 for (map<int,int>::iterator i=iv_new.begin(); i != iv_new.end(); ++
i) {
2296 iva[(*i).second] = iv[(*i).first];
2301 for (map<int,int>::iterator i=bv_new.begin(); i != bv_new.end(); ++
i) {
2302 bva[(*i).second] = bv[(*i).first];
2306 #ifdef GECODE_HAS_SET_VARS
2308 for (map<int,int>::iterator i=sv_new.begin(); i != sv_new.end(); ++
i) {
2309 sva[(*i).second] = sv[(*i).first];
2314 #ifdef GECODE_HAS_FLOAT_VARS
2316 for (map<int,int>::iterator i=fv_new.begin(); i != fv_new.end(); ++
i) {
2317 fva[(*i).second] = fv[(*i).first];
void click(Inspector *i)
Add inspector that reacts on node double clicks.
SetVarBranch SET_VAR_SIZE_MIN(BranchTbl tbl)
Select variable with smallest unknown set.
void shrinkArrays(Printer &p)
Remove all variables not needed for output.
static void post(Home home, TieBreak< IntVarBranch > int_varsel, IntValBranch int_valsel, TieBreak< IntVarBranch > bool_varsel, IntValBranch bool_valsel, SetVarBranch set_varsel, SetValBranch set_valsel, TieBreak< FloatVarBranch > float_varsel, FloatValBranch float_valsel)
Post brancher.
unsigned int a_d
Create a clone during recomputation if distance is greater than a_d (adaptive distance) ...
Which values to select for branching first.
Gecode::SetVarArray sv_aux
The introduced set variables.
SetVarBranch SET_VAR_AFC_MIN(double d, BranchTbl tbl)
Select variable with smallest accumulated failure count with decay factor d.
void postConstraint(const ConExpr &ce, AST::Node *annotation)
Post a constraint specified by ce.
int floatVarCount
Number of float variables.
void varValPrintF(const Space &home, const BrancherHandle &bh, unsigned int a, FloatVar, int i, const FloatNumBranch &nl, std::ostream &o)
Option< AST::SetLit * > domain
Options for running FlatZinc models
FloatVarBranch FLOAT_VAR_DEGREE_MAX(BranchTbl tbl)
Select variable with largest degree.
virtual Choice * choice(Space &home)
Return choice.
IntVarBranch INT_VAR_NONE(void)
Select first unassigned variable.
Combine variable selection criteria for tie-breaking.
IntSet vs2is(IntVarSpec *vs)
Which values to select for branching first.
void printDiff(std::ostream &out, const Gecode::IntVarArray &iv1, const Gecode::IntVarArray &iv2, const Gecode::BoolVarArray &bv1, const Gecode::BoolVarArray &bv2, const Gecode::SetVarArray &sv1, const Gecode::SetVarArray &sv2, const Gecode::FloatVarArray &fv1, const Gecode::FloatVarArray &fv2) const
IntConLevel
Consistency levels for integer propagators.
IntArgs arg2intargs(AST::Node *arg, int offset=0)
Convert arg (array of integers) to IntArgs.
FloatValBranch FLOAT_VAL_SPLIT_MAX(void)
Select values greater than mean of smallest and largest value.
SetVarBranch SET_VAR_NONE(void)
Select first unassigned variable.
void createBranchers(AST::Node *ann, int seed, double decay, bool ignoreUnknown, std::ostream &err=std::cerr)
Create branchers corresponding to the solve item annotations.
std::string what(void) const
const int min
Smallest allowed integer in integer set.
FloatVarArgs arg2floatvarargs(AST::Node *arg, int offset=0)
Convert n to FloatVarArgs.
bool isBool(void)
Test if node is a Boolean node.
virtual Gecode::Space * copy(bool share)
Copy function.
std::vector< bool > sv_introduced
Indicates whether a set variable is introduced by mzn2fzn.
bool getBool(void)
Cast this node to a Boolean node.
const FloatNum max
Largest allowed float value.
#define GECODE_HAS_SET_VARS
Gecode::BoolVarArray bv
The Boolean variables.
void put(unsigned int i)
Add i to the contents.
int size(void) const
Return size of array (number of elements)
Meth _method
Whether to solve as satisfaction or optimization problem.
unsigned int c_d
Create a clone after every c_d commits (commit distance)
Space * clone(bool share=true, CloneStatistics &stat=unused_clone) const
Clone space.
T * alloc(long unsigned int n)
Allocate block of n objects of type T from region.
SetValBranch ann2svalsel(AST::Node *ann, std::string r0, std::string r1, Rnd rnd)
Which values to select for branching first.
SetLit * getSet(void)
Cast this node to a set literal node.
void newIntVar(IntVarSpec *vs)
Create new integer variable from specification.
Abstract base class for comparators.
Call * getCall(void)
Return function call.
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Value propagation or consistency (naive)
int getFloatVar(void)
Cast this node to a Float variable node.
Gecode::IntVarArray iv
The integer variables.
SetVarBranch SET_VAR_ACTIVITY_MIN(double d, BranchTbl tbl)
Select variable with lowest activity with decay factor d.
void abs(Home home, FloatVar x0, FloatVar x1)
Post propagator for .
void stop(Support::Timer &timer, std::ostream &os)
Get time since start of timer and print user friendly time information.
IntAssign INT_ASSIGN_MED(void)
Select greatest value not greater than the median.
Specification for set variables.
BranchInformation branchInfo
Information for printing branches.
int boolVarCount
Number of Boolean variables.
SetValBranch SET_VAL_MIN_INC(void)
Include smallest element.
SetVarBranch SET_VAR_ACTIVITY_SIZE_MIN(double d, BranchTbl tbl)
Select variable with smallest activity divided by domain size with decay factor d.
void update(Space &, bool share, VarArray< Var > &a)
Update array to be a clone of array a.
virtual const char * what(void) const
Return information.
void dom(Home home, FloatVar x, FloatVal n)
Propagates .
IntVarBranch INT_VAR_SIZE_MIN(BranchTbl tbl)
Select variable with smallest domain size.
void minimize(int var, bool isInt, AST::Array *annotation)
Post that integer variable var should be minimized.
IntVarBranch INT_VAR_MIN_MIN(BranchTbl tbl)
Select variable with smallest min.
unsigned long int fail
Number of failed nodes in search tree.
const Val & some(void) const
bool isSetVar(void)
Test if node is a set variable node.
bool isBoolVar(void)
Test if node is a Boolean variable node.
void compare(const Space &s, std::ostream &out) const
Compare this space with space s and print the differences on out.
unsigned long int depth
Maximum depth of search stack.
TieBreak< IntVarBranch > ann2ivarsel(AST::Node *ann, Rnd rnd, double decay)
FloatVarBranch FLOAT_VAR_AFC_MIN(double d, BranchTbl tbl)
Select variable with smallest accumulated failure count with decay factor d.
FloatValBranch ann2fvalsel(AST::Node *ann, std::string r0, std::string r1)
FloatVarBranch FLOAT_VAR_ACTIVITY_SIZE_MAX(double d, BranchTbl tbl)
Select variable with largest activity divided by domain size with decay factor d. ...
IntVarBranch INT_VAR_ACTIVITY_MAX(double d, BranchTbl tbl)
Select variable with highest activity with decay factor d.
int vs2bsh(BoolVarSpec *bs)
void init(int intVars, int boolVars, int setVars, int floatVars)
Initialize space with given number of variables.
AuxVarBrancher(Space &home, bool share, AuxVarBrancher &b)
Copy constructor.
FloatVarBranch FLOAT_VAR_ACTIVITY_MAX(double d, BranchTbl tbl)
Select variable with highest activity with decay factor d.
unsigned long int propagate
Number of propagator executions.
Search::Cutoff * createCutoff(const Options &o)
Create cutoff object from options.
const int max
Largest allowed integer in integer set.
Array * getArray(void)
Cast this node to an array node.
const int max
Largest allowed integer value.
int vs2bsl(BoolVarSpec *bs)
Abstract base class for inspectors.
FlatZincSpace(void)
Construct empty space.
FloatVarBranch FLOAT_VAR_NONE(void)
Select first unassigned variable.
const int min
Smallest allowed integer value.
IntVarBranch INT_VAR_REGRET_MIN_MAX(BranchTbl tbl)
Select variable with largest min-regret.
Base-class for both propagators and branchers.
SetVarBranch SET_VAR_SIZE_MAX(BranchTbl tbl)
Select variable with largest unknown set.
IntConLevel ann2icl(AST::Node *ann)
Convert ann to IntConLevel.
void newSetVar(SetVarSpec *vs)
Create new set variable from specification.
IntAssign INT_ASSIGN_MIN(void)
Select smallest value.
IntValBranch INT_VAL_RND(Rnd r)
Select random value.
virtual Choice * choice(const Space &, Archive &e)
Return choice.
Heap heap
The single global heap.
std::vector< bool > iv_introduced
Indicates whether an integer variable is introduced by mzn2fzn.
TieBreak< IntVarBranch > bool_varsel
unsigned int id(void) const
Return brancher id.
void newBoolVar(BoolVarSpec *vs)
Create new Boolean variable from specification.
bool alias
Whether the variable aliases another variable.
SetVarBranch ann2svarsel(AST::Node *ann, Rnd rnd, double decay)
void post(FlatZincSpace &s, const ConExpr &ce, AST::Node *ann)
Post constraint specified by ce.
SetVar arg2SetVar(AST::Node *n)
Convert n to SetVar.
int optVar(void) const
Return index of variable used for optimization.
int getSetVar(void)
Cast this node to a set variable node.
double getFloat(void)
Cast this node to a Float node.
Gecode::FloatVal c(-8, 8)
void print(std::ostream &out, const Gecode::IntVarArray &iv, const Gecode::BoolVarArray &bv, const Gecode::SetVarArray &sv, const Gecode::FloatVarArray &fv) const
FloatVarBranch FLOAT_VAR_AFC_SIZE_MAX(double d, BranchTbl tbl)
Select variable with largest accumulated failure count divided by domain size with decay factor d...
int p
Number of positive literals for node type.
T * alloc(long unsigned int n)
Allocate block of n objects of type T from heap.
IntVarBranch INT_VAR_AFC_MAX(double d, BranchTbl tbl)
Select variable with largest accumulated failure count with decay factor d.
Gecode::FloatVarArray fv
The float variables.
const FloatNum min
Smallest allowed float value.
Gecode::IntArgs i(4, 1, 2, 3, 4)
IntAssign ann2asnivalsel(AST::Node *ann, Rnd rnd)
Base-class for branchers.
FloatNum n
The middle value for branching.
int n
Number of negative literals for node type.
IntVarBranch INT_VAR_DEGREE_MAX(BranchTbl tbl)
Select variable with largest degree.
std::vector< bool > fv_introduced
Indicates whether a float variable is introduced by mzn2fzn.
Option< std::pair< double, double > > domain
IntVarBranch INT_VAR_ACTIVITY_MIN(double d, BranchTbl tbl)
Select variable with lowest activity with decay factor d.
int dfs(Space *root, const Gist::Options &opt)
Create a new stand-alone Gist for root.
FloatVarBranch FLOAT_VAR_AFC_SIZE_MIN(double d, BranchTbl tbl)
Select variable with smalllest accumulated failure count divided by domain size with decay factor d...
IntAssign INT_ASSIGN_RND(Rnd r)
Select random value.
Execution has resulted in failure.
Specification for Boolean variables.
Value description class for branching.
Node representing an atom
int _optVar
Index of the variable to optimize.
virtual void archive(Archive &e) const
Archive into e.
int getIntVar(void)
Cast this node to an integer variable node.
void finalize(void)
Clean up when Gist exits.
Output support class for FlatZinc interpreter.
IntVar arg2IntVar(AST::Node *n)
Convert n to IntVar.
Choice(const Brancher &b, bool fail0)
Initialize choice for brancher b.
static void installCtrlHandler(bool install, bool force=false)
Install handler for catching Ctrl-C.
static Search::Stop * create(unsigned int node, unsigned int fail, unsigned int time, bool intr)
Create appropriate stop-object.
IntAssign INT_ASSIGN_MAX(void)
Select largest value.
SetVarBranch SET_VAR_ACTIVITY_MAX(double d, BranchTbl tbl)
Select variable with highest activity with decay factor d.
int getBoolVar(void)
Cast this node to a Boolean variable node.
The Gecode Interactive Search Tool.
bool isSet(void)
Test if node is a set literal node.
void fail(void)
Fail space.
BoolVarArgs arg2boolvarargs(AST::Node *arg, int offset=0, int siv=-1)
Convert arg to BoolVarArgs.
IntValBranch INT_VAL_MIN(void)
Select smallest value.
virtual void archive(Archive &e) const
Archive into e.
unsigned int size(I &i)
Size of all ranges of range iterator i.
void newFloatVar(FloatVarSpec *vs)
Create new float variable from specification.
virtual ExecStatus commit(Space &, const Gecode::Choice &c, unsigned int)
Perform commit for choice c.
IntValBranch INT_VAL_SPLIT_MAX(void)
Select values greater than mean of smallest and largest value.
IntVarBranch INT_VAR_MAX_MAX(BranchTbl tbl)
Select variable with largest max.
void shrinkElement(AST::Node *node, std::map< int, int > &iv, std::map< int, int > &bv, std::map< int, int > &sv, std::map< int, int > &fv)
bool l
Whether to try the lower or upper half first.
bool optVarIsInt(void) const
Return whether variable used for optimization is integer (or float)
IntVarBranch INT_VAR_RND(Rnd r)
Select random variable (uniform distribution, for tie breaking)
IntVarBranch INT_VAR_AFC_MIN(double d, BranchTbl tbl)
Select variable with smallest accumulated failure count with decay factor d.
SetValBranch SET_VAL_MAX_EXC(void)
Exclude largest element.
IntVarBranch INT_VAR_ACTIVITY_SIZE_MAX(double d, BranchTbl tbl)
Select variable with largest activity divided by domain size with decay factor d. ...
Gecode::BoolVarArray bv_aux
The introduced Boolean variables.
bool clone
Whether engines create a clone when being initialized.
Array * getArgs(unsigned int n)
void print(std::ostream &out, const Printer &p) const
Produce output on out using p.
SetValBranch SET_VAL_MAX_INC(void)
Include largest element.
Argument array for non-primitive types.
SetVarBranch SET_VAR_MAX_MAX(BranchTbl tbl)
Select variable with largest maximum unknown element.
FloatValBranch FLOAT_VAL_SPLIT_MIN(void)
Select values not greater than mean of smallest and largest value.
bool funcDep
Whether the variable functionally depends on another variable.
virtual void compare(const Space &s0, const Space &s1)=0
Call-back function.
Choice that only signals failure or success
struct Gecode::@512::NNF::@54::@55 b
For binary nodes (and, or, eqv)
SetVarBranch SET_VAR_AFC_SIZE_MIN(double d, BranchTbl tbl)
Select variable with smallest accumulated failure count divided by domain size with decay factor d...
Option< AST::SetLit * > domain
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.
bool assigned(void) const
Test if all variables are assigned.
FloatVarBranch FLOAT_VAR_RND(Rnd r)
Select random variable (uniform distribution, for tie breaking)
unsigned int size(void) const
Return size (cardinality) of set.
Passing integer variables.
bool isBoolArray(AST::Node *b, int &singleInt)
Check if b is array of Booleans (or has a single integer)
virtual void print(const Space &, const Gecode::Choice &c, unsigned int, std::ostream &o) const
Print explanation.
std::vector< bool > bv_introduced
Indicates whether a Boolean variable is introduced by mzn2fzn.
bool done
Flag whether brancher is done.
Passing integer arguments.
Passing Boolean variables.
static const IntSet empty
Empty set.
FloatValBranch float_valsel
int size(void) const
Return size of array (number of elements)
IntVarBranch INT_VAR_AFC_SIZE_MIN(double d, BranchTbl tbl)
Select variable with smallest accumulated failure count divided by domain size with decay factor d...
bool isInt(int &i)
Test if node is int, if yes set i to the value.
bool _optVarIsInt
Whether variable to optimize is integer (or float)
IntSet arg2intset(AST::Node *n)
Convert n to IntSet.
Gecode::FloatVarArray fv_aux
The introduced float variables.
SetValBranch SET_VAL_MIN_EXC(void)
Exclude smallest element.
SetVarBranch SET_VAR_AFC_SIZE_MAX(double d, BranchTbl tbl)
Select variable with largest accumulated failure count divided by domain size with decay factor d...
Boolean integer variables.
bool isString(void)
Test if node is a string node.
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
bool assigned
Whether the variable is assigned.
AuxVarBrancher(Home home, TieBreak< IntVarBranch > int_varsel0, IntValBranch int_valsel0, TieBreak< IntVarBranch > bool_varsel0, IntValBranch bool_valsel0, SetVarBranch set_varsel0, SetValBranch set_valsel0, TieBreak< FloatVarBranch > float_varsel0, FloatValBranch float_valsel0)
Construct brancher.
void update(Space &home, bool share, SharedHandle &sh)
Updating during cloning.
IntValBranch INT_VAL_MAX(void)
Select largest value.
int getInt(void)
Cast this node to an integer node.
void print(std::basic_ostream< Char, Traits > &s, bool assigned, IL &lb, IU &ub, unsigned int cardMin, unsigned int cardMax)
Print set view.
virtual size_t size(void) const
Report size occupied.
Exception: Base-class for exceptions
Print statistics for script.
SetVarBranch SET_VAR_RND(Rnd r)
Select random variable (uniform distribution, for tie breaking)
Base class for variables.
IntValBranch INT_VALUES_MIN(void)
Try all values starting from smallest.
void free(T *b, long unsigned int n)
Delete n objects starting at b.
BrancherHandle assign(Home home, const FloatVarArgs &x, FloatAssign fa, FloatBranchFilter bf, FloatVarValPrint vvp)
Assign all x with value selection vals.
virtual void print(std::ostream &)=0
Output string representation.
Exception signaling type error
Node * x
Pointer to corresponding Boolean expression node.
FloatVarBranch FLOAT_VAR_MIN_MIN(BranchTbl tbl)
Select variable with smallest min.
Choice for performing commit
bool hasAtom(const std::string &id)
Test if node has atom with id.
SharedHandle::Object * object(void) const
Access to the shared object.
bool isFloatVar(void)
Test if node is a float variable node.
Which values to select for assignment.
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
Exception class for FlatZinc errors
Specification for floating point variables.
TieBreak< FloatVarBranch > ann2fvarsel(AST::Node *ann, Rnd rnd, double decay)
IntVarBranch INT_VAR_AFC_SIZE_MAX(double d, BranchTbl tbl)
Select variable with largest accumulated failure count divided by domain size with decay factor d...
void flattenAnnotations(AST::Array *ann, std::vector< AST::Node * > &out)
The default consistency for a constraint.
int bab(Space *root, const Gist::Options &opt)
Create a new stand-alone Gist for branch-and-bound search of root.
AST::Array * _solveAnnotations
Annotations on the solve item.
IntValBranch INT_VAL_MED(void)
Select greatest value not greater than the median.
struct Gecode::Space::@49::@51 c
Data available only during copying.
IntVarBranch INT_VAR_ACTIVITY_SIZE_MIN(double d, BranchTbl tbl)
Select variable with smallest activity divided by domain size with decay factor d.
~FlatZincSpace(void)
Destructor.
An window for simple text output.
bool needAuxVars
Whether the introduced variables still need to be copied.
virtual bool status(const Space &_home) const
Check status of brancher, return true if alternatives left.
void solve(AST::Array *annotation)
Post the solve item.
unsigned long int restart
Number of restarts.
#define GECODE_HAS_FLOAT_VARS
void varValPrint(const Space &home, const BrancherHandle &bh, unsigned int a, Var, int i, const int &n, std::ostream &o)
TieBreak< FloatVarBranch > float_varsel
bool isArray(void)
Test if node is an array node.
virtual Actor * copy(Space &home, bool share)
Copy brancher.
void aliasBool2Int(int iv, int bv)
Link integer variable iv to Boolean variable bv.
A space that can be initialized with a FlatZinc model.
Gecode::IntVarArray iv_aux
The introduced integer variables.
struct Gecode::Space::@49::@50 p
Data only available during propagation.
void shrinkArrays(Space &home, int &optVar, bool optVarIsInt, Gecode::IntVarArray &iv, Gecode::BoolVarArray &bv, Gecode::SetVarArray &sv, Gecode::FloatVarArray &fv)
CompareStatus compare(I &i, J &j)
Check whether range iterator i is a subset of j, or whether they are disjoint.
Bounds propagation or consistency.
Stop * stop
Stop object for stopping search.
class Gecode::Gist::Options::_I inspect
IntValBranch INT_VAL_SPLIT_MIN(void)
Select values not greater than mean of smallest and largest value.
int explore(Space *root, bool bab, const Options &opt)
Create a new stand-alone Gist for root using bab.
void run(std::ostream &out, const Printer &p, const FlatZincOptions &opt, Gecode::Support::Timer &t_total)
Run the search.
Gecode toplevel namespace
int * iv_boolalias
Indicates whether an integer variable aliases a Boolean variable.
unsigned long int node
Number of nodes expanded.
void maximize(int var, bool isInt, AST::Array *annotation)
Post that integer variable var should be maximized.
int setVarCount
Number of set variables.
Node representing a function call
int intVarCount
Number of integer variables.
IntValBranch ann2ivalsel(AST::Node *ann, std::string &r0, std::string &r1, Rnd rnd)
SetVarArgs arg2setvarargs(AST::Node *arg, int offset=0, int doffset=0, const IntSet &od=IntSet::empty)
Convert n to SetVarArgs.
A node in a FlatZinc abstract syntax tree.
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.
BrancherHandle branch(Home home, const FloatVarArgs &x, FloatVarBranch vars, FloatValBranch vals, FloatBranchFilter bf, FloatVarValPrint vvp)
Branch over x with variable selection vars and value selection vals.
Which variable to select for branching.
FloatVarBranch FLOAT_VAR_ACTIVITY_MIN(double d, BranchTbl tbl)
Select variable with lowest activity with decay factor d.
SetVarBranch SET_VAR_MIN_MIN(BranchTbl tbl)
Select variable with smallest minimum unknown element.
struct Gecode::@512::NNF::@54::@56 a
For atomic nodes.
FloatVarBranch FLOAT_VAR_ACTIVITY_SIZE_MIN(double d, BranchTbl tbl)
Select variable with smallest activity divided by domain size with decay factor d.
FloatVarBranch FLOAT_VAR_SIZE_MAX(BranchTbl tbl)
Select variable with largest domain size.
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.
SetVarBranch SET_VAR_AFC_MAX(double d, BranchTbl tbl)
Select variable with largest accumulated failure count with decay factor d.
bool introduced
Whether the variable was introduced in the mzn2fzn translation.
std::string getString(void)
Cast this node to a string node.
FloatVarBranch FLOAT_VAR_AFC_MAX(double d, BranchTbl tbl)
Select variable with largest accumulated failure count with decay factor d.
FloatVar arg2FloatVar(AST::Node *n)
Convert n to FloatVar.
Domain propagation or consistency.
Depth-first search engine.
Branching on the introduced variables.
IntVarBranch INT_VAR_SIZE_MAX(BranchTbl tbl)
Select variable with largest domain size.
Meth method(void) const
Return whether to solve a satisfaction or optimization problem.
Registry & registry(void)
Return global registry object.
FloatValArgs arg2floatargs(AST::Node *arg, int offset=0)
Convert n to FloatValArgs.
Option< AST::SetLit * > upperBound
virtual size_t dispose(Space &)
Delete brancher and return its size.
AST::Array * solveAnnotations(void) const
Return the solve item annotations.
bool fail
Whether brancher should fail.
TieBreak< IntVarBranch > int_varsel
FloatVarBranch FLOAT_VAR_SIZE_MIN(BranchTbl tbl)
Select variable with smallest domain size.
void init(AST::Array *output)
BoolVar arg2BoolVar(AST::Node *n)
Convert n to BoolVar.
IntSetArgs arg2intsetargs(AST::Node *arg, int offset=0)
Convert arg to IntSetArgs.
Abstract representation of a constraint.