distinct.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>
* Guido Tack <tack@gecode.org>
*
* Contributing authors:
* Gabor Szokoli <szokoli@gecode.org>
*
* Copyright:
* Christian Schulte, 2002
* Guido Tack, 2004
* Gabor Szokoli, 2003
*
* 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_DISTINCT_HH__
#define __GECODE_INT_DISTINCT_HH__
#include <gecode/int.hh>
#include <gecode/int/view-val-graph.hh>
#include <gecode/int/rel.hh>
namespace Gecode { namespace Int { namespace Distinct {
template<class View>
class Val : public NaryPropagator<View,PC_INT_VAL> {
protected:
using NaryPropagator<View,PC_INT_VAL>::x;
Val(Home home, ViewArray<View>& x);
Val(Space& home, Val<View>& p);
public:
#ifdef GECODE_HAS_CBS
virtual void solndistrib(Space& home, Propagator::SendMarginal send) const;
virtual void domainsizesum(Propagator::InDecision in,
unsigned int& size, unsigned int& size_b) const;
#endif
virtual Actor* copy(Space& home);
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
static ExecStatus post(Home home, ViewArray<View>& x);
};
#ifdef GECODE_HAS_CBS
template<class View>
void cbsdistinct(Space& home, unsigned int prop_id, const ViewArray<View>& x,
Propagator::SendMarginal send);
template<class View>
void cbssize(const ViewArray<View>& x, Propagator::InDecision in,
unsigned int& size, unsigned int& size_b);
#endif
template<class View, bool complete>
ExecStatus prop_val(Space& home, ViewArray<View>&);
template<class View>
class Bnd : public Propagator {
protected:
ViewArray<View> x;
ViewArray<View> y;
int min_x;
int max_x;
Bnd(Home home, ViewArray<View>& x);
Bnd(Space& home, Bnd<View>& p);
public:
#ifdef GECODE_HAS_CBS
virtual void solndistrib(Space& home, Propagator::SendMarginal send) const;
virtual void domainsizesum(Propagator::InDecision in,
unsigned int& size, unsigned int& size_b) const;
#endif
static ExecStatus post(Home home, ViewArray<View>& x);
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
virtual void reschedule(Space& home);
virtual Actor* copy(Space& home);
virtual size_t dispose(Space& home);
};
template<class View>
ExecStatus prop_bnd(Space& home, ViewArray<View>& x, int& min_x, int& max_x);
template<class View>
ExecStatus prop_bnd(Space& home, ViewArray<View>& x);
template<class View>
class Graph : public ViewValGraph::Graph<View> {
public:
using ViewValGraph::Graph<View>::view;
using ViewValGraph::Graph<View>::n_view;
using ViewValGraph::Graph<View>::val;
using ViewValGraph::Graph<View>::n_val;
using ViewValGraph::Graph<View>::count;
using ViewValGraph::Graph<View>::scc;
using ViewValGraph::Graph<View>::match;
Graph(void);
ExecStatus init(Space& home, ViewArray<View>& x);
bool mark(void);
ExecStatus prune(Space& home, bool& assigned);
bool sync(void);
};
template<class View>
class DomCtrl {
protected:
Graph<View> g;
public:
DomCtrl(void);
bool available(void);
ExecStatus init(Space& home, ViewArray<View>& x);
ExecStatus sync(void);
ExecStatus propagate(Space& home, bool& assigned);
};
template<class View>
class Dom : public NaryPropagator<View,PC_INT_DOM> {
protected:
using NaryPropagator<View,PC_INT_DOM>::x;
DomCtrl<View> dc;
Dom(Space& home, Dom<View>& p);
Dom(Home home, ViewArray<View>& x);
public:
#ifdef GECODE_HAS_CBS
virtual void solndistrib(Space& home, Propagator::SendMarginal send) const;
virtual void domainsizesum(Propagator::InDecision in,
unsigned int& size, unsigned int& size_b) const;
#endif
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
virtual Actor* copy(Space& home);
static ExecStatus post(Home home, ViewArray<View>& x);
};
template<class View>
class TerDom : public TernaryPropagator<View,PC_INT_DOM> {
protected:
using TernaryPropagator<View,PC_INT_DOM>::x0;
using TernaryPropagator<View,PC_INT_DOM>::x1;
using TernaryPropagator<View,PC_INT_DOM>::x2;
TerDom(Space& home, TerDom<View>& p);
TerDom(Home home, View x0, View x1, View x2);
public:
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
virtual Actor* copy(Space& home);
static ExecStatus post(Home home, View x0, View x1, View x2);
};
class EqIte : public BinaryPropagator<IntView,PC_INT_DOM> {
protected:
using BinaryPropagator<IntView,PC_INT_DOM>::x0;
using BinaryPropagator<IntView,PC_INT_DOM>::x1;
int c0, c1;
EqIte(Space& home, EqIte& p);
EqIte(Home home, IntView x0, IntView x1, int c0, int c1);
public:
GECODE_INT_EXPORT
virtual Actor* copy(Space& home);
GECODE_INT_EXPORT
virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
GECODE_INT_EXPORT
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
static ExecStatus post(Home home, IntView x0, IntView x1, int c0, int c1);
};
}}}
#include <gecode/int/distinct/cbs.hpp>
#include <gecode/int/distinct/val.hpp>
#include <gecode/int/distinct/bnd.hpp>
#include <gecode/int/distinct/ter-dom.hpp>
#include <gecode/int/distinct/graph.hpp>
#include <gecode/int/distinct/dom-ctrl.hpp>
#include <gecode/int/distinct/dom.hpp>
#include <gecode/int/distinct/eqite.hpp>
#endif
// STATISTICS: int-prop
Gecode::ActorLink::Actor
friend class Actor
Definition core.hpp:590
Gecode::BinaryPropagator< IntView, PC_INT_DOM >::x0
IntView x0
Definition pattern.hpp:87
Gecode::BinaryPropagator< IntView, PC_INT_DOM >::BinaryPropagator
BinaryPropagator(Space &home, BinaryPropagator &p)
Gecode::BinaryPropagator< IntView, PC_INT_DOM >::x1
IntView x1
Definition pattern.hpp:87
Gecode::Home
Home class for posting propagators
Definition core.hpp:856
Gecode::Int::Distinct::Bnd::max_x
int max_x
Maximum (approximation) of view in x.
Definition distinct.hh:161
Gecode::Int::Distinct::Bnd::post
static ExecStatus post(Home home, ViewArray< View > &x)
Post propagator for view array x.
Definition bnd.hpp:476
Gecode::Int::Distinct::Bnd::propagate
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition bnd.hpp:381
Gecode::Int::Distinct::Bnd::reschedule
virtual void reschedule(Space &home)
Schedule function.
Definition bnd.hpp:87
Gecode::Int::Distinct::Bnd::copy
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition bnd.hpp:72
Gecode::Int::Distinct::Bnd::y
ViewArray< View > y
Views on which to perform value-propagation (subset of x).
Definition distinct.hh:157
Gecode::Int::Distinct::Bnd::cost
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function.
Definition bnd.hpp:78
Gecode::Int::Distinct::Bnd::Bnd
Bnd(Home home, ViewArray< View > &x)
Constructor for posting.
Definition bnd.hpp:38
Gecode::Int::Distinct::Bnd::dispose
virtual size_t dispose(Space &home)
Destructor.
Definition bnd.hpp:56
Gecode::Int::Distinct::Bnd::x
ViewArray< View > x
Views on which to perform bounds-propagation.
Definition distinct.hh:155
Gecode::Int::Distinct::Bnd::min_x
int min_x
Minimum (approximation) of view in x.
Definition distinct.hh:159
Gecode::Int::Distinct::DomCtrl
Propagation controller for domain consistent distinct.
Definition distinct.hh:250
Gecode::Int::Distinct::DomCtrl::init
ExecStatus init(Space &home, ViewArray< View > &x)
Initialize view-value graph for views x.
Definition dom-ctrl.hpp:55
Gecode::Int::Distinct::DomCtrl::propagate
ExecStatus propagate(Space &home, bool &assigned)
Perform propagation, assigned is true if a view gets assigned.
Definition dom-ctrl.hpp:68
Gecode::Int::Distinct::DomCtrl::available
bool available(void)
Check whether a view-value graph is available.
Definition dom-ctrl.hpp:49
Gecode::Int::Distinct::DomCtrl::sync
ExecStatus sync(void)
Synchronize available view-value graph.
Definition dom-ctrl.hpp:61
Gecode::Int::Distinct::DomCtrl::g
Graph< View > g
Propagation is performed on a view-value graph.
Definition distinct.hh:253
Gecode::Int::Distinct::DomCtrl::DomCtrl
DomCtrl(void)
Initialize with non-initialized view-value graph.
Definition dom-ctrl.hpp:45
Gecode::Int::Distinct::Dom::post
static ExecStatus post(Home home, ViewArray< View > &x)
Post propagator for views x.
Definition dom.hpp:45
Gecode::Int::Distinct::Dom::propagate
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition dom.hpp:96
Gecode::Int::Distinct::Dom::copy
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition dom.hpp:74
Gecode::Int::Distinct::Dom::cost
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function.
Definition dom.hpp:65
Gecode::Int::Distinct::Dom::Dom
Dom(Space &home, Dom< View > &p)
Constructor for cloning p.
Definition dom.hpp:60
Gecode::Int::Distinct::Dom::dc
DomCtrl< View > dc
Propagation controller.
Definition distinct.hh:287
Gecode::Int::Distinct::EqIte::EqIte
EqIte(Space &home, EqIte &p)
Constructor for cloning p.
Definition eqite.hpp:43
Gecode::Int::Distinct::EqIte::copy
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition eqite.cpp:46
Gecode::Int::Distinct::EqIte::cost
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as high ternary).
Definition eqite.cpp:41
Gecode::Int::Distinct::EqIte::post
static ExecStatus post(Home home, IntView x0, IntView x1, int c0, int c1)
Post if-then-else propagator.
Definition eqite.hpp:49
Gecode::Int::Distinct::EqIte::c1
int c1
Definition distinct.hh:354
Gecode::Int::Distinct::EqIte::c0
int c0
The integer constant.
Definition distinct.hh:354
Gecode::Int::Distinct::EqIte::propagate
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition eqite.cpp:51
Gecode::Int::Distinct::Graph
View-value graph for propagation.
Definition distinct.hh:218
Gecode::Int::Distinct::Graph::Graph
Graph(void)
Construct graph as not yet initialized.
Definition graph.hpp:40
Gecode::Int::Distinct::Graph::mark
bool mark(void)
Mark edges in graph, return true if pruning is at all possible.
Definition graph.hpp:176
Gecode::Int::Distinct::Graph::sync
bool sync(void)
Synchronize graph with new view domains.
Definition graph.hpp:112
Gecode::Int::Distinct::Graph::init
ExecStatus init(Space &home, ViewArray< View > &x)
Initialize graph.
Definition graph.hpp:44
Gecode::Int::Distinct::Graph::prune
ExecStatus prune(Space &home, bool &assigned)
Prune unmarked edges, assigned is true if a view got assigned.
Definition graph.hpp:240
Gecode::Int::Distinct::TerDom::TerDom
TerDom(Space &home, TerDom< View > &p)
Constructor for cloning p.
Definition ter-dom.hpp:56
Gecode::Int::Distinct::TerDom::propagate
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition ter-dom.hpp:93
Gecode::Int::Distinct::TerDom::post
static ExecStatus post(Home home, View x0, View x1, View x2)
Post propagator for views x.
Definition ter-dom.hpp:49
Gecode::Int::Distinct::TerDom::copy
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition ter-dom.hpp:61
Gecode::Int::Distinct::Val::copy
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition val.hpp:172
Gecode::Int::Distinct::Val::propagate
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition val.hpp:178
Gecode::Int::Distinct::Val::post
static ExecStatus post(Home home, ViewArray< View > &x)
Post propagator for view array x.
Definition val.hpp:185
Gecode::Int::Distinct::Val::Val
Val(Home home, ViewArray< View > &x)
Constructor for posting.
Definition val.hpp:147
Gecode::Int::IntView
Integer view for integer variables.
Definition view.hpp:129
Gecode::Int::ViewValGraph::Graph
View-value graph base class.
Definition view-val-graph.hh:294
Gecode::Int::ViewValGraph::Graph::count
unsigned int count
Marking counter.
Definition view-val-graph.hh:305
Gecode::Int::ViewValGraph::Graph::view
ViewNode< View > ** view
Array of view nodes.
Definition view-val-graph.hh:297
Gecode::Int::ViewValGraph::Graph::match
bool match(ViewNodeStack &m, ViewNode< View > *x)
Find a matching for node x.
Definition graph.hpp:87
Gecode::Int::ViewValGraph::Graph::n_view
int n_view
Number of view nodes.
Definition view-val-graph.hh:301
Gecode::Int::ViewValGraph::Graph::n_val
int n_val
Number of value nodes.
Definition view-val-graph.hh:303
Gecode::Int::ViewValGraph::Graph::scc
void scc(void)
Compute the strongly connected components.
Definition graph.hpp:142
Gecode::Int::ViewValGraph::Graph::val
ValNode< View > * val
Array of value nodes.
Definition view-val-graph.hh:299
Gecode::NaryPropagator< View, PC_INT_VAL >::x
ViewArray< View > x
Definition pattern.hpp:145
Gecode::NaryPropagator< View, PC_INT_VAL >::NaryPropagator
NaryPropagator(Space &home, NaryPropagator &p)
Gecode::PropCost
Propagation cost.
Definition core.hpp:486
Gecode::Propagator::size
size_t size
The size of the propagator (used during subsumption).
Definition core.hpp:1077
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
Gecode::TernaryPropagator< View, PC_INT_DOM >::x2
View x2
Definition pattern.hpp:116
Gecode::TernaryPropagator< View, PC_INT_DOM >::x1
View x1
Definition pattern.hpp:116
Gecode::TernaryPropagator< View, PC_INT_DOM >::x0
View x0
Definition pattern.hpp:116
Gecode::TernaryPropagator< View, PC_INT_DOM >::TernaryPropagator
TernaryPropagator(Space &home, TernaryPropagator &p)
Gecode::View
Gecode::ViewArray
View arrays.
Definition array.hpp:253
bnd.hpp
cbs.hpp
dom.hpp
graph.hpp
dom-ctrl.hpp
eqite.hpp
int.hh
GECODE_INT_EXPORT
#define GECODE_INT_EXPORT
Definition int.hh:81
Gecode::ModEventDelta
int ModEventDelta
Modification event deltas.
Definition core.hpp:89
val.hpp
rel.hh
Gecode::Int::Distinct
Distinct propagators
Gecode::Int::Distinct::prop_bnd
ExecStatus prop_bnd(Space &home, ViewArray< View > &x, int &min_x, int &max_x)
Perform bounds consistent distinct propagation.
Definition bnd.hpp:308
Gecode::Int::Distinct::prop_val
ExecStatus prop_val(Space &home, ViewArray< View > &)
Eliminate singletons by naive value propagation.
Definition val.hpp:42
Gecode::Int
Finite domain integers.
Gecode::Int::PC_INT_VAL
const Gecode::PropCond PC_INT_VAL
Propagate when a view becomes assigned (single value).
Definition var-type.hpp:82
Gecode::Int::PC_INT_DOM
const Gecode::PropCond PC_INT_DOM
Propagate when domain changes.
Definition var-type.hpp:100
Gecode
Gecode toplevel namespace
Gecode::ExecStatus
ExecStatus
Definition core.hpp:472
ter-dom.hpp
view-val-graph.hh