Originally posted by: TracedWill
Hi,
In constraint programming, it is common to use the value of decision variables as an index in other variables, especially in assignment problems. I am trying to do this in CPLEX, but I get an error. My code is the following:
using CP;
tuple myTuple {
key int foo;
key int bar;
int ram;
}
{myTuple} myTuples = ...;
range myRange = 1..3;
dvar int myVar[myRange] in myRange;
//minimize ...
subject to{
forall(i in myRange)
item(myTuples,<i,myVar[i]>).ram >= myVar[i];
}
And data:
myTuples = {
<1,1,1>,<1,2,1>,<1,3,2>,<2,1,3>,<2,2,1>,<2,3,2>
};
The problem and data is random, it is only to show how I use the item-command on a tuple with two keys and a property that I want to extract using the value of the decision variable as the second key.
#DecisionOptimization#OPLusingCPLEXOptimizer