linear.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>
* Vincent Barichard <Vincent.Barichard@univ-angers.fr>
*
* Copyright:
* Christian Schulte, 2002
* Guido Tack, 2004
* Vincent Barichard, 2012
*
* 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_FLOAT_LINEAR_HH__
#define __GECODE_FLOAT_LINEAR_HH__
#include <gecode/int.hh>
#include <gecode/float.hh>
namespace Gecode { namespace Float { namespace Linear {
template<class P, class N, PropCond pc>
class Lin : public Propagator {
protected:
ViewArray<P> x;
ViewArray<N> y;
FloatVal c;
Lin(Space& home, Lin<P,N,pc>& p);
Lin(Home home, ViewArray<P>& x, ViewArray<N>& y, FloatVal c);
public:
virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
virtual void reschedule(Space& home);
virtual size_t dispose(Space& home);
};
template<class View>
void bounds_p(ModEventDelta med, ViewArray<View>& x,
FloatVal& c, FloatNum& sl, FloatNum& su);
template<class View>
void bounds_n(ModEventDelta med, ViewArray<View>& y,
FloatVal& c, FloatNum& sl, FloatNum& su);
template<class P, class N>
class Eq : public Lin<P,N,PC_FLOAT_BND> {
protected:
using Lin<P,N,PC_FLOAT_BND>::x;
using Lin<P,N,PC_FLOAT_BND>::y;
using Lin<P,N,PC_FLOAT_BND>::c;
Eq(Space& home, Eq& p);
public:
Eq(Home home, ViewArray<P>& x, ViewArray<N>& y, FloatVal c);
virtual Actor* copy(Space& home);
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
static ExecStatus
post(Home home, ViewArray<P>& x, ViewArray<N>& y, FloatVal c);
};
template<class P, class N>
class Lq : public Lin<P,N,PC_FLOAT_BND> {
protected:
using Lin<P,N,PC_FLOAT_BND>::x;
using Lin<P,N,PC_FLOAT_BND>::y;
using Lin<P,N,PC_FLOAT_BND>::c;
Lq(Space& home, Lq& p);
public:
Lq(Home home, ViewArray<P>& x, ViewArray<N>& y, FloatVal c);
virtual Actor* copy(Space& home);
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
static ExecStatus
post(Home home, ViewArray<P>& x, ViewArray<N>& y, FloatVal c);
};
}}}
#include <gecode/float/linear/nary.hpp>
namespace Gecode { namespace Float { namespace Linear {
class Term {
public:
FloatVal a;
FloatView x;
};
GECODE_FLOAT_EXPORT void
estimate(Term* t, int n, FloatVal c, FloatNum& l, FloatNum& u);
GECODE_FLOAT_EXPORT void
post(Home home, Term* t, int n, FloatRelType frt, FloatVal c);
GECODE_FLOAT_EXPORT void
post(Home home, Term* t, int n, FloatRelType frt, FloatVal c, Reify r);
}}}
#endif
// STATISTICS: float-prop
Gecode::ActorLink::Actor
friend class Actor
Definition core.hpp:590
Gecode::FloatVal
Float value type.
Definition float.hh:334
Gecode::Float::FloatView
Float view for float variables.
Definition view.hpp:52
Gecode::Float::Linear::Eq::post
static ExecStatus post(Home home, ViewArray< P > &x, ViewArray< N > &y, FloatVal c)
Post propagator for .
Definition nary.hpp:128
Gecode::Float::Linear::Eq::copy
virtual Actor * copy(Space &home)
Create copy during cloning.
Definition nary.hpp:141
Gecode::Float::Linear::Eq::Eq
Eq(Space &home, Eq &p)
Constructor for cloning p.
Definition nary.hpp:136
Gecode::Float::Linear::Eq::propagate
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition nary.hpp:147
Gecode::Float::Linear::Lin::cost
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as low linear).
Definition nary.hpp:60
Gecode::Float::Linear::Lin::dispose
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Definition nary.hpp:73
Gecode::Float::Linear::Lin::bounds_n
void bounds_n(ModEventDelta med, ViewArray< View > &y, FloatVal &c, FloatNum &sl, FloatNum &su)
Compute bounds information for negative views.
Gecode::Float::Linear::Lin::bounds_p
void bounds_p(ModEventDelta med, ViewArray< View > &x, FloatVal &c, FloatNum &sl, FloatNum &su)
Compute bounds information for positive views.
Gecode::Float::Linear::Lin::Lin
Lin(Space &home, Lin< P, N, pc > &p)
Constructor for cloning p.
Definition nary.hpp:52
Gecode::Float::Linear::Lin::x
ViewArray< P > x
Array of positive views.
Definition linear.hh:60
Gecode::Float::Linear::Lin::reschedule
virtual void reschedule(Space &home)
Schedule function.
Definition nary.hpp:66
Gecode::Float::Linear::Lin::y
ViewArray< N > y
Array of negative views.
Definition linear.hh:62
Gecode::Float::Linear::Lin::c
FloatVal c
Constant value.
Definition linear.hh:64
Gecode::Float::Linear::Lq::post
static ExecStatus post(Home home, ViewArray< P > &x, ViewArray< N > &y, FloatVal c)
Post propagator for .
Definition nary.hpp:258
Gecode::Float::Linear::Lq::copy
virtual Actor * copy(Space &home)
Create copy during cloning.
Definition nary.hpp:270
Gecode::Float::Linear::Lq::propagate
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition nary.hpp:276
Gecode::Float::Linear::Lq::Lq
Lq(Space &home, Lq &p)
Constructor for cloning p.
Definition nary.hpp:265
Gecode::Float::Linear::Term
Class for describing linear term .
Definition linear.hh:166
Gecode::Float::Linear::Term::a
FloatVal a
Coefficient.
Definition linear.hh:169
Gecode::Float::Linear::Term::x
FloatView x
View.
Definition linear.hh:171
Gecode::Home
Home class for posting propagators
Definition core.hpp:856
Gecode::PropCost
Propagation cost.
Definition core.hpp:486
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::Reify
Reification specification.
Definition int.hh:876
Gecode::ViewArray
View arrays.
Definition array.hpp:253
float.hh
GECODE_FLOAT_EXPORT
#define GECODE_FLOAT_EXPORT
Definition float.hh:68
int.hh
Gecode::Float::Linear::post
void post(Home home, Term *t, int n, FloatRelType frt, FloatVal c)
Post propagator for linear constraint over floats.
Definition post.cpp:238
Gecode::ModEventDelta
int ModEventDelta
Modification event deltas.
Definition core.hpp:89
Gecode::FloatNum
double FloatNum
Floating point number base type.
Definition float.hh:106
Gecode::FloatRelType
FloatRelType
Relation types for floats.
Definition float.hh:1068
Gecode::Float::Linear
Linear propagators
Gecode::Float::Linear::estimate
void estimate(Term *t, int n, FloatVal c, FloatNum &l, FloatNum &u)
Estimate lower and upper bounds.
Definition post.cpp:45
Gecode::Float
Floating point numbers.
Gecode::Float::PC_FLOAT_BND
const Gecode::PropCond PC_FLOAT_BND
Propagate when minimum or maximum of a view changes.
Definition var-type.hpp:292
Gecode
Gecode toplevel namespace
Gecode::ExecStatus
ExecStatus
Definition core.hpp:472
nary.hpp