linear-programming - LP / MILP (CPLEX) 困难
问题描述
我正在尝试使用 CPLEX 解决优化问题。
//Variables
int n = ...;
range time =1..n; //n definido em data
dvar float+ c[time] in 0..0.9;
dvar float+ d[time] in 0..0.9;
dvar float+ x[time];
int beta[time]=...;
float pc[time]=...;
float pd[time]=...;
//Expressions
dexpr float objective = sum(t in time) (d[t]*pd[t]-c[t]*pc[t]);
//Model
maximize objective;
subject to {
x[1] == 0.5;
c[1] == 0;
d[1] == 0;
forall(t in time)
const1:
x[t] <= 1;
forall(t in time: t!=1)
const2:
(x[t] == x[t-1] + c[t] - beta[t]*d[t]);
}
谁能告诉我如何防止 d[t] 和 c[t] 同时大于 0?
基本上我想写这个:
if( d[t] > 0) c[t] = 0;
谢谢,
解决方案
您可以使用逻辑约束:
( d[t] <= 0) || (c[t] <= 0);
推荐阅读
- node.js - 如何将 NewRelic 集成到与 Webpack 捆绑的 Node Typescript Express 服务器中?
- html - 重新编码动态录制的音频流?
- javascript - 如何在 Chart.js 上设置 y 轴标签?
- amazon-web-services - 无法通过 boto3 删除 route53 记录集
- python - Django保存全局API客户端实例变量的正确方法
- javascript - 如何对键是数字字符串的数组进行排序
- python-3.x - 如何从 sympy 矩阵中选择多列?索引损坏?
- python - 仅将列表长度等于 1 的行转换为字符串
- python - 如何根据其他列中的两个条件在特定位置插入多列
- javascript - FormType 未在 Dynamics CRM 2016 上返回正确的值