Generated on Wed Jan 24 2018 21:22:26 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: 2017-02-16 12:11:51 +0100 (Thu, 16 Feb 2017) $ by $Author: schulte $
13  * $Revision: 15434 $
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,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 
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: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
Computation spaces.
Definition: core.hpp:1748
FloatNumBranch val(const Space &home, FloatView x, int i)
Return value of view x at position i.
Definition: val-sel.hpp:91
Value selection class for values smaller than median of view.
Definition: branch.hh:229
FloatNum n
The middle value for branching.
Definition: float.hh:1411
ValSelLq(Space &home, const ValBranch< Var > &vb)
Constructor for initialization.
Definition: val-sel.hpp:57
Value description class for branching.
Definition: float.hh:1408
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:1413
void dispose(Space &home)
Delete value selection.
Definition: val-sel.hpp:101
Float view for float variables.
Definition: view.hpp:56
Post propagator for SetVar SetOpType SetVar SetRelType r
Definition: set.hh:784
Value selection class for values smaller than median of view.
Definition: branch.hh:245
void update(Space &home, bool share, SharedHandle &sh)
Updating during cloning.
Definition: core.hpp:3127
Archive & operator>>(Archive &e, FloatNumBranch &nl)
Definition: val-sel.hpp:48
Value branching information.
Definition: branch-val.hpp:45
Archive representation
Definition: archive.hpp:45
#define forceinline
Definition: config.hpp:173
Post propagator for SetVar x
Definition: set.hh:784
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:702
Gecode toplevel namespace
bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
Definition: val-sel.hpp:97
~Rnd(void)
Destructor.
Definition: rnd.cpp:75
ValSelRnd(Space &home, const ValBranch< Var > &vb)
Constructor for initialization.
Definition: val-sel.hpp:83
Base class for value selection.
ValSelGq(Space &home, const ValBranch< Var > &vb)
Constructor for initialization.
Definition: val-sel.hpp:70