Generated on Wed Jul 21 2021 00:00:00 for Gecode by doxygen 1.9.1
val-sel.hpp
Go to the documentation of this file.
1 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2 /*
3  * Main authors:
4  * Christian Schulte <schulte@gecode.org>
5  * Vincent Barichard <Vincent.Barichard@univ-angers.fr>
6  *
7  * Copyright:
8  * Christian Schulte, 2012
9  * Vincent Barichard, 2012
10  *
11  * This file is part of Gecode, the generic constraint
12  * development environment:
13  * http://www.gecode.org
14  *
15  * Permission is hereby granted, free of charge, to any person obtaining
16  * a copy of this software and associated documentation files (the
17  * "Software"), to deal in the Software without restriction, including
18  * without limitation the rights to use, copy, modify, merge, publish,
19  * distribute, sublicense, and/or sell copies of the Software, and to
20  * permit persons to whom the Software is furnished to do so, subject to
21  * the following conditions:
22  *
23  * The above copyright notice and this permission notice shall be
24  * included in all copies or substantial portions of the Software.
25  *
26  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
27  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
29  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
30  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
31  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
32  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33  *
34  */
35 
36 namespace Gecode {
37 
39  operator <<(Archive& e, FloatNumBranch nl) {
40  return e << nl.n << nl.l;
41  }
42 
43  forceinline Archive&
44  operator >>(Archive& e, FloatNumBranch& nl) {
45  return e >> nl.n >> nl.l;
46  }
47 
48 }
49 
50 namespace Gecode { namespace Float { namespace Branch {
51 
54  : ValSel<FloatView,FloatNumBranch>(home,vb) {}
57  : ValSel<FloatView,FloatNumBranch>(home,vs) {}
59  ValSelLq::val(const Space&, FloatView x, int) {
60  FloatNumBranch nl;
61  nl.n = x.med(); nl.l = true;
62  return nl;
63  }
64 
67  : ValSel<FloatView,FloatNumBranch>(home,vb) {}
70  : ValSel<FloatView,FloatNumBranch>(home,vs) {}
72  ValSelGq::val(const Space&, FloatView x, int) {
73  FloatNumBranch nl;
74  nl.n = x.med(); nl.l = false;
75  return nl;
76  }
77 
80  : ValSel<FloatView,FloatNumBranch>(home,vb), r(vb.rnd()) {}
83  : ValSel<FloatView,FloatNumBranch>(home,vs), r(vs.r) {
84  }
86  ValSelRnd::val(const Space&, FloatView x, int) {
87  FloatNumBranch nl;
88  nl.n = x.med(); nl.l = (r(2U) == 0U);
89  return nl;
90  }
91  forceinline bool
92  ValSelRnd::notice(void) const {
93  return true;
94  }
95  forceinline void
97  r.~Rnd();
98  }
99 
100 }}}
101 
102 // STATISTICS: float-branch
103 
Node * x
Pointer to corresponding Boolean expression node.
Definition: bool-expr.cpp:249
NNF * r
Right subtree.
Definition: bool-expr.cpp:242
Archive representation
Definition: archive.hpp:42
Value description class for branching.
Definition: float.hh:1462
bool l
Whether to try the lower or upper half first.
Definition: float.hh:1467
FloatNum n
The middle value for branching.
Definition: float.hh:1465
Value selection class for values smaller than median of view.
Definition: branch.hh:241
FloatNumBranch val(const Space &home, FloatView x, int i)
Return value of view x at position i.
Definition: val-sel.hpp:72
ValSelGq(Space &home, const ValBranch< Var > &vb)
Constructor for initialization.
Definition: val-sel.hpp:66
Value selection class for values smaller than median of view.
Definition: branch.hh:225
FloatNumBranch val(const Space &home, FloatView x, int i)
Return value of view x at position i.
Definition: val-sel.hpp:59
ValSelLq(Space &home, const ValBranch< Var > &vb)
Constructor for initialization.
Definition: val-sel.hpp:53
Value selection class for random value of view.
Definition: branch.hh:257
FloatNumBranch val(const Space &home, FloatView x, int i)
Return value of view x at position i.
Definition: val-sel.hpp:86
bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
Definition: val-sel.hpp:92
ValSelRnd(Space &home, const ValBranch< Var > &vb)
Constructor for initialization.
Definition: val-sel.hpp:79
void dispose(Space &home)
Delete value selection.
Definition: val-sel.hpp:96
Rnd r
The used random number generator.
Definition: branch.hh:260
Float view for float variables.
Definition: view.hpp:52
~Rnd(void)
Destructor.
Definition: rnd.cpp:68
Computation spaces.
Definition: core.hpp:1742
Value branching information.
Definition: val.hpp:41
Base class for value selection.
Definition: val-sel.hpp:44
#define forceinline
Definition: config.hpp:192