I have a pretty big model (around 5 million variables and constraints).
The building time is a few minutes and the solving time is a few minutes too (with gurobi)
But it takes very long to write the model (about 2 hours)
This is the time if I use model.write('model.lp', io_options={'symbolic_solver_labels': True})
to be able to record it
It's about the same time if I use SolverFactory
and solve
directly the model from pyomo
here is a little sample, I understand that this model is trivial for gurobi, so I'm not comparing the solving time with the building time here, but I don't understand why it's so long, I though that the problem could come from the disk writing speed, but it seems that the disk is never overloaded and almost not used
import pyomo.environ as pyo
import time
size = 500000
model = pyo.ConcreteModel()
model.set = pyo.RangeSet(0, size)
model.x = pyo.Var(model.set, within=pyo.Reals)
model.constrList = pyo.ConstraintList()
for i in range(size):
model.constrList.add(expr = model.x[i] >= 1)
model.obj = pyo.Objective(expr=sum(model.x[i] for i in range(size)), sense=pyo.minimize)
opt = pyo.SolverFactory('gurobi')
_time = time.time()
res = opt.solve(model)
print(">>> total time () in {:.2f}s".format(time.time() - _time))
print(res)
the results are that the time of the whole solve function is 27 s, but the solving time of gurobi is only 4 s.