00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef __GECODE_INT_BRANCH_HH__
00039 #define __GECODE_INT_BRANCH_HH__
00040
00041 #include <gecode/int.hh>
00042
00048 namespace Gecode { namespace Int { namespace Branch {
00049
00068 template<class View>
00069 class MeritMin : public MeritBase<View,int> {
00070 public:
00071 using typename MeritBase<View,int>::Var;
00073 MeritMin(Space& home, const VarBranch<Var>& vb);
00075 MeritMin(Space& home, bool shared, MeritMin& m);
00077 int operator ()(const Space& home, View x, int i);
00078 };
00079
00086 template<class View>
00087 class MeritMax : public MeritBase<View,int> {
00088 public:
00089 using typename MeritBase<View,int>::Var;
00091 MeritMax(Space& home, const VarBranch<Var>& vb);
00093 MeritMax(Space& home, bool shared, MeritMax& m);
00095 int operator ()(const Space& home, View x, int i);
00096 };
00097
00104 template<class View>
00105 class MeritSize : public MeritBase<View,unsigned int> {
00106 public:
00107 using typename MeritBase<View,unsigned int>::Var;
00109 MeritSize(Space& home, const VarBranch<Var>& vb);
00111 MeritSize(Space& home, bool shared, MeritSize& m);
00113 unsigned int operator ()(const Space& home, View x, int i);
00114 };
00115
00122 template<class View>
00123 class MeritDegreeSize : public MeritBase<View,double> {
00124 public:
00125 using typename MeritBase<View,double>::Var;
00127 MeritDegreeSize(Space& home, const VarBranch<Var>& vb);
00129 MeritDegreeSize(Space& home, bool shared, MeritDegreeSize& m);
00131 double operator ()(const Space& home, View x, int i);
00132 };
00133
00140 template<class View>
00141 class MeritAFCSize : public MeritBase<View,double> {
00142 using typename MeritBase<View,double>::Var;
00143 protected:
00145 AFC afc;
00146 public:
00148 MeritAFCSize(Space& home, const VarBranch<Var>& vb);
00150 MeritAFCSize(Space& home, bool shared, MeritAFCSize& m);
00152 double operator ()(const Space& home, View x, int i);
00154 bool notice(void) const;
00156 void dispose(Space& home);
00157 };
00158
00165 template<class View>
00166 class MeritActionSize : public MeritBase<View,double> {
00167 using typename MeritBase<View,double>::Var;
00168 protected:
00170 Action action;
00171 public:
00173 MeritActionSize(Space& home, const VarBranch<Var>& vb);
00175 MeritActionSize(Space& home, bool shared, MeritActionSize& m);
00177 double operator ()(const Space& home, View x, int i);
00179 bool notice(void) const;
00181 void dispose(Space& home);
00182 };
00183
00190 template<class View>
00191 class MeritCHBSize : public MeritBase<View,double> {
00192 using typename MeritBase<View,double>::Var;
00193 protected:
00195 CHB chb;
00196 public:
00198 MeritCHBSize(Space& home, const VarBranch<Var>& vb);
00200 MeritCHBSize(Space& home, bool shared, MeritCHBSize& m);
00202 double operator ()(const Space& home, View x, int i);
00204 bool notice(void) const;
00206 void dispose(Space& home);
00207 };
00208
00215 template<class View>
00216 class MeritRegretMin : public MeritBase<View,unsigned int> {
00217 public:
00218 using typename MeritBase<View,unsigned int>::Var;
00220 MeritRegretMin(Space& home, const VarBranch<Var>& vb);
00222 MeritRegretMin(Space& home, bool shared, MeritRegretMin& m);
00224 unsigned int operator ()(const Space& home, View x, int i);
00225 };
00226
00233 template<class View>
00234 class MeritRegretMax : public MeritBase<View,unsigned int> {
00235 public:
00236 using typename MeritBase<View,unsigned int>::Var;
00238 MeritRegretMax(Space& home, const VarBranch<Var>& vb);
00240 MeritRegretMax(Space& home, bool shared, MeritRegretMax& m);
00242 unsigned int operator ()(const Space& home, View x, int i);
00243 };
00244
00245 }}}
00246
00247 #include <gecode/int/branch/merit.hpp>
00248
00249 namespace Gecode { namespace Int { namespace Branch {
00250
00252 GECODE_INT_EXPORT
00253 ViewSel<IntView>* viewsel(Space& home, const IntVarBranch& ivb);
00255 GECODE_INT_EXPORT
00256 ViewSel<BoolView>* viewsel(Space& home, const BoolVarBranch& bvb);
00257
00258 }}}
00259
00260 namespace Gecode { namespace Int { namespace Branch {
00261
00280 template<class View>
00281 class ValSelMin : public ValSel<View,int> {
00282 public:
00283 using typename ValSel<View,int>::Var;
00285 ValSelMin(Space& home, const ValBranch<Var>& vb);
00287 ValSelMin(Space& home, bool shared, ValSelMin& vs);
00289 int val(const Space& home, View x, int i);
00290 };
00291
00298 template<class View>
00299 class ValSelMax : public ValSel<View,int> {
00300 public:
00301 using typename ValSel<View,int>::Var;
00303 ValSelMax(Space& home, const ValBranch<Var>& vb);
00305 ValSelMax(Space& home, bool shared, ValSelMax& vs);
00307 int val(const Space& home, View x, int i);
00308 };
00309
00316 template<class View>
00317 class ValSelMed : public ValSel<View,int> {
00318 public:
00319 using typename ValSel<View,int>::Var;
00321 ValSelMed(Space& home, const ValBranch<Var>& vb);
00323 ValSelMed(Space& home, bool shared, ValSelMed& vs);
00325 int val(const Space& home, View x, int i);
00326 };
00327
00334 template<class View>
00335 class ValSelAvg : public ValSel<View,int> {
00336 public:
00337 using typename ValSel<View,int>::Var;
00339 ValSelAvg(Space& home, const ValBranch<Var>& vb);
00341 ValSelAvg(Space& home, bool shared, ValSelAvg& vs);
00343 int val(const Space& home, View x, int i);
00344 };
00345
00352 template<class View>
00353 class ValSelRnd : public ValSel<View,int> {
00354 using typename ValSel<View,int>::Var;
00355 protected:
00357 Rnd r;
00358 public:
00360 ValSelRnd(Space& home, const ValBranch<Var>& vb);
00362 ValSelRnd(Space& home, bool shared, ValSelRnd& vs);
00364 int val(const Space& home, View x, int i);
00366 bool notice(void) const;
00368 void dispose(Space& home);
00369 };
00370
00377 class ValSelRangeMin : public ValSel<IntView,int> {
00378 public:
00380 ValSelRangeMin(Space& home, const ValBranch<IntVar>& vb);
00382 ValSelRangeMin(Space& home, bool shared, ValSelRangeMin& vs);
00384 int val(const Space& home, IntView x, int i);
00385 };
00386
00393 class ValSelRangeMax : public ValSel<IntView,int> {
00394 public:
00396 ValSelRangeMax(Space& home, const ValBranch<IntVar>& vb);
00398 ValSelRangeMax(Space& home, bool shared, ValSelRangeMax& vs);
00400 int val(const Space& home, IntView x, int i);
00401 };
00402
00403 }}}
00404
00405 #include <gecode/int/branch/val-sel.hpp>
00406
00407 namespace Gecode { namespace Int { namespace Branch {
00408
00410 template<class View>
00411 class EqNGL : public ViewValNGL<View,int,PC_INT_VAL> {
00412 using ViewValNGL<View,int,PC_INT_VAL>::x;
00413 using ViewValNGL<View,int,PC_INT_VAL>::n;
00414 public:
00416 EqNGL(Space& home, View x, int n);
00418 EqNGL(Space& home, bool share, EqNGL& ngl);
00420 virtual NGL::Status status(const Space& home) const;
00422 virtual ExecStatus prune(Space& home);
00424 virtual NGL* copy(Space& home, bool share);
00425 };
00426
00428 template<class View>
00429 class NqNGL : public ViewValNGL<View,int,PC_INT_DOM> {
00430 using ViewValNGL<View,int,PC_INT_DOM>::x;
00431 using ViewValNGL<View,int,PC_INT_DOM>::n;
00432 public:
00434 NqNGL(Space& home, View x, int n);
00436 NqNGL(Space& home, bool share, NqNGL& ngl);
00438 virtual NGL::Status status(const Space& home) const;
00440 virtual ExecStatus prune(Space& home);
00442 virtual NGL* copy(Space& home, bool share);
00443 };
00444
00446 template<class View>
00447 class LqNGL : public ViewValNGL<View,int,PC_INT_BND> {
00448 using ViewValNGL<View,int,PC_INT_BND>::x;
00449 using ViewValNGL<View,int,PC_INT_BND>::n;
00450 public:
00452 LqNGL(Space& home, View x, int n);
00454 LqNGL(Space& home, bool share, LqNGL& ngl);
00456 virtual NGL::Status status(const Space& home) const;
00458 virtual ExecStatus prune(Space& home);
00460 virtual NGL* copy(Space& home, bool share);
00461 };
00462
00464 template<class View>
00465 class GqNGL : public ViewValNGL<View,int,PC_INT_BND> {
00466 using ViewValNGL<View,int,PC_INT_BND>::x;
00467 using ViewValNGL<View,int,PC_INT_BND>::n;
00468 public:
00470 GqNGL(Space& home, View x, int n);
00472 GqNGL(Space& home, bool share, GqNGL& ngl);
00474 virtual NGL::Status status(const Space& home) const;
00476 virtual ExecStatus prune(Space& home);
00478 virtual NGL* copy(Space& home, bool share);
00479 };
00480
00481 }}}
00482
00483 #include <gecode/int/branch/ngl.hpp>
00484
00485 namespace Gecode { namespace Int { namespace Branch {
00486
00505 template<class View>
00506 class ValCommitEq : public ValCommit<View,int> {
00507 public:
00508 using typename ValCommit<View,int>::Var;
00510 ValCommitEq(Space& home, const ValBranch<Var>& vb);
00512 ValCommitEq(Space& home, bool shared, ValCommitEq& vc);
00514 ModEvent commit(Space& home, unsigned int a, View x, int i, int n);
00516 NGL* ngl(Space& home, unsigned int a, View x, int n) const;
00518 void print(const Space& home, unsigned int a, View x, int i, int n,
00519 std::ostream& o) const;
00520 };
00521
00528 template<class View>
00529 class ValCommitLq : public ValCommit<View,int> {
00530 public:
00531 using typename ValCommit<View,int>::Var;
00533 ValCommitLq(Space& home, const ValBranch<Var>& vb);
00535 ValCommitLq(Space& home, bool shared, ValCommitLq& vc);
00537 ModEvent commit(Space& home, unsigned int a, View x, int i, int n);
00539 NGL* ngl(Space& home, unsigned int a, View x, int n) const;
00541 void print(const Space& home, unsigned int a, View x, int i, int n,
00542 std::ostream& o) const;
00543 };
00544
00551 template<class View>
00552 class ValCommitGq : public ValCommit<View,int> {
00553 public:
00554 using typename ValCommit<View,int>::Var;
00556 ValCommitGq(Space& home, const ValBranch<Var>& vb);
00558 ValCommitGq(Space& home, bool shared, ValCommitGq& vc);
00560 ModEvent commit(Space& home, unsigned int a, View x, int i, int n);
00562 NGL* ngl(Space& home, unsigned int a, View x, int n) const;
00564 void print(const Space& home, unsigned int a, View x, int i, int n,
00565 std::ostream& o) const;
00566 };
00567
00574 template<class View>
00575 class ValCommitGr : public ValCommit<View,int> {
00576 public:
00577 using typename ValCommit<View,int>::Var;
00579 ValCommitGr(Space& home, const ValBranch<Var>& vb);
00581 ValCommitGr(Space& home, bool shared, ValCommitGr& vc);
00583 ModEvent commit(Space& home, unsigned int a, View x, int i, int n);
00585 NGL* ngl(Space& home, unsigned int a, View x, int n) const;
00587 void print(const Space& home, unsigned int a, View x, int i, int n,
00588 std::ostream& o) const;
00589 };
00590
00591 }}}
00592
00593 #include <gecode/int/branch/val-commit.hpp>
00594
00595 namespace Gecode { namespace Int { namespace Branch {
00596
00598 GECODE_INT_EXPORT
00599 ValSelCommitBase<IntView,int>*
00600 valselcommit(Space& home, const IntValBranch& ivb);
00601
00603 GECODE_INT_EXPORT
00604 ValSelCommitBase<BoolView,int>*
00605 valselcommit(Space& home, const BoolValBranch& bvb);
00606
00608 GECODE_INT_EXPORT
00609 ValSelCommitBase<IntView,int>*
00610 valselcommit(Space& home, const IntAssign& ia);
00611
00613 GECODE_INT_EXPORT
00614 ValSelCommitBase<BoolView,int>*
00615 valselcommit(Space& home, const BoolAssign& ba);
00616
00617 }}}
00618
00619 namespace Gecode { namespace Int { namespace Branch {
00620
00625 template<int n, bool min, class Filter, class Print>
00626 class ViewValuesBrancher : public ViewBrancher<IntView,Filter,n> {
00627 protected:
00628 using ViewBrancher<IntView,Filter,n>::x;
00629 using ViewBrancher<IntView,Filter,n>::f;
00631 Print p;
00633 ViewValuesBrancher(Space& home, bool shared, ViewValuesBrancher& b);
00635 ViewValuesBrancher(Home home, ViewArray<IntView>& x,
00636 ViewSel<IntView>* vs[n],
00637 IntBranchFilter bf,
00638 IntVarValPrint vvp);
00639 public:
00641 virtual const Choice* choice(Space& home);
00643 virtual const Choice* choice(const Space& home, Archive& e);
00645 virtual ExecStatus commit(Space& home, const Choice& c, unsigned int a);
00647 virtual NGL* ngl(Space& home, const Choice& c, unsigned int a) const;
00655 virtual void print(const Space& home, const Choice& c, unsigned int a,
00656 std::ostream& o) const;
00658 virtual Actor* copy(Space& home, bool share);
00660 static void post(Home home, ViewArray<IntView>& x,
00661 ViewSel<IntView>* vs[n],
00662 IntBranchFilter bf,
00663 IntVarValPrint vvp);
00665 virtual size_t dispose(Space& home);
00666 };
00667
00669 template<int n, bool min>
00670 void postviewvaluesbrancher(Home home, ViewArray<IntView>& x,
00671 ViewSel<IntView>* vs[n],
00672 IntBranchFilter bf,
00673 IntVarValPrint vvp);
00674
00675 }}}
00676
00677 #include <gecode/int/branch/view-values.hpp>
00678
00679 #endif
00680
00681