val-commit.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 {
forceinline
ValCommitLqGq::ValCommitLqGq(Space& home, const ValBranch<Var>& vb)
: ValCommit<FloatView,FloatVal>(home,vb) {}
forceinline
ValCommitLqGq::ValCommitLqGq(Space& home, ValCommitLqGq& vc)
: ValCommit<FloatView,FloatVal>(home,vc) {}
forceinline ModEvent
ValCommitLqGq::commit(Space& home, unsigned int a, FloatView x, int,
FloatNumBranch nl) {
// Should we try the smaller half first?
if ((a == 0) == nl.l) {
if ((x.min() == nl.n) || (x.max() == nl.n))
return x.eq(home,x.min());
else
return x.lq(home,nl.n);
} else {
if ((x.min() == nl.n) || (x.max() == nl.n))
return x.eq(home,x.max());
else
return x.gq(home,nl.n);
}
}
forceinline NGL*
ValCommitLqGq::ngl(Space&, unsigned int, FloatView, FloatNumBranch) const {
return NULL;
}
forceinline void
ValCommitLqGq::print(const Space&, unsigned int a, FloatView, int i,
FloatNumBranch nl,
std::ostream& o) const {
o << "var[" << i << "] "
<< (((a == 0) == nl.l) ? "<=" : ">=") << "(" << nl.n << ")";
}
}}}
// STATISTICS: float-branch
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::FloatVal
Float value type.
Definition float.hh:334
Gecode::Float::Branch::ValCommitLqGq::ngl
NGL * ngl(Space &home, unsigned int a, FloatView x, FloatNumBranch n) const
Create no-good literal for alternative a.
Definition val-commit.hpp:63
Gecode::Float::Branch::ValCommitLqGq::commit
ModEvent commit(Space &home, unsigned int a, FloatView x, int i, FloatNumBranch n)
Commit view x at position i to value n for alternative a.
Definition val-commit.hpp:47
Gecode::Float::Branch::ValCommitLqGq::print
void print(const Space &home, unsigned int a, FloatView x, int i, FloatNumBranch n, std::ostream &o) const
Print on o the alternative with view x at position i and value n.
Definition val-commit.hpp:67
Gecode::Float::Branch::ValCommitLqGq::ValCommitLqGq
ValCommitLqGq(Space &home, const ValBranch< Var > &vb)
Constructor for initialization.
Definition val-commit.hpp:41
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::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::gq
ModEvent gq(Space &home, int n)
Restrict domain values to be greater or equal than n.
Definition float.hpp:118
Gecode::NGL
No-good literal recorded during search.
Definition core.hpp:1340
Gecode::Space
Computation spaces.
Definition core.hpp:1742
Gecode::ValBranch
Value branching information.
Definition val.hpp:41
Gecode::ValCommit< FloatView, FloatVal >::ValCommit
ValCommit(Space &home, const ValBranch< Var > &vb)
Definition val-commit.hpp:101
Gecode::Float::Branch
Float branchers.
Gecode::Float
Floating point numbers.
Gecode
Gecode toplevel namespace
Gecode::ModEvent
int ModEvent
Type for modification events.
Definition core.hpp:62
forceinline
#define forceinline
Definition config.hpp:187