Skip to content

Commit

Permalink
Reduced run_scenario from 2 functions to 1 with same functionality (#349
Browse files Browse the repository at this point in the history
)

* Reduced run_scenario from 2 functions to 1 with same functionality

* Apply suggestions from code review

Co-authored-by: Abel Soares Siqueira <nepper271@gmail.com>
Co-authored-by: Ni Wang <125902905+gnawin@users.noreply.github.com>

---------

Co-authored-by: Abel Soares Siqueira <nepper271@gmail.com>
Co-authored-by: Ni Wang <125902905+gnawin@users.noreply.github.com>
  • Loading branch information
3 people committed Dec 13, 2023
1 parent f5899c9 commit 56c8584
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions src/run-scenario.jl
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
export run_scenario

"""
run_scenario(input_folder)
run_scenario(input_folder, output_folder)
run_scenario(input_folder[, output_folder])
Run the scenario in the given input_folder and return the sets, parameters, and solution.
If the output_folder is specified, save the sets, parameters, and solution to the output_folder.
Run the scenario in the given `input_folder` and return the sets, parameters, and solution.
The `output_folder` is optional. If it is specified, save the sets, parameters, and solution to the `output_folder`.
"""
function run_scenario(input_folder::AbstractString; write_lp_file = false)
energy_problem = create_energy_problem_from_csv_folder(input_folder)
create_model!(energy_problem; write_lp_file = write_lp_file)
solve_model!(energy_problem)
return energy_problem
end

function run_scenario(
input_folder::AbstractString,
output_folder::AbstractString;
output_folder::String = "";
write_lp_file = false,
)
energy_problem = run_scenario(input_folder; write_lp_file)
save_solution_to_file(output_folder, energy_problem)
energy_problem = create_energy_problem_from_csv_folder(input_folder)
create_model!(energy_problem; write_lp_file = write_lp_file)
solve_model!(energy_problem)

output_folder == "" ? nothing : save_solution_to_file(output_folder, energy_problem)

return energy_problem
end

0 comments on commit 56c8584

Please sign in to comment.