this repo has no description
1/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */ 2/* 3 * Main authors: 4 * David Rijsman <David.Rijsman@quintiq.com> 5 * 6 * Copyright: 7 * David Rijsman, 2009 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_INT_SEQUENCE_HH 35#define GECODE_INT_SEQUENCE_HH 36 37#include <gecode/int.hh> 38#include <gecode/int/rel.hh> 39 40namespace Gecode { namespace Int { namespace Sequence { 41 42 /** 43 * \namespace Gecode::Int::Sequence 44 * \brief %Sequence propagators 45 * 46 * This namespace contains a propagator for the 47 * cumulatives constraint as presented in 48 * Willem Jan van Hoeve, Gilles Pesant, Louis-Martin Rousseau, and 49 * Ashish Sabharwal, New filtering algorithms for combinations of 50 * among constraints. Constraints, 14(2), 273-292, 2009. 51 * 52 */ 53 54 template<class View> 55 class SupportAdvisor; 56 57 template<class View,class Val,bool iss> 58 class ViewValSupport; 59 60 /** 61 * \brief An array of %ViewValSupport data structures 62 * 63 */ 64 template<class View, class Val,bool iss> 65 class ViewValSupportArray { 66 private: 67 /// The actual array 68 ViewValSupport<View,Val,iss>* xs; 69 /// The size of the array 70 int n; 71 public: 72 /// Default constructor 73 ViewValSupportArray(void); 74 /// Copy constructor 75 ViewValSupportArray(const ViewValSupportArray<View,Val,iss>&); 76 /// Construct an ViewValSupportArray from \a x 77 ViewValSupportArray(Space& home, ViewArray<View>&, Val s, int q); 78 /// Construct an ViewValSupportArray of size \a n 79 ViewValSupportArray(Space& home, int n); 80 /// Return the current size 81 int size(void) const; 82 /// Access element \a n 83 ViewValSupport<View,Val,iss>& operator [](int n); 84 /// Access element \a n 85 const ViewValSupport<View,Val,iss>& operator [](int) const; 86 /// Cloning 87 void update(Space& home, ViewValSupportArray<View,Val,iss>& x); 88 /// Propagate 89 ExecStatus propagate(Space& home,ViewArray<View>& a,Val s,int q,int l,int u); 90 /// Advise 91 ExecStatus advise(Space& home,ViewArray<View>& a,Val s,int q,int j,const Delta& d); 92 }; 93 94 /** 95 * \brief %Sequence propagator for array of integers 96 * 97 * Requires \code #include <gecode/int/sequence.hh> \endcode 98 * \ingroup FuncIntProp 99 */ 100 template<class View, class Val> 101 class Sequence : public Propagator { 102 protected: 103 /// Constructor for cloning \a p 104 Sequence(Space& home, Sequence& p); 105 /// Constructor for creation 106 Sequence(Home home, ViewArray<View>& x, Val s, int q, int l, int u); 107 public: 108 /// Perform copying during cloning 109 virtual Actor* copy(Space& home); 110 /// Advise function 111 ExecStatus advise(Space& home, Advisor& _a, const Delta& d); 112 /// Cost function 113 virtual PropCost cost(const Space& home, const ModEventDelta& med) const; 114 /// Schedule function 115 virtual void reschedule(Space& home); 116 /// Perform propagation 117 virtual ExecStatus propagate(Space& home, const ModEventDelta& med); 118 /// Post propagator for 119 static ExecStatus post(Home home, ViewArray<View>& x, Val s, int q, int l, int u); 120 /// Check for consistency 121 static ExecStatus check(ViewArray<View>& x, Val s, int q, int l, int u); 122 /// Delete propagator and return its size 123 virtual size_t dispose(Space& home); 124 private: 125 /// Views to sequence 126 ViewArray<View> x; 127 /// Value counted in the sequence 128 Val s; 129 /// Length of each sequence 130 int q; 131 /// Lower bound 132 int l; 133 /// Upper bound 134 int u; 135 /// Array containing supports for s 136 ViewValSupportArray<View,Val,true> vvsamax; 137 /// Array containing supports for not s 138 ViewValSupportArray<View,Val,false> vvsamin; 139 /// Council for advisors 140 Council<SupportAdvisor<View> > ac; 141 /// Whether to fail when being rescheduled 142 bool tofail; 143 }; 144 145}}} 146 147#include <gecode/int/sequence/set-op.hpp> 148#include <gecode/int/sequence/violations.hpp> 149#include <gecode/int/sequence/int.hpp> 150#include <gecode/int/sequence/view.hpp> 151 152#endif 153 154// STATISTICS: int-prop