How to warmstart an LP basis other than m.read(file.bas)? var.VBasis =
回答済みI use a heuristic to generate a feasible LP basis and want to use the generated basis to warmstart gurobi (I am using gurobipy) solver.
consider a heuristic h(.):P ---> I_{B}$, where P encoding the parameters of the LP, and I_{B}\in{0,1}^{number of variables} is binary vector indicating which variables are basic and non-basic.
Simply, I want to initialize the m.VBasis of a model m with I_B.
I tried the following:
m.reset()
m.display()
m.update()
m.setParam("Method",0)
m.setParam("LPWarmStart",1)
for var, bas in zip(m.getVars(), I_B):
var.VBasis = bas
m.optimize()
But I got the following error:
Warning, invalid warm-start basis discarded
Gurobi Optimizer version 10.0.2 build v10.0.2rc0 (linux64)
CPU model: Intel(R) Xeon(R) CPU @ 2.20GHz, instruction set [SSE2|AVX|AVX2]
Thread count: 1 physical cores, 2 logical processors, using up to 2 threads
Warning, invalid warm-start basis discarded
Warning, invalid warm-start basis discarded
Optimize a model with 1563 rows, 1600 columns and 7567 nonzeros
Coefficient statistics:
Matrix range [1e+00, 4e+01]
Objective range [5e+00, 1e+03]
Bounds range [1e+00, 1e+00]
RHS range [1e+00, 4e+01]
Presolve removed 1 rows and 1 columns Presolve time: 0.02s
Presolved: 1562 rows, 1599 columns, 7566 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time 0 -5.9238592e+03 2.512500e+01 7.695986e+07 0s 303 3.2892842e+03 0.000000e+00 0.000000e+00 0s
Use crossover to convert LP symmetric solution to basic solution...
Crossover log... 0 DPushes remaining with DInf 0.0000000e+00 0s 11 PPushes remaining with PInf 0.0000000e+00 0s 0 PPushes remaining with PInf 0.0000000e+00 0s
Push phase complete: Pinf 0.0000000e+00, Dinf 2.7533531e-14 0s Iteration Objective Primal Inf. Dual Inf. Time 318 3.2892842e+03 0.000000e+00 0.000000e+00 0s
Solved in 318 iterations and 0.06 seconds (0.01 work units)
Optimal objective 3.289284196e+03
I have read the manual and searched the community posts but couldn't find a clear example. Any help is highly appreciated.
0
-
正式なコメント
This post is more than two years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum, or try Gurobot, our chatbot interface offering instant, expert-level support. -
Thanks for the clarification Riley. I tried
for var, bas in zip(m.getVars(), I_B):
var.VBasis = bas
for cont, bas in zip(m.getConstrs(), I_C):
cont.CBasis = basAnd it worked!
0 -
Good to hear! Thanks for update.
0
投稿コメントは受け付けていません。
コメント
4件のコメント