You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何解决CPLEX模型运行出现的无可行解(Infeasible)问题?

CPLEX生产计划模型无可行解(Infeasible)修复求助

我编写的CPLEX生产计划模型运行后返回无可行解(Infeasible),尝试通过注释部分代码排查冲突约束但未解决问题。以下是模型代码、数据代码及相关信息,请求协助修复:

模型代码

// 索引定义
 int I=...;
 int R =...;
 int T=...;
 range items = 1..I;            // 生产系统中的产品索引i
 range resources = 1..R;        // 定义产能的生产资源索引r
 range times = 1..T;            // 计划周期内的离散时段索引t
 range trucks = 1..3;           // 物料清单中的产品j索引

 // 数据与参数
 int lamda=...;
 float d[items][times]=...;     // 时段t内产品i的独立(外部)需求
 float b[items][trucks]=...;    // 物料清单中,每单位产品j所需的产品i数量
 int tau[items]=...;            // 产品i的生产/采购提前期
 float f[items][resources]=...; // 生产单位产品i所需资源r的占比
 float w[items][resources]=...; // 产品i生产切换时所需资源r的占比
 float ma[resources][times]=...;// 时段t内资源r可新增的最大产能占比
 float e[items]=...;            // 产品i的库存准确率
 float l[items]=...;            // 产品i的最小生产批量
 float ac[resources][times]=...;// 时段t内资源r每新增单位产能占比的成本
 float wc[items]=...;           // 时段内启动产品i生产/采购的固定成本
 float sc[items]=...;           // 单位产品i每时段的库存持有成本
 float s0[items]=...;           // 产品i的初始在手库存
 int    h[items]=...;           // 生产/采购时间的最大松弛量
 float g[items][resources]=...; // 生产产能的最大容差
 float n[items]=...;            // 库存准确率的容差

 // 决策变量
 dvar int+ p[items][times];     // 时段t内产品i的产量
 dvar int+ S[items][times];     // 时段t末产品i的库存
 dvar int+ a[resources][times]; // 时段t内资源r新增的产能占比
 dvar int+ q[items][times];     // 产品i在时段t是否生产的二元指示变量
 // 辅助变量
dvar float+ sreal[items][times];

 // 目标函数
 minimize   sum(t in times, r in resources) a[r][t]*ac[r][t] + sum(t in times, i in items)q[i][t]*wc[i] + sum(t in times, i in items) e[i]*S[i][t]*sc[i]  ;

// 约束条件
subject to {
 // 资源产能约束
 forall(t in times, r in resources)
   sum (i in items)(p[i][t]*f[i][r] + q[i][t]*w[i][r]) <= 1 + a[r][t];  //(1)
 // 物料流平衡约束
 forall (i in items, t in times:(t-tau[i]) in times)
   sum (j in trucks) p[i][t]*b[i][j] + d[i][t] + e[i]*S[i][t] == e[i]*S[i][t-1] + p[i][t-tau[i]]; //(2)
 // 新增产能上限约束
 forall (r in resources, t in times)
   a[r][t] <= ma[r][t]; //(3)
 // 最小生产批量约束
 forall (i in items, t in times)
   p[i][t] >= q[i][t]*l[i]; //(4)
 // 带容差的资源产能约束
 forall(i in items, r in resources, t in times)
    sum(j in trucks) (p[i][t] * (f[i][r] + (1 - lamda) * q[i][t] * g[i][r]) + q[i][t] * w[i][r]) <= 1 + a[r][t];//(5)
 // 需求满足容差约束(上界)
 forall(i in items, t in times:(t - (tau[i] + (1 - lamda) * h[i])) in times)
    p[i][t - (tau[i] + (1 - lamda) * h[i])] + ((e[i] + n[i] * (1 - lamda)) * (S[i][t - 1] - S[i][t])) - sum(j in trucks) (p[i][t] * b[i][j]) <= d[i][t]; //(6)
 // 需求满足容差约束(下界)
 forall(i in items, t in times:(t - (tau[i] + (1 - lamda) * h[i])) in times)
    p[i][t - (tau[i] + (1 - lamda) * h[i])] + ((e[i] - n[i] * (1 - lamda)) * (S[i][t - 1] - S[i][t])) - sum(j in trucks) (p[i][t] * b[i][j]) >= d[i][t];  //(7) 
 // 库存真实值上界约束
 forall(i in items, t in times)
    (e[i] + n[i] * (1 - lamda)) * S[i][t] <= sreal[i][t]; //(8)
 // 库存真实值下界约束
 forall(i in items, t in times)
    (e[i] - n[i] * (1 - lamda)) * S[i][t] >= sreal[i][t];  //(9)
 }

数据代码

SheetConnection excelsheet("CAPSTONE-DATA.xlsx");
 
 I=193;
 R=4;
 T=24;
 lamda=1;
 d from SheetRead(excelsheet, "Sheet1!B2:Y194");
 b from SheetRead(excelsheet, "Sheet2!B2:D194");
 tau from SheetRead(excelsheet,"Sheet3!B2:B194");
 f from SheetRead(excelsheet, "Sheet4!B2:E194");
 w from SheetRead(excelsheet, "Sheet5!B2:E194");
 ma from SheetRead(excelsheet, "Sheet6!B2:Y5");
 e from SheetRead(excelsheet, "Sheet7!B2:B194");
 l from SheetRead(excelsheet, "Sheet8!B2:B194");
 ac from SheetRead(excelsheet, "Sheet9!B2:Y5");
 wc from SheetRead(excelsheet, "Sheet10!B2:B194");
 sc from SheetRead(excelsheet, "Sheet11!B2:B194");
 s0 from SheetRead(excelsheet, "Sheet12!B2:B194");
 h from SheetRead(excelsheet, "Sheet13!B2:B194");
 g from SheetRead(excelsheet, "Sheet14!B2:E194");
 n from SheetRead(excelsheet, "Sheet15!B2:B194");

数据说明:数据存储在名为CAPSTONE-DATA.xlsx的Excel文件中,涵盖193种产品、4类生产资源、24个计划周期,参数lamda取值为1。


内容的提问来源于stack exchange,提问作者Bún Real Cool

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.04 23:09:52