【发布时间】:2017-10-14 06:02:55
【问题描述】:
我想用 CPLEX-C# 解决 MILP 问题。我的问题很大,为了提高 CPU 时间,我想使用初始解决方案。我想将此解决方案添加到 cplex 并开始使用给定的初始解决方案来解决问题。我使用了以下代码:
try
{
startvar = new INumVar[numberOfAllNode * numberOfAllNode];
startval = new double[numberOfAllNode * numberOfAllNode];
for (int i = 0, idx = 0; i < numberOfAllNode; i++)
for (int j = 0; j < numberOfAllNode; j++)
{
startvar[idx] = X[i][j];
startval[idx] = start[i][j];
idx++;
}
startvar = null;
startval = null;
cplex.AddMIPStart(startvar, startval,Cplex.MIPStartEffort.SolveMIP);
}
catch (ILOG.Concert.Exception)
{
throw;
}
在这段代码中,我有多维数组决策变量X[i][j](二元决策变量),值等于start[i][j]。 start[i][j] 的值作为参数存储为double [] array。当我运行代码时,出现以下错误:
Warning: No solution found from 1 MIP starts.
Root node processing (before b&c):
Real time = 5.07 sec. (2238.50 ticks)
Parallel b&c, 4 threads:
Real time = 0.00 sec. (0.00 ticks)
Sync time (average) = 0.00 sec.
Wait time (average) = 0.00 sec.
------------
Total (root+branch&cut) = 5.07 sec. (2238.50 ticks)
Couldn't Solve The Problem!
我有两个问题: 1)我必须把这段代码放在模型的哪个部分? (我的意思是在所有约束之后添加目标值并调用 addMin 或 addMax 或在它们之前?)
2) 当我推荐startvar = null; startval = null;时出现以下错误:
An unhandled exception of type 'ILOG.CPLEX.Cplex.UnknownObjectException' occurred in CPLEX.exe
Additional information: CPLEX Error: object is unknown to IloCplex
如果您能帮忙解决这个问题,我将不胜感激。
【问题讨论】:
标签: c# cplex mixed-integer-programming