merit.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>
*
* Contributing authors:
* Vincent Barichard <Vincent.Barichard@univ-angers.fr>
*
* Copyright:
* Christian Schulte, 2012
* 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.
*
*/
namespace Gecode { namespace Float { namespace Branch {
// Minimum merit
forceinline
MeritMin::MeritMin(Space& home, const VarBranch<Var>& vb)
: MeritBase<FloatView,double>(home,vb) {}
forceinline
MeritMin::MeritMin(Space& home, MeritMin& m)
: MeritBase<FloatView,double>(home,m) {}
forceinline double
MeritMin::operator ()(const Space&, FloatView x, int) {
return x.min();
}
// Maximum merit
forceinline
MeritMax::MeritMax(Space& home, const VarBranch<Var>& vb)
: MeritBase<FloatView,double>(home,vb) {}
forceinline
MeritMax::MeritMax(Space& home, MeritMax& m)
: MeritBase<FloatView,double>(home,m) {}
forceinline double
MeritMax::operator ()(const Space&, FloatView x, int) {
return x.max();
}
// Size merit
forceinline
MeritSize::MeritSize(Space& home, const VarBranch<Var>& vb)
: MeritBase<FloatView,double>(home,vb) {}
forceinline
MeritSize::MeritSize(Space& home, MeritSize& m)
: MeritBase<FloatView,double>(home,m) {}
forceinline double
MeritSize::operator ()(const Space&, FloatView x, int) {
return x.size();
}
// Degree over size merit
forceinline
MeritDegreeSize::MeritDegreeSize(Space& home, const VarBranch<Var>& vb)
: MeritBase<FloatView,double>(home,vb) {}
forceinline
MeritDegreeSize::MeritDegreeSize(Space& home,
MeritDegreeSize& m)
: MeritBase<FloatView,double>(home,m) {}
forceinline double
MeritDegreeSize::operator ()(const Space&, FloatView x, int) {
return x.size() / static_cast<double>(x.degree());
}
// AFC over size merit
forceinline
MeritAFCSize::MeritAFCSize(Space& home, const VarBranch<Var>& vb)
: MeritBase<FloatView,double>(home,vb), afc(vb.afc()) {}
forceinline
MeritAFCSize::MeritAFCSize(Space& home, MeritAFCSize& m)
: MeritBase<FloatView,double>(home,m), afc(m.afc) {}
forceinline double
MeritAFCSize::operator ()(const Space&, FloatView x, int) {
return x.afc() / static_cast<double>(x.size());
}
forceinline bool
MeritAFCSize::notice(void) const {
return false;
}
forceinline void
MeritAFCSize::dispose(Space&) {
// Not needed
afc.~AFC();
}
// Action over size merit
forceinline
MeritActionSize::MeritActionSize(Space& home,
const VarBranch<Var>& vb)
: MeritBase<FloatView,double>(home,vb), action(vb.action()) {}
forceinline
MeritActionSize::MeritActionSize(Space& home,
MeritActionSize& m)
: MeritBase<FloatView,double>(home,m), action(m.action) {}
forceinline double
MeritActionSize::operator ()(const Space&, FloatView x, int i) {
return action[i] / static_cast<double>(x.size());
}
forceinline bool
MeritActionSize::notice(void) const {
return true;
}
forceinline void
MeritActionSize::dispose(Space&) {
action.~Action();
}
// CHB Q-score over size merit
forceinline
MeritCHBSize::MeritCHBSize(Space& home,
const VarBranch<Var>& vb)
: MeritBase<FloatView,double>(home,vb), chb(vb.chb()) {}
forceinline
MeritCHBSize::MeritCHBSize(Space& home,
MeritCHBSize& m)
: MeritBase<FloatView,double>(home,m), chb(m.chb) {}
forceinline double
MeritCHBSize::operator ()(const Space&, FloatView x, int i) {
return chb[i] / static_cast<double>(x.size());
}
forceinline bool
MeritCHBSize::notice(void) const {
return true;
}
forceinline void
MeritCHBSize::dispose(Space&) {
chb.~CHB();
}
}}}
// STATISTICS: float-branch
Gecode::Float::Branch::MeritAFCSize::operator()
double operator()(const Space &home, FloatView x, int i)
Return AFC over size as merit for view x at position i.
Definition merit.hpp:97
Gecode::Float::Branch::MeritAFCSize::afc
AFC afc
AFC information.
Definition branch.hh:133
Gecode::Float::Branch::MeritAFCSize::dispose
void dispose(Space &home)
Dispose view selection.
Definition merit.hpp:105
Gecode::Float::Branch::MeritAFCSize::notice
bool notice(void) const
Whether dispose must always be called (that is, notice is needed).
Definition merit.hpp:101
Gecode::Float::Branch::MeritAFCSize::MeritAFCSize
MeritAFCSize(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition merit.hpp:91
Gecode::Float::Branch::MeritActionSize::notice
bool notice(void) const
Whether dispose must always be called (that is, notice is needed).
Definition merit.hpp:124
Gecode::Float::Branch::MeritActionSize::dispose
void dispose(Space &home)
Dispose view selection.
Definition merit.hpp:128
Gecode::Float::Branch::MeritActionSize::action
Action action
Action information.
Definition branch.hh:156
Gecode::Float::Branch::MeritActionSize::MeritActionSize
MeritActionSize(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition merit.hpp:112
Gecode::Float::Branch::MeritActionSize::operator()
double operator()(const Space &home, FloatView x, int i)
Return action over size as merit for view x at position i.
Definition merit.hpp:120
Gecode::Float::Branch::MeritCHBSize::notice
bool notice(void) const
Whether dispose must always be called (that is, notice is needed).
Definition merit.hpp:147
Gecode::Float::Branch::MeritCHBSize::chb
CHB chb
CHB information.
Definition branch.hh:179
Gecode::Float::Branch::MeritCHBSize::dispose
void dispose(Space &home)
Dispose view selection.
Definition merit.hpp:151
Gecode::Float::Branch::MeritCHBSize::operator()
double operator()(const Space &home, FloatView x, int i)
Return CHB Q-score over size as merit for view x at position i.
Definition merit.hpp:143
Gecode::Float::Branch::MeritCHBSize::MeritCHBSize
MeritCHBSize(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition merit.hpp:135
Gecode::Float::Branch::MeritDegreeSize::MeritDegreeSize
MeritDegreeSize(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition merit.hpp:78
Gecode::Float::Branch::MeritDegreeSize::operator()
double operator()(const Space &home, FloatView x, int i)
Return degree over size as merit for view x at position i.
Definition merit.hpp:85
Gecode::Float::Branch::MeritMax::operator()
double operator()(const Space &home, FloatView x, int i)
Return maximum as merit for view x at position i.
Definition merit.hpp:60
Gecode::Float::Branch::MeritMax::MeritMax
MeritMax(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition merit.hpp:54
Gecode::Float::Branch::MeritMin::operator()
double operator()(const Space &home, FloatView x, int i)
Return minimum as merit for view x at position i.
Definition merit.hpp:48
Gecode::Float::Branch::MeritMin::MeritMin
MeritMin(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition merit.hpp:42
Gecode::Float::Branch::MeritSize::MeritSize
MeritSize(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition merit.hpp:66
Gecode::Float::Branch::MeritSize::operator()
double operator()(const Space &home, FloatView x, int i)
Return size as merit for view x at position i.
Definition merit.hpp:72
Gecode::Float::FloatView
Float view for float variables.
Definition view.hpp:52
Gecode::Float::FloatView::max
FloatNum max(void) const
Return maximum of domain.
Definition float.hpp:64
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::MeritBase< FloatView, double >::MeritBase
MeritBase(Space &home, const VarBranch< Var > &vb)
Definition merit.hpp:176
Gecode::Space
Computation spaces.
Definition core.hpp:1742
Gecode::VarBranch
Variable branching information.
Definition var.hpp:55
Gecode::VarImpView::degree
unsigned int degree(void) const
Return degree (number of subscribed propagators and advisors).
Definition view.hpp:499
Gecode::VarImpView::afc
double afc(void) const
Return accumulated failure count.
Definition view.hpp:504
Gecode::Float::Branch
Float branchers.
Gecode::Float
Floating point numbers.
Gecode
Gecode toplevel namespace
forceinline
#define forceinline
Definition config.hpp:187