this repo has no description
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
36namespace Gecode {
37
38 forceinline Archive&
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
50namespace Gecode { namespace Float { namespace Branch {
51
52 forceinline
53 ValSelLq::ValSelLq(Space& home, const ValBranch<Var>& vb)
54 : ValSel<FloatView,FloatNumBranch>(home,vb) {}
55 forceinline
56 ValSelLq::ValSelLq(Space& home, ValSelLq& vs)
57 : ValSel<FloatView,FloatNumBranch>(home,vs) {}
58 forceinline FloatNumBranch
59 ValSelLq::val(const Space&, FloatView x, int) {
60 FloatNumBranch nl;
61 nl.n = x.med(); nl.l = true;
62 return nl;
63 }
64
65 forceinline
66 ValSelGq::ValSelGq(Space& home, const ValBranch<Var>& vb)
67 : ValSel<FloatView,FloatNumBranch>(home,vb) {}
68 forceinline
69 ValSelGq::ValSelGq(Space& home, ValSelGq& vs)
70 : ValSel<FloatView,FloatNumBranch>(home,vs) {}
71 forceinline FloatNumBranch
72 ValSelGq::val(const Space&, FloatView x, int) {
73 FloatNumBranch nl;
74 nl.n = x.med(); nl.l = false;
75 return nl;
76 }
77
78 forceinline
79 ValSelRnd::ValSelRnd(Space& home, const ValBranch<Var>& vb)
80 : ValSel<FloatView,FloatNumBranch>(home,vb), r(vb.rnd()) {}
81 forceinline
82 ValSelRnd::ValSelRnd(Space& home, ValSelRnd& vs)
83 : ValSel<FloatView,FloatNumBranch>(home,vs), r(vs.r) {
84 }
85 forceinline FloatNumBranch
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
96 ValSelRnd::dispose(Space&) {
97 r.~Rnd();
98 }
99
100}}}
101
102// STATISTICS: float-branch
103