Originally posted by: bluemoon32
Hello everyone. I wrote a code for a balanced transportation problem. I get the data from an excel file. My dat. and mod. files are below. I got an error when I run it, it says the size of the range is not the size of the array. I guess the problem is in the demand range. How can I solve this problem? I also attached the xlsx. file. Thank you.
dat. file
m=3;
n=4;
SheetConnection data ("Book1.xlsx");
supply from SheetRead (data,"supply");
demand from SheetRead (data,"demand");
cost from SheetRead (data,"cost");
mod. file
// parameters
int m=...; // Number of plants
int n=...; // Number of cities
range plants=1..m;
range cities=1..n;
float cost [cities]=...;
float supply [plants]=...;
float demand [plants]=...;
// Decision Variables
dvar float+ x[plants][cities];
minimize sum (i in plants, j in cities) cost[i] * x[i][j];
subject to {
forall(i in plants)
demandc:
sum(j in cities) x[i][j] <= supply[i];
forall(j in cities)
supplyc:
sum(i in plants) x[i][j] >= demand[j];
}
#DecisionOptimization#OPLusingCPLEXOptimizer