-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #988 from NREL-Sienna/jd/custom_model_improvements
Jd/custom model improvements
- Loading branch information
Showing
37 changed files
with
510 additions
and
1,259 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
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
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
50 changes: 50 additions & 0 deletions
50
docs/src/model_developer_guide/structure_of_operation_problem.md
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,50 @@ | ||
# Structure of an operations problem model | ||
|
||
In most cases operation problem models are optimization models. Although in `PowerSimulations.jl` it is | ||
possible to define arbitrary problems that can reflect heuristic decision rules, this is not the common case. This page focuses on explaining the structure of operations problems that employ an optimization problem and solver. | ||
|
||
The first aspect to consider when thinking about developing a model compatible with `PowerSimulations.jl` is that although we support all of `JuMP.jl` objects, you need to employ [anonymous constraints and variables in JuMP](https://jump.dev/JuMP.jl/stable/manual/variables/#anonymous_variables) | ||
and register the constraints, variables and other optimization objects into PowerSimulations.jl's optimization container. Otherwise the features to use your problem in the simulation like the coordination with other problems and post processing won't work. | ||
|
||
!!! info | ||
The requirements for the simulation of Power Systems operations are more strict than solving an optimization problem once with just `JuMP.jl`. The requirements imposed by `PowerSimulations.jl` to integrate your models in a simulation are designed to help with other complex operations that go beyond `JuMP.jl` scope. | ||
|
||
!!! warning | ||
All the code in this page is considered "pseudo-code". Copy-paste will likely not work out of the box. You need to develop the internals of the functions correctly for the examples below to work. | ||
|
||
## Registering a variable in the model | ||
|
||
To register a variable in the model, the developer must first allocate the container into the | ||
optimization container and then populate it. For example, it require start the build function as follows: | ||
|
||
!!! info | ||
We recommend calling `import PowerSimulations` and defining the constant `CONST PSI = PowerSimulations` to | ||
make it easier to read the code and determine which package is responsible for defining the functions. | ||
|
||
```julia | ||
function PSI.build_model!(model::PSI.DecisionModel{MyCustomModel}) | ||
container = PSI.get_optimization_container(model) | ||
PSI.set_time_steps!(container, 1:24) | ||
|
||
# Create the container for the variable | ||
variable = PSI.add_variable_container!( | ||
container, | ||
PSI.ActivePowerVariable(), # <- This variable is defined in PowerSimulations but the user can define their own | ||
PSY.ThermalGeneration, # <- Device type for the variable. Can be from PSY or custom defined | ||
devices_names, # <- First container dimension | ||
time_steps, # <- Second container dimension | ||
) | ||
|
||
# Iterate over the devices and time to store the JuMP variables into the container. | ||
for t in time_steps, d in devices | ||
name = PSY.get_name(d) | ||
variable[name, t] = JuMP.@variable(get_jump_model(container)) | ||
# It is possible to use PSY getter functions to retrieve data from the generators | ||
# Any other variable property can be specified inside this loop. | ||
JuMP.set_upper_bound(variable[name, t], UB_DATA) # <- Optional | ||
JuMP.set_lower_bound(variable[name, t], LB_DATA) # <- Optional | ||
end | ||
|
||
return | ||
end | ||
``` |
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
File renamed without changes.
Oops, something went wrong.
4fc6be7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator register()
4fc6be7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration pull request created: JuliaRegistries/General/90938
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: