afc.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>
*
* Copyright:
* Christian Schulte, 2013
*
* 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.
*
*/
namespace Gecode {
class AFC {
protected:
int n;
public:
AFC(void);
AFC(const AFC& a);
AFC& operator =(const AFC& a);
template<class Var>
AFC(Home home, const VarArgArray<Var>& x, double d, bool share=true);
template<class Var>
void init(Home home, const VarArgArray<Var>& x, double d, bool share=true);
operator bool(void) const;
GECODE_KERNEL_EXPORT static const AFC def;
~AFC(void);
int size(void) const;
void decay(Space& home, double d);
double decay(const Space& home) const;
};
template<class Char, class Traits>
std::basic_ostream<Char,Traits>&
operator <<(std::basic_ostream<Char,Traits>& os,
const AFC& a);
/*
* AFC
*
*/
forceinline int
AFC::size(void) const {
assert(n >= 0);
return n;
}
forceinline
AFC::AFC(void) : n(-1) {}
forceinline
AFC::operator bool(void) const {
return n >= 0;
}
template<class Var>
forceinline
AFC::AFC(Home home, const VarArgArray<Var>& x, double d, bool share)
: n(x.size()) {
if ((d < 0.0) || (d > 1.0))
throw IllegalDecay("AFC");
static_cast<Space&>(home).afc_decay(d);
if (!share)
static_cast<Space&>(home).afc_unshare();
}
template<class Var>
forceinline void
AFC::init(Home home, const VarArgArray<Var>& x, double d, bool share) {
n = x.size();
if ((d < 0.0) || (d > 1.0))
throw IllegalDecay("AFC");
static_cast<Space&>(home).afc_decay(d);
if (!share)
static_cast<Space&>(home).afc_unshare();
}
forceinline
AFC::AFC(const AFC& a)
: n(a.n) {}
forceinline AFC&
AFC::operator =(const AFC& a) {
n=a.n;
return *this;
}
forceinline
AFC::~AFC(void) {}
forceinline void
AFC::decay(Space& home, double d) {
if ((d < 0.0) || (d > 1.0))
throw IllegalDecay("AFC");
home.afc_decay(d);
}
forceinline double
AFC::decay(const Space& home) const {
return home.afc_decay();
}
template<class Char, class Traits>
std::basic_ostream<Char,Traits>&
operator <<(std::basic_ostream<Char,Traits>& os,
const AFC& a) {
(void)a;
return os << "AFC(no information available)";
}
}
// STATISTICS: kernel-branch
Gecode::AFC
Class for AFC (accumulated failure count) management.
Definition afc.hpp:40
Gecode::AFC::~AFC
~AFC(void)
Destructor.
Definition afc.hpp:157
Gecode::AFC::n
int n
Number of views.
Definition afc.hpp:43
Gecode::AFC::size
int size(void) const
Return number of AFC values.
Definition afc.hpp:113
Gecode::AFC::AFC
AFC(void)
Construct as not yet intialized.
Definition afc.hpp:119
Gecode::AFC::operator=
AFC & operator=(const AFC &a)
Assignment operator.
Definition afc.hpp:152
Gecode::AFC::def
static const AFC def
Default (empty) AFC information.
Definition afc.hpp:78
Gecode::AFC::init
void init(Home home, const VarArgArray< Var > &x, double d, bool share=true)
Initialize for variables x and decay factor d.
Definition afc.hpp:138
Gecode::AFC::decay
void decay(Space &home, double d)
Set decay factor to d.
Definition afc.hpp:160
Gecode::ArgArrayBase::size
int size(void) const
Return size of array (number of elements).
Definition array.hpp:1607
Gecode::Home
Home class for posting propagators
Definition core.hpp:856
Gecode::IllegalDecay
Exception: illegal decay factor
Definition exception.hpp:107
Gecode::Space
Computation spaces.
Definition core.hpp:1742
Gecode::Space::afc_decay
void afc_decay(double d)
Set AFC decay factor to d
Definition core.hpp:3247
Gecode::VarArgArray
Argument array for variables.
Definition array.hpp:774
GECODE_KERNEL_EXPORT
#define GECODE_KERNEL_EXPORT
Definition kernel.hh:70
Gecode
Gecode toplevel namespace
Gecode::operator<<
Archive & operator<<(Archive &e, FloatNumBranch nl)
Definition val-sel.hpp:39
forceinline
#define forceinline
Definition config.hpp:187