no-overlap.hh
Go to the documentation of this file.
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
* Main authors:
* Christian Schulte <schulte@gecode.org>
*
* Copyright:
* Christian Schulte, 2011
*
* 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_NO_OVERLAP_HH__
#define __GECODE_INT_NO_OVERLAP_HH__
#include <gecode/int.hh>
namespace Gecode { namespace Int { namespace NoOverlap {
class FixDim {
protected:
IntView c;
int s;
ExecStatus ssc(Space& home, int n);
ExecStatus lec(Space& home, int n);
ExecStatus nooverlap(Space& home, int n, int m);
public:
FixDim(void);
FixDim(IntView c, int s);
int ssc(void) const;
int lsc(void) const;
int sec(void) const;
int lec(void) const;
ExecStatus nooverlap(Space& home, FixDim& d);
void update(Space& home, FixDim& d);
void subscribe(Space& home, Propagator& p);
void cancel(Space& home, Propagator& p);
void reschedule(Space& home, Propagator& p);
};
class FlexDim {
protected:
IntView c0;
IntView s;
IntView c1;
ExecStatus ssc(Space& home, int n);
ExecStatus lec(Space& home, int n);
ExecStatus nooverlap(Space& home, int n, int m);
public:
FlexDim(void);
FlexDim(IntView c0, IntView s, IntView c1);
int ssc(void) const;
int lsc(void) const;
int sec(void) const;
int lec(void) const;
ExecStatus nooverlap(Space& home, FlexDim& d);
void update(Space& home, FlexDim& d);
void subscribe(Space& home, Propagator& p);
void cancel(Space& home, Propagator& p);
void reschedule(Space& home, Propagator& p);
};
}}}
#include <gecode/int/no-overlap/dim.hpp>
namespace Gecode { namespace Int { namespace NoOverlap {
template<class Dim, int n>
class ManBox {
protected:
Dim d[n];
public:
const Dim& operator [](int i) const;
Dim& operator [](int i);
static int dim(void);
bool mandatory(void) const;
bool optional(void) const;
bool excluded(void) const;
ExecStatus exclude(Space& home);
bool nooverlap(const ManBox<Dim,n>& b) const;
bool overlap(const ManBox<Dim,n>& b) const;
ExecStatus nooverlap(Space& home, ManBox<Dim,n>& b);
void update(Space& home, ManBox<Dim,n>& r);
void subscribe(Space& home, Propagator& p);
void cancel(Space& home, Propagator& p);
void reschedule(Space& home, Propagator& p);
};
template<class Dim, int n>
class OptBox : public ManBox<Dim,n> {
protected:
using ManBox<Dim,n>::d;
BoolView o;
public:
void optional(BoolView o);
bool mandatory(void) const;
bool optional(void) const;
bool excluded(void) const;
ExecStatus exclude(Space& home);
void update(Space& home, OptBox<Dim,n>& r);
void subscribe(Space& home, Propagator& p);
void cancel(Space& home, Propagator& p);
void reschedule(Space& home, Propagator& p);
};
}}}
#include <gecode/int/no-overlap/box.hpp>
namespace Gecode { namespace Int { namespace NoOverlap {
template<class Box>
class Base : public Propagator {
protected:
Box* b;
int n;
Base(Home home, Box* b, int n);
Base(Space& home, Base<Box>& p, int m);
static int partition(Box* b, int i, int n);
public:
virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
virtual void reschedule(Space& home);
virtual size_t dispose(Space& home);
};
template<class Box>
class ManProp : public Base<Box> {
protected:
using Base<Box>::b;
using Base<Box>::n;
ManProp(Home home, Box* b, int n);
ManProp(Space& home, ManProp<Box>& p);
public:
static ExecStatus post(Home home, Box* b, int n);
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
virtual Actor* copy(Space& home);
virtual size_t dispose(Space& home);
};
template<class Box>
class OptProp : public Base<Box> {
protected:
using Base<Box>::b;
using Base<Box>::n;
int m;
OptProp(Home home, Box* b, int n, int m);
OptProp(Space& home, OptProp<Box>& p);
public:
static ExecStatus post(Home home, Box* b, int n);
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
virtual Actor* copy(Space& home);
virtual size_t dispose(Space& home);
};
}}}
#include <gecode/int/no-overlap/base.hpp>
#include <gecode/int/no-overlap/man.hpp>
#include <gecode/int/no-overlap/opt.hpp>
#endif
// STATISTICS: int-prop
box.hpp
Gecode::ActorLink::Actor
friend class Actor
Definition core.hpp:590
Gecode::Home
Home class for posting propagators
Definition core.hpp:856
Gecode::Int::BoolView
Boolean view for Boolean variables.
Definition view.hpp:1380
Gecode::Int::IntView
Integer view for integer variables.
Definition view.hpp:129
Gecode::Int::NoOverlap::Base::n
int n
Number of mandatory boxes: b[0] ... b[n-1].
Definition no-overlap.hh:239
Gecode::Int::NoOverlap::Base::Base
Base(Home home, Box *b, int n)
Constructor for posting with n mandatory boxes.
Definition base.hpp:38
Gecode::Int::NoOverlap::Base::cost
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function.
Definition base.hpp:77
Gecode::Int::NoOverlap::Base::dispose
virtual size_t dispose(Space &home)
Destructor.
Definition base.hpp:59
Gecode::Int::NoOverlap::Base::b
Box * b
Boxes.
Definition no-overlap.hh:237
Gecode::Int::NoOverlap::Base::partition
static int partition(Box *b, int i, int n)
Partition n boxes b starting at position i.
Definition base.hpp:46
Gecode::Int::NoOverlap::Base::reschedule
virtual void reschedule(Space &home)
Schedule function.
Definition base.hpp:83
Gecode::Int::NoOverlap::FixDim::subscribe
void subscribe(Space &home, Propagator &p)
Subscribe propagator p to dimension.
Definition dim.hpp:101
Gecode::Int::NoOverlap::FixDim::update
void update(Space &home, FixDim &d)
Update dimension during cloning.
Definition dim.hpp:95
Gecode::Int::NoOverlap::FixDim::c
IntView c
Coordinate.
Definition no-overlap.hh:52
Gecode::Int::NoOverlap::FixDim::reschedule
void reschedule(Space &home, Propagator &p)
Schedule propagator p.
Definition dim.hpp:109
Gecode::Int::NoOverlap::FixDim::lsc
int lsc(void) const
Return largest start coordinate.
Definition dim.hpp:52
Gecode::Int::NoOverlap::FixDim::FixDim
FixDim(void)
Default constructor.
Definition dim.hpp:41
Gecode::Int::NoOverlap::FixDim::s
int s
Size.
Definition no-overlap.hh:54
Gecode::Int::NoOverlap::FixDim::ssc
int ssc(void) const
Return smallest start coordinate.
Definition dim.hpp:48
Gecode::Int::NoOverlap::FixDim::sec
int sec(void) const
Return smallest end coordinate.
Definition dim.hpp:56
Gecode::Int::NoOverlap::FixDim::nooverlap
ExecStatus nooverlap(Space &home, int n, int m)
Dimension must not overlap with coordinates n to m.
Definition dim.hpp:75
Gecode::Int::NoOverlap::FixDim::lec
int lec(void) const
Return largest end coordinate.
Definition dim.hpp:60
Gecode::Int::NoOverlap::FixDim::cancel
void cancel(Space &home, Propagator &p)
Cancel propagator p from dimension.
Definition dim.hpp:105
Gecode::Int::NoOverlap::FlexDim::ssc
int ssc(void) const
Return smallest start coordinate.
Definition dim.hpp:125
Gecode::Int::NoOverlap::FlexDim::lsc
int lsc(void) const
Return largest start coordinate.
Definition dim.hpp:129
Gecode::Int::NoOverlap::FlexDim::c1
IntView c1
End coordinate.
Definition no-overlap.hh:100
Gecode::Int::NoOverlap::FlexDim::s
IntView s
Size.
Definition no-overlap.hh:98
Gecode::Int::NoOverlap::FlexDim::subscribe
void subscribe(Space &home, Propagator &p)
Subscribe propagator p to dimension.
Definition dim.hpp:182
Gecode::Int::NoOverlap::FlexDim::sec
int sec(void) const
Return smallest end coordinate.
Definition dim.hpp:133
Gecode::Int::NoOverlap::FlexDim::FlexDim
FlexDim(void)
Default constructor.
Definition dim.hpp:119
Gecode::Int::NoOverlap::FlexDim::nooverlap
ExecStatus nooverlap(Space &home, int n, int m)
Dimension must not overlap with coordinates n to m.
Definition dim.hpp:152
Gecode::Int::NoOverlap::FlexDim::c0
IntView c0
Start coordinate.
Definition no-overlap.hh:96
Gecode::Int::NoOverlap::FlexDim::reschedule
void reschedule(Space &home, Propagator &p)
Schedule propagator p.
Definition dim.hpp:194
Gecode::Int::NoOverlap::FlexDim::cancel
void cancel(Space &home, Propagator &p)
Cancel propagator p from dimension.
Definition dim.hpp:188
Gecode::Int::NoOverlap::FlexDim::update
void update(Space &home, FlexDim &d)
Update dimension during cloning.
Definition dim.hpp:175
Gecode::Int::NoOverlap::FlexDim::lec
int lec(void) const
Return largest end coordinate.
Definition dim.hpp:137
Gecode::Int::NoOverlap::ManBox
Mandatory box class.
Definition no-overlap.hh:146
Gecode::Int::NoOverlap::ManBox::d
Dim d[n]
Dimensions.
Definition no-overlap.hh:149
Gecode::Int::NoOverlap::ManBox::dim
static int dim(void)
Return number of dimensions.
Definition box.hpp:54
Gecode::Int::NoOverlap::ManBox::nooverlap
bool nooverlap(const ManBox< Dim, n > &b) const
Check whether this box does not any longer overlap with b.
Definition box.hpp:82
Gecode::Int::NoOverlap::ManBox::operator[]
const Dim & operator[](int i) const
Access to dimension i.
Definition box.hpp:42
Gecode::Int::NoOverlap::ManBox::reschedule
void reschedule(Space &home, Propagator &p)
Schedule propagator p.
Definition box.hpp:139
Gecode::Int::NoOverlap::ManBox::update
void update(Space &home, ManBox< Dim, n > &r)
Update box during cloning.
Definition box.hpp:120
Gecode::Int::NoOverlap::ManBox::overlap
bool overlap(const ManBox< Dim, n > &b) const
Check whether this box overlaps with b.
Definition box.hpp:91
Gecode::Int::NoOverlap::ManBox::excluded
bool excluded(void) const
Whether box is excluded.
Definition box.hpp:65
Gecode::Int::NoOverlap::ManBox::mandatory
bool mandatory(void) const
Whether box is mandatory.
Definition box.hpp:60
Gecode::Int::NoOverlap::ManBox::subscribe
void subscribe(Space &home, Propagator &p)
Subscribe propagator p to box.
Definition box.hpp:127
Gecode::Int::NoOverlap::ManBox::optional
bool optional(void) const
Whether box is optional.
Definition box.hpp:70
Gecode::Int::NoOverlap::ManBox::exclude
ExecStatus exclude(Space &home)
Exclude box.
Definition box.hpp:76
Gecode::Int::NoOverlap::ManBox::cancel
void cancel(Space &home, Propagator &p)
Cancel propagator p from box.
Definition box.hpp:133
Gecode::Int::NoOverlap::ManProp::ManProp
ManProp(Home home, Box *b, int n)
Constructor for posting.
Definition man.hpp:38
Gecode::Int::NoOverlap::ManProp::propagate
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition man.hpp:70
Gecode::Int::NoOverlap::ManProp::dispose
virtual size_t dispose(Space &home)
Destructor.
Definition man.hpp:51
Gecode::Int::NoOverlap::ManProp::post
static ExecStatus post(Home home, Box *b, int n)
Post propagator for boxes b.
Definition man.hpp:43
Gecode::Int::NoOverlap::ManProp::copy
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition man.hpp:64
Gecode::Int::NoOverlap::OptBox
Optional box class.
Definition no-overlap.hh:191
Gecode::Int::NoOverlap::OptBox::update
void update(Space &home, OptBox< Dim, n > &r)
Update box during cloning.
Definition box.hpp:179
Gecode::Int::NoOverlap::OptBox::o
BoolView o
Whether box is optional or not.
Definition no-overlap.hh:195
Gecode::Int::NoOverlap::OptBox::optional
bool optional(void) const
Whether box is optional.
Definition box.hpp:166
Gecode::Int::NoOverlap::OptBox::mandatory
bool mandatory(void) const
Whether box is mandatory.
Definition box.hpp:156
Gecode::Int::NoOverlap::OptBox::exclude
ExecStatus exclude(Space &home)
Exclude box.
Definition box.hpp:172
Gecode::Int::NoOverlap::OptBox::reschedule
void reschedule(Space &home, Propagator &p)
Schedule propagator p.
Definition box.hpp:198
Gecode::Int::NoOverlap::OptBox::subscribe
void subscribe(Space &home, Propagator &p)
Subscribe propagator p to box.
Definition box.hpp:186
Gecode::Int::NoOverlap::OptBox::cancel
void cancel(Space &home, Propagator &p)
Cancel propagator p from box.
Definition box.hpp:192
Gecode::Int::NoOverlap::OptBox::excluded
bool excluded(void) const
Whether box is excluded.
Definition box.hpp:161
Gecode::Int::NoOverlap::OptProp::dispose
virtual size_t dispose(Space &home)
Destructor.
Definition opt.hpp:57
Gecode::Int::NoOverlap::OptProp::post
static ExecStatus post(Home home, Box *b, int n)
Post propagator for boxes b.
Definition opt.hpp:46
Gecode::Int::NoOverlap::OptProp::propagate
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition opt.hpp:78
Gecode::Int::NoOverlap::OptProp::OptProp
OptProp(Home home, Box *b, int n, int m)
Constructor for posting.
Definition opt.hpp:38
Gecode::Int::NoOverlap::OptProp::copy
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition opt.hpp:72
Gecode::Int::NoOverlap::OptProp::m
int m
Number of optional boxes: b[n] ... b[n+m-1].
Definition no-overlap.hh:299
Gecode::PropCost
Propagation cost.
Definition core.hpp:486
Gecode::Propagator
Base-class for propagators.
Definition core.hpp:1064
Gecode::Propagator::Space
friend class Space
Definition core.hpp:1066
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
dim.hpp
int.hh
Gecode::ModEventDelta
int ModEventDelta
Modification event deltas.
Definition core.hpp:89
base.hpp
man.hpp
Gecode::Int::NoOverlap
No-overlap propagators
Definition no-overlap.cpp:38
Gecode::Int
Finite domain integers.
Gecode
Gecode toplevel namespace
Gecode::ExecStatus
ExecStatus
Definition core.hpp:472
opt.hpp