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

Change display of EnergyProblem variable #413

Merged
merged 4 commits into from
Jan 18, 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
3 changes: 3 additions & 0 deletions src/create-model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ function create_model!(energy_problem; kwargs...)
constraints_partitions = energy_problem.constraints_partitions
energy_problem.model =
create_model(graph, representative_periods, constraints_partitions; kwargs...)
energy_problem.termination_status = JuMP.OPTIMIZE_NOT_CALLED
energy_problem.solved = false
energy_problem.objective_value = NaN
return energy_problem
end

Expand Down
8 changes: 8 additions & 0 deletions src/structures.jl
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,11 @@ mutable struct EnergyProblem
)
end
end

function Base.show(io::IO, ep::EnergyProblem)
println(io, "EnergyProblem:")
println(io, " - Model created: ", !isnothing(ep.model))
println(io, " - Solved: ", ep.solved)
println(io, " - Termination status: ", ep.termination_status)
println(io, " - Objective_value: ", ep.objective_value)
end
1 change: 1 addition & 0 deletions test/test-case-studies.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ end
write_lp_file = true,
log_file = "model.log",
)
println(energy_problem)
@test energy_problem.objective_value ≈ 269238.43825 atol = 1e-5
end
end
Expand Down
Loading