Skip to content

Commit 62727e8

Browse files
author
Christian Schulte
committed
More rational structure
git-svn-id: svn+ssh://svn.gecode.org/srv/gecode/svn/gecode/trunk@15631 64335634-5103-0410-b293-fc3d331e086d
1 parent 18d191e commit 62727e8

File tree

16 files changed

+19564
-18984
lines changed

16 files changed

+19564
-18984
lines changed

Makefile.dep

Lines changed: 18999 additions & 18720 deletions
Large diffs are not rendered by default.

Makefile.in

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,8 @@ INTBUILDDIRS = \
467467
FLOATSRC0 = \
468468
var/float.cpp var-imp/float.cpp \
469469
arithmetic.cpp array.cpp branch.cpp rel.cpp linear.cpp \
470-
linear/post.cpp bool.cpp \
470+
linear/post.cpp bool.cpp channel.cpp \
471+
transcendental.cpp trigonometric.cpp \
471472
branch/action.cpp branch/chb.cpp rounding.cpp exec.cpp \
472473
branch/val-sel-commit.cpp branch/view-sel.cpp dom.cpp \
473474
relax.cpp \
@@ -480,8 +481,10 @@ FLOATHDR0 = \
480481
view/scale.hpp view/print.hpp view/rel-test.hpp \
481482
var-imp/float.hpp var-imp/delta.hpp \
482483
var/float.hpp var/print.hpp linear.hh linear/nary.hpp \
483-
arithmetic.hh arithmetic/sqr-sqrt-abs.hpp arithmetic/pow-nroot.hpp \
484-
arithmetic/mult.hpp arithmetic/div.hpp arithmetic/min-max-channel.hpp \
484+
arithmetic.hh arithmetic/sqr-sqrt.hpp arithmetic/pow-nroot.hpp \
485+
arithmetic/mult.hpp arithmetic/div.hpp arithmetic/min-max.hpp \
486+
arithmetic/abs.hpp \
487+
channel.hh channel.hpp channel/channel.hpp \
485488
transcendental.hh transcendental/exp-log.hpp trigonometric.hh \
486489
trigonometric/sincos.hpp trigonometric/asinacos.hpp \
487490
trigonometric/tanatan.hpp \
@@ -528,7 +531,7 @@ FLOATBUILDDIRS = \
528531
float float/var float/var-imp float/view \
529532
float/linear float/branch float/rel float/branch \
530533
float/arithmetic float/transcendental float/trigonometric \
531-
float/trace
534+
float/trace float/channel
532535

533536
#
534537
# SET COMPONENTS

gecode/float.hh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,16 +1335,21 @@ namespace Gecode {
13351335
GECODE_FLOAT_EXPORT void
13361336
channel(Home home, FloatVar x0, IntVar x1);
13371337
/// Post propagator for channeling a float and an integer variable \f$ x_0 = x_1\f$
1338-
GECODE_FLOAT_EXPORT void
1338+
void
13391339
channel(Home home, IntVar x0, FloatVar x1);
13401340
/// Post propagator for channeling a float and a Boolean variable \f$ x_0 = x_1\f$
13411341
GECODE_FLOAT_EXPORT void
13421342
channel(Home home, FloatVar x0, BoolVar x1);
13431343
/// Post propagator for channeling a float and a Boolean variable \f$ x_0 = x_1\f$
1344-
GECODE_FLOAT_EXPORT void
1344+
void
13451345
channel(Home home, BoolVar x0, FloatVar x1);
13461346
//@}
13471347

1348+
}
1349+
1350+
#include <gecode/float/channel.hpp>
1351+
1352+
namespace Gecode {
13481353

13491354
/**
13501355
* \defgroup TaskModelFloatExec Synchronized execution

gecode/float/arithmetic.cpp

Lines changed: 0 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@
3838
*/
3939

4040
#include <gecode/float/arithmetic.hh>
41-
#ifdef GECODE_HAS_MPFR
42-
#include <gecode/float/transcendental.hh>
43-
#include <gecode/float/trigonometric.hh>
44-
#endif
4541

4642
namespace Gecode {
4743

@@ -139,113 +135,6 @@ namespace Gecode {
139135
(Arithmetic::Div<FloatView,FloatView,FloatView>::post(home,x0,x1,x2)));
140136
}
141137

142-
#ifdef GECODE_HAS_MPFR
143-
void
144-
exp(Home home, FloatVar x0, FloatVar x1) {
145-
using namespace Float;
146-
GECODE_POST;
147-
GECODE_ES_FAIL((Transcendental::Exp<FloatView,FloatView>::post(home,x0,x1)));
148-
}
149-
150-
void
151-
log(Home home, FloatVar x0, FloatVar x1) {
152-
using namespace Float;
153-
GECODE_POST;
154-
GECODE_ES_FAIL((Transcendental::Exp<FloatView,FloatView>
155-
::post(home,x1,x0)));
156-
}
157-
158-
void
159-
log(Home home, FloatNum base, FloatVar x0, FloatVar x1) {
160-
using namespace Float;
161-
GECODE_POST;
162-
GECODE_ES_FAIL((Transcendental::Pow<FloatView,FloatView>
163-
::post(home,base,x1,x0)));
164-
}
165-
166-
void
167-
pow(Home home, FloatNum base, FloatVar x0, FloatVar x1) {
168-
using namespace Float;
169-
GECODE_POST;
170-
GECODE_ES_FAIL((Transcendental::Pow<FloatView,FloatView>
171-
::post(home,base,x0,x1)));
172-
}
173-
174-
void
175-
asin(Home home, FloatVar x0, FloatVar x1) {
176-
using namespace Float;
177-
GECODE_POST;
178-
GECODE_ES_FAIL((Trigonometric::ASin<FloatView,FloatView>::post(home,x0,x1)));
179-
}
180-
181-
void
182-
sin(Home home, FloatVar x0, FloatVar x1) {
183-
using namespace Float;
184-
GECODE_POST;
185-
GECODE_ES_FAIL((Trigonometric::Sin<FloatView,FloatView>::post(home,x0,x1)));
186-
}
187-
188-
void
189-
acos(Home home, FloatVar x0, FloatVar x1) {
190-
using namespace Float;
191-
GECODE_POST;
192-
GECODE_ES_FAIL((Trigonometric::ACos<FloatView,FloatView>::post(home,x0,x1)));
193-
}
194-
195-
void
196-
cos(Home home, FloatVar x0, FloatVar x1) {
197-
using namespace Float;
198-
GECODE_POST;
199-
GECODE_ES_FAIL((Trigonometric::Cos<FloatView,FloatView>::post(home,x0,x1)));
200-
}
201-
202-
void
203-
atan(Home home, FloatVar x0, FloatVar x1) {
204-
using namespace Float;
205-
GECODE_POST;
206-
GECODE_ES_FAIL((Trigonometric::ATan<FloatView,FloatView>::post(home,x0,x1)));
207-
}
208-
209-
void
210-
tan(Home home, FloatVar x0, FloatVar x1) {
211-
using namespace Float;
212-
GECODE_POST;
213-
GECODE_ES_FAIL((Trigonometric::Tan<FloatView,FloatView>::post(home,x0,x1)));
214-
}
215-
#endif
216-
217-
void
218-
channel(Home home, FloatVar x0, IntVar x1) {
219-
using namespace Float;
220-
using namespace Int;
221-
GECODE_POST;
222-
GECODE_ES_FAIL((Arithmetic::Channel<FloatView,IntView>::post(home,x0,x1)));
223-
}
224-
225-
void
226-
channel(Home home, IntVar x0, FloatVar x1) {
227-
using namespace Float;
228-
using namespace Int;
229-
GECODE_POST;
230-
GECODE_ES_FAIL((Arithmetic::Channel<FloatView,IntView>::post(home,x1,x0)));
231-
}
232-
233-
void
234-
channel(Home home, FloatVar x0, BoolVar x1) {
235-
using namespace Float;
236-
using namespace Int;
237-
GECODE_POST;
238-
GECODE_ES_FAIL((Arithmetic::Channel<FloatView,BoolView>::post(home,x0,x1)));
239-
}
240-
241-
void
242-
channel(Home home, BoolVar x0, FloatVar x1) {
243-
using namespace Float;
244-
using namespace Int;
245-
GECODE_POST;
246-
GECODE_ES_FAIL((Arithmetic::Channel<FloatView,BoolView>::post(home,x1,x0)));
247-
}
248-
249138
}
250139

251140
// STATISTICS: float-post

gecode/float/arithmetic.hh

Lines changed: 3 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -292,35 +292,6 @@ namespace Gecode { namespace Float { namespace Arithmetic {
292292
};
293293

294294

295-
/**
296-
* \brief %Propagator for bounds multiplication operator
297-
*
298-
* The types \a A, \a B and \a C give the types of the views.
299-
*
300-
* Requires \code #include <gecode/float/arithmetic.hh> \endcode
301-
* \ingroup FuncFloatProp
302-
*/
303-
/*
304-
template<class A, class B, class C>
305-
class Mult : public MixTernaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND,C,PC_FLOAT_BND> {
306-
protected:
307-
using MixTernaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND,C,PC_FLOAT_BND>::x0;
308-
using MixTernaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND,C,PC_FLOAT_BND>::x1;
309-
using MixTernaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND,C,PC_FLOAT_BND>::x2;
310-
/// Constructor for cloning \a p
311-
Mult(Space& home, bool share, Mult& p);
312-
/// Constructor for creation
313-
Mult(Home home, A x0, B x1, C x2);
314-
public:
315-
/// Create copy during cloning
316-
virtual Actor* copy(Space& home, bool share);
317-
/// Perform propagation
318-
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
319-
/// Post propagator for \f$ x_0 * x_1 = x_2\f$
320-
static ExecStatus post(Home home, A x0, B x1, C x2);
321-
};
322-
*/
323-
324295
/**
325296
* \brief %Propagator for bounds division operator
326297
*
@@ -431,39 +402,14 @@ namespace Gecode { namespace Float { namespace Arithmetic {
431402
static ExecStatus post(Home home, ViewArray<View>& x, View y);
432403
};
433404

434-
/**
435-
* \brief %Propagator for bounds consistent integer part operator
436-
*
437-
* Requires \code #include <gecode/float/arithmetic.hh> \endcode
438-
* \ingroup FuncFloatProp
439-
*/
440-
template<class A, class B>
441-
class Channel :
442-
public MixBinaryPropagator<A,PC_FLOAT_BND,B,Gecode::Int::PC_INT_BND> {
443-
protected:
444-
using MixBinaryPropagator<A,PC_FLOAT_BND,B,Gecode::Int::PC_INT_BND>::x0;
445-
using MixBinaryPropagator<A,PC_FLOAT_BND,B,Gecode::Int::PC_INT_BND>::x1;
446-
447-
/// Constructor for cloning \a p
448-
Channel(Space& home, bool share, Channel& p);
449-
/// Constructor for creation
450-
Channel(Home home, A x0, B x1);
451-
public:
452-
/// Create copy during cloning
453-
virtual Actor* copy(Space& home, bool share);
454-
/// Perform propagation
455-
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
456-
/// Post propagator for \f$ int(x_0) = x_1\f$
457-
static ExecStatus post(Home home, A x0, B x1);
458-
};
459-
460405
}}}
461406

462-
#include <gecode/float/arithmetic/sqr-sqrt-abs.hpp>
407+
#include <gecode/float/arithmetic/sqr-sqrt.hpp>
408+
#include <gecode/float/arithmetic/abs.hpp>
463409
#include <gecode/float/arithmetic/pow-nroot.hpp>
464410
#include <gecode/float/arithmetic/mult.hpp>
465411
#include <gecode/float/arithmetic/div.hpp>
466-
#include <gecode/float/arithmetic/min-max-channel.hpp>
412+
#include <gecode/float/arithmetic/min-max.hpp>
467413

468414
#endif
469415

gecode/float/arithmetic/abs.hpp

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2+
/*
3+
* Main authors:
4+
* Christian Schulte <[email protected]>
5+
* Guido Tack <[email protected]>
6+
* Vincent Barichard <[email protected]>
7+
*
8+
* Copyright:
9+
* Christian Schulte, 2004
10+
* Guido Tack, 2006
11+
* Vincent Barichard, 2012
12+
*
13+
* Last modified:
14+
* $Date$ by $Author$
15+
* $Revision$
16+
*
17+
* This file is part of Gecode, the generic constraint
18+
* development environment:
19+
* http://www.gecode.org
20+
*
21+
* Permission is hereby granted, free of charge, to any person obtaining
22+
* a copy of this software and associated documentation files (the
23+
* "Software"), to deal in the Software without restriction, including
24+
* without limitation the rights to use, copy, modify, merge, publish,
25+
* distribute, sublicense, and/or sell copies of the Software, and to
26+
* permit persons to whom the Software is furnished to do so, subject to
27+
* the following conditions:
28+
*
29+
* The above copyright notice and this permission notice shall be
30+
* included in all copies or substantial portions of the Software.
31+
*
32+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
33+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
34+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
35+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
36+
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
37+
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
38+
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
39+
*
40+
*/
41+
42+
namespace Gecode { namespace Float { namespace Arithmetic {
43+
44+
template<class A, class B>
45+
forceinline
46+
Abs<A,B>::Abs(Home home, A x0, B x1)
47+
: MixBinaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND>(home,x0,x1) {}
48+
49+
template<class A, class B>
50+
ExecStatus
51+
Abs<A,B>::post(Home home, A x0, B x1) {
52+
(void) new (home) Abs<A,B>(home,x0,x1);
53+
return ES_OK;
54+
}
55+
56+
template<class A, class B>
57+
forceinline
58+
Abs<A,B>::Abs(Space& home, bool share, Abs<A,B>& p)
59+
: MixBinaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND>(home,share,p) {}
60+
61+
template<class A, class B>
62+
Actor*
63+
Abs<A,B>::copy(Space& home, bool share) {
64+
return new (home) Abs<A,B>(home,share,*this);
65+
}
66+
67+
template<class A, class B>
68+
ExecStatus
69+
Abs<A,B>::propagate(Space& home, const ModEventDelta&) {
70+
GECODE_ME_CHECK(x1.eq(home,abs(x0.val())));
71+
if (x0.min() >= 0)
72+
GECODE_ME_CHECK(x0.eq(home,FloatVal(x1.min(), x1.max())));
73+
else if (x0.max() <= 0)
74+
GECODE_ME_CHECK(x0.eq(home,FloatVal(-x1.max(), -x1.min())));
75+
else
76+
GECODE_ME_CHECK(x0.eq(home,FloatVal(-x1.max(), x1.max())));
77+
return (x0.assigned() && x1.assigned()) ? home.ES_SUBSUMED(*this) : ES_FIX;
78+
}
79+
80+
}}}
81+
82+
// STATISTICS: float-prop
83+

0 commit comments

Comments
 (0)