assign.cc
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "gecode/int/branch.hh"
00023
00024 namespace Gecode { namespace Int { namespace Branch {
00025
00026 size_t
00027 AssignDesc::size(void) const {
00028 return sizeof(*this);
00029 }
00030
00031
00032 bool
00033 Assign::status(const Space*) const {
00034 for (int i = pos; i<x.size(); i++)
00035 if (!x[i].assigned()) {
00036 pos = i;
00037 return true;
00038 }
00039 return false;
00040 }
00041 ExecStatus
00042 Assign::commit(Space* home, const BranchingDesc* _d, unsigned int) {
00043 const AssignDesc* d = static_cast<const AssignDesc*>(_d);
00044 return me_failed(x[d->pos()].eq(home,d->val())) ? ES_FAILED : ES_OK;
00045 }
00046
00047
00048 Actor*
00049 AssignMin::copy(Space* home, bool share) {
00050 return new (home) AssignMin(home,share,*this);
00051 }
00052 const BranchingDesc*
00053 AssignMin::description(const Space*) const {
00054 assert(!x[pos].assigned());
00055 return new AssignDesc(this, pos, x[pos].min());
00056 }
00057
00058
00059 Actor*
00060 AssignMed::copy(Space* home, bool share) {
00061 return new (home) AssignMed(home,share,*this);
00062 }
00063 const BranchingDesc*
00064 AssignMed::description(const Space*) const {
00065 assert(!x[pos].assigned());
00066 return new AssignDesc(this, pos, x[pos].med());
00067 }
00068
00069
00070 Actor*
00071 AssignMax::copy(Space* home, bool share) {
00072 return new (home) AssignMax(home,share,*this);
00073 }
00074 const BranchingDesc*
00075 AssignMax::description(const Space*) const {
00076 assert(!x[pos].assigned());
00077 return new AssignDesc(this, pos, x[pos].max());
00078 }
00079
00080 }}}
00081
00082
00083