我需要使用选项";poolstub";但当我尝试检索它们时,我会出错。我会一步一步地解释一切。这是我的代码:
option solver cplex;
model my_model.mod;
data my_data.dat;
option cplex_options 'poolstub=multmip poolcapacity=10 populate=1 poolintensity=4 poolreplace=1';
solve;
在这一点上,AMPLE给了我这个:
CPLEX 20.1.0.0: poolstub=multmip
poolcapacity=10
populate=1
poolintensity=4
poolreplace=1
CPLEX 20.1.0.0: optimal solution; objective 4.153846154
66 dual simplex iterations (0 in phase I)
AMPL似乎没有将解决方案存储在池中。事实上,如果我试图用这个代码检索它们
for {i in 1..Current.npool} {
solution ('multmip' & i & '.sol');
display _varname, _var;
}
我得到这个错误:
Bad suffix .npool for Initial
context: for {i in >>> 1..Current.npool} <<< {
Possible suffix values for Initial.suffix:
astatus exitcode message relax
result sstatus stage
for{...} { ? ampl: for{...} { ? ampl:
我没有整数变量,只有实数变量,我读到CPLEX不支持线性程序的填充方法。这可能是问题所在,还是缺少其他东西?提前感谢
您已经正确地识别了您的问题。实体Initial
没有npool
后缀,这意味着解算器(在您的案例中为CPLEX(没有返回后缀。
Gurobi可以为线性程序返回该信息,但它似乎与最佳解决方案相同,因此不会给您任何额外的信息(更多关于AMPL Gurobi选项的信息(。
以下是AMPL脚本示例:
model net1.mod;
data net1.dat;
option solver gurobi;
option gurobi_options 'ams_stub=allopt ams_mode=1';
solve;
for {n in 1..Total_Cost.npool} {
solution ("allopt" & n & ".sol");
display Ship;
}
输出(在我的机器上(:
Gurobi 9.1.1: ams_stub=allopt
ams_mode=2
ams_epsabs=0.5
Gurobi 9.1.1: optimal solution; objective 1819
1 simplex iterations
Alternative MIP solution 1, objective = 1819
1 alternative MIP solutions written to "allopt1.sol"
... "allopt1.sol".
Alternative solutions do not include dual variable values.
Best solution is available in "allopt1.sol".
suffix npool OUT;
Alternative MIP solution 1, objective = 1819
Ship :=
NE BOS 90
NE BWI 60
NE EWR 100
PITT NE 250
PITT SE 200
SE ATL 70
SE BWI 60
SE EWR 20
SE MCO 50
;
文件net1.mod
和net1.dat
来自AMPL手册。
当求解MIP时,解算器可以存储它在过程中发现的次优解,因为出于某种原因,它们可能对建模者感兴趣。就LP而言,你对单纯形算法访问的顶点感兴趣吗?