I am trying to solve 9 planting decisions for 3 crops on each of 3 farms.
I am given data for Available land on each farm, Available water on each farm, Maximum Quota for each crop, Water Consumption for each crop, and Profit for each crop. I am not allowed to list all of the coefficients in the .dat file.
Below is what I have entered in the .dat file:
Farms = {Rice,Barns,Snyder};
Crops = {Corn,Wheat,SoyBeans};
UsableLand = [400,600,300];
Water = [600,800,375];
MaximumQuota = [600,500,325];
WaterConsumption = [3,2,1];
Profit = [1000,750,250];
There are 3 constraints: Usable Land, Available water, and Maximum Quota.
The Objective is to maximize profit.
Below is what I have in the .mod file which is (finally) solving with no errors but not giving me the correct answer that Excel's solver runs. Any guidance would be greatly appreciated!
{string} Farms = ...;
{string} Crops = ...;
int UsableLand[Farms]=...;
int Water[Farms]=...;
int MaximumQuota[Crops]=...;
int WaterConsumption[Crops]=...;
int Profit[Crops]=...;
constraint LandAcre[Farms];
constraint WaterAcre[Farms];
constraint CropLimit[Crops];
dvar float+ ProductionAmount[Crops][Farms];
maximize
sum(i in Crops, p in Farms)
Profit[i]*ProductionAmount[i][p];
subject to {
forall(i in Farms)
LandAcre[i]:
sum(j in Crops, p in Farms) ProductionAmount[j][p] <= UsableLand[i];
forall(i in Farms)
WaterAcre[i]:
sum(j in Crops, p in Farms) WaterConsumption[j] <= Water[i];
forall(i in Crops)
CropLimit[i]:
sum(j in Crops, p in Farms) ProductionAmount[j][p] <= MaximumQuota[i];
}