I am modeling a vehicle routing and scheduling problem using CP. I have 2 kinds of decision variables, that is, sequencing and start time of each node.
The sequencing variable contains the node number, and start time of each node depends on the order it is traveled. Thus, I require to use sequencing variable as an index of start time variables.
But I got this error:
<docplex.cp.expression.CpoIntVar object at 0x0000022A9E070C70>
It is how I write my code:
x={d:sub.integer_var_list(n[d],0, len(I)-1,"X") for d in D}
start={d:{i:sub.interval_var(start=[t[0][i],T-p[i,d]-t[i][len(I)-1]],size=p[i,d]) for i in C[d]} for d in D}
sub.add(sub.sum(sub.end_of(start[d][x[d][n[d]-2]]),t[x[d][n[d]-2]][x[d][n[d]-1]])<=T)
I appreciate you to help me in this regard
An indexing operation using a decision variable in constraint programming can be implemented using an
elementglobal constraint. The documentation for theelementconstraint in CP Optimiser's Python interface can be found here: https://ibmdecisionoptimization.github.io/docplex-doc/cp/docplex.cp.modeler.py.html#docplex.cp.modeler.elementThis means that instead of
y = x[i]whereiis a variable, you would instead writey = model.element(x, i).