sequence.hh
Go to the documentation of this file.
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
* Main authors:
* David Rijsman <David.Rijsman@quintiq.com>
*
* Copyright:
* David Rijsman, 2009
*
* This file is part of Gecode, the generic constraint
* development environment:
* http://www.gecode.org
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#ifndef __GECODE_INT_SEQUENCE_HH__
#define __GECODE_INT_SEQUENCE_HH__
#include <gecode/int.hh>
#include <gecode/int/rel.hh>
namespace Gecode { namespace Int { namespace Sequence {
template<class View>
class SupportAdvisor;
template<class View,class Val,bool iss>
class ViewValSupport;
template<class View, class Val,bool iss>
class ViewValSupportArray {
private:
ViewValSupport<View,Val,iss>* xs;
int n;
public:
ViewValSupportArray(void);
ViewValSupportArray(const ViewValSupportArray<View,Val,iss>&);
ViewValSupportArray(Space& home, ViewArray<View>&, Val s, int q);
ViewValSupportArray(Space& home, int n);
int size(void) const;
ViewValSupport<View,Val,iss>& operator [](int n);
const ViewValSupport<View,Val,iss>& operator [](int) const;
void update(Space& home, ViewValSupportArray<View,Val,iss>& x);
ExecStatus propagate(Space& home,ViewArray<View>& a,Val s,int q,int l,int u);
ExecStatus advise(Space& home,ViewArray<View>& a,Val s,int q,int j,const Delta& d);
};
template<class View, class Val>
class Sequence : public Propagator {
protected:
Sequence(Space& home, Sequence& p);
Sequence(Home home, ViewArray<View>& x, Val s, int q, int l, int u);
public:
virtual Actor* copy(Space& home);
ExecStatus advise(Space& home, Advisor& _a, const Delta& d);
virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
virtual void reschedule(Space& home);
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
static ExecStatus post(Home home, ViewArray<View>& x, Val s, int q, int l, int u);
static ExecStatus check(ViewArray<View>& x, Val s, int q, int l, int u);
virtual size_t dispose(Space& home);
private:
ViewArray<View> x;
Val s;
int q;
int l;
int u;
ViewValSupportArray<View,Val,true> vvsamax;
ViewValSupportArray<View,Val,false> vvsamin;
Council<SupportAdvisor<View> > ac;
bool tofail;
};
}}}
#include <gecode/int/sequence/set-op.hpp>
#include <gecode/int/sequence/violations.hpp>
#include <gecode/int/sequence/int.hpp>
#include <gecode/int/sequence/view.hpp>
#endif
// STATISTICS: int-prop
Gecode::ActorLink::Actor
friend class Actor
Definition core.hpp:590
Gecode::Delta
Generic domain change information to be supplied to advisors.
Definition core.hpp:204
Gecode::Home
Home class for posting propagators
Definition core.hpp:856
Gecode::Int::Sequence::Sequence
Sequence propagator for array of integers
Definition sequence.hh:101
Gecode::Int::Sequence::Sequence::reschedule
virtual void reschedule(Space &home)
Schedule function.
Definition int.hpp:157
Gecode::Int::Sequence::Sequence::advise
ExecStatus advise(Space &home, Advisor &_a, const Delta &d)
Advise function.
Definition int.hpp:71
Gecode::Int::Sequence::Sequence::post
static ExecStatus post(Home home, ViewArray< View > &x, Val s, int q, int l, int u)
Post propagator for.
Definition int.hpp:133
Gecode::Int::Sequence::Sequence::copy
virtual Actor * copy(Space &home)
Perform copying during cloning.
Definition int.hpp:145
Gecode::Int::Sequence::Sequence::propagate
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition int.hpp:167
Gecode::Int::Sequence::Sequence::check
static ExecStatus check(ViewArray< View > &x, Val s, int q, int l, int u)
Check for consistency.
Definition int.hpp:109
Gecode::Int::Sequence::Sequence::dispose
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Definition int.hpp:99
Gecode::Int::Sequence::Sequence::cost
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function.
Definition int.hpp:151
Gecode::Int::Sequence::Sequence::Sequence
Sequence(Space &home, Sequence &p)
Constructor for cloning p.
Definition int.hpp:60
Gecode::Int::Sequence::SupportAdvisor
Class for advising the propagator.
Definition view.hpp:44
Gecode::Int::Sequence::ViewValSupportArray
An array of ViewValSupport data structures.
Definition sequence.hh:65
Gecode::Int::Sequence::ViewValSupportArray::ViewValSupportArray
ViewValSupportArray(void)
Default constructor.
Definition view.hpp:412
Gecode::Int::Sequence::ViewValSupportArray::update
void update(Space &home, ViewValSupportArray< View, Val, iss > &x)
Cloning.
Definition view.hpp:461
Gecode::Int::Sequence::ViewValSupportArray::advise
ExecStatus advise(Space &home, ViewArray< View > &a, Val s, int q, int j, const Delta &d)
Advise.
Definition view.hpp:482
Gecode::Int::Sequence::ViewValSupportArray::propagate
ExecStatus propagate(Space &home, ViewArray< View > &a, Val s, int q, int l, int u)
Propagate.
Definition view.hpp:473
Gecode::Int::Sequence::ViewValSupportArray::size
int size(void) const
Return the current size.
Definition view.hpp:441
Gecode::Int::Sequence::ViewValSupportArray::operator[]
ViewValSupport< View, Val, iss > & operator[](int n)
Access element n.
Definition view.hpp:447
Gecode::Int::Sequence::ViewValSupport
Class for view value support structure.
Definition view.hpp:80
Gecode::PropCost
Propagation cost.
Definition core.hpp:486
Gecode::Propagator::Space
friend class Space
Definition core.hpp:1066
Gecode::Propagator::Advisor
friend class Advisor
Definition core.hpp:1068
Gecode::Propagator::Council
friend class Council
Definition core.hpp:1069
Gecode::Propagator::med
ModEventDelta med
A set of modification events (used during propagation).
Definition core.hpp:1075
Gecode::Propagator::Propagator
Propagator(Home home)
Constructor for posting.
Definition core.hpp:3498
Gecode::Space
Computation spaces.
Definition core.hpp:1742
Gecode::Val
Gecode::ViewArray
View arrays.
Definition array.hpp:253
int.hpp
int.hh
Gecode::ModEventDelta
int ModEventDelta
Modification event deltas.
Definition core.hpp:89
rel.hh
view.hpp
Gecode::Int
Finite domain integers.
Gecode
Gecode toplevel namespace
Gecode::ExecStatus
ExecStatus
Definition core.hpp:472
set-op.hpp
violations.hpp