Skip to content

Commit

Permalink
fix: get results with infeasible termination status instead of Runtim…
Browse files Browse the repository at this point in the history
…eError

Signed-off-by: Victor Garcia Reolid <[email protected]>
  • Loading branch information
victorgarcia98 committed Jul 23, 2023
1 parent ebbc65a commit 51a3148
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions flexmeasures/data/models/planning/linear_optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,16 @@ def cost_function(m):
model.costs = Objective(rule=cost_function, sense=minimize)

# Solve
results = SolverFactory(current_app.config.get("FLEXMEASURES_LP_SOLVER")).solve(
model
)
solver_name = current_app.config.get("FLEXMEASURES_LP_SOLVER")
opt = SolverFactory(solver_name)

if "highs" in solver_name.lower():
try:
results = opt.solve(model)
except RuntimeError:
results = opt.solve(model, load_solutions=False)
else:
results = opt.solve(model)

planned_costs = value(model.costs)
planned_power_per_device = []
Expand Down

0 comments on commit 51a3148

Please sign in to comment.