Generated on Sat Apr 10 2021 00:00:00 for Gecode by doxygen 1.9.1
man-prop.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  * Guido Tack <tack@gecode.org>
6  *
7  * Copyright:
8  * Christian Schulte, 2009
9  * Guido Tack, 2010
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 
36 namespace Gecode { namespace Int { namespace Cumulative {
37 
38  template<class ManTask, class Cap, class PL>
41  : TaskProp<ManTask,PL>(home,t), c(c0) {
42  c.subscribe(home,*this,PC_INT_BND);
43  }
44 
45  template<class ManTask, class Cap, class PL>
48  : TaskProp<ManTask,PL>(home,p) {
49  c.update(home,p.c);
50  }
51 
52  template<class ManTask, class Cap, class PL>
55  // Capacity must be nonnegative
56  GECODE_ME_CHECK(c.gq(home, 0));
57  // Check that tasks do not overload resource
58  for (int i=0; i<t.size(); i++)
59  if (t[i].c() > c.max())
60  return ES_FAILED;
61  if (t.size() == 1)
62  GECODE_ME_CHECK(c.gq(home, t[0].c()));
63  if (t.size() > 1) {
64  if (c.assigned() && c.val()==1) {
66  for (int i=0; i<t.size(); i++)
67  mt[i]=t[i];
69  ::post(home,mt);
70  } else {
71  (void) new (home) ManProp<ManTask,Cap,PL>(home,c,t);
72  }
73  }
74  return ES_OK;
75  }
76 
77  template<class ManTask, class Cap, class PL>
78  Actor*
80  return new (home) ManProp<ManTask,Cap,PL>(home,*this);
81  }
82 
83  template<class ManTask, class Cap, class PL>
84  forceinline size_t
86  (void) TaskProp<ManTask,PL>::dispose(home);
87  c.cancel(home,*this,PC_INT_BND);
88  return sizeof(*this);
89  }
90 
91  template<class ManTask, class Cap, class PL>
94  // Only bounds changes?
95  if (IntView::me(med) != ME_INT_DOM)
96  GECODE_ES_CHECK(overload(home,c.max(),t));
97 
98  if (PL::advanced)
100 
101  if (PL::basic)
102  GECODE_ES_CHECK(timetabling(home,*this,c,t));
103 
104  if (Cap::varderived() && c.assigned() && (c.val() == 1)) {
105  // Check that tasks do not overload resource
106  for (int i=0; i<t.size(); i++)
107  if (t[i].c() > 1)
108  return ES_FAILED;
109  // Rewrite to unary resource constraint
111  for (int i=0; i<t.size(); i++)
112  ut[i]=t[i];
113  GECODE_REWRITE(*this,
115  ::post(home(*this),ut)));
116  }
117 
118  if (!PL::basic && c.assigned())
119  GECODE_ES_CHECK(subsumed(home,*this,c.val(),t));
120 
121  return ES_NOFIX;
122  }
123 
124 }}}
125 
126 // STATISTICS: int-prop
NodeType t
Type of node.
Definition: bool-expr.cpp:230
int p
Number of positive literals for node type.
Definition: bool-expr.cpp:232
Base-class for both propagators and branchers.
Definition: core.hpp:628
friend FloatVal max(const FloatVal &x, const FloatVal &y)
Definition: val.hpp:386
Home class for posting propagators
Definition: core.hpp:856
Scheduling propagator for cumulative resource with mandatory tasks.
Definition: cumulative.hh:702
virtual Actor * copy(Space &home)
Perform copying during cloning.
Definition: man-prop.hpp:79
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: man-prop.hpp:93
Cap c
Resource capacity.
Definition: cumulative.hh:706
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Definition: man-prop.hpp:85
static ExecStatus post(Home home, Cap c, TaskArray< ManTask > &t)
Post propagator that schedules tasks on cumulative resource.
Definition: man-prop.hpp:54
ManProp(Home home, Cap c, TaskArray< ManTask > &t)
Constructor for creation.
Definition: man-prop.hpp:40
Task array.
Definition: task.hh:165
Propagator for tasks
Definition: task.hh:424
Traits class for mapping tasks to task views.
Definition: task.hh:157
Scheduling propagator for unary resource with mandatory tasks
Definition: unary.hh:791
Computation spaces.
Definition: core.hpp:1742
static ModEvent me(const ModEventDelta &med)
Return modification event for view type in med.
Definition: view.hpp:552
ExecStatus
Definition: core.hpp:472
@ ES_OK
Execution is okay.
Definition: core.hpp:476
@ ES_FAILED
Execution has resulted in failure.
Definition: core.hpp:474
@ ES_NOFIX
Propagation has not computed fixpoint.
Definition: core.hpp:475
void post(Home home, Term *t, int n, FloatRelType frt, FloatVal c)
Post propagator for linear constraint over floats.
Definition: post.cpp:238
int ModEventDelta
Modification event deltas.
Definition: core.hpp:89
#define GECODE_ME_CHECK(me)
Check whether modification event me is failed, and forward failure.
Definition: macros.hpp:52
#define GECODE_REWRITE(prop, post)
Rewrite propagator by executing post function.
Definition: macros.hpp:116
#define GECODE_ES_CHECK(es)
Check whether execution status es is failed or subsumed, and forward failure or subsumption.
Definition: macros.hpp:91
ExecStatus timetabling(Space &home, Propagator &p, Cap c, TaskArray< Task > &t)
Perform time-tabling propagation.
ExecStatus edgefinding(Space &home, int c, TaskViewArray< TaskView > &t)
ExecStatus subsumed(Space &home, Propagator &p, int c, TaskArray< Task > &t)
Check for subsumption (all tasks must be assigned)
Definition: subsumption.hpp:38
ExecStatus overload(Space &home, int c, TaskArray< ManTask > &t)
Check mandatory tasks t for overload.
Definition: overload.hpp:41
const Gecode::PropCond PC_INT_BND
Propagate when minimum or maximum of a view changes.
Definition: var-type.hpp:91
const Gecode::ModEvent ME_INT_DOM
Domain operation has changed the domain.
Definition: var-type.hpp:72
Gecode::FloatVal c(-8, 8)
Gecode::IntArgs i({1, 2, 3, 4})
#define forceinline
Definition: config.hpp:192