Performance¶
https://pascua.iit.comillas.edu/aramos/simio/transpa/s_GoodOptimizationModelingPracticesPyomo.pdf
Threads¶
solver.options['Threads'] = int(
(psutil.cpu_count(logical=True) + psutil.cpu_count(logical=False))/2
)
Sensitivity analysis with persistent solvers¶
Sequential resolution of similar problems in memory
solver.remove_constraint(model.ConstraintName)
model.del_component(model.SetName)
solver.add_constraint(model.ConstraintName)
Distributed computing¶
Create the problems and send them to be solved in parallel, and retrieve the solution once solved
model.ConstraintName.deactivate()
model.del_component(model.SetName)
model.ConstraintName.activate()
problem formulation performance¶
https://pianshen.com/ask/437410350304/
slow
def flows(model, et, t):
return pyo.quicksum(
model.in_flow[:, et, t],
linear=True,
start=pyo.quicksum(model.out_flow[:, et, t], linear=True)
) == 0
model.add_component(
'flows',
pyo.Constraint(model.energy_type, model.t, rule=flows)
)
It turns out the problem was with the slices [:, et, t]: