Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jd/multiple fixes #1145

Merged
merged 72 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
eb5c88c
add two terminal constraints and variables
rodrigomha Aug 8, 2024
238d9b7
add PWL Flow Calculations
rodrigomha Aug 9, 2024
495a168
comment TODO
rodrigomha Aug 9, 2024
a76e640
add LL and UB for SOS variable
rodrigomha Aug 9, 2024
7e08060
add sparse method for PWL vars
rodrigomha Aug 14, 2024
aa97451
add SOS formulation
rodrigomha Aug 15, 2024
d46bd21
fix add to expression for PWL model
rodrigomha Aug 15, 2024
9203617
add Z,W model
rodrigomha Aug 15, 2024
9cc16bf
remove compact stuff
rodrigomha Sep 10, 2024
477a98b
add better variable names
rodrigomha Sep 11, 2024
377cf9c
fix addition
jd-lara Sep 17, 2024
298a709
add nonspin slack
rodrigomha Sep 17, 2024
9b20947
save fixed value for variable
jd-lara Sep 21, 2024
7d46f73
change implementation of must_run vars
jd-lara Sep 21, 2024
ba0bc69
change implementation of range constraints with must run
jd-lara Sep 21, 2024
cc436e1
WP fix addition to expressions
jd-lara Sep 21, 2024
6957939
remove JSON -> JSON3
jd-lara Sep 21, 2024
8c718ce
change use of onvar
jd-lara Sep 23, 2024
0ce9578
add new default
jd-lara Sep 23, 2024
1e5011f
WIP fix initial conditions
jd-lara Sep 23, 2024
aea5144
improve testing
jd-lara Sep 23, 2024
d1912be
save fixed value for variable
jd-lara Sep 21, 2024
42ac5e3
change implementation of must_run vars
jd-lara Sep 21, 2024
ddcb5dd
change implementation of range constraints with must run
jd-lara Sep 21, 2024
0dab167
WP fix addition to expressions
jd-lara Sep 21, 2024
36d1765
remove JSON -> JSON3
jd-lara Sep 21, 2024
236eda6
change use of onvar
jd-lara Sep 23, 2024
c734e78
add new default
jd-lara Sep 23, 2024
8ce9292
WIP fix initial conditions
jd-lara Sep 23, 2024
0b6baac
improve testing
jd-lara Sep 23, 2024
8fed4e8
Merge branch 'jd/multiple_fixes' of https://github.com/NREL-SIIP/Powe…
jd-lara Sep 23, 2024
2204b5b
add lp writter option
jd-lara Sep 23, 2024
066ac2d
WIP change IC handling for must run
jd-lara Sep 24, 2024
fa4c2fc
update tests
jd-lara Sep 25, 2024
a4fea25
update aux vars calculations
jd-lara Sep 25, 2024
6db1560
add missing method to avoid ambiguity
jd-lara Sep 25, 2024
283b6d0
use correct time in inicond
jd-lara Sep 25, 2024
17f30d0
Merge pull request #1147 from NREL-Sienna/rh/fix_compact_marketbid
jd-lara Sep 25, 2024
3e2354c
remove file write
jd-lara Sep 25, 2024
25ac4a5
fix json3 changes
jd-lara Sep 25, 2024
8172759
add additional aqua tests
jd-lara Sep 25, 2024
f0fade0
update function signature update initial conditions
jd-lara Sep 25, 2024
cfad9de
add cross package test
jd-lara Sep 25, 2024
ab0de86
remove debug
jd-lara Sep 25, 2024
88dfd7f
update tests
jd-lara Sep 27, 2024
a3a3f25
fix incorrect no load cost
jd-lara Sep 28, 2024
f617917
add monotonicity check
jd-lara Sep 28, 2024
dbd26d3
add must run to performance test
jd-lara Sep 30, 2024
fb967c5
fix pwl implementation for must run
jd-lara Oct 1, 2024
3074972
remove SOS formulation
rodrigomha Oct 1, 2024
7b42fe1
update twoterminal dispatch model
rodrigomha Oct 1, 2024
2fa41a2
remove HVDC losses in different asynch regions
rodrigomha Oct 1, 2024
de63f6f
bump PSY version
rodrigomha Oct 1, 2024
3c5d9db
Merge branch 'main' into rh/add_pwl_twoterminalhvdc
rodrigomha Oct 2, 2024
4d3770e
update PM translator
rodrigomha Oct 2, 2024
54d1d91
remove Direction Constraint
rodrigomha Oct 2, 2024
1ab2484
add HVDC losses to DCP model
rodrigomha Oct 2, 2024
48b82c6
add missing methods for ics
jd-lara Oct 4, 2024
f15d14a
handle thermal modeling
jd-lara Oct 4, 2024
33036f7
update ramp constraints
jd-lara Oct 4, 2024
d7def69
add must run conditionals
jd-lara Oct 4, 2024
4d537ac
fix recorder
jd-lara Oct 4, 2024
e4cf9ee
handle parameters and initial conditions
jd-lara Oct 4, 2024
98a66a7
update obj function
rodrigomha Oct 7, 2024
9bec277
update multiplier HVDC
rodrigomha Oct 7, 2024
7721814
update tests
rodrigomha Oct 7, 2024
a8899e3
update test values
rodrigomha Oct 7, 2024
85ca5cb
Merge pull request #1132 from NREL-Sienna/rh/add_pwl_twoterminalhvdc
jd-lara Oct 7, 2024
5848f77
add vom cost to objective
rodrigomha Oct 7, 2024
94a4e75
update name to onvar cost
rodrigomha Oct 7, 2024
7a21da9
use variable cost method
rodrigomha Oct 8, 2024
1482504
remove old constraint export
rodrigomha Oct 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/workflows/cross-package-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: CrossPackageTest

on:
push:
branches: [main]
tags: [v*]
pull_request:

jobs:
test:
name: Julia v${{ matrix.julia-version }} - ${{ matrix.package_name }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
julia-version: [1]
os: [ubuntu-latest]
package_name: [HydroPowerSimulations, StorageSystemsSimulations]
continue-on-error: true
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.julia-version }}
arch: x64
- uses: julia-actions/julia-buildpkg@latest
- name: Clone ${{matrix.package_name}}
uses: actions/checkout@v2
with:
repository: NREL-Sienna/${{matrix.package_name}}.jl
path: downstream
- name: Run the tests
shell: julia --project=downstream {0}
run: |
using Pkg
try
# Force it to use this PR's version of the package
Pkg.develop(PackageSpec(path=".")) # resolver may fail with main deps
Pkg.update()
Pkg.test() # resolver may fail with test time deps
catch err
err isa Pkg.Resolve.ResolverError || rethrow()
# If we can't resolve that means this is incompatible by SemVer, and this is fine.
# It means we marked this as a breaking change, so we don't need to worry about
# mistakenly introducing a breaking change as we have intentionally made one.
@info "Not compatible with this release. No problem." exception=err
exit(0) # Exit immediately, as a success
end
5 changes: 2 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,14 @@ DocStringExtensions = "~v0.9"
HDF5 = "~0.17"
InfrastructureSystems = "2"
InteractiveUtils = "1"
JSON = "0.21"
JSON3 = "1"
JuMP = "1"
LinearAlgebra = "1"
Logging = "1"
MathOptInterface = "1"
PowerModels = "^0.21"
PowerNetworkMatrices = "^0.11.1"
PowerSystems = "4"
PowerNetworkMatrices = "^0.11"
PowerSystems = "^4.4"
PrettyTables = "2"
ProgressMeter = "^1.5"
Serialization = "1"
Expand Down
1 change: 0 additions & 1 deletion docs/src/api/PowerSimulations.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,6 @@ FlowLimitConstraint
FlowRateConstraint
FlowRateConstraintFromTo
FlowRateConstraintToFrom
HVDCLossesAbsoluteValue
HVDCPowerBalance
NetworkFlowConstraint
RateLimitConstraint
Expand Down
1 change: 0 additions & 1 deletion src/PowerSimulations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,6 @@ import TimeSeries

# I/O Imports
import DataFrames
import JSON
import CSV
import HDF5
import PrettyTables
Expand Down
17 changes: 1 addition & 16 deletions src/core/constraints.jl
Original file line number Diff line number Diff line change
Expand Up @@ -332,23 +332,8 @@ The specified constraint is formulated as:
```
"""
struct PhaseAngleControlLimit <: ConstraintType end
"""
Struct to create the constraints that set the losses through a lossy HVDC two-terminal line.

For more information check [Branch Formulations](@ref PowerSystems.Branch-Formulations).

The specified constraints are formulated as:

```math
\\begin{align*}
& f_t^\\text{to-from} - f_t^\\text{from-to} \\le \\ell_t,\\quad \\forall t \\in \\{1,\\dots, T\\} \\\\
& f_t^\\text{from-to} - f_t^\\text{to-from} \\le \\ell_t,\\quad \\forall t \\in \\{1,\\dots, T\\}
\\end{align*}
```
"""
struct HVDCLossesAbsoluteValue <: ConstraintType end
struct HVDCDirection <: ConstraintType end
struct InterfaceFlowLimit <: ConstraintType end
struct HVDCFlowCalculationConstraint <: ConstraintType end

abstract type PowerVariableLimitsConstraint <: ConstraintType end
"""
Expand Down
5 changes: 5 additions & 0 deletions src/core/formulations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ struct HVDCTwoTerminalLossless <: AbstractTwoTerminalDCLineFormulation end
Branch type to represent lossy power flow on DC lines
"""
struct HVDCTwoTerminalDispatch <: AbstractTwoTerminalDCLineFormulation end
"""
Branch type to represent piecewise lossy power flow on two terminal DC lines
"""
struct HVDCTwoTerminalPiecewiseLoss <: AbstractTwoTerminalDCLineFormulation end

# Not Implemented
# struct VoltageSourceDC <: AbstractTwoTerminalDCLineFormulation end

Expand Down
12 changes: 9 additions & 3 deletions src/core/initial_conditions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Container for the initial condition data
"""
mutable struct InitialCondition{
T <: InitialConditionType,
U <: Union{JuMP.VariableRef, Float64},
U <: Union{JuMP.VariableRef, Float64, Nothing},
}
component::PSY.Component
value::U
Expand Down Expand Up @@ -39,16 +39,22 @@ function get_condition(
return jump_value(p.value)
end

function get_condition(
::InitialCondition{T, Nothing},
) where {T <: InitialConditionType}
return nothing
end

get_component(ic::InitialCondition) = ic.component
get_value(ic::InitialCondition) = ic.value
get_component_name(ic::InitialCondition) = PSY.get_name(ic.component)
get_component_type(ic::InitialCondition) = typeof(ic.component)
get_ic_type(
::Type{InitialCondition{T, U}},
) where {T <: InitialConditionType, U <: Union{JuMP.VariableRef, Float64}} = T
) where {T <: InitialConditionType, U <: Union{JuMP.VariableRef, Float64, Nothing}} = T
get_ic_type(
::InitialCondition{T, U},
) where {T <: InitialConditionType, U <: Union{JuMP.VariableRef, Float64}} = T
) where {T <: InitialConditionType, U <: Union{JuMP.VariableRef, Float64, Nothing}} = T

"""
Stores data to populate initial conditions before the build call
Expand Down
16 changes: 14 additions & 2 deletions src/core/optimization_container.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ function get_objective_expression(v::ObjectiveFunction)
if iszero(v.variant_terms)
return v.invariant_terms
else
return JuMP.add_to_expression!(v.variant_terms, v.invariant_terms)
# JuMP doesn't support expression conversion from Affn to QuadExpressions
if isa(v.invariant_terms, JuMP.GenericQuadExpr)
return JuMP.add_to_expression!(v.invariant_terms, v.variant_terms)
else
return JuMP.add_to_expression!(v.variant_terms, v.invariant_terms)
end
end
end
get_sense(v::ObjectiveFunction) = v.sense
Expand Down Expand Up @@ -1503,7 +1508,8 @@ function _add_initial_condition_container!(
else
param_type = Float64
end
ini_conds = Vector{InitialCondition{T, param_type}}(undef, length_devices)
ini_type = Union{InitialCondition{T, param_type}, InitialCondition{T, Nothing}}
ini_conds = Vector{ini_type}(undef, length_devices)
_assign_container!(container.initial_conditions, ic_key, ini_conds)
return ini_conds
end
Expand Down Expand Up @@ -1716,6 +1722,9 @@ function _process_duals(container::OptimizationContainer, lp_optimizer)
if JuMP.has_upper_bound(first(variable))
cache[key][:ub] = JuMP.upper_bound.(variable)
end
if JuMP.is_fixed(first(variable)) && is_integer_flag
cache[key][:fixed_int_value] = jump_value.(v)
end
cache[key][:integer] = is_integer_flag
JuMP.fix.(variable, var_cache[key]; force = true)
end
Expand Down Expand Up @@ -1756,6 +1765,9 @@ function _process_duals(container::OptimizationContainer, lp_optimizer)
else
JuMP.unfix.(variable)
JuMP.set_binary.(variable)
if haskey(cache[key], :fixed_int_value)
JuMP.fix.(variable, cache[key][:fixed_int_value])
end
#= Needed if a model has integer variables
if haskey(cache[key], :lb) && JuMP.has_lower_bound(first(variable))
JuMP.set_lower_bound.(variable, cache[key][:lb])
Expand Down
30 changes: 30 additions & 0 deletions src/core/variables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,36 @@ Docs abbreviation: ``u^\\text{dir}``
"""
struct HVDCFlowDirectionVariable <: VariableType end

"""
Struct to dispatch the creation of HVDC Received Flow at From Bus Variables for PWL formulations

Docs abbreviation: ``x``
"""
struct HVDCActivePowerReceivedFromVariable <: VariableType end

"""
Struct to dispatch the creation of HVDC Received Flow at To Bus Variables for PWL formulations

Docs abbreviation: ``y``
"""
struct HVDCActivePowerReceivedToVariable <: VariableType end

abstract type SparseVariableType <: VariableType end

"""
Struct to dispatch the creation of HVDC Piecewise Loss Variables

Docs abbreviation: ``h`` or ``w``
"""
struct HVDCPiecewiseLossVariable <: SparseVariableType end

"""
Struct to dispatch the creation of HVDC Piecewise Binary Loss Variables

Docs abbreviation: ``z``
"""
struct HVDCPiecewiseBinaryLossVariable <: SparseVariableType end

"""
Struct to dispatch the creation of piecewise linear cost variables for objective function

Expand Down Expand Up @@ -274,6 +302,8 @@ const START_VARIABLES = (HotStartVariable, WarmStartVariable, ColdStartVariable)

should_write_resulting_value(::Type{PieceWiseLinearCostVariable}) = false
should_write_resulting_value(::Type{PieceWiseLinearBlockOffer}) = false
should_write_resulting_value(::Type{HVDCPiecewiseLossVariable}) = false
should_write_resulting_value(::Type{HVDCPiecewiseBinaryLossVariable}) = false
convert_result_to_natural_units(::Type{ActivePowerVariable}) = true
convert_result_to_natural_units(::Type{PowerAboveMinimumVariable}) = true
convert_result_to_natural_units(::Type{ActivePowerInVariable}) = true
Expand Down
Loading
Loading