Generated on Thu Apr 5 2018 19:44:19 for Gecode by doxygen 1.8.13
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  * Last modified:
12  * $Date$ by $Author$
13  * $Revision$
14  *
15  * This file is part of Gecode, the generic constraint
16  * development environment:
17  * http://www.gecode.org
18  *
19  * Permission is hereby granted, free of charge, to any person obtaining
20  * a copy of this software and associated documentation files (the
21  * "Software"), to deal in the Software without restriction, including
22  * without limitation the rights to use, copy, modify, merge, publish,
23  * distribute, sublicense, and/or sell copies of the Software, and to
24  * permit persons to whom the Software is furnished to do so, subject to
25  * the following conditions:
26  *
27  * The above copyright notice and this permission notice shall be
28  * included in all copies or substantial portions of the Software.
29  *
30  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
31  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
32  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
33  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
34  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
35  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
36  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37  *
38  */
39 
40 namespace Gecode {
41 
42  forceinline Archive&
44  return e << nl.n << nl.l;
45  }
46 
49  return e >> nl.n >> nl.l;
50  }
51 
52 }
53 
54 namespace Gecode { namespace Float { namespace Branch {
55 
58  : ValSel<FloatView,FloatNumBranch>(home,vb) {}
61  : ValSel<FloatView,FloatNumBranch>(home,vs) {}
63  ValSelLq::val(const Space&, FloatView x, int) {
64  FloatNumBranch nl;
65  nl.n = x.med(); nl.l = true;
66  return nl;
67  }
68 
71  : ValSel<FloatView,FloatNumBranch>(home,vb) {}
74  : ValSel<FloatView,FloatNumBranch>(home,vs) {}
76  ValSelGq::val(const Space&, FloatView x, int) {
77  FloatNumBranch nl;
78  nl.n = x.med(); nl.l = false;
79  return nl;
80  }
81 
84  : ValSel<FloatView,FloatNumBranch>(home,vb), r(vb.rnd()) {}
87  : ValSel<FloatView,FloatNumBranch>(home,vs), r(vs.r) {
88  }
90  ValSelRnd::val(const Space&, FloatView x, int) {
91  FloatNumBranch nl;
92  nl.n = x.med(); nl.l = (r(2U) == 0U);
93  return nl;
94  }
95  forceinline bool
96  ValSelRnd::notice(void) const {
97  return true;
98  }
99  forceinline void
101  r.~Rnd();
102  }
103 
104 }}}
105 
106 // STATISTICS: float-branch
107 
Value selection class for random value of view.
Definition: branch.hh:261
FloatNum med(void) const
Return median of domain (closest representation)
Definition: float.hpp:72
Rnd r
The used random number generator.
Definition: branch.hh:264
#define forceinline
Definition: config.hpp:182
Computation spaces.
Definition: core.hpp:1668
FloatNumBranch val(const Space &home, FloatView x, int i)
Return value of view x at position i.
Definition: val-sel.hpp:90
Value selection class for values smaller than median of view.
Definition: branch.hh:229
FloatNum n
The middle value for branching.
Definition: float.hh:1466
ValSelLq(Space &home, const ValBranch< Var > &vb)
Constructor for initialization.
Definition: val-sel.hpp:57
Value description class for branching.
Definition: float.hh:1463
FloatNumBranch val(const Space &home, FloatView x, int i)
Return value of view x at position i.
Definition: val-sel.hpp:76
FloatNumBranch val(const Space &home, FloatView x, int i)
Return value of view x at position i.
Definition: val-sel.hpp:63
bool l
Whether to try the lower or upper half first.
Definition: float.hh:1468
void dispose(Space &home)
Delete value selection.
Definition: val-sel.hpp:100
Float view for float variables.
Definition: view.hpp:56
Post propagator for SetVar SetOpType SetVar SetRelType r
Definition: set.hh:769
Value selection class for values smaller than median of view.
Definition: branch.hh:245
Archive & operator>>(Archive &e, FloatNumBranch &nl)
Definition: val-sel.hpp:48
Value branching information.
Definition: val.hpp:45
Archive representation
Definition: archive.hpp:46
Post propagator for SetVar x
Definition: set.hh:769
Archive & operator<<(Archive &e, FloatNumBranch nl)
Definition: val-sel.hpp:43
Gecode toplevel namespace
bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
Definition: val-sel.hpp:96
~Rnd(void)
Destructor.
Definition: rnd.cpp:72
ValSelRnd(Space &home, const ValBranch< Var > &vb)
Constructor for initialization.
Definition: val-sel.hpp:83
Base class for value selection.
Definition: val-sel.hpp:48
ValSelGq(Space &home, const ValBranch< Var > &vb)
Constructor for initialization.
Definition: val-sel.hpp:70