Skip to content

Commit

Permalink
Rename base periods to appropriate names (#556)
Browse files Browse the repository at this point in the history
  • Loading branch information
abelsiqueira authored Mar 18, 2024
1 parent 62ab5cb commit 1350c39
Show file tree
Hide file tree
Showing 40 changed files with 267 additions and 279 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion benchmark/EU/profiles-rep-periods-availability.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
,,,p.u.
profile_name,rep_period,time_step,value
profile_name,rep_period,timestep,value
NL_Wind_Onshore,1,1,0.007717831
NL_Wind_Onshore,1,2,0.006234769
NL_Wind_Onshore,1,3,0.007409822
Expand Down
2 changes: 1 addition & 1 deletion benchmark/EU/profiles-rep-periods-demand.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
,,,p.u.
profile_name,rep_period,time_step,value
profile_name,rep_period,timestep,value
NL_E_Demand,1,1,0.68144623
NL_E_Demand,1,2,0.666893812
NL_E_Demand,1,3,0.656786995
Expand Down
2 changes: 1 addition & 1 deletion benchmark/EU/profiles-rep-periods-inflows.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
,,,p.u.
profile_name,rep_period,time_step,value
profile_name,rep_period,timestep,value
BE_Hydro,1,1,0.4007930950734051
BE_Hydro,1,2,0.4007930950734051
BE_Hydro,1,3,0.4007930950734051
Expand Down
2 changes: 1 addition & 1 deletion benchmark/EU/rep-periods-data.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
,hours,,hours
id,weight,num_time_steps,resolution
id,weight,num_timesteps,resolution
1,1,8760,1.0
14 changes: 7 additions & 7 deletions benchmark/profiling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ end

#%%

@time graph, representative_periods, base_periods =
@time graph, representative_periods, timeframe =
create_graph_and_representative_periods_from_csv_folder(input_dir);
@benchmark create_graph_and_representative_periods_from_csv_folder($input_dir)
# @profview create_graph_and_representative_periods_from_csv_folder(input_dir);
Expand All @@ -50,17 +50,17 @@ end
#%%

@time dataframes =
construct_dataframes(graph, representative_periods, constraints_partitions, base_periods)
construct_dataframes(graph, representative_periods, constraints_partitions, timeframe)
@benchmark construct_dataframes(
$graph,
$representative_periods,
$constraints_partitions,
$base_periods,
$timeframe,
)
# @profview construct_dataframes($graph, $representative_periods, $constraints_partitions, $base_periods)
# @profview construct_dataframes($graph, $representative_periods, $constraints_partitions, $timeframe)

#%%

@time model = create_model(graph, representative_periods, dataframes, base_periods);
@benchmark create_model($graph, $representative_periods, $dataframes, $base_periods)
# @profview create_model(graph, representative_periods, dataframes, base_periods);
@time model = create_model(graph, representative_periods, dataframes, timeframe);
@benchmark create_model($graph, $representative_periods, $dataframes, $timeframe)
# @profview create_model(graph, representative_periods, dataframes, timeframe);
20 changes: 10 additions & 10 deletions docs/src/how-to-use.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ The `Missing` data meaning depends on the parameter, for instance:

- `investment_limit`: There is no investment limit.

#### `assets-base-periods-profiles.csv` and `assets-rep-periods-profiles.csv`
#### `assets-timeframe-profiles.csv` and `assets-rep-periods-profiles.csv`

These files contain the reference to profiles for each asset at each base period step, or at each representative period.
These files contain the reference to profiles for each asset at each period, or at each representative period.

#### `flows-rep-periods-profiles.csv`

Similar to their `asset` counterpart.

#### `profiles-base-periods-<type>.csv` and `profiles-rep-periods-<type>.csv`
#### `profiles-timeframe-<type>.csv` and `profiles-rep-periods-<type>.csv`

For each `type` defined in either `assets-*-periods-profiles` or `flows-rep-periods-profiles`, one of these files must exist.
They store the profile data as indexed by a profile name.
Expand Down Expand Up @@ -106,9 +106,9 @@ The table below shows various results for different formats for a representative

Similar to `assets-rep-periods-partitions.csv`, but for flows.

#### `assets-base-periods-partitions.csv`
#### `assets-timeframe-partitions.csv`

Similar to their `rep-periods` counterpart, but for the base periods.
Similar to their `rep-periods` counterpart, but for the timeframe.

#### `rep-periods-data.csv`

Expand Down Expand Up @@ -147,7 +147,7 @@ It hides the complexity behind the energy problem, making the usage more friendl
- `graph`: The [Graph](@ref) object that defines the geometry of the energy problem.
- `representative_periods`: A vector of [Representative Periods](@ref representative-periods).
- `constraints_partitions`: Dictionaries that connect pairs of asset and representative periods to [time partitions (vectors of time blocks)](@ref Partition).
- `base_periods`: The number of periods of the `representative_periods`.
- `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.
- `solved`: A boolean indicating whether the `model` has been solved or not.
Expand All @@ -161,7 +161,7 @@ It hides the complexity behind the energy problem, making the usage more friendl

The `EnergyProblem` can also be constructed using the minimal constructor below.

- `EnergyProblem(graph, representative_periods, base_periods)`: Constructs a new `EnergyProblem` object with the given graph, representative periods, and base periods. The `constraints_partitions` field is computed from the `representative_periods`, and the other fields are initialized with default values.
- `EnergyProblem(graph, representative_periods, timeframe)`: Constructs a new `EnergyProblem` object with the given graph, representative periods, and timeframe. The `constraints_partitions` field is computed from the `representative_periods`, and the other fields are initialized with default values.

See the [basic example tutorial](@ref basic-example) to see how these can be used.

Expand Down Expand Up @@ -227,9 +227,9 @@ The solution object is a NamedTuple 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, time_block]`: The flow value for a given flow `(u, v)` at a given representative period `rp`, and time block `time_block`. The list of time blocks is defined by `graph[(u, v)].partitions[rp]`.
- `storage_level_intra_rp[a, rp, time_block]`: The storage level for the storage asset `a` within (intra) a representative period `rp` and a time block `time_block`. The list of time blocks is defined by `constraints_partitions`, which was used to create the model.
- `storage_level_inter_rp[a, bp]`: The storage level for the storage asset `a` between (inter) representative periods in the base periods `bp`.
- `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`.

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

Expand Down
12 changes: 6 additions & 6 deletions docs/src/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ using TulipaEnergyModel
input_dir = "../../test/inputs/Tiny" # hide
# input_dir should be the path to Tiny
graph, representative_periods, base_periods = create_graph_and_representative_periods_from_csv_folder(input_dir)
graph, representative_periods, timeframe = create_graph_and_representative_periods_from_csv_folder(input_dir)
```

To create the model we also need a time partition for the constraints.
Expand All @@ -99,13 +99,13 @@ The `constraints_partitions` has two dictionaries with the keys `:lowest_resolut
Finally, we also need dataframes that store the linearized indexes of the variables.

```@example manual
dataframes = construct_dataframes(graph, representative_periods, constraints_partitions, base_periods)
dataframes = construct_dataframes(graph, representative_periods, constraints_partitions, timeframe)
```

Now we can compute the model.

```@example manual
model = create_model(graph, representative_periods, dataframes, base_periods)
model = create_model(graph, representative_periods, dataframes, timeframe)
```

Finally, we can compute the solution.
Expand Down Expand Up @@ -343,7 +343,7 @@ df = filter(
energy_problem.dataframes[:flows],
view = true,
)
[energy_problem.graph[u, v].flow[(rp, row.time_block)] for row in eachrow(df)]
[energy_problem.graph[u, v].flow[(rp, row.timesteps_block)] for row in eachrow(df)]
```

To create a vector with the all values of `storage_level_intra_rp` for a given `a` and `rp`, one can run
Expand All @@ -356,7 +356,7 @@ df = filter(
energy_problem.dataframes[:lowest_storage_level_intra_rp],
view = true,
)
[energy_problem.graph[a].storage_level_intra_rp[(rp, row.time_block)] for row in eachrow(df)]
[energy_problem.graph[a].storage_level_intra_rp[(rp, row.timesteps_block)] for row in eachrow(df)]
```

To create a vector with the all values of `storage_level_inter_rp` for a given `a`, one can run
Expand All @@ -368,7 +368,7 @@ df = filter(
energy_problem.dataframes[:storage_level_inter_rp],
view = true,
)
[energy_problem.graph[a].storage_level_inter_rp[row.base_period_block] for row in eachrow(df)]
[energy_problem.graph[a].storage_level_inter_rp[row.periods_block] for row in eachrow(df)]
```

### The solution inside the dataframes object
Expand Down
Loading

0 comments on commit 1350c39

Please sign in to comment.