Generated on Tue Mar 24 2020 14:04:04 for Gecode by doxygen 1.8.17
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 
38  forceinline Archive&
40  return e << nl.n << nl.l;
41  }
42 
43  forceinline Archive&
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 
bool l
Whether to try the lower or upper half first.
Definition: float.hh:1467
Post propagator for SetVar x
Definition: set.hh:767
Archive & operator>>(Archive &e, FloatNumBranch &nl)
Definition: val-sel.hpp:44
ValSelRnd(Space &home, const ValBranch< Var > &vb)
Constructor for initialization.
Definition: val-sel.hpp:79
bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
Definition: val-sel.hpp:92
Base class for value selection.
Definition: val-sel.hpp:44
~Rnd(void)
Destructor.
Definition: rnd.cpp:68
Rnd r
The used random number generator.
Definition: branch.hh:260
Archive representation
Definition: archive.hpp:42
Computation spaces.
Definition: core.hpp:1742
ValSelLq(Space &home, const ValBranch< Var > &vb)
Constructor for initialization.
Definition: val-sel.hpp:53
FloatNumBranch val(const Space &home, FloatView x, int i)
Return value of view x at position i.
Definition: val-sel.hpp:72
Gecode toplevel namespace
Float view for float variables.
Definition: view.hpp:52
void dispose(Space &home)
Delete value selection.
Definition: val-sel.hpp:96
Value selection class for random value of view.
Definition: branch.hh:257
Post propagator for SetVar SetOpType SetVar SetRelType r
Definition: set.hh:767
Value description class for branching.
Definition: float.hh:1462
Value branching information.
Definition: val.hpp:41
FloatNum n
The middle value for branching.
Definition: float.hh:1465
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
#define forceinline
Definition: config.hpp:185
FloatNumBranch val(const Space &home, FloatView x, int i)
Return value of view x at position i.
Definition: val-sel.hpp:86
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:241
Archive & operator<<(Archive &e, FloatNumBranch nl)
Definition: val-sel.hpp:39