在 cplex c++ 音乐会技术中从模型中删除约束
Removing constraint from a model in cplex c++ concert tech
>我有一个约束集
for(int t = 0; t < NbPeriods; t++){
for (int j =0; j < NbLocations; j++){
IloExpr Ct1(env);
for(int u = 0; u < t; u++){
Ct1 += Fortified[u][j];
}
model.add(Interdicted[t][j] <= 1 - Ct1);
}
}
经过一些修改后,我必须从模型中删除此约束集。 model.remove()
不起作用。在这种情况下,我如何使用IloRangeArray protection(env)
来做到这一点。
在添加到模型并保存在容器中(例如,IloConstraintArray
)之前,您需要通过IloConstraint
定义约束。Cplex 通过名称而不是表达式从模型中移除约束。在您的情况下,
IloConstraintArray cons_array(env);
for(int t = 0; t < NbPeriods; t++){
for (int j =0; j < NbLocations; j++){
IloExpr Ct1(env);
for(int u = 0; u < t; u++){
Ct1 += Fortified[u][j];
}
IloConstraint cons = Interdicted[t][j] <= 1 - Ct1;
model.add(cons);
cons_array.add(cons);
}
}
要删除
for (int i = 0; i < NbPeriods*NbLocations; i++)
model.remove( cons_array[i] );
您还可以使用 cplex.exportModel("model.lp")
在添加和移除约束后将模型导出到文件,并检查是否删除了约束
相关文章:
- 将数组的地址分配给变量并删除
- 删除一个线程上有数百万个字符串的大型哈希映射会影响另一个线程的性能
- C/C++编译器通常会删除重复的库吗
- 从链接列表c++中删除一个项目
- C++如何通过用户输入删除列表元素
- 为什么在C++中使用私有复制构造函数与删除复制构造函数
- 是否需要删除包含对象的"pair"?
- 如何在自删除后将对象设置为nullptr
- 迭代时从向量和内存中删除对象
- Qt创建者-如何删除Clang代码模型
- 在拖放 QML 列表中插入/删除项目使用 cpp 模型查看
- 使用自定义模型从Qtreeview删除行
- 在 gurobi c++ 中从模型中删除约束
- Qt:从视图中删除模型
- 在 cplex c++ 音乐会技术中从模型中删除约束
- 为什么QML正在删除我的C++ListView模型
- 我正在寻找一种在从模型中删除并重新添加修改后的可提取对象后操作 iloextract 对象的方法
- Qt5 C++:从QListView的模型中删除项目以及如何计算项目
- 从QStringListModel作为模型的QListview中删除单个项目
- 在QTableView的自定义模型中添加和删除项目