Generated on Wed Jul 21 2021 00:00:00 for Gecode by doxygen 1.9.1
order.cpp
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  *
6  * Copyright:
7  * Christian Schulte, 2019
8  *
9  * This file is part of Gecode, the generic constraint
10  * development environment:
11  * http://www.gecode.org
12  *
13  * Permission is hereby granted, free of charge, to any person obtaining
14  * a copy of this software and associated documentation files (the
15  * "Software"), to deal in the Software without restriction, including
16  * without limitation the rights to use, copy, modify, merge, publish,
17  * distribute, sublicense, and/or sell copies of the Software, and to
18  * permit persons to whom the Software is furnished to do so, subject to
19  * the following conditions:
20  *
21  * The above copyright notice and this permission notice shall be
22  * included in all copies or substantial portions of the Software.
23  *
24  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31  *
32  */
33 
34 #include <gecode/minimodel.hh>
35 #include "test/int.hh"
36 
37 namespace Test { namespace Int {
38 
40  namespace Order {
41 
48  class Int : public Test {
49  protected:
51  int p0, p1;
52  public:
54  Int(int _p0, int _p1)
55  : Test("Order::"+str(_p0)+"::"+str(_p1),3,0,6),
56  p0(_p0), p1(_p1) {}
58  virtual bool solution(const Assignment& x) const {
59  int s0 = x[0], s1 = x[1], b = x[2];
60  if (b > 1)
61  return false;
62  return ((s0+p0<=s1) && (b == 0)) || ((s1+p1<=s0) && (b == 1));
63  }
65  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
66  using namespace Gecode;
67  order(home, x[0], p0, x[1], p1, channel(home, x[2]));
68  }
69  };
71  class Create {
72  public:
74  Create(void) {
75  for (int i=1; i<=4; i++)
76  for (int j=1; j<=4; j++)
77  (void) new Int(i,j);
78  }
79  };
80 
83 
84  }
85 }}
86 
87 // STATISTICS: test-int
88 
struct Gecode::@602::NNF::@65::@66 b
For binary nodes (and, or, eqv)
Node * x
Pointer to corresponding Boolean expression node.
Definition: bool-expr.cpp:249
Integer variable array.
Definition: int.hh:763
Computation spaces.
Definition: core.hpp:1742
Base class for assignments
Definition: int.hh:59
Help class to create and register tests.
Definition: order.cpp:71
Create(void)
Perform creation and registration.
Definition: order.cpp:74
Test order for integer variables
Definition: order.cpp:48
int p0
Processing times.
Definition: order.cpp:51
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: order.cpp:58
Int(int _p0, int _p1)
Create and register test.
Definition: order.cpp:54
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: order.cpp:65
static std::string str(Gecode::IntPropLevel ipl)
Map integer propagation level to string.
Definition: int.hpp:209
void channel(Home home, FloatVar x0, IntVar x1)
Post propagator for channeling a float and an integer variable .
Definition: channel.cpp:41
void order(Home home, IntVar s0, int p0, IntVar s1, int p1, BoolVar b, IntPropLevel)
Post propagators for ordering two tasks.
Definition: order.cpp:41
Gecode::IntArgs i({1, 2, 3, 4})
General test support.
Definition: afc.cpp:39