view.hpp
Go to the documentation of this file.
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
* Main authors:
* Christian Schulte <schulte@gecode.org>
* Vincent Barichard <Vincent.Barichard@univ-angers.fr>
*
* Copyright:
* Christian Schulte, 2005
* 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.
*
*/
#include <iostream>
namespace Gecode { namespace Float {
class FloatView : public VarImpView<FloatVar> {
protected:
using VarImpView<FloatVar>::x;
public:
FloatView(void);
FloatView(const FloatVar& y);
FloatView(FloatVarImp* y);
FloatVal domain(void) const;
FloatNum min(void) const;
FloatNum max(void) const;
FloatNum med(void) const;
FloatVal val(void) const;
FloatNum size(void) const;
bool zero_in(void) const;
bool in(FloatNum n) const;
bool in(const FloatVal& n) const;
ModEvent lq(Space& home, int n);
ModEvent lq(Space& home, FloatNum n);
ModEvent lq(Space& home, FloatVal n);
ModEvent gq(Space& home, int n);
ModEvent gq(Space& home, FloatNum n);
ModEvent gq(Space& home, FloatVal n);
ModEvent eq(Space& home, int n);
ModEvent eq(Space& home, FloatNum n);
ModEvent eq(Space& home, const FloatVal& n);
FloatNum min(const Delta& d) const;
FloatNum max(const Delta& d) const;
static ModEventDelta med(ModEvent me);
};
template<class Char, class Traits>
std::basic_ostream<Char,Traits>&
operator <<(std::basic_ostream<Char,Traits>& os, const FloatView& x);
class MinusView : public DerivedView<FloatView> {
protected:
using DerivedView<FloatView>::x;
public:
MinusView(void);
explicit MinusView(const FloatView& y);
FloatVal domain(void) const;
FloatNum min(void) const;
FloatNum max(void) const;
FloatNum med(void) const;
FloatVal val(void) const;
FloatNum size(void) const;
bool zero_in(void) const;
bool in(FloatNum n) const;
bool in(const FloatVal& n) const;
ModEvent lq(Space& home, int n);
ModEvent lq(Space& home, FloatNum n);
ModEvent lq(Space& home, FloatVal n);
ModEvent gq(Space& home, int n);
ModEvent gq(Space& home, FloatNum n);
ModEvent gq(Space& home, FloatVal n);
ModEvent eq(Space& home, int n);
ModEvent eq(Space& home, FloatNum n);
ModEvent eq(Space& home, const FloatVal& n);
FloatNum min(const Delta& d) const;
FloatNum max(const Delta& d) const;
static ModEventDelta med(ModEvent me);
};
template<class Char, class Traits>
std::basic_ostream<Char,Traits>&
operator <<(std::basic_ostream<Char,Traits>& os, const MinusView& x);
bool operator ==(const MinusView& x, const MinusView& y);
bool operator !=(const MinusView& x, const MinusView& y);
class OffsetView : public DerivedView<FloatView> {
protected:
FloatNum c;
using DerivedView<FloatView>::x;
public:
OffsetView(void);
explicit OffsetView(const FloatView& y, FloatNum c);
FloatNum offset(void) const;
void offset(FloatNum n);
FloatVal domain(void) const;
FloatNum min(void) const;
FloatNum max(void) const;
FloatNum med(void) const;
FloatVal val(void) const;
FloatNum size(void) const;
bool zero_in(void) const;
bool in(FloatNum n) const;
bool in(const FloatVal& n) const;
ModEvent lq(Space& home, int n);
ModEvent lq(Space& home, FloatNum n);
ModEvent lq(Space& home, FloatVal n);
ModEvent gq(Space& home, int n);
ModEvent gq(Space& home, FloatNum n);
ModEvent gq(Space& home, FloatVal n);
ModEvent eq(Space& home, int n);
ModEvent eq(Space& home, FloatNum n);
ModEvent eq(Space& home, const FloatVal& n);
FloatNum min(const Delta& d) const;
FloatNum max(const Delta& d) const;
static ModEventDelta med(ModEvent me);
void update(Space& home, OffsetView& y);
bool operator <(const OffsetView& y) const;
};
template<class Char, class Traits>
std::basic_ostream<Char,Traits>&
operator <<(std::basic_ostream<Char,Traits>& os, const OffsetView& x);
bool operator ==(const OffsetView& x, const OffsetView& y);
bool operator !=(const OffsetView& x, const OffsetView& y);
class ScaleView : public DerivedView<FloatView> {
protected:
using DerivedView<FloatView>::x;
FloatVal a;
public:
ScaleView(void);
ScaleView(FloatVal b, const FloatView& y);
FloatVal domain(void) const;
FloatVal scale(void) const;
FloatNum min(void) const;
FloatNum max(void) const;
FloatNum med(void) const;
FloatVal val(void) const;
FloatNum size(void) const;
bool zero_in(void) const;
bool in(FloatNum n) const;
bool in(const FloatVal& n) const;
ModEvent lq(Space& home, int n);
ModEvent lq(Space& home, FloatNum n);
ModEvent lq(Space& home, FloatVal n);
ModEvent gq(Space& home, int n);
ModEvent gq(Space& home, FloatNum n);
ModEvent gq(Space& home, FloatVal n);
ModEvent eq(Space& home, int n);
ModEvent eq(Space& home, FloatNum n);
ModEvent eq(Space& home, const FloatVal& n);
FloatNum min(const Delta& d) const;
FloatNum max(const Delta& d) const;
static ModEventDelta med(ModEvent me);
void update(Space& home, ScaleView& y);
bool operator <(const ScaleView& y) const;
};
template<class Char, class Traits>
std::basic_ostream<Char,Traits>&
operator <<(std::basic_ostream<Char,Traits>& os, const ScaleView& x);
bool operator ==(const ScaleView& x, const ScaleView& y);
bool operator !=(const ScaleView& x, const ScaleView& y);
}}
#include <gecode/float/var/float.hpp>
#include <gecode/float/view/float.hpp>
#include <gecode/float/view/minus.hpp>
#include <gecode/float/view/offset.hpp>
#include <gecode/float/view/scale.hpp>
#include <gecode/float/view/print.hpp>
#include <gecode/float/var/print.hpp>
namespace Gecode { namespace Float {
enum RelTest {
RT_FALSE = 0,
RT_MAYBE = 1,
RT_TRUE = 2
};
template<class View> RelTest rtest_eq(View x, View y);
template<class View> RelTest rtest_eq(View x, FloatVal n);
template<class View> RelTest rtest_lq(View x, View y);
template<class View> RelTest rtest_lq(View x, FloatVal n);
template<class View> RelTest rtest_le(View x, View y);
template<class View> RelTest rtest_le(View x, FloatVal n);
}}
#include <gecode/float/view/rel-test.hpp>
// STATISTICS: float-var
Gecode::Delta
Generic domain change information to be supplied to advisors.
Definition core.hpp:204
Gecode::DerivedView< FloatView >::x
FloatView x
Definition view.hpp:238
Gecode::DerivedView< FloatView >::DerivedView
DerivedView(void)
Definition view.hpp:584
Gecode::DerivedView< FloatView >::me
static ModEvent me(const ModEventDelta &med)
Definition view.hpp:639
Gecode::FloatVal
Float value type.
Definition float.hh:334
Gecode::FloatVar
Float variables.
Definition float.hh:870
Gecode::Float::FloatVarImp
Float variable implementation.
Definition var-imp.hpp:76
Gecode::Float::FloatView
Float view for float variables.
Definition view.hpp:52
Gecode::Float::FloatView::domain
FloatVal domain(void) const
Return domain.
Definition float.hpp:56
Gecode::Float::FloatView::max
FloatNum max(void) const
Return maximum of domain.
Definition float.hpp:64
Gecode::Float::FloatView::eq
ModEvent eq(Space &home, int n)
Restrict domain values to be equal to n.
Definition float.hpp:131
Gecode::Float::FloatView::lq
ModEvent lq(Space &home, int n)
Restrict domain values to be less or equal than n.
Definition float.hpp:105
Gecode::Float::FloatView::min
FloatNum min(void) const
Return minimum of domain.
Definition float.hpp:60
Gecode::Float::FloatView::size
FloatNum size(void) const
Return size of domain (distance between maximum and minimum).
Definition float.hpp:77
Gecode::Float::FloatView::in
bool in(FloatNum n) const
Test whether n is contained in domain.
Definition float.hpp:91
Gecode::Float::FloatView::val
FloatVal val(void) const
Return assigned value.
Definition float.hpp:72
Gecode::Float::FloatView::med
FloatNum med(void) const
Return median of domain (closest representation).
Definition float.hpp:68
Gecode::Float::FloatView::zero_in
bool zero_in(void) const
Test whether 0 is contained in domain.
Definition float.hpp:87
Gecode::Float::FloatView::gq
ModEvent gq(Space &home, int n)
Restrict domain values to be greater or equal than n.
Definition float.hpp:118
Gecode::Float::FloatView::FloatView
FloatView(void)
Default constructor.
Definition float.hpp:43
Gecode::Float::MinusView
Minus float view.
Definition view.hpp:154
Gecode::Float::MinusView::eq
ModEvent eq(Space &home, int n)
Restrict domain values to be equal to n.
Definition minus.hpp:128
Gecode::Float::MinusView::size
FloatNum size(void) const
Return size of domain (distance between maximum and minimum).
Definition minus.hpp:74
Gecode::Float::MinusView::domain
FloatVal domain(void) const
Return domain.
Definition minus.hpp:53
Gecode::Float::MinusView::min
FloatNum min(void) const
Return minimum of domain.
Definition minus.hpp:57
Gecode::Float::MinusView::lq
ModEvent lq(Space &home, int n)
Restrict domain values to be less or equal than n.
Definition minus.hpp:102
Gecode::Float::MinusView::max
FloatNum max(void) const
Return maximum of domain.
Definition minus.hpp:61
Gecode::Float::MinusView::med
FloatNum med(void) const
Return median of domain (closest representation).
Definition minus.hpp:65
Gecode::Float::MinusView::gq
ModEvent gq(Space &home, int n)
Restrict domain values to be greater or equal than n.
Definition minus.hpp:115
Gecode::Float::MinusView::zero_in
bool zero_in(void) const
Test whether 0 is contained in domain.
Definition minus.hpp:84
Gecode::Float::MinusView::in
bool in(FloatNum n) const
Test whether n is contained in domain.
Definition minus.hpp:88
Gecode::Float::MinusView::val
FloatVal val(void) const
Return assigned value.
Definition minus.hpp:69
Gecode::Float::MinusView::MinusView
MinusView(void)
Default constructor.
Definition minus.hpp:43
Gecode::Float::OffsetView
OffsetView float view.
Definition view.hpp:266
Gecode::Float::OffsetView::operator<
bool operator<(const OffsetView &y) const
Whether this view comes before view y (arbitray order).
Definition offset.hpp:184
Gecode::Float::OffsetView::domain
FloatVal domain(void) const
Return domain.
Definition offset.hpp:62
Gecode::Float::OffsetView::in
bool in(FloatNum n) const
Test whether n is contained in domain.
Definition offset.hpp:97
Gecode::Float::OffsetView::size
FloatNum size(void) const
Return size of domain (distance between maximum and minimum).
Definition offset.hpp:83
Gecode::Float::OffsetView::eq
ModEvent eq(Space &home, int n)
Restrict domain values to be equal to n.
Definition offset.hpp:137
Gecode::Float::OffsetView::val
FloatVal val(void) const
Return assigned value.
Definition offset.hpp:78
Gecode::Float::OffsetView::update
void update(Space &home, OffsetView &y)
Definition offset.hpp:174
Gecode::Float::OffsetView::OffsetView
OffsetView(void)
Default constructor.
Definition offset.hpp:43
Gecode::Float::OffsetView::c
FloatNum c
Offset.
Definition view.hpp:269
Gecode::Float::OffsetView::gq
ModEvent gq(Space &home, int n)
Restrict domain values to be greater or equal than n.
Definition offset.hpp:124
Gecode::Float::OffsetView::med
FloatNum med(void) const
Return median of domain (closest representation).
Definition offset.hpp:74
Gecode::Float::OffsetView::max
FloatNum max(void) const
Return maximum of domain.
Definition offset.hpp:70
Gecode::Float::OffsetView::lq
ModEvent lq(Space &home, int n)
Restrict domain values to be less or equal than n.
Definition offset.hpp:111
Gecode::Float::OffsetView::min
FloatNum min(void) const
Return minimum of domain.
Definition offset.hpp:66
Gecode::Float::OffsetView::zero_in
bool zero_in(void) const
Test whether 0 is contained in domain.
Definition offset.hpp:93
Gecode::Float::OffsetView::offset
FloatNum offset(void) const
Return offset.
Definition offset.hpp:54
Gecode::Float::ScaleView
Scale float view.
Definition view.hpp:395
Gecode::Float::ScaleView::scale
FloatVal scale(void) const
Return scale factor of scale view.
Definition scale.hpp:54
Gecode::Float::ScaleView::update
void update(Space &home, ScaleView &y)
Definition scale.hpp:179
Gecode::Float::ScaleView::a
FloatVal a
Scale factor.
Definition view.hpp:399
Gecode::Float::ScaleView::zero_in
bool zero_in(void) const
Test whether 0 is contained in domain.
Definition scale.hpp:89
Gecode::Float::ScaleView::min
FloatNum min(void) const
Return minimum of domain.
Definition scale.hpp:62
Gecode::Float::ScaleView::lq
ModEvent lq(Space &home, int n)
Restrict domain values to be less or equal than n.
Definition scale.hpp:107
Gecode::Float::ScaleView::operator<
bool operator<(const ScaleView &y) const
Whether this view comes before view y (arbitray order).
Definition scale.hpp:189
Gecode::Float::ScaleView::size
FloatNum size(void) const
Return size of domain (distance between maximum and minimum).
Definition scale.hpp:79
Gecode::Float::ScaleView::gq
ModEvent gq(Space &home, int n)
Restrict domain values to be greater or equal than n.
Definition scale.hpp:123
Gecode::Float::ScaleView::med
FloatNum med(void) const
Return median of domain (closest representation).
Definition scale.hpp:70
Gecode::Float::ScaleView::ScaleView
ScaleView(void)
Default constructor.
Definition scale.hpp:43
Gecode::Float::ScaleView::in
bool in(FloatNum n) const
Test whether n is contained in domain.
Definition scale.hpp:93
Gecode::Float::ScaleView::val
FloatVal val(void) const
Return assigned value.
Definition scale.hpp:74
Gecode::Float::ScaleView::domain
FloatVal domain(void) const
Return domain.
Definition scale.hpp:58
Gecode::Float::ScaleView::max
FloatNum max(void) const
Return maximum of domain.
Definition scale.hpp:66
Gecode::Float::ScaleView::eq
ModEvent eq(Space &home, int n)
Restrict domain values to be equal to n.
Definition scale.hpp:139
Gecode::Space
Computation spaces.
Definition core.hpp:1742
Gecode::View
Gecode::VarImpView< FloatVar >::me
static ModEvent me(const ModEventDelta &med)
Definition view.hpp:552
Gecode::VarImpView< FloatVar >::VarImpView
VarImpView(void)
Definition view.hpp:476
Gecode::VarImpView< FloatVar >::x
VarImpType * x
Definition view.hpp:141
print.hpp
minus.hpp
offset.hpp
print.hpp
rel-test.hpp
scale.hpp
float.hpp
float.hpp
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::Float
Floating point numbers.
Gecode::Float::RelTest
RelTest
Result of testing relation.
Definition view.hpp:533
Gecode::Float::RT_TRUE
@ RT_TRUE
Relation does hold.
Definition view.hpp:536
Gecode::Float::RT_FALSE
@ RT_FALSE
Relation does not hold.
Definition view.hpp:534
Gecode::Float::RT_MAYBE
@ RT_MAYBE
Relation may hold or not.
Definition view.hpp:535
Gecode::Float::operator!=
bool operator!=(const MinusView &x, const MinusView &y)
Definition minus.hpp:169
Gecode::Float::rtest_le
RelTest rtest_le(View x, View y)
Test whether view x is less than view y.
Definition rel-test.hpp:70
Gecode::Float::rtest_eq
RelTest rtest_eq(View x, View y)
Test whether views x and y are equal.
Definition rel-test.hpp:40
Gecode::Float::operator==
bool operator==(const MinusView &x, const MinusView &y)
Definition minus.hpp:165
Gecode::Float::rtest_lq
RelTest rtest_lq(View x, View y)
Test whether view x is less or equal than view y.
Definition rel-test.hpp:54
Gecode::Float::operator<<
std::basic_ostream< Char, Traits > & operator<<(std::basic_ostream< Char, Traits > &os, const FloatView &x)
Definition print.hpp:58
Gecode::Int::RelTest
RelTest
Result of testing relation.
Definition view.hpp:1734
Gecode
Gecode toplevel namespace
Gecode::ModEvent
int ModEvent
Type for modification events.
Definition core.hpp:62