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 unsigned int
00027 Assign::branch(Space*) {
00028 for (int i = pos; i<x.size(); i++)
00029 if (!x[i].assigned()) {
00030 pos = i;
00031 return 1;
00032 }
00033 return 0;
00034 }
00035
00036
00037 Actor*
00038 AssignMin::copy(Space* home, bool share) {
00039 return new (home) AssignMin(home,share,*this);
00040 }
00041 BranchingDesc*
00042 AssignMin::description(void) {
00043 return new PosValDesc<int>(this, pos, x[pos].min());
00044 }
00045 ExecStatus
00046 AssignMin::commit(Space* home, unsigned int, BranchingDesc* _d) {
00047 PosValDesc<int>* d = static_cast<PosValDesc<int>*>(_d);
00048 int p, v;
00049 if (d == NULL) {
00050 p = pos; v = x[pos].min();
00051 } else {
00052 p = d->pos(); v = d->val();
00053 }
00054 return me_failed(x[p].eq(home,v)) ? ES_FAILED : ES_OK;
00055 }
00056
00057
00058 Actor*
00059 AssignMed::copy(Space* home, bool share) {
00060 return new (home) AssignMed(home,share,*this);
00061 }
00062 BranchingDesc*
00063 AssignMed::description(void) {
00064 return new PosValDesc<int>(this, pos, x[pos].med());
00065 }
00066 ExecStatus
00067 AssignMed::commit(Space* home, unsigned int, BranchingDesc* _d) {
00068 PosValDesc<int>* d = static_cast<PosValDesc<int>*>(_d);
00069 int p, v;
00070 if (d == NULL) {
00071 p = pos; v = x[pos].med();
00072 } else {
00073 p = d->pos(); v = d->val();
00074 }
00075 return me_failed(x[p].eq(home,v)) ? ES_FAILED : ES_OK;
00076 }
00077
00078
00079 Actor*
00080 AssignMax::copy(Space* home, bool share) {
00081 return new (home) AssignMax(home,share,*this);
00082 }
00083 BranchingDesc*
00084 AssignMax::description(void) {
00085 return new PosValDesc<int>(this, pos, x[pos].max());
00086 }
00087 ExecStatus
00088 AssignMax::commit(Space* home, unsigned int, BranchingDesc* _d) {
00089 PosValDesc<int>* d = static_cast<PosValDesc<int>*>(_d);
00090 int p, v;
00091 if (d == NULL) {
00092 p = pos; v = x[pos].max();
00093 } else {
00094 p = d->pos(); v = d->val();
00095 }
00096 return me_failed(x[p].eq(home,v)) ? ES_FAILED : ES_OK;
00097 }
00098
00099 }}}
00100
00101
00102