Generated on Wed Jan 4 17:49:08 2006 for Gecode by doxygen 1.4.6

assign.cc

Go to the documentation of this file.
00001 /*
00002  *  Main authors:
00003  *     Christian Schulte <schulte@gecode.org>
00004  *
00005  *  Copyright:
00006  *     Christian Schulte, 2002
00007  *
00008  *  Last modified:
00009  *     $Date: 2005-07-31 13:17:12 +0200 (Sun, 31 Jul 2005) $ by $Author: schulte $
00010  *     $Revision: 2094 $
00011  *
00012  *  This file is part of Gecode, the generic constraint
00013  *  development environment:
00014  *     http://www.gecode.org
00015  *
00016  *  See the file "LICENSE" for information on usage and
00017  *  redistribution of this file, and for a
00018  *     DISCLAIMER OF ALL WARRANTIES.
00019  *
00020  */
00021 
00022 #include "int/branch.hh"
00023 
00024 namespace Gecode { namespace Int { namespace Branch {
00025 
00026   unsigned int
00027   Assign::branch(void) {
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 // STATISTICS: int-branch
00102