Generated on Tue Jan 28 2020 00:00:00 for Gecode by doxygen 1.8.17
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  * Last modified:
12  * $Date: 2016-04-19 17:19:45 +0200 (Tue, 19 Apr 2016) $ by $Author: schulte $
13  * $Revision: 14967 $
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 { namespace Int { namespace Cumulative {
41 
42  template<class ManTask, class Cap, class PL>
45  : TaskProp<ManTask,PL>(home,t), c(c0) {
46  c.subscribe(home,*this,PC_INT_BND);
47  }
48 
49  template<class ManTask, class Cap, class PL>
53  : TaskProp<ManTask,PL>(home,shared,p) {
54  c.update(home,shared,p.c);
55  }
56 
57  template<class ManTask, class Cap, class PL>
60  // Capacity must be nonnegative
61  GECODE_ME_CHECK(c.gq(home, 0));
62  // Check that tasks do not overload resource
63  for (int i=t.size(); i--; )
64  if (t[i].c() > c.max())
65  return ES_FAILED;
66  if (t.size() == 1)
67  GECODE_ME_CHECK(c.gq(home, t[0].c()));
68  if (t.size() > 1) {
69  if (c.assigned() && c.val()==1) {
71  for (int i=t.size(); i--; )
72  mt[i]=t[i];
74  ::post(home,mt);
75  } else {
76  (void) new (home) ManProp<ManTask,Cap,PL>(home,c,t);
77  }
78  }
79  return ES_OK;
80  }
81 
82  template<class ManTask, class Cap, class PL>
83  Actor*
84  ManProp<ManTask,Cap,PL>::copy(Space& home, bool share) {
85  return new (home) ManProp<ManTask,Cap,PL>(home,share,*this);
86  }
87 
88  template<class ManTask, class Cap, class PL>
89  forceinline size_t
91  (void) TaskProp<ManTask,PL>::dispose(home);
92  c.cancel(home,*this,PC_INT_BND);
93  return sizeof(*this);
94  }
95 
96  template<class ManTask, class Cap, class PL>
99  // Only bounds changes?
100  if (IntView::me(med) != ME_INT_DOM)
101  GECODE_ES_CHECK(overload(home,c.max(),t));
102 
103  if (PL::advanced)
104  GECODE_ES_CHECK(edgefinding(home,c.max(),t));
105 
106  if (PL::basic)
107  GECODE_ES_CHECK(timetabling(home,*this,c,t));
108 
109  if (Cap::varderived() && c.assigned() && (c.val() == 1)) {
110  // Check that tasks do not overload resource
111  for (int i=t.size(); i--; )
112  if (t[i].c() > 1)
113  return ES_FAILED;
114  // Rewrite to unary resource constraint
116  for (int i=t.size(); i--;)
117  ut[i]=t[i];
118  GECODE_REWRITE(*this,
120  ::post(home(*this),ut)));
121  }
122 
123  if (!PL::basic && c.assigned())
124  GECODE_ES_CHECK(subsumed(home,*this,c.val(),t));
125 
126  return ES_NOFIX;
127  }
128 
129 }}}
130 
131 // STATISTICS: int-prop
#define forceinline
Definition: config.hpp:173
friend FloatVal max(const FloatVal &x, const FloatVal &y)
Definition: val.hpp:390
Cap c
Resource capacity.
Definition: cumulative.hh:710
Scheduling propagator for cumulative resource with mandatory tasks.
Definition: cumulative.hh:706
Gecode::IntArgs i(4, 1, 2, 3, 4)
NodeType t
Type of node.
Definition: bool-expr.cpp:234
virtual Actor * copy(Space &home, bool share)
Perform copying during cloning.
Definition: man-prop.hpp:84
Computation spaces.
Definition: core.hpp:1748
ExecStatus subsumed(Space &home, Propagator &p, int c, TaskArray< Task > &t)
Check for subsumption (all tasks must be assigned)
Definition: subsumption.hpp:42
Base-class for both propagators and branchers.
Definition: core.hpp:696
ExecStatus timetabling(Space &home, Propagator &p, Cap c, TaskArray< Task > &t)
Perform time-tabling propagation.
ManProp(Home home, Cap c, TaskArray< ManTask > &t)
Constructor for creation.
Definition: man-prop.hpp:44
Traits class for mapping tasks to task views.
Definition: task.hh:161
Gecode toplevel namespace
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: man-prop.hpp:98
#define GECODE_ES_CHECK(es)
Check whether execution status es is failed or subsumed, and forward failure or subsumption.
Definition: macros.hpp:95
Home class for posting propagators
Definition: core.hpp:922
ExecStatus edgefinding(Space &home, int c, TaskViewArray< TaskView > &t)
static ModEvent me(const ModEventDelta &med)
Return modification event for view type in med.
Propagator for tasks
Definition: task.hh:428
TFE post(PropagatorGroup g)
Only post functions (but not propagators) from g are considered.
ExecStatus overload(Space &home, int c, TaskArray< ManTask > &t)
Check mandatory tasks t for overload.
Definition: overload.hpp:45
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Definition: man-prop.hpp:90
Scheduling propagator for unary resource with mandatory tasks
Definition: unary.hh:795
const Gecode::PropCond PC_INT_BND
Propagate when minimum or maximum of a view changes.
Definition: var-type.hpp:91
static ExecStatus post(Home home, Cap c, TaskArray< ManTask > &t)
Post propagator that schedules tasks on cumulative resource.
Definition: man-prop.hpp:59
bool shared(const IntSet &, VX)
Definition: view-base.hpp:122
#define GECODE_ME_CHECK(me)
Check whether modification event me is failed, and forward failure.
Definition: macros.hpp:56
Gecode::FloatVal c(-8, 8)
@ ES_FAILED
Execution has resulted in failure.
Definition: core.hpp:542
int ModEventDelta
Modification event deltas.
Definition: core.hpp:169
@ ES_NOFIX
Propagation has not computed fixpoint.
Definition: core.hpp:543
const Gecode::ModEvent ME_INT_DOM
Domain operation has changed the domain.
Definition: var-type.hpp:72
#define GECODE_REWRITE(prop, post)
Rewrite propagator by executing post function.
Definition: macros.hpp:120
@ ES_OK
Execution is okay.
Definition: core.hpp:544
int p
Number of positive literals for node type.
Definition: bool-expr.cpp:236
ExecStatus
Definition: core.hpp:540