Originally posted by: Vgoel77
I am trying to model an inventory balance constraint in my CP model. I am using the C++ API and am having trouble with the cumulFunction.
Help is appreciated.
I am trying to model the following constraint over a time horizon:
i = i0 + p - z
i: inventory in tank
i0: initial inventory (given)
z: profile for volume withdrawn from tank (depends on scheduling decisions)
p: profile for volume input in to tank (given)
i, p, z are modeled as cumulFunctions.
Pseudocode IloCumulFunctionExpr p(env);
p += sum_t IloStep(t, prod[t]); // prod is a time indexed vector of input
IloCumulFunctionExpr z(env);
z += sum_j IloStepAtEnd(w[j], s) // w[j] are interval vars and s is a fixed amount withdrawn from tank during each interval
IloCumulFunctionExpr i(env);
i += IloStep(0, i0);
i += p;
i -= z;
model.add(IloAlwaysIn(i,0,T,0,C)// inventory is between 0 and C=capacity during t=0 to t=T
Questions 1) Does the code above look reasonable?
2) Are cumulfunction expressions passed by value or reference to the model? i.e. can I call .end() on i after the call to model.add?
Similarly, can I call z.end() after it has been used to calculate i (ie after the statement i -=z and before model.add(...))
3) do I need to call model.add(z), model.add(p), model.add(i) for the above model to work correctly?
4) if I include the call "env.out() << model" in my code, all constraints print correctly except the model.add(IloAlwaysIn(...)). It says something like "IloExtractable unknown". Is the operator<< not overloaded for cumulFunctionExpressions?
,
s: (fixed) size of withdrawal
The model is trying to schedule withdrawals from a tank. Each withdrawal is of constant amount and takes a unit of time. there are constraints on the withdrawal schedule that are not relevant to this issue.
Pseudocode w[i]: interval variables
p: cum function for input in tank: this data is fixed
z = sum_i step(w[i])*s
o = max(0,ui-c)
i = ui - o
alwaysIn(i,t0,tmax,0,c)
objective: minimize total overflow (= area under cum function for "o")
#CPOptimizer#DecisionOptimization