val-sel.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, 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 {
forceinline Archive&
operator <<(Archive& e, FloatNumBranch nl) {
return e << nl.n << nl.l;
}
forceinline Archive&
operator >>(Archive& e, FloatNumBranch& nl) {
return e >> nl.n >> nl.l;
}
}
namespace Gecode { namespace Float { namespace Branch {
forceinline
ValSelLq::ValSelLq(Space& home, const ValBranch<Var>& vb)
: ValSel<FloatView,FloatNumBranch>(home,vb) {}
forceinline
ValSelLq::ValSelLq(Space& home, ValSelLq& vs)
: ValSel<FloatView,FloatNumBranch>(home,vs) {}
forceinline FloatNumBranch
ValSelLq::val(const Space&, FloatView x, int) {
FloatNumBranch nl;
nl.n = x.med(); nl.l = true;
return nl;
}
forceinline
ValSelGq::ValSelGq(Space& home, const ValBranch<Var>& vb)
: ValSel<FloatView,FloatNumBranch>(home,vb) {}
forceinline
ValSelGq::ValSelGq(Space& home, ValSelGq& vs)
: ValSel<FloatView,FloatNumBranch>(home,vs) {}
forceinline FloatNumBranch
ValSelGq::val(const Space&, FloatView x, int) {
FloatNumBranch nl;
nl.n = x.med(); nl.l = false;
return nl;
}
forceinline
ValSelRnd::ValSelRnd(Space& home, const ValBranch<Var>& vb)
: ValSel<FloatView,FloatNumBranch>(home,vb), r(vb.rnd()) {}
forceinline
ValSelRnd::ValSelRnd(Space& home, ValSelRnd& vs)
: ValSel<FloatView,FloatNumBranch>(home,vs), r(vs.r) {
}
forceinline FloatNumBranch
ValSelRnd::val(const Space&, FloatView x, int) {
FloatNumBranch nl;
nl.n = x.med(); nl.l = (r(2U) == 0U);
return nl;
}
forceinline bool
ValSelRnd::notice(void) const {
return true;
}
forceinline void
ValSelRnd::dispose(Space&) {
r.~Rnd();
}
}}}
// STATISTICS: float-branch
Gecode::Archive
Archive representation
Definition archive.hpp:42
Gecode::FloatNumBranch
Value description class for branching.
Definition float.hh:1462
Gecode::FloatNumBranch::l
bool l
Whether to try the lower or upper half first.
Definition float.hh:1467
Gecode::FloatNumBranch::n
FloatNum n
The middle value for branching.
Definition float.hh:1465
Gecode::Float::Branch::ValSelGq::val
FloatNumBranch val(const Space &home, FloatView x, int i)
Return value of view x at position i.
Definition val-sel.hpp:72
Gecode::Float::Branch::ValSelGq::ValSelGq
ValSelGq(Space &home, const ValBranch< Var > &vb)
Constructor for initialization.
Definition val-sel.hpp:66
Gecode::Float::Branch::ValSelLq::val
FloatNumBranch val(const Space &home, FloatView x, int i)
Return value of view x at position i.
Definition val-sel.hpp:59
Gecode::Float::Branch::ValSelLq::ValSelLq
ValSelLq(Space &home, const ValBranch< Var > &vb)
Constructor for initialization.
Definition val-sel.hpp:53
Gecode::Float::Branch::ValSelRnd::val
FloatNumBranch val(const Space &home, FloatView x, int i)
Return value of view x at position i.
Definition val-sel.hpp:86
Gecode::Float::Branch::ValSelRnd::notice
bool notice(void) const
Whether dispose must always be called (that is, notice is needed).
Definition val-sel.hpp:92
Gecode::Float::Branch::ValSelRnd::ValSelRnd
ValSelRnd(Space &home, const ValBranch< Var > &vb)
Constructor for initialization.
Definition val-sel.hpp:79
Gecode::Float::Branch::ValSelRnd::dispose
void dispose(Space &home)
Delete value selection.
Definition val-sel.hpp:96
Gecode::Float::Branch::ValSelRnd::r
Rnd r
The used random number generator.
Definition branch.hh:260
Gecode::Float::FloatView
Float view for float variables.
Definition view.hpp:52
Gecode::Float::FloatView::med
FloatNum med(void) const
Return median of domain (closest representation).
Definition float.hpp:68
Gecode::Space
Computation spaces.
Definition core.hpp:1742
Gecode::ValBranch
Value branching information.
Definition val.hpp:41
Gecode::ValSel< FloatView, FloatNumBranch >::ValSel
ValSel(Space &home, const ValBranch< Var > &vb)
Definition val-sel.hpp:98
Gecode::Float::Branch
Float branchers.
Gecode::Float
Floating point numbers.
Gecode
Gecode toplevel namespace
Gecode::operator<<
Archive & operator<<(Archive &e, FloatNumBranch nl)
Definition val-sel.hpp:39
Gecode::operator>>
Archive & operator>>(Archive &e, FloatNumBranch &nl)
Definition val-sel.hpp:44
forceinline
#define forceinline
Definition config.hpp:187