generated from NREL-Sienna/Sienna-Template
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4e455f4
commit 14601b0
Showing
2 changed files
with
190 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
function OptimizationProblemResults(model::InvestmentModel) | ||
status = get_run_status(model) | ||
status != RunStatus.SUCCESSFULLY_FINALIZED && | ||
error("problem was not solved successfully: $status") | ||
|
||
model_store = get_store(model) | ||
|
||
if isempty(model_store) | ||
error("Model Solved as part of a Simulation.") | ||
end | ||
|
||
# TODO: Look at how timesteps are extracted from the model | ||
# timestamps = get_timestamps(model) | ||
optimizer_stats = IS.Optimization.to_dataframe(get_optimizer_stats(model)) | ||
|
||
aux_variable_values = | ||
Dict(x => read_aux_variable(model, x) for x in list_aux_variable_keys(model)) | ||
variable_values = Dict(x => read_variable(model, x) for x in list_variable_keys(model)) | ||
dual_values = Dict(x => read_dual(model, x) for x in list_dual_keys(model)) | ||
parameter_values = | ||
Dict(x => read_parameter(model, x) for x in list_parameter_keys(model)) | ||
expression_values = | ||
Dict(x => read_expression(model, x) for x in list_expression_keys(model)) | ||
|
||
sys = get_system(model) | ||
|
||
return OptimizationProblemResults( | ||
get_problem_base_power(model), | ||
timestamps, | ||
sys, | ||
IS.get_uuid(sys), | ||
aux_variable_values, | ||
variable_values, | ||
dual_values, | ||
parameter_values, | ||
expression_values, | ||
optimizer_stats, | ||
get_metadata(get_optimization_container(model)), | ||
IS.strip_module_name(typeof(model)), | ||
get_output_dir(model), | ||
mkpath(joinpath(get_output_dir(model), "results")), | ||
) | ||
end |