Originally posted by: K_Darkwah
Hi all,
I am a newbie in using OPL, but i have to figure this for my project due Thursay.
I have multilple biomass, potential plant and supply centers. The initial aim was to find the optimal plant location for various plants, for eg. if we decided we wanted one plant, for two etc. and this has been ok.
The next thing is to use trucks of different mass and sizes to haul the biomass and different trucks for the fuel. I taught of defining 3 binary variables (B1, B2, B3) and using these with the respective costs and then add the constraint B1+B2+B3 ==1 since we wanted to select the best truck. I wanted to use the big M to make use the truck that is chosen is used to transport the product but i am not sure if what i have written makes sense by using the number of trucks <=M*PlantOpen.
When I run the code i get errors like:
Description Resource Path Location Type
CPLEX(default) cannot extract expression: CSMass[d][b][(m)] / (12.35*B1+14.1192934782562*B2+15.7514925827285*B3). New CS Ferm Unknown OPL Problem Marker
Description Resource Path Location Type
CPLEX(default) cannot extract expression: EtOHVol[d][e][(m)] / (6060*B1+6928.17153669899*B2+7729.07247379229*B3). New CS Ferm Unknown OPL Problem Marker
Description Resource Path Location Type
CPLEX(default) cannot extract model: IloAlgorithm cannot extract extractable. New CS Ferm Unknown OPL Problem Marker
I know the division of the expressions below by B1, B2, B3 which a binary decision variables is causing the problem but I dont know how to fix this or other problems in the code. If what I have provided is not enough I can send the code to anyone willing to help me out. Thanks for your time.
Sample code
dvar boolean PlantOpen[PlantLocation];
dvar boolean B1;
dvar boolean B2;
dvar boolean B3;
dvar float+ CSMass[PlantLocation][BiomassLocation][ onth]; //Mass of biomass transported
dvar float+ CSAgedSupply[BiomassLocation][Month]; //Old stock of biomass
dvar float+ EtOHVol[PlantLocation][ProductLocation][Month]; // Gallons of Ethanol Shipped
dexpr float CSTotalSupply[b in BiomassLocation,m in Month]=CSAgedSupply[b][m]+CSNewSupply[b][m]; //Total biomass supply per month
dexpr float CSTrucks [d in PlantLocation,b in BiomassLocation,m in Month]=(CSMass[d][b]
[m]/(B1*CSTruckMassA+B2*CSTruckMassB+B3*CSTruckMassC)); // Number of Trucks to transport biomass
dexpr float EtOHTrucks[d in PlantLocation,e in ProductLocation,m in Month]=(EtOHVol[d][e][m]/((B1*EtOHTruckVolA)+B2*EtOHTruckVolB+B3*EtOHTruckVolC)); // Number of trucks to transport fuel
//making sure Truck that is chosen is used
forall(d in PlantLocation)
sum(b in BiomassLocation, m in Month)
/CSTrucksZ[d][b][m])<=M*(B1+B2+B3);
#DecisionOptimization#OPLusingCPLEXOptimizer