Evaluators
FullSpaceEvaluator
Argos.FullSpaceEvaluator
— TypeFullSpaceEvaluator{T, VI, VT, MT} <: AbstractNLPEvaluator
Structure to evaluate the optimal power flow problem in the full-space.
When a new point x
is passed to the evaluator, one has to refresh the internal stack
by calling the function update!
Examples
julia> flp = Argos.FullSpaceEvaluator(ExaPF.load_polar("case9.m"))
A FullSpaceEvaluator object
* device: CPU()
* #vars: 19
* #cons: 36
julia> x = Argos.initial(flp)
19-element Vector{Float64}:
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
1.0
1.0
1.0
1.0
1.0
1.0
1.0
1.0
1.0
1.63
0.85
julia> Argos.update!(flp, x); # update values in stack
julia> Argos.objective(flp, x) # get objective
4509.0275
ReducedSpaceEvaluator
Argos.ReducedSpaceEvaluator
— TypeReducedSpaceEvaluator{T, VI, VT, MT} <: AbstractNLPEvaluator
Reduced-space evaluator projecting the optimal power flow problem into the powerflow manifold defined by the nonlinear equation $g(x, u) = 0$. The state $x(u)$ is defined implicitly, as a function of the control $u$. Hence, the powerflow equation is implicitly satisfied when we are using this evaluator.
Once a new point u
is passed to the evaluator, the user needs to call the method update!
to find the corresponding state $x(u)$ satisfying the balance equation $g(x(u), u) = 0$ and refresh the values in the internal stack.
Taking as input an ExaPF.PolarForm
structure, the reduced evaluator builds the bounds corresponding to the control u
, The reduced evaluator could be instantiated on the host memory, or on a specific device (currently, only CUDA is supported).
Examples
julia> nlp = Argos.ReducedSpaceEvaluator(ExaPF.load_polar("case9.m"))
A ReducedSpaceEvaluator object
* device: CPU()
* #vars: 5
* #cons: 28
* linear solver: ExaPF.LinearSolvers.DirectSolver{SuiteSparse.UMFPACK.UmfpackLU{Float64, Int64}}
julia> u = Argos.initial(nlp)
5-element Vector{Float64}:
1.0
1.0
1.0
1.63
0.85
julia> Argos.update!(nlp, u); # solve power-flow
julia> obj = Argos.objective(nlp, u); # get objective
julia> obj ≈ 5438.323706
true
If a GPU is available, we could instantiate nlp
as
julia> nlp_gpu = ReducedSpaceEvaluator(datafile; device=CUDADevice())
A ReducedSpaceEvaluator object
* device: KernelAbstractions.CUDADevice()
* #vars: 5
* #cons: 10
* constraints:
- voltage_magnitude_constraints
- active_power_constraints
- reactive_power_constraints
* linear solver: ExaPF.LinearSolvers.DirectSolver()
Note
Mathematically, we set apart the state $x$ from the control $u$. In the implementation of ReducedSpaceEvaluator
, we only deal with a control u
and an attribute stack
, storing all the physical values needed to describe the network. The attribute buffer
stores the values of the control u
and the state x
Each time we are calling the method update!
, the values of the control are copied into the buffer.
SlackEvaluator
Argos.SlackEvaluator
— TypeSlackEvaluator{Evaluator<:AbstractNLPEvaluator, T, VT} <: AbstractNLPEvaluator
Reformulate a problem with inequality constraints as an equality constrained problem, by introducing a set of slack variables.
Description
A SlackEvaluator
takes as input an original AbstractNLPEvaluator
, subject to inequality constraints
\[\begin{aligned} \min_{u \in \mathbb{R}^n} \quad & f(u)\\ \mathrm{s.t.} \quad & h^♭ ≤ h(u) ≤ h^♯,\\ & u^♭ ≤ u ≤ u^♯. \end{aligned}\]
The SlackEvaluator
instance rewrites this problem with inequalities as a new problem comprising only equality constraints, by introducing $m$ slack variables $s_1, ⋯, s_m$. The new problem writes out
\[\begin{aligned} \min_{u \in \mathbb{R}^n, s \in \mathbb{R}^m} \quad & f(u)\\ \mathrm{s.t.} \quad & h(u) - s = 0 \\ & u^♭ ≤ u ≤ u^♯, \\ & h^♭ ≤ s ≤ h^♯. \end{aligned}\]
Attributes
inner::Evaluator
: original evaluators_min::VT
: stores lower bounds for slack variabless_max::VT
: stores upper bounds for slack variablesnv::Int
: number of original variablesns::Int
: number of slack variables
AugLagEvaluator
Argos.AugLagEvaluator
— TypeAugLagEvaluator{Evaluator<:AbstractNLPEvaluator, T, VT} <: AbstractPenaltyEvaluator
Augmented-Lagrangian evaluator.
Description
Takes as input any AbstractNLPEvaluator
encoding a non-linear problem
\[\begin{aligned} \min_u \quad & f(u)\\ \mathrm{s.t.} \quad & h^♭ ≤ h(u) ≤ h^♯,\\ & u^♭ ≤ u ≤ u^♯, \end{aligned}\]
and return a new evaluator reformulating the original problem by moving the $m$ constraints $h^♭ ≤ h(u) ≤ h^♯$ into the objective using a set of penalties $ϕ_1, ⋯, ϕ_m$ and multiplier estimates $λ_1, ⋯, λ_m$:
\[\begin{aligned} \min_u \quad & f(u) + \sum_{i=1}^m ϕ_i(h_i, λ_i) \\ \mathrm{s.t.} \quad & u^♭ ≤ u ≤ u^♯, \end{aligned}\]
This evaluator considers explicitly the inequality constraints, without reformulating them by introducing slack variables. Each penalty $ϕ_i$ is defined as
\[ϕ_i(h_i, λ_i) = λ_i^⊤ φ_i(h_i) + \frac \rho2 \| φ_i(h_i) \|_2^2\]
with $φ_i$ a function to compute the current infeasibility
\[φ_i(h_i, λ_i) = \max\{0 , λ_i + ρ (h_i - h_i^♯) \} + \min\{0 , λ_i + ρ (h_i - h_i^♭) \}\]
Attributes
inner::Evaluator
: original problem.cons_type
: type of the constraints of the original problem (equalities or inequalities).cons::VT
: a buffer storing the current evaluation of the constraints for the inner evaluator.rho::T
: current penalty.λ::VT
: current multiplier.scaler::MaxScaler{T,VT}
: a scaler to rescale the range of the constraints in the original problem.
BridgeDeviceEvaluator
Argos.BridgeDeviceEvaluator
— TypeBridgeDeviceEvaluator{Evaluator, DVT, DMT} <: AbstractNLPEvaluator
Bridge an evaluator nlp
instantiated on the device to use it on the host memory. The bridge evaluator moves the data between the host and device automatically.
Example
julia> polar = ExaPF.load_polar("case9.m", CUDADevice())
# Load an evaluator on a CUDA GPU
julia> flp = Argos.FullSpaceEvaluator(polar)
julia> bdg = Argos.bridge(flp)
julia> x = Argos.initial(bdg)
julia> @assert isa(x, Array) # x is defined on the host memory
julia> Argos.objective(bdg, x) # evaluate the objective on the device