Skip to content

Commit

Permalink
Update energy_problem.solution documentation (#551)
Browse files Browse the repository at this point in the history
  • Loading branch information
clizbe committed Mar 20, 2024
1 parent d49ba31 commit a1985e2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
8 changes: 5 additions & 3 deletions docs/src/how-to-use.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ It hides the complexity behind the energy problem, making the usage more friendl
- `timeframe`: The number of periods of the `representative_periods`.
- `dataframes`: The data frames used to linearize the variables and constraints. These are used internally in the model only.
- `model`: A JuMP.Model object representing the optimization model.
- `solution`: A structure of the variable values (investments, flows, etc) in the solution.
- `solved`: A boolean indicating whether the `model` has been solved or not.
- `objective_value`: The objective value of the solved problem.
- `termination_status`: The termination status of the optimization model.
Expand Down Expand Up @@ -222,14 +223,15 @@ Nothing is defined outside of these time steps, so, for instance, if the represe

### Solution

The solution object is a NamedTuple with the following fields:
The solution object `energy_problem.solution` is a mutable struct with the following fields:

- `objective_value`: A Float64 with the objective value at the solution.
- `assets_investment[a]`: The investment for each asset, indexed on the investable asset `a`.
- `flows_investment[u, v]`: The investment for each flow, indexed on the investable flow `(u, v)`.
- `flow[(u, v), rp, timesteps_block]`: The flow value for a given flow `(u, v)` at a given representative period `rp`, and time block `timesteps_block`. The list of time blocks is defined by `graph[(u, v)].partitions[rp]`.
- `storage_level_intra_rp[a, rp, timesteps_block]`: The storage level for the storage asset `a` within (intra) a representative period `rp` and a time block `timesteps_block`. The list of time blocks is defined by `constraints_partitions`, which was used to create the model.
- `storage_level_inter_rp[a, pb]`: The storage level for the storage asset `a` between (inter) representative periods in the periods block `pb`.
- `flow[(u, v), rp, timesteps_block]`: The flow value for a given flow `(u, v)` at a given representative period. `rp`, and time block `timesteps_block`. The list of time blocks is defined by `graph[(u, v)].partitions[rp]`.
- `objective_value`: A Float64 with the objective value at the solution.
- `duals`: A Dict containing the dual variables of selected constraints.

For tips on manipulating the solution, check the [tutorial](@ref solution-tutorial).

Expand Down
22 changes: 12 additions & 10 deletions src/solve-model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,7 @@ The keyword argument `parameters` should be passed as a list of `key => value` p
These can be created manually, obtained using [`default_parameters`](@ref), or read from a file
using [`read_parameters_from_file`](@ref).
The `solution` object is a NamedTuple with the following fields:
- `objective_value`: A Float64 with the objective value at the solution.
The `solution` object is a mutable struct with the following fields:
- `assets_investment[a]`: The investment for each asset, indexed on the investable asset `a`.
To create a traditional array in the order given by the investable assets, one can run
Expand All @@ -118,13 +116,6 @@ The `solution` object is a NamedTuple with the following fields:
```
[solution.flows_investment[(u, v)] for (u, v) in edge_labels(graph) if graph[u, v].investable]
```
- `flow[(u, v), rp, timesteps_block]`: The flow value for a given flow `(u, v)` at a given representative period
`rp`, and time block `timesteps_block`. The list of time blocks is defined by `graph[(u, v)].partitions[rp]`.
To create a vector with all values of `flow` for a given `(u, v)` and `rp`, one can run
```
[solution.flow[(u, v), rp, timesteps_block] for timesteps_block in graph[u, v].partitions[rp]]
```
- `storage_level_intra_rp[a, rp, timesteps_block]`: The storage level for the storage asset `a` for a representative period `rp`
and a time block `timesteps_block`. The list of time blocks is defined by `constraints_partitions`, which was used
to create the model.
Expand All @@ -139,6 +130,17 @@ The `solution` object is a NamedTuple with the following fields:
```
[solution.storage_level_inter_rp[a, bp] for bp in graph[a].timeframe_partitions[a]]
```
- `flow[(u, v), rp, timesteps_block]`: The flow value for a given flow `(u, v)` at a given representative period
`rp`, and time block `timesteps_block`. The list of time blocks is defined by `graph[(u, v)].partitions[rp]`.
To create a vector with all values of `flow` for a given `(u, v)` and `rp`, one can run
```
[solution.flow[(u, v), rp, timesteps_block] for timesteps_block in graph[u, v].partitions[rp]]
```
- `objective_value`: A Float64 with the objective value at the solution.
```
- `duals`: A NamedTuple containing the dual variables of selected constraints.
```
## Examples
Expand Down

0 comments on commit a1985e2

Please sign in to comment.