admin管理员组文章数量:1289528
I am using Pyomo with the HiGHS solver to optimize a model. The problem I am facing is that, after solving the model and loading the solution using model.solutions.load_from(opt_results), the values do not always remain consistent throughout the process.
With CBC, the solution was always stable across all steps. However, with HiGHS, the values printed immediately after solving (print_results(model)) do not always match the values accessed later inside add_iteration_result(model).
Here is the relevant part of my code:
# Optimizer launch
opt_results = pyomo.SolverFactory('appsi_highs').solve(model, load_solutions=False, timelimit=3000)
# opt_results.write() # (no solution, hence cannot write results)
# Creating results dictionary to export
optimizer_results = SC.SolverResults(
opt_results.Solver[0].Termination_condition, cap_cons,
opt_results.Solver[0].Termination_message, opt_results.Solver[0].system_time, capacity_factor
)
# Case 1: Feasible solution found
if opt_results.solver.termination_condition == TerminationCondition.optimal:
# Loading solutions because it is optimal
model.solutions.load_from(opt_results)
completed = True
# Print and plot results
Export.print_results(model)
# Save iteration result
ITERATION = Export.add_iteration_result(model, TIME, SECTORS, I, ITERATION)
# Create result
result = Export.create_feasible_result(SC, ITERATION, Cost, K, Cmax, HEC, m, optimizer_results, model)
I previously used CBC with the same code:
opt_results = pyomo.SolverFactory('cbc').solve(model)
opt_results.write()
With CBC, the solution was always consistent across the entire process. With HiGHS, sometimes the values retrieved later do not match those initially printed.
It seems like model.solutions.load_from(opt_results) does not persist the solution properly when using HiGHS.
Has anyone else encountered this issue? Is there a better way to ensure HiGHS' solution is correctly loaded into the model?
本文标签: optimizationPyomoHiGHS Solution values sometimes change after loading the resultsStack Overflow
版权声明:本文标题:optimization - Pyomo + HiGHS: Solution values sometimes change after loading the results - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741441355a2378937.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论