4. JuMP Model¶
In this page, we describe the JuMP optimization model produced by the function UnitCommitment.build_model
. A detailed understanding of this model is not necessary if you are just interested in using the package to solve some standard unit commitment cases, but it may be useful, for example, if you need to solve a slightly different problem, with additional variables and constraints. The notation in this page generally follows [KnOsWa20].
4.1. Decision variables¶
Generators¶
Name |
Symbol |
Description |
Unit |
---|---|---|---|
|
\(u_{g}(t)\) |
True if generator |
Binary |
|
\(v_{g}(t)\) |
True is generator |
Binary |
|
\(w_{g}(t)\) |
True if generator |
Binary |
|
\(p'_{g}(t)\) |
Amount of power produced by generator |
MW |
|
\(p^k_g(t)\) |
Amount of power from piecewise linear segment |
MW |
|
\(r_g(t)\) |
Amount of reserves provided by generator |
MW |
|
\(\delta^s_g(t)\) |
True if generator |
Binary |
Buses¶
Name |
Symbol |
Description |
Unit |
---|---|---|---|
|
\(n_b(t)\) |
Net injection at bus |
MW |
|
\(s^+_b(t)\) |
Amount of load curtailed at bus |
MW |
Price-sensitive loads¶
Name |
Symbol |
Description |
Unit |
---|---|---|---|
|
\(d_{s}(t)\) |
Amount of power served to price-sensitive load |
MW |
Transmission lines¶
Name |
Symbol |
Description |
Unit |
---|---|---|---|
|
\(f_l(t)\) |
Power flow on line |
MW |
|
\(f^+_l(t)\) |
Amount of flow above the limit for line |
MW |
Warning
Since transmission and N-1 security constraints are enforced in a lazy way, most of the flow[l,t]
variables are never added to the model. Accessing model[:flow][l,t]
without first checking that the variable exists will likely generate an error.
4.2. Objective function¶
where
\(\mathcal{B}\) is the set of buses
\(\mathcal{G}\) is the set of generators
\(\mathcal{L}\) is the set of transmission lines
\(\mathcal{PS}\) is the set of price-sensitive loads
\(\mathcal{S}_g\) is the set of start-up categories for generator \(g\)
\(\mathcal{T}\) is the set of time steps
\(C^\text{curtail}(t)\) is the curtailment penalty (in $/MW)
\(C^\text{min}_g(t)\) is the cost of keeping generator \(g\) on and producing at minimum power during time \(t\) (in $)
\(C^\text{overflow}_{l}(t)\) is the flow limit penalty for line \(l\) at time \(t\) (in $/MW)
\(C^k_g(t)\) is the cost for generator \(g\) to produce 1 MW of power at time \(t\) under piecewise linear segment \(k\)
\(C^s_{g}(t)\) is the cost of starting up generator \(g\) at time \(t\) under start-up category \(s\) (in $)
\(R_{s}(t)\) is the revenue obtained from serving price-sensitive load \(s\) at time \(t\) (in $/MW)
4.3. Constraints¶
TODO
4.4. Inspecting and modifying the model¶
Accessing decision variables¶
After building a model using UnitCommitment.build_model
, it is possible to obtain a reference to the decision variables by calling model[:varname][index]
. For example, model[:is_on]["g1",1]
returns a direct reference to the JuMP variable indicating whether generator named “g1” is on at time 1. The script below illustrates how to build a model, solve it and display the solution without using the function UnitCommitment.solution
.
using Cbc
using Printf
using JuMP
using UnitCommitment
# Load benchmark instance
instance = UnitCommitment.read_benchmark("matpower/case118/2017-02-01")
# Build JuMP model
model = UnitCommitment.build_model(
instance=instance,
optimizer=Cbc.Optimizer,
)
# Solve the model
UnitCommitment.optimize!(model)
# Display commitment status
for g in instance.units
for t in 1:instance.time
@printf(
"%-10s %5d %5.1f %5.1f %5.1f\n",
g.name,
t,
value(model[:is_on][g.name, t]),
value(model[:switch_on][g.name, t]),
value(model[:switch_off][g.name, t]),
)
end
end
Fixing variables, modifying objective function and adding constraints¶
Since we now have a direct reference to the JuMP decision variables, it is possible to fix variables, change the coefficients in the objective function, or even add new constraints to the model before solving it. The script below shows how can this be accomplished. For more information on modifying an existing model, see the JuMP documentation.
using Cbc
using JuMP
using UnitCommitment
# Load benchmark instance
instance = UnitCommitment.read_benchmark("matpower/case118/2017-02-01")
# Construct JuMP model
model = UnitCommitment.build_model(
instance=instance,
optimizer=Cbc.Optimizer,
)
# Fix a decision variable to 1.0
JuMP.fix(
model[:is_on]["g1",1],
1.0,
force=true,
)
# Change the objective function
JuMP.set_objective_coefficient(
model,
model[:switch_on]["g2",1],
1000.0,
)
# Create a new constraint
@constraint(
model,
model[:is_on]["g3",1] + model[:is_on]["g4",1] <= 1,
)
# Solve the model
UnitCommitment.optimize!(model)
Adding new component to a bus¶
The following snippet shows how to add a new grid component to a particular bus. For each time step, we create decision variables for the new grid component, add these variables to the objective function, then attach the component to a particular bus by modifying some existing model constraints.
using Cbc
using JuMP
using UnitCommitment
# Load instance and build base model
instance = UnitCommitment.read_benchmark("matpower/case118/2017-02-01")
model = UnitCommitment.build_model(
instance=instance,
optimizer=Cbc.Optimizer,
)
# Get the number of time steps in the original instance
T = instance.time
# Create decision variables for the new grid component.
# In this example, we assume that the new component can
# inject up to 10 MW of power at each time step, so we
# create new continuous variables 0 ≤ x[t] ≤ 10.
@variable(model, x[1:T], lower_bound=0.0, upper_bound=10.0)
# For each time step
for t in 1:T
# Add production costs to the objective function.
# In this example, we assume a cost of $5/MW.
set_objective_coefficient(model, x[t], 5.0)
# Attach the new component to bus b1, by modifying the
# constraint `eq_net_injection`.
set_normalized_coefficient(
model[:eq_net_injection]["b1", t],
x[t],
1.0,
)
end
# Solve the model
UnitCommitment.optimize!(model)
# Show optimal values for the x variables
@show value.(x)
4.5. References¶
[KnOsWa20] Bernard Knueven, James Ostrowski and Jean-Paul Watson. “On Mixed-Integer Programming Formulations for the Unit Commitment Problem”. INFORMS Journal on Computing (2020). DOI: 10.1287/ijoc.2019.0944