Originally posted by: EBKN_Eduardo_Aime
Philippe:
Trying to flattening the bidimensional decision variables, the function "searchPhase" give me the following error: (using the example "car")
Execution of "SearchPhases" failed: "C:...Application Data\IBM\ILOG\CPLEX_Studio125\workspace\car\car.mod", line 67: Wrong argument type. The first argument contains an unsupported element. Expected: "dvar", found "object".: null.
I'm doing something wrong?
/***************************************************/
using CP;
int nbCars= ...; // # of cars
int nbOptions= ...;// # of options
int nbSlots= ...;// # of slots
range Cars= 1..nbCars;
range Options= 1..nbOptions;
range Slots= 1..nbSlots;
int demand[Cars] = ...;
int option[Options,Cars] = ...;
tuple Tcapacity{
int l;
int u;
};
Tcapacity capacity[Options] = ...;
int optionDemand[i in Options] = sum(j in Cars) demand[j] * option[i,j];
dvar int slot[Slots] in Cars;
dvar int setup[Options,Slots] in 0..1;
/* ::::::::::: Phase def for bi-dim dvars ::::::::::::::::::::*/
execute SearchPhases{
var vPhase= cp.factory;
var elements= (nbOptions* nbSlots) - 1
var phaseArray= new Array(elements);
var j= 0;
for(var iOpt= 1; iOpt==nbOptions; iOpt++)
for(var iSlot= 1; iSlot==nbSlots; iSlot++)
phaseArray[j]=setup[iOpt][iSlot]; j++;
/* This approach give me the error: Wrong argument type. Expected "dvar", found "object", "null" */
cp.setSearchPhases(vPhase.searchPhase(phaseArray));
}
/* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/
subject to{
// # of cars = demand
forall(c in Cars)
sum(s in Slots) (slot[s] == c) == demand[c];
forall(o in Options, s in 1..(nbSlots- capacity[o].u+ 1) )
sum(j in s..(s+ capacity[o].u- 1)) setup[o,j] <= capacity[o].l;
forall(o in Options, s in Slots)
setup[o,s] == option[o][slot[s]];
forall(o in Options, i in 1..optionDemand[o])
sum(s in 1.. (nbSlots- i* capacity[o].u)) setup[o,s] >=
optionDemand[o] - i* capacity[o].l;
};
#CPOptimizer#DecisionOptimization