this repo has no description
1/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */ 2/* 3 * Main authors: 4 * Christian Schulte <schulte@gecode.org> 5 * 6 * Copyright: 7 * Christian Schulte, 2013 8 * 9 * This file is part of Gecode, the generic constraint 10 * development environment: 11 * http://www.gecode.org 12 * 13 * Permission is hereby granted, free of charge, to any person obtaining 14 * a copy of this software and associated documentation files (the 15 * "Software"), to deal in the Software without restriction, including 16 * without limitation the rights to use, copy, modify, merge, publish, 17 * distribute, sublicense, and/or sell copies of the Software, and to 18 * permit persons to whom the Software is furnished to do so, subject to 19 * the following conditions: 20 * 21 * The above copyright notice and this permission notice shall be 22 * included in all copies or substantial portions of the Software. 23 * 24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 25 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 26 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 27 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 28 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 29 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 30 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 31 * 32 */ 33 34#ifndef GECODE_SEARCH_NOGOODS_HH 35#define GECODE_SEARCH_NOGOODS_HH 36 37#include <gecode/search.hh> 38 39namespace Gecode { namespace Search { 40 41 /// Class for a sentinel no-good literal 42 class GECODE_VTABLE_EXPORT NoNGL : public NGL { 43 public: 44 /// Constructor for creation 45 NoNGL(void); 46 /// Constructor for creation 47 NoNGL(Space& home); 48 /// Constructor for cloning \a ngl 49 NoNGL(Space& home, NoNGL& ngl); 50 /// Subscribe propagator \a p to all views of the no-good literal 51 virtual void subscribe(Space& home, Propagator& p); 52 /// Schedule propagator \a p for all views of the no-good literal 53 virtual void reschedule(Space& home, Propagator& p); 54 /// Cancel propagator \a p from all views of the no-good literal 55 virtual void cancel(Space& home, Propagator& p); 56 /// Test the status of the no-good literal 57 virtual NGL::Status status(const Space& home) const; 58 /// Propagate the negation of the no-good literal 59 virtual ExecStatus prune(Space& home); 60 /// Create copy 61 virtual NGL* copy(Space& home); 62 }; 63 64 /// No-good propagator 65 class GECODE_SEARCH_EXPORT NoGoodsProp : public Propagator { 66 protected: 67 /// Root of no-good literal tree 68 NGL* root; 69 /// Number of no-good literals with subscriptions 70 unsigned int n; 71 /// Constructor for creation 72 NoGoodsProp(Space& home, NGL* root); 73 /// Constructor for cloning \a p 74 NoGoodsProp(Space& home, NoGoodsProp& p); 75 public: 76 /// Perform copying during cloning 77 virtual Actor* copy(Space& home); 78 /// Const function (defined as low unary) 79 virtual PropCost cost(const Space& home, const ModEventDelta& med) const; 80 /// Schedule function 81 virtual void reschedule(Space& home); 82 /// Perform propagation 83 virtual ExecStatus propagate(Space& home, const ModEventDelta& med); 84 /// Post propagator for path \a p 85 template<class Path> 86 static ExecStatus post(Space& home, const Path& p); 87 /// Delete propagator and return its size 88 virtual size_t dispose(Space& home); 89 }; 90 91}} 92 93#include <gecode/search/nogoods.hpp> 94 95#endif 96 97// STATISTICS: search-other