43 namespace Gecode {
namespace Int {
namespace Cumulative {
59 template<
class TaskView>
63 for (
int i=
tasks.size();
i--; ) {
69 template<
class TaskView>
72 leaf(i).e = tasks[
i].e();
74 static_cast<long long int>(
c)*tasks[i].est()+tasks[
i].e();
78 template<
class TaskView>
85 template<
class TaskView>
107 template<
class TaskView>
void
110 for (
int i=tasks.
size();
i--; ) {
117 template<
class TaskView>
template<
class Node>
122 template<
class TaskView>
126 leaf(i).e = tasks[
i].e();
128 static_cast<long long int>(
c)*tasks[i].est()+tasks[
i].e();
130 static_cast<long long int>(
c-ci)*tasks[i].est()+tasks[
i].e();
137 while (!n_leaf(met)) {
138 if (
plus(node[n_right(met)].cenv,e) >
139 static_cast<long long int>(
c-ci) * tasks[i].lct()) {
142 e += node[n_right(met)].e; met = n_left(met);
154 long long int a_e = node[met].e;
155 long long int a_env = node[met].env;
156 long long int b_e = 0;
158 while (!n_root(met)) {
160 b_e += node[n_right(n_parent(met))].e;
162 a_env =
std::max(a_env,
plus(node[n_left(n_parent(met))].env,a_e));
163 a_e += node[n_left(n_parent(met))].e;
168 return plus(a_env,b_e);
187 if (l.
le + r.
e > l.
e + r.
le) {
207 template<
class TaskView>
212 for (
int i=
tasks.size();
i--; ) {
223 template<
class TaskView>
228 leaf(i).le = leaf(i).e;
230 leaf(i).lenv = leaf(i).env;
237 template<
class TaskView>
250 template<
class TaskView>
253 return root().resLenv < 0;
256 template<
class TaskView>
259 return root().resLenv;
262 template<
class TaskView>
268 template<
class TaskView>
long long int env(void) const
Return energy envelope of all tasks.
long long int env(void) const
Return energy envelope of all tasks.
long long int cenv
Energy envelope for subtree.
long long int env(int i)
Compute update for task with index i.
const FloatNum max
Largest allowed float value.
void shift(int i)
Shift task with index i from omega to lambda.
int size(void) const
Return size of array (number of elements)
Node for an omega lambda tree.
long long int env
Energy envelope for subtree.
int responsible(void) const
Return responsible task.
Gecode::FloatVal c(-8, 8)
void init(const OmegaNode &l, const OmegaNode &r)
Initialize node from left child l and right child r.
Gecode::IntArgs i(4, 1, 2, 3, 4)
OmegaTree(Region &r, int c, const TaskViewArray< TaskView > &t)
Initialize tree for tasks t and capacity c.
void update(const OmegaNode &l, const OmegaNode &r)
Update node from left child l and right child r.
void update(void)
Update all inner nodes of tree after leaves have been initialized.
int resLe
Node which is responsible for le.
void init(void)
Initialize tree after leaves have been initialized.
bool lempty(void) const
Whether has responsible task.
int resLenv
Node which is responsible for lenv.
int plus(int x, int y)
Safe addition in case x is -IntLimits::infinity.
long long int lenv(void) const
Return energy envelope of all tasks excluding lambda tasks.
ExtOmegaTree(Region &r, int c, const TaskTree< TaskView, Node > &t)
Initialize tree for tasks t and capacity c.
long long int le
Energy for subtree.
void init(const ExtOmegaNode &l, const ExtOmegaNode &r)
Initialize node from left child l and right child r.
void insert(int i)
Insert task with index i.
static const int undef
Undefined task.
Node for an extended omega tree.
OmegaNode & leaf(int i)
Return leaf for task i.
OmegaLambdaTree(Region &r, int c, const TaskViewArray< TaskView > &t)
Initialize tree for tasks t and capcity c with all tasks included in omega.
void remove(int i)
Remove task with index i.
Gecode toplevel namespace
const TaskViewArray< TaskView > & tasks
The tasks from which the tree is computed.
const long long int llinfinity
Infinity for long long integers.
void update(const ExtOmegaNode &l, const ExtOmegaNode &r)
Update node from left child l and right child r.
Task trees for task views with node type Node.
long long int e
Energy for subtree.
long long int lenv
Energy envelope for subtree.
void init(const OmegaLambdaNode &l, const OmegaLambdaNode &r)
Initialize node from left child l and right child r.
void update(const OmegaLambdaNode &l, const OmegaLambdaNode &r)
Update node from left child l and right child r.
void lremove(int i)
Remove task with index i from lambda.