Generated on Sun Feb 17 15:24:21 2019 for Gecode by doxygen 1.6.3

bool-base.hpp

Go to the documentation of this file.
00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
00002 /*
00003  *  Main authors:
00004  *     Christian Schulte <schulte@gecode.org>
00005  *
00006  *  Copyright:
00007  *     Christian Schulte, 2011
00008  *
00009  *  This file is part of Gecode, the generic constraint
00010  *  development environment:
00011  *     http://www.gecode.org
00012  *
00013  *  Permission is hereby granted, free of charge, to any person obtaining
00014  *  a copy of this software and associated documentation files (the
00015  *  "Software"), to deal in the Software without restriction, including
00016  *  without limitation the rights to use, copy, modify, merge, publish,
00017  *  distribute, sublicense, and/or sell copies of the Software, and to
00018  *  permit persons to whom the Software is furnished to do so, subject to
00019  *  the following conditions:
00020  *
00021  *  The above copyright notice and this permission notice shall be
00022  *  included in all copies or substantial portions of the Software.
00023  *
00024  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00025  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00026  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00027  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00028  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00029  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00030  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00031  *
00032  */
00033 
00034 namespace Gecode { namespace Int { namespace NValues {
00035 
00036   template<class VY>
00037   forceinline
00038   BoolBase<VY>::BoolBase(Home home,
00039                          int status0, ViewArray<BoolView>& x, VY y0)
00040     : Propagator(home), status(status0), c(home), y(y0) {
00041     y.subscribe(home,*this,PC_INT_BND);
00042     for (int i=0; i<x.size(); i++) {
00043       assert(!x[i].assigned());
00044       (void) new (home) ViewAdvisor<BoolView>(home, *this, c, x[i]);
00045     }
00046   }
00047 
00048   template<class VY>
00049   forceinline
00050   BoolBase<VY>::BoolBase(Space& home, BoolBase<VY>& p)
00051     : Propagator(home,p), status(p.status) {
00052     c.update(home,p.c);
00053     y.update(home,p.y);
00054   }
00055 
00056   template<class VY>
00057   PropCost
00058   BoolBase<VY>::cost(const Space&, const ModEventDelta&) const {
00059     return PropCost::unary(PropCost::LO);
00060   }
00061 
00062   template<class VY>
00063   void
00064   BoolBase<VY>::reschedule(Space& home) {
00065     y.reschedule(home,*this,PC_INT_BND);
00066   }
00067 
00068   template<class VY>
00069   ExecStatus
00070   BoolBase<VY>::advise(Space& home, Advisor& _a, const Delta&) {
00071     ViewAdvisor<BoolView>& a(static_cast<ViewAdvisor<BoolView>&>(_a));
00072     ExecStatus es;
00073     if (status == (VS_ZERO | VS_ONE)) {
00074       // Everything is already decided
00075       es = ES_FIX;
00076     } else {
00077       if (a.view().zero())
00078         status |= VS_ZERO;
00079       else
00080         status |= VS_ONE;
00081       es = ES_NOFIX;
00082     }
00083     a.dispose(home,c);
00084     if (c.empty())
00085       es = ES_NOFIX;
00086     return es;
00087   }
00088 
00089   template<class VY>
00090   forceinline size_t
00091   BoolBase<VY>::dispose(Space& home) {
00092     c.dispose(home);
00093     y.cancel(home,*this,PC_INT_BND);
00094     (void) Propagator::dispose(home);
00095     return sizeof(*this);
00096   }
00097 
00098 }}}
00099 
00100 // STATISTICS: int-prop