Generated on Thu Apr 5 2018 19:44:19 for Gecode by doxygen 1.8.13
core.hpp
Go to the documentation of this file.
1 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2 /*
3  * Main authors:
4  * Christian Schulte <schulte@gecode.org>
5  * Guido Tack <tack@gecode.org>
6  * Mikael Lagerkvist <lagerkvist@gecode.org>
7  *
8  * Contributing authors:
9  * Filip Konvicka <filip.konvicka@logis.cz>
10  *
11  * Copyright:
12  * Christian Schulte, 2002
13  * Guido Tack, 2003
14  * Mikael Lagerkvist, 2006
15  * LOGIS, s.r.o., 2009
16  *
17  * Bugfixes provided by:
18  * Alexander Samoilov <alexander_samoilov@yahoo.com>
19  *
20  * Last modified:
21  * $Date$ by $Author$
22  * $Revision$
23  *
24  * This file is part of Gecode, the generic constraint
25  * development environment:
26  * http://www.gecode.org
27  *
28  * Permission is hereby granted, free of charge, to any person obtaining
29  * a copy of this software and associated documentation files (the
30  * "Software"), to deal in the Software without restriction, including
31  * without limitation the rights to use, copy, modify, merge, publish,
32  * distribute, sublicense, and/or sell copies of the Software, and to
33  * permit persons to whom the Software is furnished to do so, subject to
34  * the following conditions:
35  *
36  * The above copyright notice and this permission notice shall be
37  * included in all copies or substantial portions of the Software.
38  *
39  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
40  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
41  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
42  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
43  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
44  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
45  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
46  *
47  */
48 
49 #include <iostream>
50 
51 namespace Gecode {
52 
53  class Space;
54 
63  typedef int ModEvent;
65 
67  const ModEvent ME_GEN_FAILED = -1;
69  const ModEvent ME_GEN_NONE = 0;
71  const ModEvent ME_GEN_ASSIGNED = 1;
72 
74  typedef int PropCond;
76  const PropCond PC_GEN_NONE = -1;
78  const PropCond PC_GEN_ASSIGNED = 0;
80 
91  typedef int ModEventDelta;
92 
93 }
94 
96 
97 namespace Gecode {
98 
101  public:
103  static const int idx_c = -1;
105  static const int idx_d = -1;
109  static const int free_bits = 0;
111  static const int med_fst = 0;
113  static const int med_lst = 0;
115  static const int med_mask = 0;
117  static Gecode::ModEvent me_combine(ModEvent me1, ModEvent me2);
119  static bool med_update(ModEventDelta& med, ModEvent me);
120  };
121 
124  GECODE_NEVER; return 0;
125  }
126  forceinline bool
128  GECODE_NEVER; return false;
129  }
130 
131 
132  /*
133  * These are the classes of interest
134  *
135  */
136  class ActorLink;
137  class Actor;
138  class Propagator;
139  class SubscribedPropagators;
140  class LocalObject;
141  class Advisor;
142  class AFC;
143  class Choice;
144  class Brancher;
145  class Group;
146  class PropagatorGroup;
147  class BrancherGroup;
148  class PostInfo;
149  class ViewTraceInfo;
150  class PropagateTraceInfo;
151  class CommitTraceInfo;
152  class TraceRecorder;
153  class TraceFilter;
154  class Tracer;
155 
156  template<class A> class Council;
157  template<class A> class Advisors;
158  template<class VIC> class VarImp;
159 
160 
161  /*
162  * Variable implementations
163  *
164  */
165 
173  class VarImpBase {};
174 
182  public:
184  GECODE_KERNEL_EXPORT virtual void dispose(Space& home, VarImpBase* x);
187  };
188 
195  template<class VarImp>
197  public:
199  VarImpDisposer(void);
201  virtual void dispose(Space& home, VarImpBase* x);
202  };
203 
205  class Delta {
206  template<class VIC> friend class VarImp;
207  private:
209  ModEvent me;
210  };
211 
219  template<class VIC>
220  class VarImp : public VarImpBase {
221  friend class Space;
222  friend class Propagator;
223  template<class VarImp> friend class VarImpDisposer;
224  friend class SubscribedPropagators;
225  private:
226  union {
244  } b;
245 
247  static const int idx_c = VIC::idx_c;
249  static const int idx_d = VIC::idx_d;
251  static const int free_bits = VIC::free_bits;
253  unsigned int entries;
255  unsigned int free_and_bits;
257  static const Gecode::PropCond pc_max = VIC::pc_max;
258 
259  union {
270  unsigned int idx[pc_max+1];
273  } u;
274 
276  ActorLink** actor(PropCond pc);
278  ActorLink** actorNonZero(PropCond pc);
280  unsigned int& idx(PropCond pc);
282  unsigned int idx(PropCond pc) const;
283 
290  void update(VarImp* x, ActorLink**& sub);
297  static void update(Space& home, ActorLink**& sub);
298 
300  void enter(Space& home, Propagator* p, PropCond pc);
302  void enter(Space& home, Advisor* a);
304  void resize(Space& home);
306  void remove(Space& home, Propagator* p, PropCond pc);
308  void remove(Space& home, Advisor* a);
309 
310 
311  protected:
313  void cancel(Space& home);
319  bool advise(Space& home, ModEvent me, Delta& d);
320  private:
322  void _fail(Space& home);
323  protected:
325  ModEvent fail(Space& home);
326 #ifdef GECODE_HAS_VAR_DISPOSE
327  static VarImp<VIC>* vars_d(Space& home);
330  static void vars_d(Space& home, VarImp<VIC>* x);
331 #endif
332 
333  public:
335  VarImp(Space& home);
337  VarImp(void);
338 
340 
341 
353  void subscribe(Space& home, Propagator& p, PropCond pc,
354  bool assigned, ModEvent me, bool schedule);
356  void cancel(Space& home, Propagator& p, PropCond pc);
365  void subscribe(Space& home, Advisor& a, bool assigned, bool fail);
367  void cancel(Space& home, Advisor& a, bool fail);
368 
375  unsigned int degree(void) const;
382  double afc(void) const;
384 
386 
387  VarImp(Space& home, VarImp& x);
390  bool copied(void) const;
392  VarImp* forward(void) const;
394  VarImp* next(void) const;
396 
398 
399 
406  static void schedule(Space& home, Propagator& p, ModEvent me,
407  bool force = false);
415  static void reschedule(Space& home, Propagator& p, PropCond pc,
416  bool assigned, ModEvent me);
418  static ModEvent me(const ModEventDelta& med);
420  static ModEventDelta med(ModEvent me);
422  static ModEvent me_combine(ModEvent me1, ModEvent me2);
424 
426 
427  static ModEvent modevent(const Delta& d);
430 
432 
433  unsigned int bits(void) const;
436  unsigned int& bits(void);
438 
439  protected:
441  void schedule(Space& home, PropCond pc1, PropCond pc2, ModEvent me);
442 
443  public:
445 
446  static void* operator new(size_t,Space&);
449  static void operator delete(void*,Space&);
451  static void operator delete(void*);
453  };
454 
455 
464  enum ExecStatus {
466  ES_FAILED = -1,
467  ES_NOFIX = 0,
468  ES_OK = 0,
469  ES_FIX = 1,
472  };
473 
478  class PropCost {
479  friend class Space;
480  public:
482  enum ActualCost {
483  AC_RECORD = 0,
484  AC_CRAZY_LO = 1,
485  AC_CRAZY_HI = 1,
486  AC_CUBIC_LO = 1,
487  AC_CUBIC_HI = 1,
488  AC_QUADRATIC_LO = 2,
489  AC_QUADRATIC_HI = 2,
490  AC_LINEAR_HI = 3,
491  AC_LINEAR_LO = 4,
492  AC_TERNARY_HI = 4,
493  AC_BINARY_HI = 5,
494  AC_TERNARY_LO = 5,
495  AC_BINARY_LO = 6,
496  AC_UNARY_LO = 6,
497  AC_UNARY_HI = 6,
498  AC_MAX = 6
499  };
502  public:
504  enum Mod {
505  LO,
506  HI
507  };
508  private:
510  static PropCost cost(Mod m, ActualCost lo, ActualCost hi, unsigned int n);
512  PropCost(ActualCost ac);
513  public:
515  static PropCost record(void);
517  static PropCost crazy(PropCost::Mod m, unsigned int n);
519  static PropCost crazy(PropCost::Mod m, int n);
521  static PropCost cubic(PropCost::Mod m, unsigned int n);
523  static PropCost cubic(PropCost::Mod m, int n);
525  static PropCost quadratic(PropCost::Mod m, unsigned int n);
527  static PropCost quadratic(PropCost::Mod m, int n);
529  static PropCost linear(PropCost::Mod m, unsigned int n);
531  static PropCost linear(PropCost::Mod m, int n);
533  static PropCost ternary(PropCost::Mod m);
535  static PropCost binary(PropCost::Mod m);
537  static PropCost unary(PropCost::Mod m);
538  };
539 
540 
554  AP_DISPOSE = (1 << 0),
560  AP_WEAKLY = (1 << 1),
565  AP_VIEW_TRACE = (1 << 2),
570  AP_TRACE = (1 << 3)
571  };
572 
573 
581  class ActorLink {
582  friend class Actor;
583  friend class Propagator;
584  friend class Advisor;
585  friend class Brancher;
586  friend class LocalObject;
587  friend class Space;
588  template<class VIC> friend class VarImp;
589  private:
590  ActorLink* _next; ActorLink* _prev;
591  public:
593  ActorLink* prev(void) const; void prev(ActorLink*);
595  ActorLink* next(void) const; void next(ActorLink*);
596  ActorLink** next_ref(void);
598 
600  void init(void);
602  void unlink(void);
604  void head(ActorLink* al);
606  void tail(ActorLink* al);
608  bool empty(void) const;
610  template<class T> static ActorLink* cast(T* a);
612  template<class T> static const ActorLink* cast(const T* a);
613  };
614 
615 
621  friend class ActorLink;
622  friend class Space;
623  friend class Propagator;
624  friend class Advisor;
625  friend class Brancher;
626  friend class LocalObject;
627  template<class VIC> friend class VarImp;
628  template<class A> friend class Council;
629  private:
631  static Actor* cast(ActorLink* al);
633  static const Actor* cast(const ActorLink* al);
635  GECODE_KERNEL_EXPORT static Actor* sentinel;
636  public:
638  virtual Actor* copy(Space& home) = 0;
639 
641 
644  virtual size_t dispose(Space& home);
646  static void* operator new(size_t s, Space& home);
648  static void operator delete(void* p, Space& home);
650  public:
652  GECODE_KERNEL_EXPORT virtual ~Actor(void);
654  static void* operator new(size_t s);
656  static void operator delete(void* p);
657  };
658 
659  class Home;
660 
665  class Group {
666  friend class Home;
667  friend class Propagator;
668  friend class Brancher;
669  friend class ViewTraceInfo;
670  friend class PropagateTraceInfo;
671  friend class CommitTraceInfo;
672  protected:
674  static const unsigned int GROUPID_ALL = 0U;
676  static const unsigned int GROUPID_DEF = 1U;
678  static const unsigned int GROUPID_MAX = UINT_MAX >> 2;
680  unsigned int gid;
683  static unsigned int next;
688  Group(unsigned int gid0);
689  public:
691 
694  Group(void);
696  Group(const Group& g);
698  Group& operator =(const Group& g);
700  unsigned int id(void) const;
702  bool in(Group a) const;
704  bool in(void) const;
708  static Group all;
711  static Group def;
712  };
713 
718  class PropagatorGroup : public Group {
719  friend class Propagator;
720  friend class ViewTraceInfo;
721  friend class PropagateTraceInfo;
722  protected:
724  PropagatorGroup(unsigned int gid);
725  public:
727 
728  PropagatorGroup(void);
733  PropagatorGroup& operator =(const PropagatorGroup& g);
735  Home operator ()(Space& home);
737 
741  PropagatorGroup& move(Space& home, PropagatorGroup g);
743  PropagatorGroup& move(Space& home, Propagator& p);
751  PropagatorGroup& move(Space& home, unsigned int id);
753 
755  bool operator ==(PropagatorGroup g) const;
758  bool operator !=(PropagatorGroup g) const;
761  unsigned int size(Space& home) const;
764  void kill(Space& home);
767  void disable(Space& home);
775  void enable(Space& home, bool s=true);
783  };
784 
789  class BrancherGroup : public Group {
790  friend class Brancher;
791  protected:
793  BrancherGroup(unsigned int gid);
794  public:
796 
797  BrancherGroup(void);
800  BrancherGroup(const BrancherGroup& g);
802  BrancherGroup& operator =(const BrancherGroup& g);
804  Home operator ()(Space& home);
806 
810  BrancherGroup& move(Space& home, BrancherGroup g);
812  BrancherGroup& move(Space& home, Brancher& b);
820  BrancherGroup& move(Space& home, unsigned int id);
822 
824  bool operator ==(BrancherGroup g) const;
827  bool operator !=(BrancherGroup g) const;
830  unsigned int size(Space& home) const;
833  void kill(Space& home);
841  };
842 
846  class Home {
847  friend class PostInfo;
848  protected:
857  public:
859 
860  Home(Space& s, Propagator* p=NULL,
865  Home& operator =(const Home& h);
867  operator Space&(void);
869 
871  Home operator ()(Propagator& p);
874  Home operator ()(PropagatorGroup pg);
876  Home operator ()(BrancherGroup bg);
878  Propagator* propagator(void) const;
880  PropagatorGroup propagatorgroup(void) const;
882  BrancherGroup branchergroup(void) const;
884 
886  bool failed(void) const;
889  void fail(void);
891  void notice(Actor& a, ActorProperty p, bool duplicate=false);
893  };
894 
899  friend class Space;
900  friend class PostInfo;
901  public:
903  enum What {
905  PROPAGATOR = 0,
907  BRANCHER = 1,
909  POST = 2,
911  OTHER = 3
912  };
913  protected:
915  ptrdiff_t who;
917  void propagator(Propagator& p);
919  void brancher(Brancher& b);
921  void post(PropagatorGroup g);
923  void other(void);
924  public:
926  What what(void) const;
928  const Propagator& propagator(void) const;
930  const Brancher& brancher(void) const;
932  PropagatorGroup post(void) const;
933  };
934 
938  class PostInfo {
939  protected:
942  public:
944  PostInfo(Home home);
946  ~PostInfo(void);
947  };
948 
953  friend class Space;
954  public:
956  enum Status {
957  FIX,
960  SUBSUMED
961  };
962  protected:
964  unsigned int i;
968  const Propagator* p;
972  PropagateTraceInfo(unsigned int i, PropagatorGroup g,
973  const Propagator* p, Status s);
974  public:
976  unsigned int id(void) const;
978  PropagatorGroup group(void) const;
980  const Propagator* propagator(void) const;
982  Status status(void) const;
983  };
984 
989  friend class Space;
990  protected:
992  const Brancher& b;
994  const Choice& c;
996  unsigned int a;
998  CommitTraceInfo(const Brancher& b, const Choice& c, unsigned int a);
999  public:
1001  unsigned int id(void) const;
1003  BrancherGroup group(void) const;
1005  const Brancher& brancher(void) const;
1007  const Choice& choice(void) const;
1009  unsigned int alternative(void) const;
1010  };
1011 
1017  friend class ActorLink;
1018  friend class Space;
1019  template<class VIC> friend class VarImp;
1020  friend class Advisor;
1021  template<class A> friend class Council;
1023  friend class PropagatorGroup;
1024  private:
1025  union {
1029  size_t size;
1032  } u;
1034  void* gpi_disabled;
1036  static Propagator* cast(ActorLink* al);
1038  static const Propagator* cast(const ActorLink* al);
1040  void disable(Space& home);
1042  void enable(Space& home);
1043  protected:
1045  Propagator(Home home);
1047  Propagator(Space& home, Propagator& p);
1049  Propagator* fwd(void) const;
1051  Kernel::GPI::Info& gpi(void);
1052 
1053  public:
1055 
1056 
1064  virtual void reschedule(Space& home) = 0;
1088  virtual ExecStatus propagate(Space& home, const ModEventDelta& med) = 0;
1090  virtual PropCost cost(const Space& home, const ModEventDelta& med) const = 0;
1098  ModEventDelta modeventdelta(void) const;
1135  virtual ExecStatus advise(Space& home, Advisor& a, const Delta& d);
1138  virtual void advise(Space& home, Advisor& a);
1140 
1142  double afc(void) const;
1145 
1147  unsigned int id(void) const;
1150  PropagatorGroup group(void) const;
1152  void group(PropagatorGroup g);
1154  bool disabled(void) const;
1156  };
1157 
1158 
1166  template<class A>
1167  class Council {
1168  friend class Advisor;
1169  friend class Advisors<A>;
1170  private:
1172  mutable ActorLink* advisors;
1173  public:
1175  Council(void);
1177  Council(Space& home);
1179  bool empty(void) const;
1181  void update(Space& home, Council<A>& c);
1183  void dispose(Space& home);
1184  };
1185 
1186 
1191  template<class A>
1192  class Advisors {
1193  private:
1195  ActorLink* a;
1196  public:
1198  Advisors(const Council<A>& c);
1200  bool operator ()(void) const;
1202  void operator ++(void);
1204  A& advisor(void) const;
1205  };
1206 
1207 
1218  class Advisor : private ActorLink {
1219  template<class VIC> friend class VarImp;
1220  template<class A> friend class Council;
1221  template<class A> friend class Advisors;
1223  private:
1225  bool disposed(void) const;
1227  static Advisor* cast(ActorLink* al);
1229  static const Advisor* cast(const ActorLink* al);
1230  protected:
1232  Propagator& propagator(void) const;
1233  public:
1235  template<class A>
1236  Advisor(Space& home, Propagator& p, Council<A>& c);
1238  Advisor(Space& home, Advisor& a);
1240  const ViewTraceInfo& operator ()(const Space& home) const;
1241 
1243 
1244  template<class A>
1246  void dispose(Space& home, Council<A>& c);
1248  static void* operator new(size_t s, Space& home);
1250  static void operator delete(void* p, Space& home);
1252  private:
1253 #ifndef __GNUC__
1254  static void operator delete(void* p);
1256 #endif
1257  static void* operator new(size_t s);
1259  };
1260 
1261 
1267  private:
1269  void* nl;
1270  public:
1272  enum Status {
1275  NONE
1276  };
1278  NGL(void);
1280  NGL(Space& home);
1282  NGL(Space& home, NGL& ngl);
1284  virtual void subscribe(Space& home, Propagator& p) = 0;
1286  virtual void cancel(Space& home, Propagator& p) = 0;
1288  virtual void reschedule(Space& home, Propagator& p) = 0;
1290  virtual NGL::Status status(const Space& home) const = 0;
1292  virtual ExecStatus prune(Space& home) = 0;
1294  virtual NGL* copy(Space& home) = 0;
1297  virtual bool notice(void) const;
1299  virtual size_t dispose(Space& home);
1301 
1302  bool leaf(void) const;
1305  NGL* next(void) const;
1307  void leaf(bool l);
1309  void next(NGL* n);
1311  NGL* add(NGL* n, bool l);
1313 
1315  static void* operator new(size_t s, Space& home);
1318  static void operator delete(void* s, Space& home);
1320  static void operator delete(void* p);
1322  public:
1324  GECODE_KERNEL_EXPORT virtual ~NGL(void);
1326  static void* operator new(size_t s);
1327  };
1328 
1339  friend class Space;
1340  private:
1341  unsigned int bid;
1342  unsigned int alt;
1343 
1345  unsigned int id(void) const;
1346  protected:
1348  Choice(const Brancher& b, const unsigned int a);
1349  public:
1351  unsigned int alternatives(void) const;
1353  GECODE_KERNEL_EXPORT virtual ~Choice(void);
1356  virtual void archive(Archive& e) const;
1357  };
1358 
1369  friend class ActorLink;
1370  friend class Space;
1371  friend class Choice;
1372  private:
1374  unsigned int bid;
1376  unsigned int gid;
1378  static Brancher* cast(ActorLink* al);
1380  static const Brancher* cast(const ActorLink* al);
1381  protected:
1383  Brancher(Home home);
1385  Brancher(Space& home, Brancher& b);
1386  public:
1388 
1389 
1397  virtual bool status(const Space& home) const = 0;
1405  virtual const Choice* choice(Space& home) = 0;
1407  virtual const Choice* choice(const Space& home, Archive& e) = 0;
1414  virtual ExecStatus commit(Space& home, const Choice& c,
1415  unsigned int a) = 0;
1430  virtual NGL* ngl(Space& home, const Choice& c, unsigned int a) const;
1439  virtual void print(const Space& home, const Choice& c, unsigned int a,
1440  std::ostream& o) const;
1442 
1444  unsigned int id(void) const;
1447  BrancherGroup group(void) const;
1449  void group(BrancherGroup g);
1451  };
1452 
1459  class LocalObject : public Actor {
1460  friend class ActorLink;
1461  friend class Space;
1462  friend class LocalHandle;
1463  protected:
1465  LocalObject(Home home);
1467  LocalObject(Space& home, LocalObject& l);
1469  static LocalObject* cast(ActorLink* al);
1471  static const LocalObject* cast(const ActorLink* al);
1472  private:
1474  GECODE_KERNEL_EXPORT void fwdcopy(Space& home);
1475  public:
1477  LocalObject* fwd(Space& home);
1478  };
1479 
1484  class LocalHandle {
1485  private:
1487  LocalObject* o;
1488  protected:
1490  LocalHandle(void);
1492  LocalHandle(LocalObject* lo);
1494  LocalHandle(const LocalHandle& lh);
1495  public:
1497  LocalHandle& operator =(const LocalHandle& lh);
1499  void update(Space& home, LocalHandle& lh);
1501  ~LocalHandle(void);
1502  protected:
1504  LocalObject* object(void) const;
1506  void object(LocalObject* n);
1507  };
1508 
1509 
1515  protected:
1517  unsigned long int n;
1518  public:
1520  NoGoods(void);
1523  virtual void post(Space& home) const;
1525  unsigned long int ng(void) const;
1527  void ng(unsigned long int n);
1529  virtual ~NoGoods(void);
1532  static NoGoods eng;
1533  };
1534 
1540  public:
1542  enum Type {
1546  PORTFOLIO
1547  };
1548  protected:
1550  const Type t;
1552 
1553  const unsigned long int r;
1556  const unsigned long int s;
1558  const unsigned long int f;
1560  const Space* l;
1562  const NoGoods& ng;
1564 
1566  const unsigned int a;
1569  public:
1571 
1572  MetaInfo(unsigned long int r,
1574  unsigned long int s,
1575  unsigned long int f,
1576  const Space* l,
1577  NoGoods& ng);
1579  MetaInfo(unsigned int a);
1581  Type type(void) const;
1584 
1585  unsigned long int restart(void) const;
1588  unsigned long int solution(void) const;
1590  unsigned long int fail(void) const;
1592  const Space* last(void) const;
1594  const NoGoods& nogoods(void) const;
1596 
1598  unsigned int asset(void) const;
1601  };
1602 
1611  };
1612 
1618  public:
1620  unsigned long int propagate;
1622  StatusStatistics(void);
1624  void reset(void);
1628  StatusStatistics& operator +=(const StatusStatistics& s);
1629  };
1630 
1636  public:
1638  CloneStatistics(void);
1640  void reset(void);
1644  CloneStatistics& operator +=(const CloneStatistics& s);
1645  };
1646 
1652  public:
1654  CommitStatistics(void);
1656  void reset(void);
1660  CommitStatistics& operator +=(const CommitStatistics& s);
1661  };
1662 
1663 
1664 
1669  friend class Actor;
1670  friend class Propagator;
1671  friend class PropagatorGroup;
1672  friend class Propagators;
1673  friend class Brancher;
1674  friend class BrancherGroup;
1675  friend class Branchers;
1676  friend class Advisor;
1677  template <class A> friend class Council;
1678  template<class VIC> friend class VarImp;
1679  template<class VarImp> friend class VarImpDisposer;
1680  friend class LocalObject;
1681  friend class Region;
1682  friend class AFC;
1683  friend class PostInfo;
1684  friend GECODE_KERNEL_EXPORT
1685  void trace(Home home, TraceFilter tf, int te, Tracer& t);
1686  private:
1692  ActorLink pl;
1694  ActorLink bl;
1700  Brancher* b_status;
1712  Brancher* b_commit;
1714  Brancher* brancher(unsigned int id);
1715 
1717  void kill(Brancher& b);
1719  void kill(Propagator& p);
1720 
1723  void kill_brancher(unsigned int id);
1724 
1726  static const unsigned reserved_bid = 0U;
1727 
1729  static const unsigned int sc_bits = 2;
1731  static const unsigned int sc_fast = 0;
1733  static const unsigned int sc_disabled = 1;
1735  static const unsigned int sc_trace = 2;
1736 
1737  union {
1739  struct {
1761  unsigned int bid_sc;
1763  unsigned int n_sub;
1766  } p;
1768  struct {
1775  } c;
1776  } pc;
1778  void enqueue(Propagator* p);
1783 #ifdef GECODE_HAS_VAR_DISPOSE
1787  VarImpBase* _vars_d[AllVarConf::idx_d];
1789  template<class VIC> VarImpBase* vars_d(void) const;
1791  template<class VIC> void vars_d(VarImpBase* x);
1792 #endif
1793  void update(ActorLink** sub);
1796 
1798  Actor** d_fst;
1800  Actor** d_cur;
1802  Actor** d_lst;
1803 
1805  GECODE_KERNEL_EXPORT static StatusStatistics unused_status;
1807  GECODE_KERNEL_EXPORT static CloneStatistics unused_clone;
1809  GECODE_KERNEL_EXPORT static CommitStatistics unused_commit;
1810 
1824  GECODE_KERNEL_EXPORT Space* _clone(void);
1825 
1859  void _commit(const Choice& c, unsigned int a);
1860 
1892  void _trycommit(const Choice& c, unsigned int a);
1893 
1896  TraceRecorder* findtracerecorder(void);
1897 
1905  void ap_notice_dispose(Actor* a, bool d);
1913  void ap_ignore_dispose(Actor* a, bool d);
1914 
1915  public:
1921  Space(void);
1931  Space(Space& s);
1937  virtual ~Space(void);
1944  virtual Space* copy(void) = 0;
1955  GECODE_KERNEL_EXPORT virtual void constrain(const Space& best);
1980  virtual bool master(const MetaInfo& mi);
2007  virtual bool slave(const MetaInfo& mi);
2008 
2009  /*
2010  * Member functions for search engines
2011  *
2012  */
2013 
2026  SpaceStatus status(StatusStatistics& stat=unused_status);
2027 
2060  const Choice* choice(void);
2061 
2072  const Choice* choice(Archive& e) const;
2073 
2089  Space* clone(CloneStatistics& stat=unused_clone) const;
2090 
2125  void commit(const Choice& c, unsigned int a,
2126  CommitStatistics& stat=unused_commit);
2159  void trycommit(const Choice& c, unsigned int a,
2160  CommitStatistics& stat=unused_commit);
2180  NGL* ngl(const Choice& c, unsigned int a);
2181 
2197  void print(const Choice& c, unsigned int a, std::ostream& o) const;
2198 
2208  void notice(Actor& a, ActorProperty p, bool duplicate=false);
2217  void ignore(Actor& a, ActorProperty p, bool duplicate=false);
2218 
2219 
2230  ExecStatus ES_SUBSUMED(Propagator& p);
2245  ExecStatus ES_SUBSUMED_DISPOSED(Propagator& p, size_t s);
2256  ExecStatus ES_FIX_PARTIAL(Propagator& p, const ModEventDelta& med);
2267  ExecStatus ES_NOFIX_PARTIAL(Propagator& p, const ModEventDelta& med);
2268 
2279  template<class A>
2280  ExecStatus ES_FIX_DISPOSE(Council<A>& c, A& a);
2291  template<class A>
2292  ExecStatus ES_NOFIX_DISPOSE(Council<A>& c, A& a);
2304  template<class A>
2305  ExecStatus ES_NOFIX_DISPOSE_FORCE(Council<A>& c, A& a);
2306 
2314  void fail(void);
2323  bool failed(void) const;
2328  bool stable(void) const;
2329 
2331 
2332  Home operator ()(Propagator& p);
2335  Home operator ()(PropagatorGroup pg);
2337  Home operator ()(BrancherGroup bg);
2339 
2351  template<class T>
2352  T* alloc(long unsigned int n);
2359  template<class T>
2360  T* alloc(long int n);
2367  template<class T>
2368  T* alloc(unsigned int n);
2375  template<class T>
2376  T* alloc(int n);
2386  template<class T>
2387  void free(T* b, long unsigned int n);
2397  template<class T>
2398  void free(T* b, long int n);
2408  template<class T>
2409  void free(T* b, unsigned int n);
2419  template<class T>
2420  void free(T* b, int n);
2432  template<class T>
2433  T* realloc(T* b, long unsigned int n, long unsigned int m);
2445  template<class T>
2446  T* realloc(T* b, long int n, long int m);
2458  template<class T>
2459  T* realloc(T* b, unsigned int n, unsigned int m);
2471  template<class T>
2472  T* realloc(T* b, int n, int m);
2480  template<class T>
2481  T** realloc(T** b, long unsigned int n, long unsigned int m);
2489  template<class T>
2490  T** realloc(T** b, long int n, long int m);
2498  template<class T>
2499  T** realloc(T** b, unsigned int n, unsigned int m);
2507  template<class T>
2508  T** realloc(T** b, int n, int m);
2510  void* ralloc(size_t s);
2512  void rfree(void* p, size_t s);
2514  void* rrealloc(void* b, size_t n, size_t m);
2516  template<size_t> void* fl_alloc(void);
2522  template<size_t> void fl_dispose(FreeList* f, FreeList* l);
2524 
2526 
2529  template<class T>
2530  T& construct(void);
2536  template<class T, typename A1>
2537  T& construct(A1 const& a1);
2543  template<class T, typename A1, typename A2>
2544  T& construct(A1 const& a1, A2 const& a2);
2550  template<class T, typename A1, typename A2, typename A3>
2551  T& construct(A1 const& a1, A2 const& a2, A3 const& a3);
2557  template<class T, typename A1, typename A2, typename A3, typename A4>
2558  T& construct(A1 const& a1, A2 const& a2, A3 const& a3, A4 const& a4);
2564  template<class T, typename A1, typename A2, typename A3, typename A4, typename A5>
2565  T& construct(A1 const& a1, A2 const& a2, A3 const& a3, A4 const& a4, A5 const& a5);
2567 
2569 
2570  void afc_decay(double d);
2573  double afc_decay(void) const;
2575  GECODE_KERNEL_EXPORT void afc_unshare(void);
2577 
2578  protected:
2584  class Propagators {
2585  private:
2587  Space& home;
2589  ActorLink* q;
2591  ActorLink* c;
2593  ActorLink* e;
2594  public:
2596  Propagators(Space& home);
2598  bool operator ()(void) const;
2600  void operator ++(void);
2602  Propagator& propagator(void) const;
2603  };
2610  private:
2612  Space& home;
2614  ActorLink* q;
2616  ActorLink* c;
2618  ActorLink* e;
2619  public:
2621  ScheduledPropagators(Space& home);
2623  bool operator ()(void) const;
2625  void operator ++(void);
2627  Propagator& propagator(void) const;
2628  };
2635  private:
2637  ActorLink* c;
2639  ActorLink* e;
2640  public:
2642  IdlePropagators(Space& home);
2644  bool operator ()(void) const;
2646  void operator ++(void);
2648  Propagator& propagator(void) const;
2649  };
2655  class Branchers {
2656  private:
2658  ActorLink* c;
2660  ActorLink* e;
2661  public:
2663  Branchers(Space& home);
2665  bool operator ()(void) const;
2667  void operator ++(void);
2669  Brancher& brancher(void) const;
2670  };
2671  };
2672 
2674  class Propagators {
2675  private:
2677  Space::Propagators ps;
2679  PropagatorGroup g;
2680  public:
2682  Propagators(Space& home, PropagatorGroup g);
2684  bool operator ()(void) const;
2686  void operator ++(void);
2688  const Propagator& propagator(void) const;
2689  };
2690 
2692  class Branchers {
2693  private:
2695  Space::Branchers bs;
2697  BrancherGroup g;
2698  public:
2700  Branchers(Space& home, BrancherGroup g);
2702  bool operator ()(void) const;
2704  void operator ++(void);
2706  const Brancher& brancher(void) const;
2707  };
2708 
2709 
2710 
2711 
2712  /*
2713  * Memory management
2714  *
2715  */
2716 
2717  // Space allocation: general space heaps and free lists
2718  forceinline void*
2719  Space::ralloc(size_t s) {
2720  return mm.alloc(ssd.data().sm,s);
2721  }
2722  forceinline void
2723  Space::rfree(void* p, size_t s) {
2724  return mm.reuse(p,s);
2725  }
2726  forceinline void*
2727  Space::rrealloc(void* _b, size_t n, size_t m) {
2728  char* b = static_cast<char*>(_b);
2729  if (n < m) {
2730  char* p = static_cast<char*>(ralloc(m));
2731  memcpy(p,b,n);
2732  rfree(b,n);
2733  return p;
2734  } else {
2735  rfree(b+m,m-n);
2736  return b;
2737  }
2738  }
2739 
2740  template<size_t s>
2741  forceinline void*
2743  return mm.template fl_alloc<s>(ssd.data().sm);
2744  }
2745  template<size_t s>
2746  forceinline void
2748  mm.template fl_dispose<s>(f,l);
2749  }
2750 
2751  /*
2752  * Typed allocation routines
2753  *
2754  */
2755  template<class T>
2756  forceinline T*
2757  Space::alloc(long unsigned int n) {
2758  T* p = static_cast<T*>(ralloc(sizeof(T)*n));
2759  for (long unsigned int i=n; i--; )
2760  (void) new (p+i) T();
2761  return p;
2762  }
2763  template<class T>
2764  forceinline T*
2765  Space::alloc(long int n) {
2766  assert(n >= 0);
2767  return alloc<T>(static_cast<long unsigned int>(n));
2768  }
2769  template<class T>
2770  forceinline T*
2771  Space::alloc(unsigned int n) {
2772  return alloc<T>(static_cast<long unsigned int>(n));
2773  }
2774  template<class T>
2775  forceinline T*
2777  assert(n >= 0);
2778  return alloc<T>(static_cast<long unsigned int>(n));
2779  }
2780 
2781  template<class T>
2782  forceinline void
2783  Space::free(T* b, long unsigned int n) {
2784  for (long unsigned int i=n; i--; )
2785  b[i].~T();
2786  rfree(b,n*sizeof(T));
2787  }
2788  template<class T>
2789  forceinline void
2790  Space::free(T* b, long int n) {
2791  assert(n >= 0);
2792  free<T>(b,static_cast<long unsigned int>(n));
2793  }
2794  template<class T>
2795  forceinline void
2796  Space::free(T* b, unsigned int n) {
2797  free<T>(b,static_cast<long unsigned int>(n));
2798  }
2799  template<class T>
2800  forceinline void
2801  Space::free(T* b, int n) {
2802  assert(n >= 0);
2803  free<T>(b,static_cast<long unsigned int>(n));
2804  }
2805 
2806  template<class T>
2807  forceinline T*
2808  Space::realloc(T* b, long unsigned int n, long unsigned int m) {
2809  if (n < m) {
2810  T* p = static_cast<T*>(ralloc(sizeof(T)*m));
2811  for (long unsigned int i=n; i--; )
2812  (void) new (p+i) T(b[i]);
2813  for (long unsigned int i=n; i<m; i++)
2814  (void) new (p+i) T();
2815  free<T>(b,n);
2816  return p;
2817  } else {
2818  free<T>(b+m,m-n);
2819  return b;
2820  }
2821  }
2822  template<class T>
2823  forceinline T*
2824  Space::realloc(T* b, long int n, long int m) {
2825  assert((n >= 0) && (m >= 0));
2826  return realloc<T>(b,static_cast<long unsigned int>(n),
2827  static_cast<long unsigned int>(m));
2828  }
2829  template<class T>
2830  forceinline T*
2831  Space::realloc(T* b, unsigned int n, unsigned int m) {
2832  return realloc<T>(b,static_cast<long unsigned int>(n),
2833  static_cast<long unsigned int>(m));
2834  }
2835  template<class T>
2836  forceinline T*
2837  Space::realloc(T* b, int n, int m) {
2838  assert((n >= 0) && (m >= 0));
2839  return realloc<T>(b,static_cast<long unsigned int>(n),
2840  static_cast<long unsigned int>(m));
2841  }
2842 
2843 #define GECODE_KERNEL_REALLOC(T) \
2844  template<> \
2845  forceinline T* \
2846  Space::realloc<T>(T* b, long unsigned int n, long unsigned int m) { \
2847  return static_cast<T*>(rrealloc(b,n*sizeof(T),m*sizeof(T))); \
2848  } \
2849  template<> \
2850  forceinline T* \
2851  Space::realloc<T>(T* b, long int n, long int m) { \
2852  assert((n >= 0) && (m >= 0)); \
2853  return realloc<T>(b,static_cast<long unsigned int>(n), \
2854  static_cast<long unsigned int>(m)); \
2855  } \
2856  template<> \
2857  forceinline T* \
2858  Space::realloc<T>(T* b, unsigned int n, unsigned int m) { \
2859  return realloc<T>(b,static_cast<long unsigned int>(n), \
2860  static_cast<long unsigned int>(m)); \
2861  } \
2862  template<> \
2863  forceinline T* \
2864  Space::realloc<T>(T* b, int n, int m) { \
2865  assert((n >= 0) && (m >= 0)); \
2866  return realloc<T>(b,static_cast<long unsigned int>(n), \
2867  static_cast<long unsigned int>(m)); \
2868  }
2869 
2870  GECODE_KERNEL_REALLOC(bool)
2871  GECODE_KERNEL_REALLOC(signed char)
2872  GECODE_KERNEL_REALLOC(unsigned char)
2873  GECODE_KERNEL_REALLOC(signed short int)
2874  GECODE_KERNEL_REALLOC(unsigned short int)
2875  GECODE_KERNEL_REALLOC(signed int)
2876  GECODE_KERNEL_REALLOC(unsigned int)
2877  GECODE_KERNEL_REALLOC(signed long int)
2878  GECODE_KERNEL_REALLOC(unsigned long int)
2879  GECODE_KERNEL_REALLOC(float)
2880  GECODE_KERNEL_REALLOC(double)
2881 
2882 #undef GECODE_KERNEL_REALLOC
2883 
2884  template<class T>
2885  forceinline T**
2886  Space::realloc(T** b, long unsigned int n, long unsigned int m) {
2887  return static_cast<T**>(rrealloc(b,n*sizeof(T),m*sizeof(T*)));
2888  }
2889  template<class T>
2890  forceinline T**
2891  Space::realloc(T** b, long int n, long int m) {
2892  assert((n >= 0) && (m >= 0));
2893  return realloc<T*>(b,static_cast<long unsigned int>(n),
2894  static_cast<long unsigned int>(m));
2895  }
2896  template<class T>
2897  forceinline T**
2898  Space::realloc(T** b, unsigned int n, unsigned int m) {
2899  return realloc<T*>(b,static_cast<long unsigned int>(n),
2900  static_cast<long unsigned int>(m));
2901  }
2902  template<class T>
2903  forceinline T**
2904  Space::realloc(T** b, int n, int m) {
2905  assert((n >= 0) && (m >= 0));
2906  return realloc<T*>(b,static_cast<long unsigned int>(n),
2907  static_cast<long unsigned int>(m));
2908  }
2909 
2910 
2911 #ifdef GECODE_HAS_VAR_DISPOSE
2912  template<class VIC>
2914  Space::vars_d(void) const {
2915  return _vars_d[VIC::idx_d];
2916  }
2917  template<class VIC>
2918  forceinline void
2919  Space::vars_d(VarImpBase* x) {
2920  _vars_d[VIC::idx_d] = x;
2921  }
2922 #endif
2923 
2924  // Space allocated entities: Actors, variable implementations, and advisors
2925  forceinline void
2926  Actor::operator delete(void*) {}
2927  forceinline void
2928  Actor::operator delete(void*, Space&) {}
2929  forceinline void*
2930  Actor::operator new(size_t s, Space& home) {
2931  return home.ralloc(s);
2932  }
2933 
2934  template<class VIC>
2935  forceinline void
2936  VarImp<VIC>::operator delete(void*) {}
2937  template<class VIC>
2938  forceinline void
2939  VarImp<VIC>::operator delete(void*, Space&) {}
2940  template<class VIC>
2941  forceinline void*
2942  VarImp<VIC>::operator new(size_t s, Space& home) {
2943  return home.ralloc(s);
2944  }
2945 
2946 #ifndef __GNUC__
2947  forceinline void
2948  Advisor::operator delete(void*) {}
2949 #endif
2950  forceinline void
2951  Advisor::operator delete(void*, Space&) {}
2952  forceinline void*
2953  Advisor::operator new(size_t s, Space& home) {
2954  return home.ralloc(s);
2955  }
2956 
2957  forceinline void
2958  NGL::operator delete(void*) {}
2959  forceinline void
2960  NGL::operator delete(void*, Space&) {}
2961  forceinline void*
2962  NGL::operator new(size_t s, Space& home) {
2963  return home.ralloc(s);
2964  }
2965 
2966 
2967  /*
2968  * No-goods
2969  *
2970  */
2971  forceinline
2973  : n(0) {}
2974  forceinline unsigned long int
2975  NoGoods::ng(void) const {
2976  return n;
2977  }
2978  forceinline void
2979  NoGoods::ng(unsigned long int n0) {
2980  n=n0;
2981  }
2982  forceinline
2984 
2985 
2986  /*
2987  * Information from meta search engines
2988  */
2989  forceinline
2990  MetaInfo::MetaInfo(unsigned long int r0,
2991  unsigned long int s0,
2992  unsigned long int f0,
2993  const Space* l0,
2994  NoGoods& ng0)
2995  : t(RESTART), r(r0), s(s0), f(f0), l(l0), ng(ng0), a(0) {}
2996 
2997  forceinline
2998  MetaInfo::MetaInfo(unsigned int a0)
2999  : t(PORTFOLIO), r(0), s(0), f(0), l(NULL), ng(NoGoods::eng), a(a0) {}
3000 
3002  MetaInfo::type(void) const {
3003  return t;
3004  }
3005  forceinline unsigned long int
3006  MetaInfo::restart(void) const {
3007  assert(type() == RESTART);
3008  return r;
3009  }
3010  forceinline unsigned long int
3011  MetaInfo::solution(void) const {
3012  assert(type() == RESTART);
3013  return s;
3014  }
3015  forceinline unsigned long int
3016  MetaInfo::fail(void) const {
3017  assert(type() == RESTART);
3018  return f;
3019  }
3020  forceinline const Space*
3021  MetaInfo::last(void) const {
3022  assert(type() == RESTART);
3023  return l;
3024  }
3025  forceinline const NoGoods&
3026  MetaInfo::nogoods(void) const {
3027  assert(type() == RESTART);
3028  return ng;
3029  }
3030  forceinline unsigned int
3031  MetaInfo::asset(void) const {
3032  assert(type() == PORTFOLIO);
3033  return a;
3034  }
3035 
3036 
3037 
3038  /*
3039  * ActorLink
3040  *
3041  */
3043  ActorLink::prev(void) const {
3044  return _prev;
3045  }
3046 
3048  ActorLink::next(void) const {
3049  return _next;
3050  }
3051 
3054  return &_next;
3055  }
3056 
3057  forceinline void
3059  _prev = al;
3060  }
3061 
3062  forceinline void
3064  _next = al;
3065  }
3066 
3067  forceinline void
3069  ActorLink* p = _prev; ActorLink* n = _next;
3070  p->_next = n; n->_prev = p;
3071  }
3072 
3073  forceinline void
3075  _next = this; _prev =this;
3076  }
3077 
3078  forceinline void
3080  // Inserts al at head of link-chain (that is, after this)
3081  ActorLink* n = _next;
3082  this->_next = a; a->_prev = this;
3083  a->_next = n; n->_prev = a;
3084  }
3085 
3086  forceinline void
3088  // Inserts al at tail of link-chain (that is, before this)
3089  ActorLink* p = _prev;
3090  a->_next = this; this->_prev = a;
3091  p->_next = a; a->_prev = p;
3092  }
3093 
3094  forceinline bool
3095  ActorLink::empty(void) const {
3096  return _next == this;
3097  }
3098 
3099  template<class T>
3102  // Turning al into a reference is for gcc, assume is for MSVC
3103  GECODE_NOT_NULL(a);
3104  ActorLink& t = *a;
3105  return static_cast<ActorLink*>(&t);
3106  }
3107 
3108  template<class T>
3109  forceinline const ActorLink*
3110  ActorLink::cast(const T* a) {
3111  // Turning al into a reference is for gcc, assume is for MSVC
3112  GECODE_NOT_NULL(a);
3113  const ActorLink& t = *a;
3114  return static_cast<const ActorLink*>(&t);
3115  }
3116 
3117 
3118  /*
3119  * Actor
3120  *
3121  */
3123  Actor::cast(ActorLink* al) {
3124  // Turning al into a reference is for gcc, assume is for MSVC
3125  GECODE_NOT_NULL(al);
3126  ActorLink& t = *al;
3127  return static_cast<Actor*>(&t);
3128  }
3129 
3130  forceinline const Actor*
3131  Actor::cast(const ActorLink* al) {
3132  // Turning al into a reference is for gcc, assume is for MSVC
3133  GECODE_NOT_NULL(al);
3134  const ActorLink& t = *al;
3135  return static_cast<const Actor*>(&t);
3136  }
3137 
3138  forceinline void
3139  Home::notice(Actor& a, ActorProperty p, bool duplicate) {
3140  s.notice(a,p,duplicate);
3141  }
3142 
3145  // Clone is only const for search engines. During cloning, several data
3146  // structures are updated (e.g. forwarding pointers), so we have to
3147  // cast away the constness.
3148  return const_cast<Space*>(this)->_clone();
3149  }
3150 
3151  forceinline void
3152  Space::commit(const Choice& c, unsigned int a, CommitStatistics&) {
3153  _commit(c,a);
3154  }
3155 
3156  forceinline void
3157  Space::trycommit(const Choice& c, unsigned int a, CommitStatistics&) {
3158  _trycommit(c,a);
3159  }
3160 
3161  forceinline double
3162  Space::afc_decay(void) const {
3163  return ssd.data().gpi.decay();
3164  }
3165 
3166  forceinline void
3168  ssd.data().gpi.decay(d);
3169  }
3170 
3171  forceinline size_t
3173  return sizeof(*this);
3174  }
3175 
3176 
3177  /*
3178  * Home for posting actors
3179  *
3180  */
3181  forceinline
3183  PropagatorGroup pg0, BrancherGroup bg0)
3184  : s(s0), p(p0), pg(pg0), bg(bg0) {}
3185  forceinline Home&
3187  s=h.s; p=h.p; pg=h.pg; bg=h.bg;
3188  return *this;
3189  }
3190  forceinline
3191  Home::operator Space&(void) {
3192  return s;
3193  }
3196  return Home(s,&p);
3197  }
3200  return Home(s,NULL,pg,BrancherGroup::def);
3201  }
3204  return Home(s,NULL,PropagatorGroup::def,bg);
3205  }
3208  return Home(*this,&p);
3209  }
3211  Home::propagator(void) const {
3212  return p;
3213  }
3216  return pg;
3217  }
3219  Home::branchergroup(void) const {
3220  return bg;
3221  }
3222 
3223  /*
3224  * View trace information
3225  *
3226  */
3227  forceinline void
3229  who = reinterpret_cast<ptrdiff_t>(&p) | PROPAGATOR;
3230  }
3231  forceinline void
3233  who = reinterpret_cast<ptrdiff_t>(&b) | BRANCHER;
3234  }
3235  forceinline void
3237  who = (g.id() << 2) | POST;
3238  }
3239  forceinline void
3241  who = OTHER;
3242  }
3244  ViewTraceInfo::what(void) const {
3245  return static_cast<What>(who & 3);
3246  }
3247  forceinline const Propagator&
3249  assert(what() == PROPAGATOR);
3250  // Because PROPAGATOR == 0
3251  return *reinterpret_cast<Propagator*>(who);
3252  }
3253  forceinline const Brancher&
3255  assert(what() == BRANCHER);
3256  return *reinterpret_cast<Brancher*>(who & ~3);
3257  }
3259  ViewTraceInfo::post(void) const {
3260  assert(what() == POST);
3261  return PropagatorGroup(static_cast<unsigned int>(who >> 2));
3262  }
3263 
3264  /*
3265  * Post information
3266  */
3267  forceinline
3268  PostInfo::PostInfo(Home home) : h(home) {
3269  h.pc.p.vti.post(home.propagatorgroup());
3270  }
3271  forceinline
3273  h.pc.p.vti.other();
3274  }
3275 
3276  /*
3277  * Propagate trace information
3278  *
3279  */
3280  forceinline
3282  const Propagator* p0, Status s0)
3283  : i(i0), g(g0), p(p0), s(s0) {}
3284  forceinline unsigned int
3286  return i;
3287  }
3290  return g;
3291  }
3292  forceinline const Propagator*
3294  return p;
3295  }
3298  return s;
3299  }
3300 
3301 
3302  /*
3303  * Commit trace information
3304  *
3305  */
3306  forceinline
3308  unsigned int a0)
3309  : b(b0), c(c0), a(a0) {}
3310  forceinline unsigned int
3311  CommitTraceInfo::id(void) const {
3312  return b.id();
3313  }
3316  return b.group();
3317  }
3318  forceinline const Brancher&
3320  return b;
3321  }
3322  forceinline const Choice&
3324  return c;
3325  }
3326  forceinline unsigned int
3328  return a;
3329  }
3330 
3331 
3332  /*
3333  * Propagator
3334  *
3335  */
3337  Propagator::cast(ActorLink* al) {
3338  // Turning al into a reference is for gcc, assume is for MSVC
3339  GECODE_NOT_NULL(al);
3340  ActorLink& t = *al;
3341  return static_cast<Propagator*>(&t);
3342  }
3343 
3344  forceinline const Propagator*
3345  Propagator::cast(const ActorLink* al) {
3346  // Turning al into a reference is for gcc, assume is for MSVC
3347  GECODE_NOT_NULL(al);
3348  const ActorLink& t = *al;
3349  return static_cast<const Propagator*>(&t);
3350  }
3351 
3353  Propagator::fwd(void) const {
3354  return static_cast<Propagator*>(prev());
3355  }
3356 
3357  forceinline bool
3358  Propagator::disabled(void) const {
3359  return Support::marked(gpi_disabled);
3360  }
3361 
3362  forceinline void
3363  Propagator::disable(Space& home) {
3364  home.pc.p.bid_sc |= Space::sc_disabled;
3365  gpi_disabled = Support::fmark(gpi_disabled);
3366  }
3367 
3368  forceinline void
3369  Propagator::enable(Space& home) {
3370  (void) home;
3371  gpi_disabled = Support::funmark(gpi_disabled);
3372  }
3373 
3376  return *static_cast<Kernel::GPI::Info*>(Support::funmark(gpi_disabled));
3377  }
3378 
3379  forceinline
3381  : gpi_disabled((home.propagator() != NULL) ?
3382  // Inherit propagator information
3383  home.propagator()->gpi_disabled :
3384  // New propagator information
3385  static_cast<Space&>(home).ssd.data().gpi.allocate
3386  (home.propagatorgroup().gid)) {
3387  u.advisors = NULL;
3388  assert((u.med == 0) && (u.size == 0));
3389  static_cast<Space&>(home).pl.head(this);
3390  }
3391 
3392  forceinline
3394  : gpi_disabled(p.gpi_disabled) {
3395  u.advisors = NULL;
3396  assert((u.med == 0) && (u.size == 0));
3397  // Set forwarding pointer
3398  p.prev(this);
3399  }
3400 
3403  return u.med;
3404  }
3405 
3406  forceinline double
3407  Propagator::afc(void) const {
3408  return const_cast<Propagator&>(*this).gpi().afc;
3409  }
3410 
3411  forceinline unsigned int
3412  Propagator::id(void) const {
3413  return const_cast<Propagator&>(*this).gpi().pid;
3414  }
3415 
3417  Propagator::group(void) const {
3418  return PropagatorGroup(const_cast<Propagator&>(*this).gpi().gid);
3419  }
3420 
3421  forceinline void
3423  gpi().gid = g.id();
3424  }
3425 
3428  p.u.size = s;
3429  return __ES_SUBSUMED;
3430  }
3431 
3434  p.u.size = p.dispose(*this);
3435  return __ES_SUBSUMED;
3436  }
3437 
3440  p.u.med = med;
3441  assert(p.u.med != 0);
3442  return __ES_PARTIAL;
3443  }
3444 
3447  p.u.med = AllVarConf::med_combine(p.u.med,med);
3448  assert(p.u.med != 0);
3449  return __ES_PARTIAL;
3450  }
3451 
3452 
3453 
3454  /*
3455  * Brancher
3456  *
3457  */
3459  Brancher::cast(ActorLink* al) {
3460  // Turning al into a reference is for gcc, assume is for MSVC
3461  GECODE_NOT_NULL(al);
3462  ActorLink& t = *al;
3463  return static_cast<Brancher*>(&t);
3464  }
3465 
3466  forceinline const Brancher*
3467  Brancher::cast(const ActorLink* al) {
3468  // Turning al into a reference is for gcc, assume is for MSVC
3469  GECODE_NOT_NULL(al);
3470  const ActorLink& t = *al;
3471  return static_cast<const Brancher*>(&t);
3472  }
3473 
3474  forceinline
3476  gid(_home.branchergroup().gid) {
3477  Space& home = static_cast<Space&>(_home);
3478  bid = home.pc.p.bid_sc >> Space::sc_bits;
3479  home.pc.p.bid_sc += (1 << Space::sc_bits);
3480  if ((home.pc.p.bid_sc >> Space::sc_bits) == 0U)
3481  throw TooManyBranchers("Brancher::Brancher");
3482  // If no brancher available, make it the first one
3483  if (home.b_status == &static_cast<Space&>(home).bl) {
3484  home.b_status = this;
3485  if (home.b_commit == &static_cast<Space&>(home).bl)
3486  home.b_commit = this;
3487  }
3488  home.bl.tail(this);
3489  }
3490 
3491  forceinline
3493  : bid(b.bid), gid(b.gid) {
3494  // Set forwarding pointer
3495  b.prev(this);
3496  }
3497 
3498  forceinline unsigned int
3499  Brancher::id(void) const {
3500  return bid;
3501  }
3502 
3504  Brancher::group(void) const {
3505  return BrancherGroup(gid);
3506  }
3507 
3508  forceinline void
3510  gid = g.id();
3511  }
3512 
3513 
3514  forceinline void
3515  Space::kill(Brancher& b) {
3516  assert(!failed());
3517  // Make sure that neither b_status nor b_commit does not point to b!
3518  if (b_commit == &b)
3519  b_commit = Brancher::cast(b.next());
3520  if (b_status == &b)
3521  b_status = Brancher::cast(b.next());
3522  b.unlink();
3523  rfree(&b,b.dispose(*this));
3524  }
3525 
3526  forceinline void
3527  Space::kill(Propagator& p) {
3528  assert(!failed());
3529  p.unlink();
3530  rfree(&p,p.dispose(*this));
3531  }
3532 
3534  Space::brancher(unsigned int id) {
3535  /*
3536  * Due to weakly monotonic propagators the following scenario might
3537  * occur: a brancher has been committed with all its available
3538  * choices. Then, propagation determines less information
3539  * than before and the brancher now will create new choices.
3540  * Later, during recomputation, all of these choices
3541  * can be used together, possibly interleaved with
3542  * choices for other branchers. That means all branchers
3543  * must be scanned to find the matching brancher for the choice.
3544  *
3545  * b_commit tries to optimize scanning as it is most likely that
3546  * recomputation does not generate new choices during recomputation
3547  * and hence b_commit is moved from newer to older branchers.
3548  */
3549  Brancher* b_old = b_commit;
3550  // Try whether we are lucky
3551  while (b_commit != Brancher::cast(&bl))
3552  if (id != b_commit->id())
3553  b_commit = Brancher::cast(b_commit->next());
3554  else
3555  return b_commit;
3556  if (b_commit == Brancher::cast(&bl)) {
3557  // We did not find the brancher, start at the beginning
3558  b_commit = Brancher::cast(bl.next());
3559  while (b_commit != b_old)
3560  if (id != b_commit->id())
3561  b_commit = Brancher::cast(b_commit->next());
3562  else
3563  return b_commit;
3564  }
3565  return NULL;
3566  }
3567 
3568 
3569  /*
3570  * Local objects
3571  *
3572  */
3573 
3576  // Turning al into a reference is for gcc, assume is for MSVC
3577  GECODE_NOT_NULL(al);
3578  ActorLink& t = *al;
3579  return static_cast<LocalObject*>(&t);
3580  }
3581 
3582  forceinline const LocalObject*
3584  // Turning al into a reference is for gcc, assume is for MSVC
3585  GECODE_NOT_NULL(al);
3586  const ActorLink& t = *al;
3587  return static_cast<const LocalObject*>(&t);
3588  }
3589 
3590  forceinline
3592  (void) home;
3593  ActorLink::cast(this)->prev(NULL);
3594  }
3595 
3596  forceinline
3598  ActorLink::cast(this)->prev(NULL);
3599  }
3600 
3603  if (prev() == NULL)
3604  fwdcopy(home);
3605  return LocalObject::cast(prev());
3606  }
3607 
3608  forceinline
3609  LocalHandle::LocalHandle(void) : o(NULL) {}
3610  forceinline
3612  forceinline
3613  LocalHandle::LocalHandle(const LocalHandle& lh) : o(lh.o) {}
3616  o = lh.o;
3617  return *this;
3618  }
3619  forceinline
3622  LocalHandle::object(void) const { return o; }
3623  forceinline void
3625  forceinline void
3627  object(lh.object()->fwd(home));
3628  }
3629 
3630 
3631  /*
3632  * Choices
3633  *
3634  */
3635  forceinline
3636  Choice::Choice(const Brancher& b, const unsigned int a)
3637  : bid(b.id()), alt(a) {}
3638 
3639  forceinline unsigned int
3640  Choice::alternatives(void) const {
3641  return alt;
3642  }
3643 
3644  forceinline unsigned int
3645  Choice::id(void) const {
3646  return bid;
3647  }
3648 
3649  forceinline
3651 
3652 
3653 
3654  /*
3655  * No-good literal
3656  *
3657  */
3658  forceinline bool
3659  NGL::leaf(void) const {
3660  return Support::marked(nl);
3661  }
3662  forceinline NGL*
3663  NGL::next(void) const {
3664  return static_cast<NGL*>(Support::funmark(nl));
3665  }
3666  forceinline void
3667  NGL::leaf(bool l) {
3668  nl = l ? Support::fmark(nl) : Support::funmark(nl);
3669  }
3670  forceinline void
3672  nl = Support::marked(nl) ? Support::mark(n) : n;
3673  }
3674  forceinline NGL*
3675  NGL::add(NGL* n, bool l) {
3676  nl = Support::marked(nl) ? Support::mark(n) : n;
3677  n->leaf(l);
3678  return n;
3679  }
3680 
3681  forceinline
3682  NGL::NGL(void)
3683  : nl(NULL) {}
3684  forceinline
3686  : nl(NULL) {}
3687  forceinline
3689  : nl(NULL) {}
3690  forceinline size_t
3692  return sizeof(*this);
3693  }
3694 
3695  /*
3696  * Advisor
3697  *
3698  */
3699  template<class A>
3700  forceinline
3702  // Store propagator and forwarding in prev()
3703  ActorLink::prev(&p);
3704  // Link to next advisor in next()
3705  ActorLink::next(c.advisors); c.advisors = static_cast<A*>(this);
3706  }
3707 
3708  forceinline
3710 
3711  forceinline bool
3712  Advisor::disposed(void) const {
3713  return prev() == NULL;
3714  }
3715 
3717  Advisor::cast(ActorLink* al) {
3718  return static_cast<Advisor*>(al);
3719  }
3720 
3721  forceinline const Advisor*
3722  Advisor::cast(const ActorLink* al) {
3723  return static_cast<const Advisor*>(al);
3724  }
3725 
3727  Advisor::propagator(void) const {
3728  assert(!disposed());
3729  return *Propagator::cast(ActorLink::prev());
3730  }
3731 
3732  template<class A>
3733  forceinline void
3735  assert(!disposed());
3736  ActorLink::prev(NULL);
3737  // Shorten chains of disposed advisors by one, if possible
3738  Advisor* n = Advisor::cast(next());
3739  if ((n != NULL) && n->disposed())
3740  next(n->next());
3741  }
3742 
3743  forceinline const ViewTraceInfo&
3744  Advisor::operator ()(const Space& home) const {
3745  return home.pc.p.vti;
3746  }
3747 
3748  template<class A>
3751  a.dispose(*this,c);
3752  return ES_FIX;
3753  }
3754 
3755  template<class A>
3758  a.dispose(*this,c);
3759  return ES_NOFIX;
3760  }
3761 
3762  template<class A>
3765  a.dispose(*this,c);
3766  return ES_NOFIX_FORCE;
3767  }
3768 
3769 
3770 
3771  /*
3772  * Advisor council
3773  *
3774  */
3775  template<class A>
3776  forceinline
3778 
3779  template<class A>
3780  forceinline
3782  : advisors(NULL) {}
3783 
3784  template<class A>
3785  forceinline bool
3786  Council<A>::empty(void) const {
3787  ActorLink* a = advisors;
3788  while ((a != NULL) && static_cast<A*>(a)->disposed())
3789  a = a->next();
3790  advisors = a;
3791  return a == NULL;
3792  }
3793 
3794  template<class A>
3795  forceinline void
3797  // Skip all disposed advisors
3798  {
3799  ActorLink* a = c.advisors;
3800  while ((a != NULL) && static_cast<A*>(a)->disposed())
3801  a = a->next();
3802  c.advisors = a;
3803  }
3804  // Are there any advisors to be cloned?
3805  if (c.advisors != NULL) {
3806  // The propagator in from-space
3807  Propagator* p_f = &static_cast<A*>(c.advisors)->propagator();
3808  // The propagator in to-space
3809  Propagator* p_t = Propagator::cast(p_f->prev());
3810  // Advisors in from-space
3811  ActorLink** a_f = &c.advisors;
3812  // Advisors in to-space
3813  A* a_t = NULL;
3814  while (*a_f != NULL) {
3815  if (static_cast<A*>(*a_f)->disposed()) {
3816  *a_f = (*a_f)->next();
3817  } else {
3818  // Run specific copying part
3819  A* a = new (home) A(home,*static_cast<A*>(*a_f));
3820  // Set propagator pointer
3821  a->prev(p_t);
3822  // Set forwarding pointer
3823  (*a_f)->prev(a);
3824  // Link
3825  a->next(a_t);
3826  a_t = a;
3827  a_f = (*a_f)->next_ref();
3828  }
3829  }
3830  advisors = a_t;
3831  // Enter advisor link for reset
3832  assert(p_f->u.advisors == NULL);
3833  p_f->u.advisors = c.advisors;
3834  } else {
3835  advisors = NULL;
3836  }
3837  }
3838 
3839  template<class A>
3840  forceinline void
3842  ActorLink* a = advisors;
3843  while (a != NULL) {
3844  if (!static_cast<A*>(a)->disposed())
3845  static_cast<A*>(a)->dispose(home,*this);
3846  a = a->next();
3847  }
3848  }
3849 
3850 
3851 
3852  /*
3853  * Advisor iterator
3854  *
3855  */
3856  template<class A>
3857  forceinline
3859  : a(c.advisors) {
3860  while ((a != NULL) && static_cast<A*>(a)->disposed())
3861  a = a->next();
3862  }
3863 
3864  template<class A>
3865  forceinline bool
3867  return a != NULL;
3868  }
3869 
3870  template<class A>
3871  forceinline void
3873  do {
3874  a = a->next();
3875  } while ((a != NULL) && static_cast<A*>(a)->disposed());
3876  }
3877 
3878  template<class A>
3879  forceinline A&
3880  Advisors<A>::advisor(void) const {
3881  return *static_cast<A*>(a);
3882  }
3883 
3884 
3885 
3886  /*
3887  * Space
3888  *
3889  */
3890  forceinline void
3891  Space::enqueue(Propagator* p) {
3892  ActorLink::cast(p)->unlink();
3893  ActorLink* c = &pc.p.queue[p->cost(*this,p->u.med).ac];
3894  c->tail(ActorLink::cast(p));
3895  if (c > pc.p.active)
3896  pc.p.active = c;
3897  }
3898 
3899  forceinline void
3900  Space::fail(void) {
3901  /*
3902  * Now active points beyond the last queue. This is essential as
3903  * enqueuing a propagator in a failed space keeps the space
3904  * failed.
3905  */
3906  pc.p.active = &pc.p.queue[PropCost::AC_MAX+1]+1;
3907  }
3908  forceinline void
3909  Home::fail(void) {
3910  s.fail();
3911  }
3912 
3913  forceinline bool
3914  Space::failed(void) const {
3915  return pc.p.active > &pc.p.queue[PropCost::AC_MAX+1];
3916  }
3917  forceinline bool
3918  Home::failed(void) const {
3919  return s.failed();
3920  }
3921 
3922  forceinline bool
3923  Space::stable(void) const {
3924  return ((pc.p.active < &pc.p.queue[0]) ||
3925  (pc.p.active > &pc.p.queue[PropCost::AC_MAX+1]));
3926  }
3927 
3928  forceinline void
3930  if (p & AP_DISPOSE) {
3931  ap_notice_dispose(&a,d);
3932  }
3933  if (p & AP_VIEW_TRACE) {
3934  pc.p.bid_sc |= sc_trace;
3935  }
3936  if (p & AP_TRACE) {
3937  pc.p.bid_sc |= sc_trace;
3938  }
3939  // Currently unused
3940  if (p & AP_WEAKLY) {}
3941  }
3942 
3943  forceinline void
3945  // Check wether array has already been discarded as space
3946  // deletion is already in progress
3947  if ((p & AP_DISPOSE) && (d_fst != NULL))
3948  ap_ignore_dispose(&a,d);
3949  if (p & AP_VIEW_TRACE) {}
3950  if (p & AP_TRACE) {}
3951  // Currently unused
3952  if (p & AP_WEAKLY) {}
3953  }
3954 
3955 
3956 
3957  /*
3958  * Variable implementation
3959  *
3960  */
3961  template<class VIC>
3964  assert((pc >= 0) && (pc < pc_max+2));
3965  return (pc == 0) ? b.base : b.base+u.idx[pc-1];
3966  }
3967 
3968  template<class VIC>
3971  assert((pc > 0) && (pc < pc_max+2));
3972  return b.base+u.idx[pc-1];
3973  }
3974 
3975  template<class VIC>
3976  forceinline unsigned int&
3978  assert((pc > 0) && (pc < pc_max+2));
3979  return u.idx[pc-1];
3980  }
3981 
3982  template<class VIC>
3983  forceinline unsigned int
3984  VarImp<VIC>::idx(PropCond pc) const {
3985  assert((pc > 0) && (pc < pc_max+2));
3986  return u.idx[pc-1];
3987  }
3988 
3989  template<class VIC>
3990  forceinline
3992  b.base = NULL; entries = 0;
3993  for (PropCond pc=1; pc<pc_max+2; pc++)
3994  idx(pc) = 0;
3995  free_and_bits = 0;
3996  }
3997 
3998  template<class VIC>
3999  forceinline
4001  b.base = NULL; entries = 0;
4002  for (PropCond pc=1; pc<pc_max+2; pc++)
4003  idx(pc) = 0;
4004  free_and_bits = 0;
4005  }
4006 
4007  template<class VIC>
4008  forceinline unsigned int
4009  VarImp<VIC>::degree(void) const {
4010  assert(!copied());
4011  return entries;
4012  }
4013 
4014  template<class VIC>
4015  forceinline double
4016  VarImp<VIC>::afc(void) const {
4017  double d = 0.0;
4018  // Count the afc of each propagator
4019  {
4020  ActorLink** a = const_cast<VarImp<VIC>*>(this)->actor(0);
4021  ActorLink** e = const_cast<VarImp<VIC>*>(this)->actorNonZero(pc_max+1);
4022  while (a < e) {
4023  d += Propagator::cast(*a)->afc(); a++;
4024  }
4025  }
4026  // Count the afc of each advisor's propagator
4027  {
4028  ActorLink** a = const_cast<VarImp<VIC>*>(this)->actorNonZero(pc_max+1);
4029  ActorLink** e = const_cast<VarImp<VIC>*>(this)->b.base+entries;
4030  while (a < e) {
4031  d += Advisor::cast(static_cast<ActorLink*>(Support::funmark(*a)))
4032  ->propagator().afc();
4033  a++;
4034  }
4035  }
4036  return d;
4037  }
4038 
4039  template<class VIC>
4042  return d.me;
4043  }
4044 
4045  template<class VIC>
4046  forceinline unsigned int
4047  VarImp<VIC>::bits(void) const {
4048  return free_and_bits;
4049  }
4050 
4051  template<class VIC>
4052  forceinline unsigned int&
4054  return free_and_bits;
4055  }
4056 
4057 #ifdef GECODE_HAS_VAR_DISPOSE
4058  template<class VIC>
4060  VarImp<VIC>::vars_d(Space& home) {
4061  return static_cast<VarImp<VIC>*>(home.vars_d<VIC>());
4062  }
4063 
4064  template<class VIC>
4065  forceinline void
4067  home.vars_d<VIC>(x);
4068  }
4069 #endif
4070 
4071  template<class VIC>
4072  forceinline bool
4073  VarImp<VIC>::copied(void) const {
4074  return Support::marked(b.fwd);
4075  }
4076 
4077  template<class VIC>
4079  VarImp<VIC>::forward(void) const {
4080  assert(copied());
4081  return static_cast<VarImp<VIC>*>(Support::unmark(b.fwd));
4082  }
4083 
4084  template<class VIC>
4086  VarImp<VIC>::next(void) const {
4087  assert(copied());
4088  return u.next;
4089  }
4090 
4091  template<class VIC>
4092  forceinline
4094  VarImpBase** reg;
4095  free_and_bits = x.free_and_bits & ((1 << free_bits) - 1);
4096  if (x.b.base == NULL) {
4097  // Variable implementation needs no index structure
4098  reg = &home.pc.c.vars_noidx;
4099  assert(x.degree() == 0);
4100  } else {
4101  reg = &home.pc.c.vars_u[idx_c];
4102  }
4103  // Save subscriptions in copy
4104  b.base = x.b.base;
4105  entries = x.entries;
4106  for (PropCond pc=1; pc<pc_max+2; pc++)
4107  idx(pc) = x.idx(pc);
4108 
4109  // Set forwarding pointer
4110  x.b.fwd = static_cast<VarImp<VIC>*>(Support::mark(this));
4111  // Register original
4112  x.u.next = static_cast<VarImp<VIC>*>(*reg); *reg = &x;
4113  }
4114 
4115  template<class VIC>
4118  return static_cast<ModEvent>((med & VIC::med_mask) >> VIC::med_fst);
4119  }
4120 
4121  template<class VIC>
4124  return static_cast<ModEventDelta>(me << VIC::med_fst);
4125  }
4126 
4127  template<class VIC>
4130  return VIC::me_combine(me1,me2);
4131  }
4132 
4133  template<class VIC>
4134  forceinline void
4136  bool force) {
4137  if (VIC::med_update(p.u.med,me) || force)
4138  home.enqueue(&p);
4139  }
4140 
4141  template<class VIC>
4142  forceinline void
4144  ActorLink** b = actor(pc1);
4145  ActorLink** p = actorNonZero(pc2+1);
4146  while (p-- > b)
4147  schedule(home,*Propagator::cast(*p),me);
4148  }
4149 
4150  template<class VIC>
4151  forceinline void
4152  VarImp<VIC>::resize(Space& home) {
4153  if (b.base == NULL) {
4154  assert((free_and_bits >> free_bits) == 0);
4155  // Create fresh dependency array with four entries
4156  free_and_bits += 4 << free_bits;
4157  b.base = home.alloc<ActorLink*>(4);
4158  for (int i=0; i<pc_max+1; i++)
4159  u.idx[i] = 0;
4160  } else {
4161  // Resize dependency array
4162  unsigned int n = degree();
4163  // Find out whether the area is most likely in the special area
4164  // reserved for subscriptions. If yes, just resize mildly otherwise
4165  // more agressively
4166  ActorLink** s = static_cast<ActorLink**>(home.mm.subscriptions());
4167  unsigned int m =
4168  ((s <= b.base) && (b.base < s+home.pc.p.n_sub)) ?
4169  (n+4) : ((n+1)*3>>1);
4170  ActorLink** prop = home.alloc<ActorLink*>(m);
4171  free_and_bits += (m-n) << free_bits;
4172  // Copy entries
4173  Heap::copy<ActorLink*>(prop, b.base, n);
4174  home.free<ActorLink*>(b.base,n);
4175  b.base = prop;
4176  }
4177  }
4178 
4179  template<class VIC>
4180  forceinline void
4181  VarImp<VIC>::enter(Space& home, Propagator* p, PropCond pc) {
4182  assert(pc <= pc_max);
4183  // Count one new subscription
4184  home.pc.p.n_sub += 1;
4185  if ((free_and_bits >> free_bits) == 0)
4186  resize(home);
4187  free_and_bits -= 1 << free_bits;
4188 
4189  // Enter subscription
4190  b.base[entries] = *actorNonZero(pc_max+1);
4191  entries++;
4192  for (PropCond j = pc_max; j > pc; j--) {
4193  *actorNonZero(j+1) = *actorNonZero(j);
4194  idx(j+1)++;
4195  }
4196  *actorNonZero(pc+1) = *actor(pc);
4197  idx(pc+1)++;
4198  *actor(pc) = ActorLink::cast(p);
4199 
4200 #ifdef GECODE_AUDIT
4201  ActorLink** f = actor(pc);
4202  while (f < (pc == pc_max+1 ? b.base+entries : actorNonZero(pc+1)))
4203  if (*f == p)
4204  goto found;
4205  else
4206  f++;
4207  GECODE_NEVER;
4208  found: ;
4209 #endif
4210  }
4211 
4212  template<class VIC>
4213  forceinline void
4214  VarImp<VIC>::enter(Space& home, Advisor* a) {
4215  // Note that a might be a marked pointer
4216  // Count one new subscription
4217  home.pc.p.n_sub += 1;
4218  if ((free_and_bits >> free_bits) == 0)
4219  resize(home);
4220  free_and_bits -= 1 << free_bits;
4221 
4222  // Enter subscription
4223  b.base[entries++] = *actorNonZero(pc_max+1);
4224  *actorNonZero(pc_max+1) = a;
4225  }
4226 
4227  template<class VIC>
4228  forceinline void
4230  bool assigned, ModEvent me, bool schedule) {
4231  if (assigned) {
4232  // Do not subscribe, just schedule the propagator
4233  if (schedule)
4235  } else {
4236  enter(home,&p,pc);
4237  // Schedule propagator
4238  if (schedule && (pc != PC_GEN_ASSIGNED))
4239  VarImp<VIC>::schedule(home,p,me);
4240  }
4241  }
4242 
4243  template<class VIC>
4244  forceinline void
4245  VarImp<VIC>::subscribe(Space& home, Advisor& a, bool assigned, bool fail) {
4246  if (!assigned) {
4247  Advisor* ma = static_cast<Advisor*>(Support::ptrjoin(&a,fail ? 1 : 0));
4248  enter(home,ma);
4249  }
4250  }
4251 
4252  template<class VIC>
4253  forceinline void
4255  bool assigned, ModEvent me) {
4256  if (assigned)
4258  else if (pc != PC_GEN_ASSIGNED)
4259  VarImp<VIC>::schedule(home,p,me);
4260  }
4261 
4262  template<class VIC>
4263  void
4264  VarImp<VIC>::remove(Space& home, Propagator* p, PropCond pc) {
4265  assert(pc <= pc_max);
4266  ActorLink* a = ActorLink::cast(p);
4267  // Find actor in dependency array
4268  ActorLink** f = actor(pc);
4269 #ifdef GECODE_AUDIT
4270  while (f < actorNonZero(pc+1))
4271  if (*f == a)
4272  goto found;
4273  else
4274  f++;
4275  GECODE_NEVER;
4276  found: ;
4277 #else
4278  while (*f != a) f++;
4279 #endif
4280  // Remove actor
4281  *f = *(actorNonZero(pc+1)-1);
4282  for (PropCond j = pc+1; j< pc_max+1; j++) {
4283  *(actorNonZero(j)-1) = *(actorNonZero(j+1)-1);
4284  idx(j)--;
4285  }
4286  *(actorNonZero(pc_max+1)-1) = b.base[entries-1];
4287  idx(pc_max+1)--;
4288  entries--;
4289  free_and_bits += 1 << free_bits;
4290  home.pc.p.n_sub -= 1;
4291  }
4292 
4293  template<class VIC>
4294  forceinline void
4296  if (b.base != NULL)
4297  remove(home,&p,pc);
4298  }
4299 
4300  template<class VIC>
4301  void
4302  VarImp<VIC>::remove(Space& home, Advisor* a) {
4303  // Note that a might be a marked pointer
4304  // Find actor in dependency array
4305  ActorLink** f = actorNonZero(pc_max+1);
4306 #ifdef GECODE_AUDIT
4307  while (f < b.base+entries)
4308  if (*f == a)
4309  goto found;
4310  else
4311  f++;
4312  GECODE_NEVER;
4313  found: ;
4314 #else
4315  while (*f != a) f++;
4316 #endif
4317  // Remove actor
4318  *f = b.base[--entries];
4319  free_and_bits += 1 << free_bits;
4320  home.pc.p.n_sub -= 1;
4321  }
4322 
4323  template<class VIC>
4324  forceinline void
4325  VarImp<VIC>::cancel(Space& home, Advisor& a, bool fail) {
4326  if (b.base != NULL) {
4327  Advisor* ma = static_cast<Advisor*>(Support::ptrjoin(&a,fail ? 1 : 0));
4328  remove(home,ma);
4329  }
4330  }
4331 
4332  template<class VIC>
4333  forceinline void
4335  unsigned int n_sub = degree();
4336  home.pc.p.n_sub -= n_sub;
4337  unsigned int n = (free_and_bits >> free_bits) + n_sub;
4338  home.free<ActorLink*>(b.base,n);
4339  // Must be NULL such that cloning works
4340  b.base = NULL;
4341  // Must be 0 such that degree works
4342  entries = 0;
4343  // Must be NULL such that afc works
4344  for (PropCond pc=1; pc<pc_max+2; pc++)
4345  idx(pc) = 0;
4346  free_and_bits &= (1 << free_bits) - 1;
4347  }
4348 
4349  template<class VIC>
4350  forceinline bool
4352  /*
4353  * An advisor that is executed might remove itself due to subsumption.
4354  * As entries are removed from front to back, the advisors must
4355  * be iterated in forward direction.
4356  */
4357  ActorLink** la = actorNonZero(pc_max+1);
4358  ActorLink** le = b.base+entries;
4359  if (la == le)
4360  return true;
4361  d.me = me;
4362  // An advisor that is run, might be removed during execution.
4363  // As removal is done from the back the advisors have to be executed
4364  // in inverse order.
4365  do {
4366  Advisor* a = Advisor::cast
4367  (static_cast<ActorLink*>(Support::funmark(*la)));
4368  assert(!a->disposed());
4369  Propagator& p = a->propagator();
4370  switch (p.advise(home,*a,d)) {
4371  case ES_FIX:
4372  break;
4373  case ES_FAILED:
4374  return false;
4375  case ES_NOFIX:
4376  schedule(home,p,me);
4377  break;
4378  case ES_NOFIX_FORCE:
4379  schedule(home,p,me,true);
4380  break;
4381  case __ES_SUBSUMED:
4382  default:
4383  GECODE_NEVER;
4384  }
4385  } while (++la < le);
4386  return true;
4387  }
4388 
4389  template<class VIC>
4390  void
4391  VarImp<VIC>::_fail(Space& home) {
4392  /*
4393  * An advisor that is executed might remove itself due to subsumption.
4394  * As entries are removed from front to back, the advisors must
4395  * be iterated in forward direction.
4396  */
4397  ActorLink** la = actorNonZero(pc_max+1);
4398  ActorLink** le = b.base+entries;
4399  if (la == le)
4400  return;
4401  // An advisor that is run, might be removed during execution.
4402  // As removal is done from the back the advisors have to be executed
4403  // in inverse order.
4404  do {
4405  if (Support::marked(*la)) {
4406  Advisor* a = Advisor::cast(static_cast<ActorLink*>
4407  (Support::unmark(*la)));
4408  assert(!a->disposed());
4409  Propagator& p = a->propagator();
4410  p.advise(home,*a);
4411  }
4412  } while (++la < le);
4413  }
4414 
4415  template<class VIC>
4416  ModEvent
4418  _fail(home);
4419  return ME_GEN_FAILED;
4420  }
4421 
4422  template<class VIC>
4423  forceinline void
4425  // this refers to the variable to be updated (clone)
4426  // x refers to the original
4427  // Recover from copy
4428  x->b.base = b.base;
4429  x->u.idx[0] = u.idx[0];
4430  if (pc_max > 0 && sizeof(ActorLink**) > sizeof(unsigned int))
4431  x->u.idx[1] = u.idx[1];
4432 
4433  unsigned int np =
4434  static_cast<unsigned int>(x->actorNonZero(pc_max+1) - x->actor(0));
4435  unsigned int na =
4436  static_cast<unsigned int >(x->b.base + x->entries -
4437  x->actorNonZero(pc_max+1));
4438  unsigned int n = na + np;
4439  assert(n == x->degree());
4440 
4441  ActorLink** f = x->b.base;
4442  ActorLink** t = sub;
4443 
4444  sub += n;
4445  b.base = t;
4446  // Process propagator subscriptions
4447  while (np >= 4) {
4448  ActorLink* p3 = f[3]->prev();
4449  ActorLink* p0 = f[0]->prev();
4450  ActorLink* p1 = f[1]->prev();
4451  ActorLink* p2 = f[2]->prev();
4452  t[0] = p0; t[1] = p1; t[2] = p2; t[3] = p3;
4453  np -= 4; t += 4; f += 4;
4454  }
4455  if (np >= 2) {
4456  ActorLink* p0 = f[0]->prev();
4457  ActorLink* p1 = f[1]->prev();
4458  t[0] = p0; t[1] = p1;
4459  np -= 2; t += 2; f += 2;
4460  }
4461  if (np > 0) {
4462  ActorLink* p0 = f[0]->prev();
4463  t[0] = p0;
4464  t += 1; f += 1;
4465  }
4466  // Process advisor subscriptions
4467  while (na >= 4) {
4468  ptrdiff_t m0, m1, m2, m3;
4469  ActorLink* p3 =
4470  static_cast<ActorLink*>(Support::ptrsplit(f[3],m3))->prev();
4471  ActorLink* p0 =
4472  static_cast<ActorLink*>(Support::ptrsplit(f[0],m0))->prev();
4473  ActorLink* p1 =
4474  static_cast<ActorLink*>(Support::ptrsplit(f[1],m1))->prev();
4475  ActorLink* p2 =
4476  static_cast<ActorLink*>(Support::ptrsplit(f[2],m2))->prev();
4477  t[0] = static_cast<ActorLink*>(Support::ptrjoin(p0,m0));
4478  t[1] = static_cast<ActorLink*>(Support::ptrjoin(p1,m1));
4479  t[2] = static_cast<ActorLink*>(Support::ptrjoin(p2,m2));
4480  t[3] = static_cast<ActorLink*>(Support::ptrjoin(p3,m3));
4481  na -= 4; t += 4; f += 4;
4482  }
4483  if (na >= 2) {
4484  ptrdiff_t m0, m1;
4485  ActorLink* p0 =
4486  static_cast<ActorLink*>(Support::ptrsplit(f[0],m0))->prev();
4487  ActorLink* p1 =
4488  static_cast<ActorLink*>(Support::ptrsplit(f[1],m1))->prev();
4489  t[0] = static_cast<ActorLink*>(Support::ptrjoin(p0,m0));
4490  t[1] = static_cast<ActorLink*>(Support::ptrjoin(p1,m1));
4491  na -= 2; t += 2; f += 2;
4492  }
4493  if (na > 0) {
4494  ptrdiff_t m0;
4495  ActorLink* p0 =
4496  static_cast<ActorLink*>(Support::ptrsplit(f[0],m0))->prev();
4497  t[0] = static_cast<ActorLink*>(Support::ptrjoin(p0,m0));
4498  }
4499  }
4500 
4501  template<class VIC>
4502  forceinline void
4503  VarImp<VIC>::update(Space& home, ActorLink**& sub) {
4504  VarImp<VIC>* x = static_cast<VarImp<VIC>*>(home.pc.c.vars_u[idx_c]);
4505  while (x != NULL) {
4506  VarImp<VIC>* n = x->next(); x->forward()->update(x,sub); x = n;
4507  }
4508  }
4509 
4510 
4511 
4512  /*
4513  * Variable disposer
4514  *
4515  */
4516  template<class VarImp>
4518 #ifdef GECODE_HAS_VAR_DISPOSE
4519  Space::vd[VarImp::idx_d] = this;
4520 #endif
4521  }
4522 
4523  template<class VarImp>
4524  void
4526  VarImp* x = static_cast<VarImp*>(_x);
4527  do {
4528  x->dispose(home); x = static_cast<VarImp*>(x->next_d());
4529  } while (x != NULL);
4530  }
4531 
4532  /*
4533  * Statistics
4534  */
4535 
4536  forceinline void
4538  propagate = 0;
4539  }
4540  forceinline
4542  reset();
4543  }
4546  propagate += s.propagate;
4547  return *this;
4548  }
4551  StatusStatistics t(s);
4552  return t += *this;
4553  }
4554 
4555  forceinline void
4557 
4558  forceinline
4560  reset();
4561  }
4564  CloneStatistics s;
4565  return s;
4566  }
4569  return *this;
4570  }
4571 
4572  forceinline void
4574 
4575  forceinline
4577  reset();
4578  }
4581  CommitStatistics s;
4582  return s;
4583  }
4586  return *this;
4587  }
4588 
4589  /*
4590  * Cost computation
4591  *
4592  */
4593 
4594  forceinline
4595  PropCost::PropCost(PropCost::ActualCost ac0) : ac(ac0) {}
4596 
4598  PropCost::cost(PropCost::Mod m,
4600  unsigned int n) {
4601  if (n < 2)
4602  return (m == LO) ? AC_UNARY_LO : AC_UNARY_HI;
4603  else if (n == 2)
4604  return (m == LO) ? AC_BINARY_LO : AC_BINARY_HI;
4605  else if (n == 3)
4606  return (m == LO) ? AC_TERNARY_LO : AC_TERNARY_HI;
4607  else
4608  return (m == LO) ? lo : hi;
4609  }
4610 
4613  return AC_RECORD;
4614  }
4616  PropCost::crazy(PropCost::Mod m, unsigned int n) {
4617  return cost(m,AC_CRAZY_LO,AC_CRAZY_HI,n);
4618  }
4621  assert(n >= 0);
4622  return crazy(m,static_cast<unsigned int>(n));
4623  }
4625  PropCost::cubic(PropCost::Mod m, unsigned int n) {
4626  return cost(m,AC_CUBIC_LO,AC_CUBIC_HI,n);
4627  }
4630  assert(n >= 0);
4631  return cubic(m,static_cast<unsigned int>(n));
4632  }
4634  PropCost::quadratic(PropCost::Mod m, unsigned int n) {
4635  return cost(m,AC_QUADRATIC_LO,AC_QUADRATIC_HI,n);
4636  }
4639  assert(n >= 0);
4640  return quadratic(m,static_cast<unsigned int>(n));
4641  }
4643  PropCost::linear(PropCost::Mod m, unsigned int n) {
4644  return cost(m,AC_LINEAR_LO,AC_LINEAR_HI,n);
4645  }
4648  assert(n >= 0);
4649  return linear(m,static_cast<unsigned int>(n));
4650  }
4653  return (m == LO) ? AC_TERNARY_LO : AC_TERNARY_HI;
4654  }
4657  return (m == LO) ? AC_BINARY_LO : AC_BINARY_HI;
4658  }
4661  return (m == LO) ? AC_UNARY_LO : AC_UNARY_HI;
4662  }
4663 
4664  /*
4665  * Iterators for propagators and branchers of a space
4666  *
4667  */
4668  forceinline
4670  : home(home0), q(home.pc.p.active) {
4671  while (q >= &home.pc.p.queue[0]) {
4672  if (q->next() != q) {
4673  c = q->next(); e = q; q--;
4674  return;
4675  }
4676  q--;
4677  }
4678  q = NULL;
4679  if (!home.pl.empty()) {
4680  c = Propagator::cast(home.pl.next());
4681  e = Propagator::cast(&home.pl);
4682  } else {
4683  c = e = NULL;
4684  }
4685  }
4686  forceinline bool
4688  return c != NULL;
4689  }
4690  forceinline void
4692  c = c->next();
4693  if (c == e) {
4694  if (q == NULL) {
4695  c = NULL;
4696  } else {
4697  while (q >= &home.pc.p.queue[0]) {
4698  if (q->next() != q) {
4699  c = q->next(); e = q; q--;
4700  return;
4701  }
4702  q--;
4703  }
4704  q = NULL;
4705  if (!home.pl.empty()) {
4706  c = Propagator::cast(home.pl.next());
4707  e = Propagator::cast(&home.pl);
4708  } else {
4709  c = NULL;
4710  }
4711  }
4712  }
4713  }
4716  return *Propagator::cast(c);
4717  }
4718 
4719 
4720  forceinline
4722  : home(home0), q(home.pc.p.active) {
4723  while (q >= &home.pc.p.queue[0]) {
4724  if (q->next() != q) {
4725  c = q->next(); e = q; q--;
4726  return;
4727  }
4728  q--;
4729  }
4730  q = c = e = NULL;
4731  }
4732  forceinline bool
4734  return c != NULL;
4735  }
4736  forceinline void
4738  c = c->next();
4739  if (c == e) {
4740  if (q == NULL) {
4741  c = NULL;
4742  } else {
4743  while (q >= &home.pc.p.queue[0]) {
4744  if (q->next() != q) {
4745  c = q->next(); e = q; q--;
4746  return;
4747  }
4748  q--;
4749  }
4750  q = c = e = NULL;
4751  }
4752  }
4753  }
4756  return *Propagator::cast(c);
4757  }
4758 
4759 
4760  forceinline
4762  c = Propagator::cast(home.pl.next());
4763  e = Propagator::cast(&home.pl);
4764  }
4765  forceinline bool
4767  return c != e;
4768  }
4769  forceinline void
4771  c = c->next();
4772  }
4775  return *Propagator::cast(c);
4776  }
4777 
4778 
4779  forceinline
4781  : c(Brancher::cast(home.bl.next())), e(&home.bl) {}
4782  forceinline bool
4784  return c != e;
4785  }
4786  forceinline void
4788  c = c->next();
4789  }
4792  return *Brancher::cast(c);
4793  }
4794 
4795 
4796  /*
4797  * Groups of actors
4798  */
4799  forceinline
4800  Group::Group(unsigned int gid0) : gid(gid0) {}
4801 
4802  forceinline bool
4803  Group::in(Group actor) const {
4804  return (gid == GROUPID_ALL) || (gid == actor.gid);
4805  }
4806 
4807  forceinline bool
4808  Group::in(void) const {
4809  return (gid != GROUPID_ALL) && (gid != GROUPID_DEF);
4810  }
4811 
4812  forceinline
4813  Group::Group(const Group& g) : gid(g.gid) {}
4814 
4817  gid=g.gid; return *this;
4818  }
4819 
4820  forceinline unsigned int
4821  Group::id(void) const {
4822  return gid;
4823  }
4824 
4825 
4826  forceinline
4828 
4829  forceinline
4831  : Group(gid) {}
4832 
4833  forceinline
4835  : Group(g) {}
4836 
4839  return static_cast<PropagatorGroup&>(Group::operator =(g));
4840  }
4841 
4844  return Home(home,NULL,*this,BrancherGroup::def);
4845  }
4846 
4847  forceinline bool
4849  return id() == g.id();
4850  }
4851  forceinline bool
4853  return id() != g.id();
4854  }
4855 
4858  if (id() != GROUPID_ALL)
4859  p.group(*this);
4860  return *this;
4861  }
4862 
4863 
4864  forceinline
4866 
4867  forceinline
4869  : Group(gid) {}
4870 
4871  forceinline
4873  : Group(g) {}
4874 
4877  return static_cast<BrancherGroup&>(Group::operator =(g));
4878  }
4879 
4882  return Home(home,NULL,PropagatorGroup::def,*this);
4883  }
4884 
4885  forceinline bool
4887  return id() == g.id();
4888  }
4889  forceinline bool
4891  return id() != g.id();
4892  }
4893 
4896  if (id() != GROUPID_ALL)
4897  p.group(*this);
4898  return *this;
4899  }
4900 
4901 
4902  /*
4903  * Iterators for propagators and branchers in a group
4904  *
4905  */
4906  forceinline
4908  : ps(home), g(g0) {
4909  while (ps() && !g.in(ps.propagator().group()))
4910  ++ps;
4911  }
4912  forceinline bool
4914  return ps();
4915  }
4916  forceinline void
4918  do
4919  ++ps;
4920  while (ps() && !g.in(ps.propagator().group()));
4921  }
4922  forceinline const Propagator&
4924  return ps.propagator();
4925  }
4926 
4927  forceinline
4929  : bs(home), g(g0) {
4930  while (bs() && !g.in(bs.brancher().group()))
4931  ++bs;
4932  }
4933  forceinline bool
4935  return bs();
4936  }
4937  forceinline void
4939  do
4940  ++bs;
4941  while (bs() && !g.in(bs.brancher().group()));
4942  }
4943  forceinline const Brancher&
4944  Branchers::brancher(void) const {
4945  return bs.brancher();
4946  }
4947 
4948 
4949  /*
4950  * Space construction support
4951  *
4952  */
4953  template<class T>
4954  forceinline T&
4956  return alloc<T>(1);
4957  }
4958  template<class T, typename A1>
4959  forceinline T&
4960  Space::construct(A1 const& a1) {
4961  T& t = *static_cast<T*>(ralloc(sizeof(T)));
4962  new (&t) T(a1);
4963  return t;
4964  }
4965  template<class T, typename A1, typename A2>
4966  forceinline T&
4967  Space::construct(A1 const& a1, A2 const& a2) {
4968  T& t = *static_cast<T*>(ralloc(sizeof(T)));
4969  new (&t) T(a1,a2);
4970  return t;
4971  }
4972  template<class T, typename A1, typename A2, typename A3>
4973  forceinline T&
4974  Space::construct(A1 const& a1, A2 const& a2, A3 const& a3) {
4975  T& t = *static_cast<T*>(ralloc(sizeof(T)));
4976  new (&t) T(a1,a2,a3);
4977  return t;
4978  }
4979  template<class T, typename A1, typename A2, typename A3, typename A4>
4980  forceinline T&
4981  Space::construct(A1 const& a1, A2 const& a2, A3 const& a3, A4 const& a4) {
4982  T& t = *static_cast<T*>(ralloc(sizeof(T)));
4983  new (&t) T(a1,a2,a3,a4);
4984  return t;
4985  }
4986  template<class T, typename A1, typename A2, typename A3, typename A4, typename A5>
4987  forceinline T&
4988  Space::construct(A1 const& a1, A2 const& a2, A3 const& a3, A4 const& a4, A5 const& a5) {
4989  T& t = *static_cast<T*>(ralloc(sizeof(T)));
4990  new (&t) T(a1,a2,a3,a4,a5);
4991  return t;
4992  }
4993 
4994 }
4995 
4996 // STATISTICS: kernel-core
static const int med_lst
End of bits for modification event delta.
Definition: core.hpp:113
void other(void)
Record that nothing is known at this point.
Definition: core.hpp:3240
unsigned int alternatives(void) const
Return number of alternatives.
Definition: core.hpp:3640
void reset(void)
Reset information.
Definition: core.hpp:4556
unsigned long int solution(void) const
Return number of solutions since last restart.
Definition: core.hpp:3011
const PropCond PC_GEN_NONE
Propagation condition to be ignored (convenience)
Definition: core.hpp:76
bool marked(void *p)
Check whether p is marked.
Iterator over subscribed propagators.
Definition: subscribed.hpp:36
Council of advisors
Definition: core.hpp:156
Base-class for variable implementations.
Definition: core.hpp:158
Propagator * fwd(void) const
Return forwarding pointer during copying.
Definition: core.hpp:3353
NodeType t
Type of node.
Definition: bool-expr.cpp:234
Space must be branched (at least one brancher left)
Definition: core.hpp:1610
Class to iterate over branchers in a group.
Definition: core.hpp:2692
static PropCost quadratic(PropCost::Mod m, unsigned int n)
Quadratic complexity for modifier m and size measure n.
Definition: core.hpp:4634
bool operator!=(PropagatorGroup g) const
Test whether this group is different from group g.
Definition: core.hpp:4852
unsigned int bid_sc
Id of next brancher to be created plus status control.
Definition: core.hpp:1761
BrancherGroup group(void) const
Return brancher group.
Definition: core.hpp:3315
PropagatorGroup propagatorgroup(void) const
Return propagator group.
Definition: core.hpp:3215
NNF * l
Left subtree.
Definition: bool-expr.cpp:244
unsigned int a
Alternative.
Definition: core.hpp:996
VarImp * forward(void) const
Use forward pointer if variable already copied.
Definition: core.hpp:4079
static BrancherGroup all
Group of all branchers.
Definition: core.hpp:837
Kernel::GPI::Info & gpi(void)
Provide access to global propagator information.
Definition: core.hpp:3375
LocalObject(Home home)
Constructor for creation.
Definition: core.hpp:3591
Type
Which type of information is provided.
Definition: core.hpp:1542
static PropCost linear(PropCost::Mod m, unsigned int n)
Linear complexity for modifier pcm and size measure n.
Definition: core.hpp:4643
View trace information.
Definition: core.hpp:898
Group & operator=(const Group &g)
Assignment operator.
Definition: core.hpp:4816
bool in(Group a) const
Check whether actor group a is included in this group.
Definition: core.hpp:4803
VarImp(void)
Creation of static instances.
Definition: core.hpp:4000
ExecStatus ES_SUBSUMED(Propagator &p)
Definition: core.hpp:3433
VarImpDisposer(void)
Constructor (registers disposer with kernel)
Definition: core.hpp:4517
void update(Space &home, LocalHandle &lh)
Updating during cloning.
Definition: core.hpp:3626
VarImp< VIC > * next
During cloning, points to the next copied variable.
Definition: core.hpp:272
LocalObject * object(void) const
Access to the local object.
Definition: core.hpp:3622
Actor must always be disposed.
Definition: core.hpp:554
Gecode::ActorLink * advisors
A list of advisors (used during cloning)
Definition: core.hpp:1031
const ViewTraceInfo & operator()(const Space &home) const
Provide access to view trace information.
Definition: core.hpp:3744
const Type t
Type of information.
Definition: core.hpp:1550
PropagatorGroup(void)
Constructor.
Definition: core.hpp:4827
NGL(void)
Constructor for creation.
Definition: core.hpp:3682
void cancel(Space &home, Propagator &p, IntSet &y)
Definition: rel.hpp:85
static const int free_bits
Freely available bits.
Definition: core.hpp:109
SpaceStatus
Space status
Definition: core.hpp:1607
ExecStatus ES_NOFIX_PARTIAL(Propagator &p, const ModEventDelta &med)
Propagator p has not computed partial fixpoint
Definition: core.hpp:3446
~PostInfo(void)
Reset information.
Definition: core.hpp:3272
Group of branchers.
Definition: core.hpp:789
static PropagatorGroup all
Group of all propagators.
Definition: core.hpp:779
static BrancherGroup def
Group of branchers not in any user-defined group.
Definition: core.hpp:840
Propagators(Space &home, PropagatorGroup g)
Initialize.
Definition: core.hpp:4907
friend class Home
Definition: core.hpp:666
T * realloc(T *b, long unsigned int n, long unsigned int m)
Reallocate block of n objects starting at b to m objects of type T from the space heap...
Definition: core.hpp:2808
const Propagator * propagator(void) const
Return pointer to non-subsumed propagator.
Definition: core.hpp:3293
Class to iterate over propagators in a group.
Definition: core.hpp:2674
Statistics for execution of commit
Definition: core.hpp:1651
const ModEvent ME_GEN_ASSIGNED
Generic modification event: variable is assigned a value.
Definition: core.hpp:71
unsigned int degree(void) const
Return degree (number of subscribed propagators and advisors)
Definition: core.hpp:4009
AFC afc
Definition: afc.cpp:139
Local (space-shared) object.
Definition: core.hpp:1459
Status
The status of a no-good literal.
Definition: core.hpp:1272
unsigned long int fail(void) const
Return number of failures since last restart.
Definition: core.hpp:3016
int ModEvent
Type for modification events.
Definition: core.hpp:64
static void schedule(Space &home, Propagator &p, ModEvent me, bool force=false)
Schedule propagator p with modification event me.
Definition: core.hpp:4135
void linear(Home home, const FloatVarArgs &x, FloatRelType frt, FloatVal c)
Post propagator for .
Definition: linear.cpp:45
Branchers(Space &home)
Initialize.
Definition: core.hpp:4780
static ModEvent modevent(const Delta &d)
Return modification event.
Definition: core.hpp:4041
Base-class for propagators.
Definition: core.hpp:1016
Internal: propagator is subsumed, do not use.
Definition: core.hpp:465
virtual ~Choice(void)
Destructor.
Definition: core.hpp:3650
const Brancher & b
Brancher.
Definition: core.hpp:992
T & construct(void)
Construction routines.
Definition: core.hpp:4955
Information is provided by a restart-based engine.
Definition: core.hpp:1544
Base-class for advisors.
Definition: core.hpp:1218
static const int idx_d
Index for disposal.
Definition: core.hpp:105
static ModEventDelta med(ModEvent me)
Translate modification event me into modification event delta.
Definition: core.hpp:4123
static PropCost record(void)
For recording information (no propagation allowed)
Definition: core.hpp:4612
ActorLink ** base
Subscribed actors.
Definition: core.hpp:234
Propagator & propagator(void) const
Return propagator.
Definition: core.hpp:4755
Manage memory for space.
Definition: manager.hpp:124
ExecStatus ES_NOFIX_DISPOSE(Council< A > &c, A &a)
Advisor a must be disposed and its propagator must be run
Definition: core.hpp:3757
unsigned int idx[pc_max+1]
Indices of subscribed actors.
Definition: core.hpp:270
const NoGoods & ng
No-goods from restart.
Definition: core.hpp:1562
Class to iterate over advisors of a council.
Definition: core.hpp:157
static Group def
Group of actors not in any user-defined group.
Definition: core.hpp:711
Space & h
The home space.
Definition: core.hpp:941
Handle to region.
Definition: region.hpp:57
void * mark(void *p)
Return marked pointer for unmarked pointer p.
BrancherGroup & move(Space &home, BrancherGroup g)
Move branchers from group g to this group.
Definition: core.cpp:975
PropagatorGroup pg
A propagator group.
Definition: core.hpp:854
Base-class for variable implementations.
Definition: core.hpp:173
LocalObject * local
Linked list of local objects.
Definition: core.hpp:1774
unsigned long int propagate
Number of propagator executions.
Definition: core.hpp:1620
#define forceinline
Definition: config.hpp:182
Propagation has computed fixpoint.
Definition: core.hpp:469
unsigned int id(void) const
Return a unique id for the group.
Definition: core.hpp:4821
void operator++(void)
Move iterator to next brancher.
Definition: core.hpp:4938
virtual PropCost cost(const Space &home, const ModEventDelta &med) const =0
Cost function.
static PropCost unary(PropCost::Mod m)
Single variable for modifier pcm.
Definition: core.hpp:4660
Propagator failed.
Definition: core.hpp:959
Computation spaces.
Definition: core.hpp:1668
ExecStatus prune(Space &home, ViewArray< VX > &x, ConstIntView)
Definition: rel.hpp:268
LocalHandle & operator=(const LocalHandle &lh)
Assignment operator.
Definition: core.hpp:3615
void * rrealloc(void *b, size_t n, size_t m)
Reallocate memory block starting at b from size n to size s.
Definition: core.hpp:2727
PostInfo(Home home)
Set information.
Definition: core.hpp:3268
Base-class for both propagators and branchers.
Definition: core.hpp:620
Statistics for execution of status
Definition: core.hpp:1617
void cancel(Space &home)
Cancel all subscriptions when variable implementation is assigned.
Definition: core.hpp:4334
unsigned int id(void) const
Return propagator id.
Definition: core.hpp:3412
A mutex for mutual exclausion among several threads.
Definition: thread.hpp:105
Gecode::IntSet d(v, 7)
void * funmark(void *p)
Return unmarked pointer for a possibly marked pointer p.
T * alloc(long unsigned int n)
Allocate block of n objects of type T from space heap.
Definition: core.hpp:2757
CloneStatistics operator+(const CloneStatistics &s)
Return sum with s.
Definition: core.hpp:4563
PropagatorGroup & move(Space &home, PropagatorGroup g)
Move propagators from group g to this group.
Definition: core.cpp:897
static const unsigned int GROUPID_DEF
Pre-defined default group id.
Definition: core.hpp:676
const Choice & c
Choice.
Definition: core.hpp:994
bool operator()(void) const
Test whether there are branchers left.
Definition: core.hpp:4783
The literal is subsumed.
Definition: core.hpp:1274
Gecode::FloatVal c(-8, 8)
Maximal cost value.
Definition: core.hpp:498
Configuration class for variable implementations without index structure.
Definition: core.hpp:100
int p
Number of positive literals for node type.
Definition: bool-expr.cpp:236
bool leaf(void) const
Test whether literal is a leaf.
Definition: core.hpp:3659
Handles for local (space-shared) objects.
Definition: core.hpp:1484
Class to iterate over branchers of a space.
Definition: core.hpp:2655
Gecode::IntArgs i(4, 1, 2, 3, 4)
Base-class for branchers.
Definition: core.hpp:1368
Class for AFC (accumulated failure count) management.
Definition: afc.hpp:44
const Brancher & brancher(void) const
Return currently executing brancher.
Definition: core.hpp:3254
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:238
BrancherGroup group(void) const
Return group brancher belongs to.
Definition: core.hpp:3504
CloneStatistics & operator+=(const CloneStatistics &s)
Increment by statistics s.
Definition: core.hpp:4568
const Propagator * p
Propagator.
Definition: core.hpp:968
What
What is currently executing.
Definition: core.hpp:903
void reset(void)
Reset information.
Definition: core.hpp:4573
void reset(void)
Reset information.
Definition: core.hpp:4537
Status s
Status.
Definition: core.hpp:970
BrancherGroup & operator=(const BrancherGroup &g)
Assignment operator.
Definition: core.hpp:4876
bool operator()(void) const
Test whether there are propagators left.
Definition: core.hpp:4687
double afc_decay(void) const
Return AFC decay factor.
Definition: core.hpp:3162
static ModEvent me(const ModEventDelta &med)
Project modification event for this variable type from med.
Definition: core.hpp:4117
bool copied(void) const
Is variable already copied.
Definition: core.hpp:4073
Propagator & propagator(void) const
Return propagator.
Definition: core.hpp:4774
static LocalObject * cast(ActorLink *al)
Static cast for a non-null pointer (to give a hint to optimizer)
Definition: core.hpp:3575
Execution has resulted in failure.
Definition: core.hpp:466
PropagatorGroup & operator=(const PropagatorGroup &g)
Assignment operator.
Definition: core.hpp:4838
Commit trace information.
Definition: core.hpp:988
StatusStatistics(void)
Initialize.
Definition: core.hpp:4541
Propagator & propagator(void) const
Return propagator.
Definition: core.hpp:4715
const Space * last(void) const
Return last solution found (possibly NULL)
Definition: core.hpp:3021
FloatVal operator+(const FloatVal &x)
Definition: val.hpp:168
void operator++(void)
Move iterator to next propagator.
Definition: core.hpp:4737
PropagatorGroup group(void) const
Return propagator group.
Definition: core.hpp:3289
Propagator for recording trace information.
Definition: recorder.hpp:157
Space * clone(CloneStatistics &stat=unused_clone) const
Clone space.
Definition: core.hpp:3144
Statistics for execution of clone
Definition: core.hpp:1635
Class to set group information when a post function is executed.
Definition: core.hpp:938
bool operator!=(const FloatVal &x, const FloatVal &y)
Definition: val.hpp:321
int PropCond
Type for propagation conditions.
Definition: core.hpp:74
void subscribe(Space &home, Propagator &p, IntSet &y)
Definition: rel.hpp:75
MetaInfo(unsigned long int r, unsigned long int s, unsigned long int f, const Space *l, NoGoods &ng)
Constructor for restart-based engine.
Definition: core.hpp:2990
virtual ~NoGoods(void)
Destructor.
Definition: core.hpp:2983
Type type(void) const
Return type of information.
Definition: core.hpp:3002
bool failed(void) const
Check whether space is failed.
Definition: core.hpp:3914
Propagator computed fixpoint.
Definition: core.hpp:957
ModEventDelta med
A set of modification events (used during propagation)
Definition: core.hpp:1027
void commit(const Choice &c, unsigned int a, CommitStatistics &stat=unused_commit)
Commit choice c for alternative a.
Definition: core.hpp:3152
unsigned int n_sub
Number of subscriptions.
Definition: core.hpp:1763
void fail(void)
Fail space.
Definition: core.hpp:3900
static const int idx_c
Index for update.
Definition: core.hpp:103
void operator++(void)
Move iterator to next propagator.
Definition: core.hpp:4770
Group(void)
Constructor.
Definition: core.cpp:887
static Gecode::ModEvent me_combine(ModEvent me1, ModEvent me2)
Combine modification events me1 and me2.
Definition: core.hpp:123
struct Gecode::Space::@58::@59 p
Data only available during propagation or branching.
bool failed(void) const
Check whether corresponding space is failed.
Definition: core.hpp:3918
const Space * l
Last solution found.
Definition: core.hpp:1560
static const int med_mask
Bitmask for modification event delta.
Definition: core.hpp:115
PropagatorGroup g
Propagator group.
Definition: core.hpp:966
unsigned int size(I &i)
Size of all ranges of range iterator i.
const Propagator & propagator(void) const
Return propagator.
Definition: core.hpp:4923
bool stable(void) const
Return if space is stable (at fixpoint or failed)
Definition: core.hpp:3923
ExecStatus ES_SUBSUMED_DISPOSED(Propagator &p, size_t s)
Propagator p is subsumed
Definition: core.hpp:3427
CloneStatistics(void)
Initialize.
Definition: core.hpp:4559
LocalHandle(void)
Create local handle pointing to NULL object.
Definition: core.hpp:3609
Home(Space &s, Propagator *p=NULL, PropagatorGroup pg=PropagatorGroup::def, BrancherGroup bg=BrancherGroup::def)
Initialize the home with space s and propagator p and group g.
Definition: core.hpp:3182
struct Gecode::Space::@58::@60 c
Data available only during copying.
const PropCond PC_GEN_ASSIGNED
Propagation condition for an assigned variable.
Definition: core.hpp:78
virtual void dispose(Space &home, VarImpBase *x)
Dispose list of variable implementations starting at x.
Definition: core.hpp:4525
void * ptrjoin(void *p, ptrdiff_t m)
Join unmarked pointer p and m into marked pointer.
PropagatorGroup group(void) const
Return group propagator belongs to.
Definition: core.hpp:3417
Trace filters.
Definition: filter.hpp:137
bool operator()(void) const
Test whether there are propagators left.
Definition: core.hpp:4733
size_t size
The size of the propagator (used during subsumption)
Definition: core.hpp:1029
virtual ExecStatus advise(Space &home, Advisor &a, const Delta &d)
Advise function.
Definition: core.cpp:67
static Support::Mutex m
Mutex for protection.
Definition: core.hpp:686
Group baseclass for controlling actors.
Definition: core.hpp:665
bool operator()(void) const
Test whether there advisors left.
Definition: core.hpp:3866
bool disabled(void) const
Whether propagator is currently disabled.
Definition: core.hpp:3358
friend class PropagatorGroup
Definition: core.hpp:1023
union Gecode::@585::NNF::@62 u
Union depending on nodetype t.
bool operator()(void) const
Test whether there are propagators left.
Definition: core.hpp:4766
const Choice & choice(void) const
Return choice.
Definition: core.hpp:3323
Information is provided by a portfolio-based engine.
Definition: core.hpp:1546
Council(void)
Default constructor.
Definition: core.hpp:3777
PropagatorGroup post(void) const
Return propagator group of currently executing post function.
Definition: core.hpp:3259
#define GECODE_KERNEL_EXPORT
Definition: kernel.hh:74
ExecStatus ES_FIX_DISPOSE(Council< A > &c, A &a)
Advisor a must be disposed
Definition: core.hpp:3750
void * unmark(void *p)
Return unmarked pointer for a marked pointer p.
unsigned int alternative(void) const
Return alternative.
Definition: core.hpp:3327
static unsigned int next
Next group id.
Definition: core.hpp:683
Home & operator=(const Home &h)
Assignment operator.
Definition: core.hpp:3186
IdlePropagators(Space &home)
Initialize.
Definition: core.hpp:4761
bool operator==(PropagatorGroup g) const
Test whether this group is equal to group g.
Definition: core.hpp:4848
Propagate trace information.
Definition: core.hpp:952
Choice(const Brancher &b, const unsigned int a)
Initialize for particular brancher b and alternatives a.
Definition: core.hpp:3636
Branchers(Space &home, BrancherGroup g)
Initialize.
Definition: core.hpp:4928
TFE propagator(PropagatorGroup g)
Only propagators (but not post functions) from g are considered.
Definition: filter.cpp:135
Exception: too many branchers
Definition: exception.hpp:97
ExecStatus ES_FIX_PARTIAL(Propagator &p, const ModEventDelta &med)
Propagator p has computed partial fixpoint
Definition: core.hpp:3439
void notice(Actor &a, ActorProperty p, bool duplicate=false)
Notice actor property.
Definition: core.hpp:3139
Mod
Propagation cost modifier.
Definition: core.hpp:504
Single _b(1, 4)
bool operator()(void) const
Test whether there are branchers left.
Definition: core.hpp:4934
double afc(void) const
Return accumulated failure count (plus degree)
Definition: core.hpp:4016
NGL * next(void) const
Return pointer to next literal.
Definition: core.hpp:3663
bool operator()(void) const
Test whether there are propagators left.
Definition: core.hpp:4913
BrancherGroup branchergroup(void) const
Return brancher group.
Definition: core.hpp:3219
ModEventDelta modeventdelta(void) const
Return the modification event delta.
Definition: core.hpp:3402
const NoGoods & nogoods(void) const
Return no-goods recorded from restart.
Definition: core.hpp:3026
Advisor forces rescheduling of propagator.
Definition: core.hpp:470
NoGoods(void)
Initialize.
Definition: core.hpp:2972
void free(T *b, long unsigned int n)
Delete n objects allocated from space heap starting at b.
Definition: core.hpp:2783
void * subscriptions(void) const
Get the memory area for subscriptions.
Definition: manager.hpp:302
Post propagator for SetVar SetOpType SetVar SetRelType r
Definition: set.hh:769
unsigned int id(void) const
Return brancher id.
Definition: core.hpp:3499
Class to iterate over propagators of a space.
Definition: core.hpp:2584
Home operator()(Space &home)
To augment a space argument.
Definition: core.hpp:4843
Class to iterate over idle propagators of a space.
Definition: core.hpp:2634
const Brancher & brancher(void) const
Return propagator.
Definition: core.hpp:4944
Class to store data shared among several spaces.
unsigned int i
Propagator id.
Definition: core.hpp:964
void print(std::basic_ostream< Char, Traits > &s, bool assigned, IL &lb, IU &ub, unsigned int cardMin, unsigned int cardMax)
Print set view.
Definition: print.hpp:67
struct Gecode::@585::NNF::@62::@63 b
For binary nodes (and, or, eqv)
static PropagatorGroup def
Group of propagators not in any user-defined group.
Definition: core.hpp:782
Post propagator for f(x \diamond_{\mathit{op}} y) \sim_r z \f$ void rel(Home home
void * ralloc(size_t s)
Allocate memory on space heap.
Definition: core.hpp:2719
ScheduledPropagators(Space &home)
Initialize.
Definition: core.hpp:4721
BrancherGroup(void)
Constructor.
Definition: core.hpp:4865
Propagators(Space &home)
Initialize.
Definition: core.hpp:4669
Class for storing propagator information.
Definition: gpi.hpp:46
ActualCost ac
Actual cost.
Definition: core.hpp:501
Home operator()(Propagator &p)
Return a home extended by propagator to be rewritten.
Definition: core.hpp:3195
const Brancher & brancher(void) const
Return brancher.
Definition: core.hpp:3319
static PropCost cubic(PropCost::Mod m, unsigned int n)
Cubic complexity for modifier m and size measure n.
Definition: core.hpp:4625
CommitStatistics operator+(const CommitStatistics &s)
Return sum with s.
Definition: core.hpp:4580
Generic domain change information to be supplied to advisors.
Definition: core.hpp:205
void ignore(Actor &a, ActorProperty p, bool duplicate=false)
Ignore actor property.
Definition: core.hpp:3944
Brancher(Home home)
Constructor for creation.
Definition: core.hpp:3475
static const int idx_c
Index for cloning.
Definition: var-type.hpp:459
Home operator()(Propagator &p)
Return a home for this space with the information that p is being rewritten.
Definition: core.hpp:3207
Propagator did not compute fixpoint.
Definition: core.hpp:958
struct Gecode::@585::NNF::@62::@64 a
For atomic nodes.
Propagator & propagator(void) const
Return the advisor&#39;s propagator.
Definition: core.hpp:3727
Choice for performing commit
Definition: core.hpp:1338
void notice(Actor &a, ActorProperty p, bool duplicate=false)
Notice actor property.
Definition: core.hpp:3929
The literal is failed.
Definition: core.hpp:1273
No-goods recorded from restarts.
Definition: core.hpp:1514
virtual size_t dispose(Space &home)
Delete actor and return its size.
Definition: core.hpp:3172
void dispose(Space &home, Council< A > &c)
Dispose the advisor.
Definition: core.hpp:3734
Propagation cost.
Definition: core.hpp:478
void operator++(void)
Move iterator to next advisor.
Definition: core.hpp:3872
Archive representation
Definition: archive.hpp:46
Advisor(Space &home, Propagator &p, Council< A > &c)
Constructor for creation.
Definition: core.hpp:3701
#define GECODE_KERNEL_REALLOC(T)
Definition: core.hpp:2843
bool operator!=(BrancherGroup g) const
Test whether this group is different from group g.
Definition: core.hpp:4890
ExecStatus
Definition: core.hpp:464
const unsigned long int r
Number of restarts.
Definition: core.hpp:1554
static ModEventDelta med_combine(ModEventDelta med1, ModEventDelta med2)
Combine modification event delta med1 with med2.
Definition: var-type.hpp:889
CommitStatistics & operator+=(const CommitStatistics &s)
Increment by statistics s.
Definition: core.hpp:4585
bool assigned(View x, int v)
Whether x is assigned to value v.
Definition: single.hpp:47
void operator++(void)
Move iterator to next propagator.
Definition: core.hpp:4691
unsigned int id(void) const
Return brancher identifier.
Definition: core.hpp:3311
static PropCost crazy(PropCost::Mod m, unsigned int n)
Exponential complexity for modifier m and size measure n.
Definition: core.hpp:4616
unsigned long int restart(void) const
Return number of restarts.
Definition: core.hpp:3006
Space & s
The space where the propagator is to be posted.
Definition: core.hpp:850
static NoGoods eng
Empty no-goods.
Definition: core.hpp:1532
const Propagator & propagator(void) const
Return currently executing propagator.
Definition: core.hpp:3248
static const PropCond pc_max
Maximal propagation condition.
Definition: core.hpp:107
Home operator()(Space &home)
To augment a space argument.
Definition: core.hpp:4881
LocalObject * fwd(Space &home)
Return forwarding pointer.
Definition: core.hpp:3602
void operator++(void)
Move iterator to next brancher.
Definition: core.hpp:4787
static void reschedule(Space &home, Propagator &p, PropCond pc, bool assigned, ModEvent me)
Schedule propagator p.
Definition: core.hpp:4254
Base-class for freelist-managed objects.
Definition: manager.hpp:102
void trycommit(const Choice &c, unsigned int a, CommitStatistics &stat=unused_commit)
If possible, commit choice c for alternative a.
Definition: core.hpp:3157
unsigned int asset(void) const
Return number of asset in portfolio.
Definition: core.hpp:3031
ModEvent fail(Space &home)
Run advisors to be run on failure and returns ME_GEN_FAILED.
Definition: core.hpp:4417
void operator++(void)
Move iterator to next propagator.
Definition: core.hpp:4917
Internal: propagator has computed partial fixpoint, do not use.
Definition: core.hpp:471
Variable implementation disposer
Definition: core.hpp:196
double afc
The afc value.
Definition: gpi.hpp:53
void fl_dispose(FreeList *f, FreeList *l)
Return freelist-managed memory to freelist.
Definition: core.hpp:2747
const ModEvent ME_GEN_NONE
Generic modification event: no modification.
Definition: core.hpp:69
Post propagator for SetVar x
Definition: set.hh:769
void * fmark(void *p)
Return marked pointer for p (possibly already marked)
VarImp< VIC > * fwd
Forwarding pointer.
Definition: core.hpp:243
Execution is okay.
Definition: core.hpp:468
Status status(void) const
Return propagator status.
Definition: core.hpp:3297
Tracer.
Definition: tracer.hpp:153
virtual size_t dispose(Space &home)
Dispose.
Definition: core.hpp:3691
Propagation has not computed fixpoint.
Definition: core.hpp:467
PropagateTraceInfo(unsigned int i, PropagatorGroup g, const Propagator *p, Status s)
Initialize.
Definition: core.hpp:3281
bool operator==(BrancherGroup g) const
Test whether this group is equal to group g.
Definition: core.hpp:4886
unsigned int id(void) const
Return propagator identifier.
Definition: core.hpp:3285
Propagator * p
A propagator (possibly) that is currently being rewritten.
Definition: core.hpp:852
void fail(void)
Mark space as failed.
Definition: core.hpp:3909
void trace(Home home, const FloatVarArgs &x, TraceFilter tf, int te, FloatTracer &t)
Create a tracer for float variables.
Definition: trace.cpp:43
NGL * add(NGL *n, bool l)
Add node n and mark it as leaf l and return n.
Definition: core.hpp:3675
Propagator * propagator(void) const
Return propagator (or NULL) for currently rewritten propagator.
Definition: core.hpp:3211
bool in(void) const
Check whether this is a real group (and not just default)
Definition: core.hpp:4808
void * ptrsplit(void *p, ptrdiff_t &m)
Split possibly marked pointer p into mark m and unmarked pointer.
bool operator==(const FloatVal &x, const FloatVal &y)
Definition: val.hpp:298
StatusStatistics operator+(const StatusStatistics &s)
Return sum with s.
Definition: core.hpp:4550
#define GECODE_NOT_NULL(p)
Assert that a pointer is never NULL.
Definition: macros.hpp:79
static PropCost ternary(PropCost::Mod m)
Three variables for modifier pcm.
Definition: core.hpp:4652
Propagator(Home home)
Constructor for posting.
Definition: core.hpp:3380
Gecode toplevel namespace
static Group all
Group of all actors.
Definition: core.hpp:708
Information passed by meta search engines.
Definition: core.hpp:1539
BrancherGroup bg
A brancher group.
Definition: core.hpp:856
static ModEvent me_combine(ModEvent me1, ModEvent me2)
Combine modifications events me1 and me2.
Definition: core.hpp:4129
ActorLink * active
Cost level with next propagator to be executed.
Definition: core.hpp:1752
#define GECODE_VTABLE_EXPORT
Definition: support.hh:76
Class to iterate over scheduled propagators of a space.
Definition: core.hpp:2609
unsigned int pid
Propagator identifier.
Definition: gpi.hpp:49
What what(void) const
Return what is currently executing.
Definition: core.hpp:3244
VarImpBase * vars_noidx
Keep variables during copying without index structure.
Definition: core.hpp:1772
Group of propagators.
Definition: core.hpp:718
ActorProperty
Actor properties.
Definition: core.hpp:545
VarImp * next(void) const
Return next copied variable.
Space is failed
Definition: core.hpp:1608
void reschedule(Space &home, Propagator &p, IntSet &y)
Definition: rel.hpp:96
unsigned long int ng(void) const
Return number of no-goods posted.
Definition: core.hpp:2975
ActualCost
The actual cost values that are used.
Definition: core.hpp:482
static const unsigned int GROUPID_ALL
Fake id for group of all actors.
Definition: core.hpp:674
unsigned long int n
Number of no-goods.
Definition: core.hpp:1517
void * fl_alloc(void)
Allocate from freelist-managed memory.
Definition: core.hpp:2742
const unsigned long int s
Number of solutions since last restart.
Definition: core.hpp:1556
int ModEventDelta
Modification event deltas.
Definition: core.hpp:91
CommitTraceInfo(const Brancher &b, const Choice &c, unsigned int a)
Initialize.
Definition: core.hpp:3307
unsigned int gid
Group identifier.
Definition: gpi.hpp:51
static const int idx_d
Index for dispose.
Definition: var-type.hpp:461
ptrdiff_t who
Encoding a tagged pointer or a tagged group id.
Definition: core.hpp:915
Home class for posting propagators
Definition: core.hpp:846
unsigned int bits(void) const
Provide access to free bits.
Definition: core.hpp:4047
Base class for heap allocated objects.
Definition: heap.hpp:344
static const int med_fst
Start of bits for modification event delta.
Definition: core.hpp:111
static PropCost binary(PropCost::Mod m)
Two variables for modifier pcm.
Definition: core.hpp:4656
#define GECODE_NEVER
Assert that this command is never executed.
Definition: macros.hpp:60
A & advisor(void) const
Return advisor.
Definition: core.hpp:3880
const unsigned long int f
Number of failures since last restart.
Definition: core.hpp:1558
static bool med_update(ModEventDelta &med, ModEvent me)
Update modification even delta med by me, return true on change.
Definition: core.hpp:127
StatusStatistics & operator+=(const StatusStatistics &s)
Increment by statistics s.
Definition: core.hpp:4545
void unary(Home home, const IntVarArgs &s, const IntArgs &p, IntPropLevel ipl)
Post propagators for scheduling tasks on unary resources.
Definition: unary.cpp:48
void update(IntSet &y, Space &home, IntSet &py)
Definition: rel.hpp:107
bool advise(Space &home, ModEvent me, Delta &d)
Run advisors when variable implementation has been modified with modification event me and domain cha...
Definition: core.hpp:4351
Brancher & brancher(void) const
Return propagator.
Definition: core.hpp:4791
const unsigned int a
Number of asset in portfolio.
Definition: core.hpp:1567
CommitStatistics(void)
Initialize.
Definition: core.hpp:4576
const ModEvent ME_GEN_FAILED
Generic modification event: failed variable.
Definition: core.hpp:67
ViewTraceInfo vti
View trace information.
Definition: core.hpp:1765
Base class for Variable type disposer.
Definition: core.hpp:181
Status
Propagator status.
Definition: core.hpp:956
ExecStatus ES_NOFIX_DISPOSE_FORCE(Council< A > &c, A &a)
Advisor a must be disposed and its propagator must be forcefully rescheduled
Definition: core.hpp:3764
const bool clone
Whether engines create a clone when being initialized.
Definition: search.hh:110
double afc(void) const
Return the accumlated failure count.
Definition: core.hpp:3407
TFE post(PropagatorGroup g)
Only post functions (but not propagators) from g are considered.
Definition: filter.cpp:142
void rfree(void *p, size_t s)
Free memory previously allocated with alloc (might be reused later)
Definition: core.hpp:2723
unsigned int gid
The group id.
Definition: core.hpp:680
void subscribe(Space &home, Propagator &p, PropCond pc, bool assigned, ModEvent me, bool schedule)
Subscribe propagator p with propagation condition pc.
Definition: core.hpp:4229
Space is solved (no brancher left)
Definition: core.hpp:1609
No-good literal recorded during search.
Definition: core.hpp:1266
~LocalHandle(void)
Destructor.
Definition: core.hpp:3620