Skip to content
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

Display timer for energy problem #482

Merged
merged 7 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions src/run-scenario.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,24 @@ function run_scenario(
)
to = TimerOutput()

energy_problem =
@timeit to "create_energy_problem_from_csv_folder" create_energy_problem_from_csv_folder(
input_folder,
)
@timeit to "create_model!" create_model!(energy_problem; write_lp_file = write_lp_file)
@timeit to "solve_model!" solve_model!(energy_problem, optimizer; parameters = parameters)
elapsed_time_read_data = @elapsed begin
energy_problem =
@timeit to "create_energy_problem_from_csv_folder" create_energy_problem_from_csv_folder(
input_folder,
)
end

elapsed_time_create_model = @elapsed begin
@timeit to "create_model!" create_model!(energy_problem; write_lp_file = write_lp_file)
end

elapsed_time_solve_model = @elapsed begin
@timeit to "solve_model!" solve_model!(energy_problem, optimizer; parameters = parameters)
end

energy_problem.time_read_data = elapsed_time_read_data
energy_problem.time_create_model = elapsed_time_create_model
energy_problem.time_solve_model = elapsed_time_solve_model

if output_folder != ""
@timeit to "save_solution_to_file" save_solution_to_file(output_folder, energy_problem)
Expand Down
9 changes: 9 additions & 0 deletions src/structures.jl
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ mutable struct EnergyProblem
solved::Bool
objective_value::Float64
termination_status::JuMP.TerminationStatusCode
time_read_data::Float64
time_create_model::Float64
time_solve_model::Float64

"""
EnergyProblem(graph, representative_periods)
Expand All @@ -176,6 +179,9 @@ mutable struct EnergyProblem
false,
NaN,
JuMP.OPTIMIZE_NOT_CALLED,
NaN,
NaN,
NaN,
)
end
end
Expand All @@ -186,4 +192,7 @@ function Base.show(io::IO, ep::EnergyProblem)
println(io, " - Solved: ", ep.solved)
println(io, " - Termination status: ", ep.termination_status)
println(io, " - Objective value: ", ep.objective_value)
println(io, " - Time for reading the data (in seconds): ", ep.time_read_data)
println(io, " - Time for creating the model (in seconds): ", ep.time_create_model)
println(io, " - Time for solving the model (in seconds): ", ep.time_solve_model)
end
Loading