【问题标题】:CPLEX ILOG - 3 Crops across 3 FarmsCPLEX ILOG - 3 个农场的 3 种作物
【发布时间】:2021-04-04 17:42:42
【问题描述】:

我正在尝试解决 3 个农场的 3 个作物的 9 个种植决策。

我获得了每个农场的可用土地、每个农场的可用水、每种作物的最大配额、每种作物的用水量以及每种作物的利润的数据。我不允许列出 .dat 文件中的所有系数。

以下是我在 .dat 文件中输入的内容:

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];

有 3 个限制条件:可用土地、可用水和最大配额。
目标是最大化利润。

以下是我在 .mod 文件中的内容,该文件(最终)没有错误地求解,但没有给我 Excel 求解器运行的正确答案。任何指导将不胜感激!

{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];
}

【问题讨论】:

    标签: linear-programming cplex ilog


    【解决方案1】:

    这看起来很可疑:

      forall(i in Farms)
        LandAcre[i]:
            sum(j in Crops, p in Farms)   ProductionAmount[j][p] <= UsableLand[i];
    

    应该是这样的:

      forall(i in Farms)
        LandAcre[i]:
            sum(j in Crops)   ProductionAmount[j][i] <= UsableLand[i];
    

    其他约束也一样。

    一个有用的调试工具是写出 LP 文件并检查它是否有意外情况。

    【讨论】:

    • 我更改为 dvar float+ ProductionAmount[Crops][Farms]; maximize sum(i in Crops) Profit[i]*ProductionAmount[i][i]; subject to { forall(i in Farms) LandAcre[i]: sum(j in Crops) ProductionAmount[j][i] &lt;= UsableLand[i]; forall(i in Farms) WaterAcre[i]: sum(j in Crops) WaterConsumption[j] &lt;= Water[i]; forall(i in Crops) CropLimit[i]: sum(j in Crops) ProductionAmount[j][i] &lt;= MaximumQuota[i]; } 并收到错误 Operator not available for int * dvar float+ [ ][Farms]
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多