Generated on Sat Feb 7 2015 02:01:15 for Gecode by doxygen 1.8.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  * Last modified:
12  * $Date: 2013-05-29 13:53:43 +0200 (Wed, 29 May 2013) $ by $Author: schulte $
13  * $Revision: 13672 $
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 
47  forceinline Archive&
49  return e >> nl.n >> nl.l;
50  }
51 
52 }
53 
54 namespace Gecode { namespace Float { namespace Branch {
55 
57  ValSelLq::ValSelLq(Space& home, const ValBranch& vb)
58  : ValSel<FloatView,FloatNumBranch>(home,vb) {}
61  : ValSel<FloatView,FloatNumBranch>(home,shared,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 
70  ValSelGq::ValSelGq(Space& home, const ValBranch& vb)
71  : ValSel<FloatView,FloatNumBranch>(home,vb) {}
74  : ValSel<FloatView,FloatNumBranch>(home,shared,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,shared,vs) {
88  r.update(home,shared,vs.r);
89  }
91  ValSelRnd::val(const Space&, FloatView x, int) {
92  FloatNumBranch nl;
93  nl.n = x.med(); nl.l = (r(2U) == 0U);
94  return nl;
95  }
96  forceinline bool
97  ValSelRnd::notice(void) const {
98  return true;
99  }
100  forceinline void
102  r.~Rnd();
103  }
104 
105 }}}
106 
107 // STATISTICS: float-branch
108 
Value selection class for random value of view.
Definition: branch.hh:238
Rnd r
The used random number generator.
Definition: branch.hh:241
ValSelGq(Space &home, const ValBranch &vb)
Constructor for initialization.
Definition: val-sel.hpp:70
Computation spaces.
Definition: core.hpp:1362
FloatNumBranch val(const Space &home, FloatView x, int i)
Return value of view x at position i.
Definition: val-sel.hpp:91
ValSelLq(Space &home, const ValBranch &vb)
Constructor for initialization.
Definition: val-sel.hpp:57
Value selection class for values smaller than median of view.
Definition: branch.hh:206
FloatNum n
The middle value for branching.
Definition: float.hh:1375
Value description class for branching.
Definition: float.hh:1372
NNF * r
Right subtree.
Definition: bool-expr.cpp:246
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:1377
void dispose(Space &home)
Delete value selection.
Definition: val-sel.hpp:101
Float view for float variables.
Definition: view.hpp:56
Value selection class for values smaller than median of view.
Definition: branch.hh:222
void update(Space &home, bool share, SharedHandle &sh)
Updating during cloning.
Definition: core.hpp:2656
Archive & operator>>(Archive &e, FloatNumBranch &nl)
Definition: val-sel.hpp:48
Value branching information.
Definition: branch-val.hpp:44
Node * x
Pointer to corresponding Boolean expression node.
Definition: bool-expr.cpp:253
Archive representation
Definition: archive.hpp:45
FloatNum med(void) const
Return median of domain (closest representation)
Definition: float.hpp:72
#define forceinline
Definition: config.hpp:132
ValSelRnd(Space &home, const ValBranch &vb)
Constructor for initialization.
Definition: val-sel.hpp:83
bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
Definition: val-sel.hpp:97
Archive & operator<<(Archive &e, FloatNumBranch nl)
Definition: val-sel.hpp:43
bool shared(const ConstView< ViewA > &, const ConstView< ViewB > &)
Test whether views share same variable.
Definition: view.hpp:662
Gecode toplevel namespace
Base class for value selection.