-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement solution saving and exporting for refactored code #1000
base: main
Are you sure you want to change the base?
Conversation
Benchmark Results
Benchmark PlotsA plot of the benchmark results have been uploaded as an artifact to the workflow run for this PR. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1000 +/- ##
==========================================
- Coverage 95.43% 95.06% -0.38%
==========================================
Files 29 29
Lines 1140 1155 +15
==========================================
+ Hits 1088 1098 +10
- Misses 52 57 +5 ☔ View full report in Codecov by Sentry. |
energy_problem.termination_status = JuMP.termination_status(model) | ||
if energy_problem.solution === nothing | ||
if energy_problem.termination_status != JuMP.OPTIMAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This option in JuMP is more generic, I propose using it instead of only the optimal condition:
if energy_problem.termination_status != JuMP.OPTIMAL | |
if !JuMP.is_solved_and_feasible(model) |
status = JuMP.termination_status(model) | ||
if status == JuMP.OPTIMIZE_NOT_CALLED | ||
@error("The model was not solved yet, use one of the solve_model functions") | ||
return | ||
elseif status != JuMP.OPTIMAL | ||
@error("The model was not solved to optimality, cannot get solution") | ||
return | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here the same, I propose simplifying like this:
status = JuMP.termination_status(model) | |
if status == JuMP.OPTIMIZE_NOT_CALLED | |
@error("The model was not solved yet, use one of the solve_model functions") | |
return | |
elseif status != JuMP.OPTIMAL | |
@error("The model was not solved to optimality, cannot get solution") | |
return | |
end | |
if !JuMP.is_solved_and_feasible(model) | |
@error("The model has a termination status: $JuMP.termination_status(model), with primal status $JuMP.primal_status(model), and dual status $JuMP.dual_status(model)") | |
return | |
end |
@@ -320,158 +320,52 @@ end | |||
save_solution_to_file(output_folder, energy_problem) | |||
|
|||
Saves the solution from `energy_problem` in CSV files inside `output_file`. | |||
Notice that this assumes that the solution has been computed by [`save_solution!`](@ref). | |||
""" | |||
function save_solution_to_file(output_folder, energy_problem::EnergyProblem) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To differentiate more from the save_solution
function and account for future options to export to another format, I propose renaming this function as export_solution_to_csv_files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @abelsiqueira; I have left some comments. Let me know what you think.
save_solution_to_file
Related issues
Closes #115
Closes #818
Checklist
I am following the contributing guidelines
Tests are passing
Lint workflow is passing
Docs were updated and workflow is passing