diff --git a/.github/workflows/performance_comparison.yml b/.github/workflows/performance_comparison.yml new file mode 100644 index 0000000000..6166364b58 --- /dev/null +++ b/.github/workflows/performance_comparison.yml @@ -0,0 +1,72 @@ +name: 'Performance Comparison' + +on: + pull_request: + +jobs: + comparison: + runs-on: ubuntu-latest + steps: + - uses: julia-actions/setup-julia@latest + - uses: actions/checkout@v1 + - name: Run Perfomance Test Master + run: | + julia --project=test -e 'using Pkg; Pkg.add(PackageSpec(name="PowerSimulationsDynamics", rev="master")); Pkg.instantiate()' + julia -t 4 --project=test test/performance/performance_test.jl "Master" + - name: Run Perfomance Test Branch + run: | + julia --project=test -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()' + julia -t 4 --project=test test/performance/performance_test.jl "This Branch" + - name: Read precompile results + id: precompile_results + run: | + body="$(cat precompile_time.txt)" + body="${body//'%'/'%25'}" + body="${body//$'\n'/'%0A'}" + body="${body//$'\r'/'%0D'}" + echo "::set-output name=body::$body" + - name: Read build results + id: build_results + run: | + body="$(cat build_time.txt)" + body="${body//'%'/'%25'}" + body="${body//$'\n'/'%0A'}" + body="${body//$'\r'/'%0D'}" + echo "::set-output name=body::$body" + - name: Find Comment + uses: peter-evans/find-comment@v1 + id: fc + with: + issue-number: ${{ github.event.pull_request.number }} + comment-author: 'github-actions[bot]' + body-includes: Performance Results + - name: Create comment + if: steps.fc.outputs.comment-id == '' + uses: peter-evans/create-or-update-comment@v1 + with: + issue-number: ${{ github.event.pull_request.number }} + body: | + Performance Results + | Version | Precompile Time | + | :--- | :----: | + ${{ steps.precompile_results.outputs.body }} + + | Version | Build Time | + | :--- | :----: | + ${{ steps.build_results.outputs.body }} + - name: Update comment + if: steps.fc.outputs.comment-id != '' + uses: peter-evans/create-or-update-comment@v1 + with: + comment-id: ${{ steps.fc.outputs.comment-id }} + body: | + Performance Results + | Version | Precompile Time | + | :--- | :----: | + ${{ steps.precompile_results.outputs.body }} + + | Version | Build Time | + | :--- | :----: | + ${{ steps.build_results.outputs.body }} + + edit-mode: replace diff --git a/Project.toml b/Project.toml index ba1fac5459..f9ae3cb889 100644 --- a/Project.toml +++ b/Project.toml @@ -19,7 +19,6 @@ JuMP = "4076af6c-e467-56ae-b986-b466b2749572" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" Logging = "56ddb016-857b-54e1-b83d-db4d58db5568" MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee" -ParameterJuMP = "774612a8-9878-5177-865a-ca53ae2495f9" Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" PowerModels = "c36e90e8-916a-50a6-bd94-075b64ef4655" PowerSystems = "bcd98974-b02a-5e2f-9ee0-a103f5c450dd" @@ -41,7 +40,6 @@ JSON = "0.21" JSON3 = "1" JuMP = "1" MathOptInterface = "1" -ParameterJuMP = "~v0.4" PowerModels = "~0.19" PowerSystems = "^1.24" PrettyTables = "^1.3, 2" diff --git a/README.md b/README.md index 70c41b1c67..668bc44860 100644 --- a/README.md +++ b/README.md @@ -21,24 +21,25 @@ The flexible modeling framework is enabled through a modular set of capabilities For example, an annual production cost modeling simulation can be created by formulating a unit commitment model against system data to assemble a set of 365 daily time-coupled scheduling problems. -### _Simulations_ enabled by PowerSimulations +## Simulations enabled by PowerSimulations +- Integrated Resource Planning - Production Cost Modeling -### _Model_ formulations contained in PowerSimulations +## Opertation model formulations contained in PowerSimulations - [Unit Commitment](https://en.wikipedia.org/wiki/Unit_commitment_problem_in_electrical_power_production) - [Economic Dispatch](https://en.wikipedia.org/wiki/Economic_dispatch) -### Installation +## Installation ```julia julia> ] -(v1.6) pkg> add PowerSystems -(v1.6) pkg> add PowerSimulations +(v1.8) pkg> add PowerSystems +(v1.8) pkg> add PowerSimulations ``` -### Usage +## Usage `PowerSimulations.jl` uses [PowerSystems.jl](https://github.com/NREL/PowerSystems.jl) to handle the data used in the simulations. diff --git a/src/PowerSimulations.jl b/src/PowerSimulations.jl index df24527992..eddee7a92a 100644 --- a/src/PowerSimulations.jl +++ b/src/PowerSimulations.jl @@ -367,7 +367,6 @@ import JuMP: optimizer_with_attributes import JuMP.Containers: DenseAxisArray, SparseAxisArray export optimizer_with_attributes import MathOptInterface -import ParameterJuMP import LinearAlgebra import JSON3 import PowerSystems @@ -425,7 +424,6 @@ const PSI = PowerSimulations const IS = InfrastructureSystems const MOI = MathOptInterface const MOIU = MathOptInterface.Utilities -const PJ = ParameterJuMP const MOPFM = MOI.FileFormats.Model const TS = TimeSeries diff --git a/src/core/definitions.jl b/src/core/definitions.jl index c27351fe9d..5406c55f11 100644 --- a/src/core/definitions.jl +++ b/src/core/definitions.jl @@ -10,15 +10,22 @@ const BUILD_PROBLEMS_TIMER = TimerOutputs.TimerOutput() const RUN_OPERATION_MODEL_TIMER = TimerOutputs.TimerOutput() const RUN_SIMULATION_TIMER = TimerOutputs.TimerOutput() -# Type Alias for JuMP and PJ containers -const PGAE = PJ.ParametrizedGenericAffExpr{Float64, JuMP.VariableRef} +# Type Alias for JuMP containers const GAE = JuMP.GenericAffExpr{Float64, JuMP.VariableRef} const JuMPAffineExpressionArray = Matrix{GAE} const JuMPAffineExpressionVector = Vector{GAE} const JuMPConstraintArray = DenseAxisArray{JuMP.ConstraintRef} -const JuMPVariableArray = DenseAxisArray{JuMP.VariableRef} -const JuMPParamArray = DenseAxisArray{PJ.ParameterRef} +const JuMPVariableMatrix = DenseAxisArray{ + JuMP.VariableRef, + 2, + Tuple{Vector{String}, UnitRange{Int64}}, + Tuple{ + JuMP.Containers._AxisLookup{Dict{String, Int64}}, + JuMP.Containers._AxisLookup{Tuple{Int64, Int64}}, + }, +} const JuMPFloatArray = DenseAxisArray{Float64} +const JuMPVariableArray = DenseAxisArray{JuMP.VariableRef} # Settings constants const UNSET_HORIZON = 0 diff --git a/src/core/initial_conditions.jl b/src/core/initial_conditions.jl index 3b037fdad8..5aa560332d 100644 --- a/src/core/initial_conditions.jl +++ b/src/core/initial_conditions.jl @@ -19,7 +19,7 @@ get_component_type(::ICKey{T, U}) where {T <: InitialConditionType, U <: PSY.Com """ Container for the initial condition data """ -struct InitialCondition{T <: InitialConditionType, U <: Union{PJ.ParameterRef, Float64}} +struct InitialCondition{T <: InitialConditionType, U <: Union{JuMP.VariableRef, Float64}} component::PSY.Component value::U end @@ -28,7 +28,7 @@ function InitialCondition( ::Type{T}, component::PSY.Component, value::U, -) where {T <: InitialConditionType, U <: Union{PJ.ParameterRef, Float64}} +) where {T <: InitialConditionType, U <: Union{JuMP.VariableRef, Float64}} return InitialCondition{T, U}(component, value) end @@ -39,7 +39,7 @@ function InitialCondition( ) where { T <: InitialConditionType, U <: PSY.Component, - V <: Union{PJ.ParameterRef, Float64}, + V <: Union{JuMP.VariableRef, Float64}, } return InitialCondition{T, U}(component, value) end @@ -49,7 +49,7 @@ function get_condition(p::InitialCondition{T, Float64}) where {T <: InitialCondi end function get_condition( - p::InitialCondition{T, PJ.ParameterRef}, + p::InitialCondition{T, JuMP.VariableRef}, ) where {T <: InitialConditionType} return jump_value(p.value) end @@ -60,10 +60,10 @@ 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{PJ.ParameterRef, Float64}} = T +) where {T <: InitialConditionType, U <: Union{JuMP.VariableRef, Float64}} = T get_ic_type( ::InitialCondition{T, U}, -) where {T <: InitialConditionType, U <: Union{PJ.ParameterRef, Float64}} = T +) where {T <: InitialConditionType, U <: Union{JuMP.VariableRef, Float64}} = T """ Stores data to populate initial conditions before the build call diff --git a/src/core/optimization_container.jl b/src/core/optimization_container.jl index 7378326a49..c6a61ae67f 100644 --- a/src/core/optimization_container.jl +++ b/src/core/optimization_container.jl @@ -116,8 +116,7 @@ function OptimizationContainer( end return OptimizationContainer( - jump_model === nothing ? _make_jump_model(settings) : - _finalize_jump_model!(jump_model, settings), + jump_model === nothing ? JuMP.Model() : jump_model, 1:1, IS.time_period_conversion(resolution), settings, @@ -254,7 +253,27 @@ function _validate_warm_start_support(JuMPmodel::JuMP.Model, warm_start_enabled: return solver_supports_warm_start end -function _finalize_jump_model!(JuMPmodel::JuMP.Model, settings::Settings) +function _finalize_jump_model!(container::OptimizationContainer, settings::Settings) + @debug "Instantiating the JuMP model" _group = LOG_GROUP_OPTIMIZATION_CONTAINER + if built_for_recurrent_solves(container) && get_optimizer(settings) === nothing + throw( + IS.ConflictingInputsError( + "Optimizer can not be nothing when building for recurrent solves", + ), + ) + end + + if get_direct_mode_optimizer(settings) + optimizer = () -> MOI.instantiate(get_optimizer(settings)) + container.JuMPmodel = JuMP.direct_model(optimizer()) + elseif get_optimizer(settings) === nothing + @debug "The optimization model has no optimizer attached" _group = + LOG_GROUP_OPTIMIZATION_CONTAINER + else + JuMP.set_optimizer(container.JuMPmodel, get_optimizer(settings)) + end + + JuMPmodel = container.JuMPmodel warm_start_enabled = get_warm_start(settings) solver_supports_warm_start = _validate_warm_start_support(JuMPmodel, warm_start_enabled) set_warm_start!(settings, solver_supports_warm_start) @@ -269,41 +288,14 @@ function _finalize_jump_model!(JuMPmodel::JuMP.Model, settings::Settings) JuMP.set_silent(JuMPmodel) @debug "optimizer set to silent" _group = LOG_GROUP_OPTIMIZATION_CONTAINER end - return JuMPmodel -end - -function _prepare_jump_model_for_simulation!(JuMPmodel::JuMP.Model, settings::Settings) - if !haskey(JuMPmodel.ext, :ParameterJuMP) - @debug "Model doesn't have Parameters enabled. Parameters will be enabled" _group = - LOG_GROUP_OPTIMIZATION_CONTAINER - PJ.enable_parameters(JuMPmodel) - JuMP.set_optimizer(JuMPmodel, optimizer) - end return end -function _make_jump_model(settings::Settings) - @debug "Instantiating the JuMP model" _group = LOG_GROUP_OPTIMIZATION_CONTAINER - optimizer = get_optimizer(settings) - if get_direct_mode_optimizer(settings) - JuMPmodel = JuMP.direct_model(MOI.instantiate(optimizer)) - elseif optimizer === nothing - JuMPmodel = JuMP.Model() - @debug "The optimization model has no optimizer attached" _group = - LOG_GROUP_OPTIMIZATION_CONTAINER - else - JuMPmodel = JuMP.Model(optimizer) - end - _finalize_jump_model!(JuMPmodel, settings) - return JuMPmodel -end - function init_optimization_container!( container::OptimizationContainer, ::Type{T}, sys::PSY.System, ) where {T <: PM.AbstractPowerModel} - @assert container.JuMPmodel !== nothing PSY.set_units_base_system!(sys, "SYSTEM_BASE") # The order of operations matter settings = get_settings(container) @@ -338,6 +330,7 @@ function init_optimization_container!( stats = get_optimizer_stats(container) stats.detailed_stats = get_detailed_optimizer_stats(settings) + _finalize_jump_model!(container, settings) return end @@ -369,13 +362,8 @@ function get_problem_size(container::OptimizationContainer) return "The current total number of variables is $(vars) and total number of constraints is $(cons)" end -# This function is necessary while we switch from ParameterJuMP to POI -function _make_container_array(parameter_jump::Bool, ax...) - if parameter_jump - return remove_undef!(DenseAxisArray{PGAE}(undef, ax...)) - else - return remove_undef!(DenseAxisArray{GAE}(undef, ax...)) - end +function _make_container_array(ax...) + return remove_undef!(DenseAxisArray{GAE}(undef, ax...)) end function _make_system_expressions!( @@ -383,13 +371,12 @@ function _make_system_expressions!( bus_numbers::Vector{Int}, ::Type{<:PM.AbstractPowerModel}, ) - parameter_jump = built_for_recurrent_solves(container) time_steps = get_time_steps(container) container.expressions = Dict( ExpressionKey(ActivePowerBalance, PSY.Bus) => - _make_container_array(parameter_jump, bus_numbers, time_steps), + _make_container_array(bus_numbers, time_steps), ExpressionKey(ReactivePowerBalance, PSY.Bus) => - _make_container_array(parameter_jump, bus_numbers, time_steps), + _make_container_array(bus_numbers, time_steps), ) return end @@ -399,11 +386,10 @@ function _make_system_expressions!( bus_numbers::Vector{Int}, ::Type{<:PM.AbstractActivePowerModel}, ) - parameter_jump = built_for_recurrent_solves(container) time_steps = get_time_steps(container) container.expressions = Dict( ExpressionKey(ActivePowerBalance, PSY.Bus) => - _make_container_array(parameter_jump, bus_numbers, time_steps), + _make_container_array(bus_numbers, time_steps), ) return end @@ -413,11 +399,10 @@ function _make_system_expressions!( ::Vector{Int}, ::Type{CopperPlatePowerModel}, ) - parameter_jump = built_for_recurrent_solves(container) time_steps = get_time_steps(container) container.expressions = Dict( ExpressionKey(ActivePowerBalance, PSY.System) => - _make_container_array(parameter_jump, time_steps), + _make_container_array(time_steps), ) return end @@ -427,13 +412,12 @@ function _make_system_expressions!( bus_numbers::Vector{Int}, ::Type{T}, ) where {T <: Union{PTDFPowerModel, StandardPTDFModel}} - parameter_jump = built_for_recurrent_solves(container) time_steps = get_time_steps(container) container.expressions = Dict( ExpressionKey(ActivePowerBalance, PSY.System) => - _make_container_array(parameter_jump, time_steps), + _make_container_array(time_steps), ExpressionKey(ActivePowerBalance, PSY.Bus) => - _make_container_array(parameter_jump, bus_numbers, time_steps), + _make_container_array(bus_numbers, time_steps), ) return end @@ -717,7 +701,7 @@ function _add_variable_container!( axs..., ) where {T <: VariableType, U <: Union{PSY.Component, PSY.System}} if sparse - var_container = sparse_container_spec(Float64, axs...) + var_container = sparse_container_spec(JuMP.VariableRef, axs...) # We initialize sparse containers with Float64, not ideal and introduces type instability, # because JuMP.Containers.SparseAxisArrays can't be initialized with undef else @@ -930,7 +914,7 @@ function _add_param_container!( sparse=false, ) where {T <: VariableValueParameter, U <: PSY.Component} # Temporary while we change to POI vs PJ - param_type = built_for_recurrent_solves(container) ? PJ.ParameterRef : Float64 + param_type = built_for_recurrent_solves(container) ? JuMP.VariableRef : Float64 if sparse param_array = sparse_container_spec(param_type, axs...) multiplier_array = sparse_container_spec(Float64, axs...) @@ -951,7 +935,7 @@ function _add_param_container!( sparse=false, ) where {T <: TimeSeriesParameter, U <: PSY.Component, V <: PSY.TimeSeriesData} # Temporary while we change to POI vs PJ - param_type = built_for_recurrent_solves(container) ? PJ.ParameterRef : Float64 + param_type = built_for_recurrent_solves(container) ? JuMP.VariableRef : Float64 if sparse param_array = sparse_container_spec(param_type, axs...) multiplier_array = sparse_container_spec(Float64, axs...) @@ -1170,8 +1154,7 @@ function add_expression_container!( meta=CONTAINER_KEY_EMPTY_META, ) where {T <: ExpressionType, U <: Union{PSY.Component, PSY.System}} expr_key = ExpressionKey(T, U, meta) - expr_type = built_for_recurrent_solves(container) ? PGAE : GAE - return _add_expression_container!(container, expr_key, expr_type, axs...; sparse=sparse) + return _add_expression_container!(container, expr_key, GAE, axs...; sparse=sparse) end function add_expression_container!( @@ -1242,7 +1225,7 @@ function _add_initial_condition_container!( length_devices::Int, ) where {T <: InitialConditionType, U <: Union{PSY.Component, PSY.System}} if built_for_recurrent_solves(container) - ini_conds = Vector{InitialCondition{T, PJ.ParameterRef}}(undef, length_devices) + ini_conds = Vector{InitialCondition{T, JuMP.VariableRef}}(undef, length_devices) else ini_conds = Vector{InitialCondition{T, Float64}}(undef, length_devices) end diff --git a/src/core/parameters.jl b/src/core/parameters.jl index 2a4bb6c857..68f18a5774 100644 --- a/src/core/parameters.jl +++ b/src/core/parameters.jl @@ -65,10 +65,10 @@ get_sos_status(attr::CostFunctionAttributes) = attr.sos_status get_variable_type(attr::CostFunctionAttributes) = attr.variable_type get_uses_compact_power(attr::CostFunctionAttributes) = attr.uses_compact_power -struct ParameterContainer +struct ParameterContainer{T <: AbstractArray, U <: AbstractArray} attributes::ParameterAttributes - parameter_array::AbstractArray - multiplier_array::AbstractArray + parameter_array::T + multiplier_array::U end function ParameterContainer(parameter_array, multiplier_array) @@ -95,11 +95,6 @@ function _set_parameter!( return end -function _set_parameter!(array::AbstractArray, ::JuMP.Model, value::Float64, ixs::Tuple) - array[ixs...] = value - return -end - function _set_parameter!( array::AbstractArray{Vector{NTuple{2, Float64}}}, ::JuMP.Model, @@ -111,7 +106,17 @@ function _set_parameter!( end function _set_parameter!( - array::AbstractArray{PJ.ParameterRef}, + array::AbstractArray{JuMP.VariableRef}, + model::JuMP.Model, + value::Float64, + ixs::Tuple, +) + array[ixs...] = add_jump_parameter(model, value) + return +end + +function _set_parameter!( + array::SparseAxisArray{Union{Nothing, JuMP.VariableRef}}, model::JuMP.Model, value::Float64, ixs::Tuple, diff --git a/src/core/store_common.jl b/src/core/store_common.jl index 1e0057df94..a4d7eab587 100644 --- a/src/core/store_common.jl +++ b/src/core/store_common.jl @@ -69,14 +69,14 @@ function write_model_dual_results!( return end -function calaculate_parameter_values( +function calculate_parameter_values( param_array::DenseAxisArray, multiplier_array::DenseAxisArray, ) return jump_value.(param_array) .* multiplier_array end -function calaculate_parameter_values( +function calculate_parameter_values( param_array::SparseAxisArray, multiplier_array::SparseAxisArray, ) @@ -107,7 +107,7 @@ function write_model_parameter_results!( param_array = get_parameter_array(container) multiplier_array = get_multiplier_array(container) # @assert_op length(axes(param_array)) == 2 - data = calaculate_parameter_values(param_array, multiplier_array) + data = calculate_parameter_values(param_array, multiplier_array) write_result!(store, model_name, key, index, update_timestamp, data) if export_params !== nothing && diff --git a/src/devices_models/devices/common/add_to_expression.jl b/src/devices_models/devices/common/add_to_expression.jl index a93a36cec6..fe6fa2b4f2 100644 --- a/src/devices_models/devices/common/add_to_expression.jl +++ b/src/devices_models/devices/common/add_to_expression.jl @@ -78,16 +78,7 @@ end function _add_to_jump_expression!( expression::T, - parameter::PJ.ParameterRef, - multiplier::Float64, -) where {T <: JuMP.AbstractJuMPScalar} - PJ.add_to_expression!(expression, multiplier, parameter) - return -end - -function _add_to_jump_expression!( - expression::T, - var::Union{JuMP.VariableRef, PJ.ParameterRef}, + var::Union{JuMP.VariableRef, JuMP.VariableRef}, multiplier::Float64, constant::Float64, ) where {T <: JuMP.AbstractJuMPScalar} @@ -580,17 +571,17 @@ function add_to_expression!( add_expressions!(container, T, devices, model) end expression = get_expression(container, T(), V) - for d in devices, - t in get_time_steps(container), - sub_comp in [PSY.ThermalGen, PSY.RenewableGen] - sub_comp_key = string(sub_comp) - name = PSY.get_name(d) - _add_to_jump_expression!( - expression[name, sub_comp_key, t], - variable[name, sub_comp_key, t], - 1.0, - ) + for d in devices + !haskey(PSY.get_ext(d), "subtypes") && continue + for sub_comp_key in PSY.get_ext(d)["subtypes"], t in get_time_steps(container) + name = PSY.get_name(d) + _add_to_jump_expression!( + expression[name, sub_comp_key, t], + variable[name, sub_comp_key, t], + 1.0, + ) + end end return end diff --git a/src/devices_models/devices/common/add_variable.jl b/src/devices_models/devices/common/add_variable.jl index 205f754527..e095e14760 100644 --- a/src/devices_models/devices/common/add_variable.jl +++ b/src/devices_models/devices/common/add_variable.jl @@ -178,7 +178,7 @@ function add_variable!( ) where { T <: SubComponentVariableType, U <: Union{Vector{D}, IS.FlattenIteratorWrapper{D}}, -} where {D <: PSY.Component} +} where {D <: PSY.HybridSystem} @assert !isempty(devices) time_steps = get_time_steps(container) settings = get_settings(container) @@ -196,29 +196,38 @@ function add_variable!( sparse=true, ) - for t in time_steps, d in devices, subcomp in subcomp_types + for d in devices, (ix, subcomp) in enumerate(subcomp_types) !does_subcomponent_exist(d, subcomp) && continue - subcomp_key = string(subcomp) - name = PSY.get_name(d) - variable[name, subcomp_key, t] = JuMP.@variable( - container.JuMPmodel, - base_name = "$(variable_type)_$(D)_$(subcomp)_{$(name), $(t)}", - binary = binary - ) - - ub = get_variable_upper_bound(variable_type, d, formulation) - ub !== nothing && JuMP.set_upper_bound(variable[name, subcomp_key, t], ub) - - lb = get_variable_lower_bound(variable_type, d, formulation) - lb !== nothing && - !binary && - JuMP.set_lower_bound(variable[name, subcomp_key, t], lb) - - if get_warm_start(settings) - init = get_variable_warm_start_value(variable_type, d, formulation) - init !== nothing && JuMP.set_start_value(variable[name, subcomp_key, t], init) + subcomp_key = subcomp_keys[ix] + if !haskey(PSY.get_ext(d), "subtypes") + PSY.get_ext(d)["subtypes"] = [subcomp_key] + else + push!(PSY.get_ext(d)["subtypes"], subcomp_key) + end + for t in time_steps + name = PSY.get_name(d) + variable[name, subcomp_key, t] = JuMP.@variable( + get_jump_model(container), + base_name = "$(variable_type)_$(D)_$(subcomp)_{$(name), $(t)}", + binary = binary + ) + + ub = get_variable_upper_bound(variable_type, d, formulation) + ub !== nothing && JuMP.set_upper_bound(variable[name, subcomp_key, t], ub) + + lb = get_variable_lower_bound(variable_type, d, formulation) + lb !== nothing && + !binary && + JuMP.set_lower_bound(variable[name, subcomp_key, t], lb) + + if get_warm_start(settings) + init = get_variable_warm_start_value(variable_type, d, formulation) + init !== nothing && + JuMP.set_start_value(variable[name, subcomp_key, t], init) + end end end - + # Workaround to remove invalid key combinations + filter!(x -> x.second !== nothing, variable.data) return end diff --git a/src/devices_models/devices/common/duration_constraints.jl b/src/devices_models/devices/common/duration_constraints.jl index c23de7eb73..08a4e66441 100644 --- a/src/devices_models/devices/common/duration_constraints.jl +++ b/src/devices_models/devices/common/duration_constraints.jl @@ -279,7 +279,7 @@ function device_duration_parameters!( for t in time_steps for (ix, ic) in enumerate(initial_duration[:, 1]) name = get_component_name(ic) - IS.@assert_op typeof(get_value(ic)) == PJ.ParameterRef + IS.@assert_op typeof(get_value(ic)) == JuMP.VariableRef # Minimum Up-time Constraint lhs_on = JuMP.GenericAffExpr{Float64, JuMP.VariableRef}(0) for i in UnitRange{Int}(Int(t - duration_data[ix].up + 1), t) @@ -304,7 +304,7 @@ function device_duration_parameters!( end for (ix, ic) in enumerate(initial_duration[:, 2]) - IS.@assert_op typeof(get_value(ic)) == PJ.ParameterRef + IS.@assert_op typeof(get_value(ic)) == JuMP.VariableRef name = get_component_name(ic) # Minimum Down-time Constraint lhs_off = JuMP.GenericAffExpr{Float64, JuMP.VariableRef}(0) @@ -439,5 +439,9 @@ function device_duration_compact_retrospective!( JuMP.@constraint(container.JuMPmodel, lhs_off + varon[name, t] <= 1.0) end end + for c in [con_up, con_down] + # Workaround to remove invalid key combinations + filter!(x -> x.second !== nothing, c.data) + end return end diff --git a/src/devices_models/devices/common/range_constraint.jl b/src/devices_models/devices/common/range_constraint.jl index 943b4e405a..a00e1ced61 100644 --- a/src/devices_models/devices/common/range_constraint.jl +++ b/src/devices_models/devices/common/range_constraint.jl @@ -650,7 +650,7 @@ function lower_bound_range_with_parameter!( constraint_container::JuMPConstraintArray, lhs_array, param_multiplier::JuMPFloatArray, - param_array::Union{JuMPParamArray, JuMPFloatArray}, + param_array::Union{JuMPVariableArray, JuMPFloatArray}, devices::IS.FlattenIteratorWrapper{V}, ) where {V <: PSY.Component} time_steps = axes(constraint_container)[2] @@ -758,7 +758,7 @@ function upper_bound_range_with_parameter!( constraint_container::JuMPConstraintArray, lhs_array, param_multiplier::JuMPFloatArray, - param_array::Union{JuMPParamArray, JuMPFloatArray}, + param_array::Union{JuMPVariableArray, JuMPFloatArray}, devices::IS.FlattenIteratorWrapper{V}, ) where {V <: PSY.Component} time_steps = axes(constraint_container)[2] diff --git a/src/devices_models/devices/common/rateofchange_constraints.jl b/src/devices_models/devices/common/rateofchange_constraints.jl index f1a0c7c317..02836ee771 100644 --- a/src/devices_models/devices/common/rateofchange_constraints.jl +++ b/src/devices_models/devices/common/rateofchange_constraints.jl @@ -90,7 +90,7 @@ function add_linear_ramp_constraints!( ramp_limits = PSY.get_ramp_limits(get_component(ic)) ic_power = get_value(ic) @debug "add rate_of_change_constraint" name ic_power - @assert (parameters && isa(ic_power, PJ.ParameterRef)) || !parameters + @assert (parameters && isa(ic_power, JuMP.VariableRef)) || !parameters con_up[name, 1] = JuMP.@constraint( container.JuMPmodel, expr_up[name, 1] - ic_power <= ramp_limits.up * minutes_per_period @@ -143,7 +143,7 @@ function add_linear_ramp_constraints!( ramp_limits = PSY.get_ramp_limits(get_component(ic)) ic_power = get_value(ic) @debug "add rate_of_change_constraint" name ic_power - @assert (parameters && isa(ic_power, PJ.ParameterRef)) || !parameters + @assert (parameters && isa(ic_power, JuMP.VariableRef)) || !parameters con_up[name, 1] = JuMP.@constraint( container.JuMPmodel, variable[name, 1] - ic_power <= ramp_limits.up * minutes_per_period @@ -229,7 +229,7 @@ function add_semicontinuous_ramp_constraints!( power_limits = PSY.get_active_power_limits(device) ic_power = get_value(ic) @debug "add rate_of_change_constraint" name ic_power - @assert (parameters && isa(ic_power, PJ.ParameterRef)) || !parameters + @assert (parameters && isa(ic_power, JuMP.VariableRef)) || !parameters con_up[name, 1] = JuMP.@constraint( container.JuMPmodel, expr_up[name, 1] - ic_power <= @@ -289,7 +289,7 @@ function add_semicontinuous_ramp_constraints!( power_limits = PSY.get_active_power_limits(device) ic_power = get_value(ic) @debug "add rate_of_change_constraint" name ic_power - @assert (parameters && isa(ic_power, PJ.ParameterRef)) || !parameters + @assert (parameters && isa(ic_power, JuMP.VariableRef)) || !parameters con_up[name, 1] = JuMP.@constraint( container.JuMPmodel, variable[name, 1] - ic_power <= diff --git a/src/devices_models/devices/hybrid_generation.jl b/src/devices_models/devices/hybrid_generation.jl index db0f433146..9aeab637eb 100644 --- a/src/devices_models/devices/hybrid_generation.jl +++ b/src/devices_models/devices/hybrid_generation.jl @@ -190,7 +190,7 @@ function add_lower_bound_range_constraints_impl!( T::Type{ComponentActivePowerVariableLimitsConstraint}, array, devices::IS.FlattenIteratorWrapper{V}, - model::DeviceModel{V, W}, + ::DeviceModel{V, W}, ) where {V <: PSY.HybridSystem, W <: AbstractDeviceFormulation} constraint = T() component_type = V @@ -224,7 +224,7 @@ function add_upper_bound_range_constraints_impl!( T::Type{ComponentActivePowerVariableLimitsConstraint}, array, devices::IS.FlattenIteratorWrapper{V}, - model::DeviceModel{V, W}, + ::DeviceModel{V, W}, ) where {V <: PSY.HybridSystem, W <: AbstractDeviceFormulation} constraint = T() component_type = V @@ -434,6 +434,10 @@ function add_constraints!( constraint_lb[name, subcomp, t] = JuMP.@constraint(container.JuMPmodel, var[name, subcomp_key, t] >= limits.min) end + for c in [constraint_ub, constraint_lb] + # Workaround to remove invalid key combinations + filter!(x -> x.second !== nothing, c.data) + end return end ######################## Energy balance constraints ############################ @@ -518,14 +522,19 @@ function add_constraints!( for d in devices, t in time_steps name = PSY.get_name(d) - - constraint[name, t] = JuMP.@constraint( - container.JuMPmodel, - var_p[name, t] == - var_sub_p[name, string(PSY.RenewableGen), t] + - var_sub_p[name, string(PSY.ThermalGen), t] + - var_out[name, t] - var_in[name, t] - ) + if haskey(PSY.get_ext(d), "subtypes") + subtypes = PSY.get_ext(d)["subtypes"] + constraint[name, t] = JuMP.@constraint( + container.JuMPmodel, + var_p[name, t] - sum(var_sub_p[name, s, t] for s in subtypes) - + var_out[name, t] + var_in[name, t] == 0.0 + ) + else + constraint[name, t] = JuMP.@constraint( + container.JuMPmodel, + var_p[name, t] - var_out[name, t] + var_in[name, t] == 0.0 + ) + end end return diff --git a/src/devices_models/devices/thermal_generation.jl b/src/devices_models/devices/thermal_generation.jl index 3b755e9eb9..beb1f01e1e 100644 --- a/src/devices_models/devices/thermal_generation.jl +++ b/src/devices_models/devices/thermal_generation.jl @@ -962,6 +962,10 @@ function add_constraints!( end end end + for c in con + # Workaround to remove invalid key combinations + filter!(x -> x.second !== nothing, c.data) + end return end @@ -1094,7 +1098,10 @@ function add_constraints!( end end end - + for c in [con_ub, con_lb] + # Workaround to remove invalid key combinations + filter!(x -> x.second !== nothing, c.data) + end return end diff --git a/src/feedforward/feedforward_constraints.jl b/src/feedforward/feedforward_constraints.jl index e43e780d80..0468284ed2 100644 --- a/src/feedforward/feedforward_constraints.jl +++ b/src/feedforward/feedforward_constraints.jl @@ -207,7 +207,7 @@ The Parameters are initialized using the uppper boundary values of the provided # Arguments * container::OptimizationContainer : the optimization_container model built in PowerSimulations * cons_name::Symbol : name of the constraint -* param_reference : Reference to the PJ.ParameterRef used to determine the upperbound +* param_reference : Reference to the JuMP.VariableRef used to determine the upperbound * var_key::VariableKey : the name of the continuous variable """ function add_feedforward_constraints!( @@ -266,7 +266,7 @@ The Parameters are initialized using the uppper boundary values of the provided # Arguments * container::OptimizationContainer : the optimization_container model built in PowerSimulations * cons_name::Symbol : name of the constraint -* param_reference : Reference to the PJ.ParameterRef used to determine the upperbound +* param_reference : Reference to the JuMP.VariableRef used to determine the upperbound * var_key::VariableKey : the name of the continuous variable """ function add_feedforward_constraints!( diff --git a/src/initial_conditions/add_initial_condition.jl b/src/initial_conditions/add_initial_condition.jl index 202bdbab64..ce78e0739a 100644 --- a/src/initial_conditions/add_initial_condition.jl +++ b/src/initial_conditions/add_initial_condition.jl @@ -28,7 +28,7 @@ function _get_initial_conditions_value( ::V, container::OptimizationContainer, ) where { - T <: InitialCondition{U, PJ.ParameterRef}, + T <: InitialCondition{U, JuMP.VariableRef}, V <: Union{AbstractDeviceFormulation, AbstractServiceFormulation}, W <: PSY.Component, } where {U <: InitialConditionType} @@ -78,7 +78,7 @@ function _get_initial_conditions_value( ::V, container::OptimizationContainer, ) where { - T <: InitialCondition{U, PJ.ParameterRef}, + T <: InitialCondition{U, JuMP.VariableRef}, V <: Union{AbstractDeviceFormulation, AbstractServiceFormulation}, W <: PSY.Component, } where {U <: InitialTimeDurationOff} @@ -132,7 +132,7 @@ function _get_initial_conditions_value( ::V, container::OptimizationContainer, ) where { - T <: InitialCondition{U, PJ.ParameterRef}, + T <: InitialCondition{U, JuMP.VariableRef}, V <: Union{AbstractDeviceFormulation, AbstractServiceFormulation}, W <: PSY.Component, } where {U <: InitialTimeDurationOn} @@ -159,11 +159,10 @@ function _get_initial_conditions_value( ::V, container::OptimizationContainer, ) where { - T <: InitialCondition{U, PJ.ParameterRef}, + T <: InitialCondition{U, JuMP.VariableRef}, V <: Union{AbstractDeviceFormulation, AbstractServiceFormulation}, W <: PSY.Component, } where {U <: Union{InitialEnergyLevel, InitialEnergyLevelUp, InitialEnergyLevelDown}} - ic_data = get_initial_conditions_data(container) val = initial_condition_default(U(), component, V()) @debug "Device $(PSY.get_name(component)) initialized DeviceStatus as $var_type" _group = LOG_GROUP_BUILD_INITIAL_CONDITIONS @@ -181,7 +180,6 @@ function _get_initial_conditions_value( V <: Union{AbstractDeviceFormulation, AbstractServiceFormulation}, W <: PSY.Component, } where {U <: Union{InitialEnergyLevel, InitialEnergyLevelUp, InitialEnergyLevelDown}} - ic_data = get_initial_conditions_data(container) val = initial_condition_default(U(), component, V()) @debug "Device $(PSY.get_name(component)) initialized DeviceStatus as $var_type" _group = LOG_GROUP_BUILD_INITIAL_CONDITIONS @@ -203,4 +201,5 @@ function add_initial_condition!( ini_cond_vector[ix] = _get_initial_conditions_value(ini_cond_vector, component, D(), U(), container) end + return end diff --git a/src/initial_conditions/calculate_initial_condition.jl b/src/initial_conditions/calculate_initial_condition.jl index 18139d6ec3..62af678391 100644 --- a/src/initial_conditions/calculate_initial_condition.jl +++ b/src/initial_conditions/calculate_initial_condition.jl @@ -2,11 +2,11 @@ Default implementation of set_initial_condition_value """ function set_ic_quantity!( - ic::InitialCondition{T, PJ.ParameterRef}, + ic::InitialCondition{T, JuMP.VariableRef}, var_value::Float64, ) where {T <: InitialConditionType} @assert isfinite(var_value) ic - PJ.set_value(ic.value, var_value) + fix_parameter_value(ic.value, var_value) return end diff --git a/src/initial_conditions/initialization.jl b/src/initial_conditions/initialization.jl index 67bf4d0808..4b16dfb740 100644 --- a/src/initial_conditions/initialization.jl +++ b/src/initial_conditions/initialization.jl @@ -33,14 +33,31 @@ function get_initial_conditions_template(model::OperationModel) return ic_template end +function _make_init_jump_model(ic_settings::Settings) + optimizer = get_optimizer(ic_settings) + JuMPmodel = JuMP.Model(optimizer) + warm_start_enabled = get_warm_start(ic_settings) + solver_supports_warm_start = _validate_warm_start_support(JuMPmodel, warm_start_enabled) + set_warm_start!(ic_settings, solver_supports_warm_start) + if get_optimizer_solve_log_print(ic_settings) + JuMP.unset_silent(JuMPmodel) + @debug "optimizer unset to silent" _group = LOG_GROUP_OPTIMIZATION_CONTAINER + else + JuMP.set_silent(JuMPmodel) + @debug "optimizer set to silent" _group = LOG_GROUP_OPTIMIZATION_CONTAINER + end + return JuMPmodel +end + function build_initial_conditions_model!(model::T) where {T <: OperationModel} model.internal.ic_model_container = deepcopy(get_optimization_container(model)) ic_settings = deepcopy(model.internal.ic_model_container.settings) main_problem_horizon = get_horizon(ic_settings) # TODO: add an interface to allow user to configure initial_conditions problem - model.internal.ic_model_container.JuMPmodel = _make_jump_model(ic_settings) + model.internal.ic_model_container.JuMPmodel = _make_init_jump_model(ic_settings) template = get_initial_conditions_template(model) model.internal.ic_model_container.settings = ic_settings + model.internal.ic_model_container.built_for_recurrent_solves = false set_horizon!(ic_settings, min(INITIALIZATION_PROBLEM_HORIZON, main_problem_horizon)) init_optimization_container!( model.internal.ic_model_container, diff --git a/src/initial_conditions/update_initial_conditions.jl b/src/initial_conditions/update_initial_conditions.jl index 295d243b06..b0f7aa9568 100644 --- a/src/initial_conditions/update_initial_conditions.jl +++ b/src/initial_conditions/update_initial_conditions.jl @@ -34,6 +34,7 @@ function update_initial_conditions!( _update_initial_conditions!(model, key, source) return end + function update_initial_conditions!( model::EmulationModel, key::ICKey{T, U}, diff --git a/src/network_models/area_balance_model.jl b/src/network_models/area_balance_model.jl index a53516fe28..7c8a8d325c 100644 --- a/src/network_models/area_balance_model.jl +++ b/src/network_models/area_balance_model.jl @@ -17,8 +17,7 @@ function area_balance( area_balance = get_variable(container, ActivePowerVariable(), PSY.Area) for (k, buses_in_area) in area_mapping for t in time_steps - area_net = - built_for_recurrent_solves(container) ? zero(PGAE) : JuMP.AffExpr(0.0) + area_net = JuMP.AffExpr(0.0) for b in buses_in_area JuMP.add_to_expression!(area_net, nodal_net_balance[PSY.get_number(b), t]) end diff --git a/src/operation/initial_conditions_update_in_memory_store.jl b/src/operation/initial_conditions_update_in_memory_store.jl index d7cd27ec83..b8767a273c 100644 --- a/src/operation/initial_conditions_update_in_memory_store.jl +++ b/src/operation/initial_conditions_update_in_memory_store.jl @@ -7,7 +7,7 @@ function update_initial_conditions!( ::Dates.Millisecond, ) where { T <: InitialCondition{InitialTimeDurationOn, S}, -} where {S <: Union{Float64, PJ.ParameterRef}} +} where {S <: Union{Float64, JuMP.VariableRef}} for ic in ics var_val = get_aux_variable_value(store, TimeDurationOn(), get_component_type(ic)) set_ic_quantity!(ic, get_last_recorded_value(var_val)[get_component_name(ic)]) @@ -21,7 +21,7 @@ function update_initial_conditions!( ::Dates.Millisecond, ) where { T <: InitialCondition{InitialTimeDurationOff, S}, -} where {S <: Union{Float64, PJ.ParameterRef}} +} where {S <: Union{Float64, JuMP.VariableRef}} for ic in ics var_val = get_aux_variable_value(store, TimeDurationOff(), get_component_type(ic)) set_ic_quantity!(ic, get_last_recorded_value(var_val)[get_component_name(ic)]) @@ -33,7 +33,9 @@ function update_initial_conditions!( ics::Vector{T}, store::EmulationModelStore, ::Dates.Millisecond, -) where {T <: InitialCondition{DevicePower, S}} where {S <: Union{Float64, PJ.ParameterRef}} +) where { + T <: InitialCondition{DevicePower, S}, +} where {S <: Union{Float64, JuMP.VariableRef}} for ic in ics var_val = get_variable_value(store, ActivePowerVariable(), get_component_type(ic)) set_ic_quantity!(ic, get_last_recorded_value(var_val)[get_component_name(ic)]) @@ -47,7 +49,7 @@ function update_initial_conditions!( ::Dates.Millisecond, ) where { T <: InitialCondition{DeviceStatus, S}, -} where {S <: Union{Float64, PJ.ParameterRef}} +} where {S <: Union{Float64, JuMP.VariableRef}} for ic in ics var_val = get_variable_value(store, OnVariable(), get_component_type(ic)) set_ic_quantity!(ic, get_last_recorded_value(var_val)[get_component_name(ic)]) @@ -61,7 +63,7 @@ function update_initial_conditions!( ::Dates.Millisecond, ) where { T <: InitialCondition{DeviceAboveMinPower, S}, -} where {S <: Union{Float64, PJ.ParameterRef}} +} where {S <: Union{Float64, JuMP.VariableRef}} for ic in ics var_val = get_variable_value(store, PowerAboveMinimumVariable(), get_component_type(ic)) @@ -76,7 +78,7 @@ function update_initial_conditions!( ::Dates.Millisecond, ) where { T <: InitialCondition{InitialEnergyLevel, S}, -} where {S <: Union{Float64, PJ.ParameterRef}} +} where {S <: Union{Float64, JuMP.VariableRef}} for ic in ics var_val = get_variable_value(store, EnergyVariable(), get_component_type(ic)) set_ic_quantity!(ic, get_last_recorded_value(var_val)[get_component_name(ic)]) @@ -90,7 +92,7 @@ function update_initial_conditions!( ::Dates.Millisecond, ) where { T <: InitialCondition{InitialEnergyLevelUp, S}, -} where {S <: Union{Float64, PJ.ParameterRef}} +} where {S <: Union{Float64, JuMP.VariableRef}} for ic in ics var_val = get_variable_value(store, EnergyVariableUp(), get_component_type(ic)) set_ic_quantity!(ic, get_last_recorded_value(var_val)[get_component_name(ic)]) @@ -104,7 +106,7 @@ function update_initial_conditions!( ::Dates.Millisecond, ) where { T <: InitialCondition{InitialEnergyLevelDown, S}, -} where {S <: Union{Float64, PJ.ParameterRef}} +} where {S <: Union{Float64, JuMP.VariableRef}} for ic in ics var_val = get_variable_value(store, EnergyVariableDown(), get_component_type(ic)) set_ic_quantity!(ic, get_last_recorded_value(var_val)[get_component_name(ic)]) diff --git a/src/operation/model_numerical_analysis_utils.jl b/src/operation/model_numerical_analysis_utils.jl index 879d073dd1..0cffa99448 100644 --- a/src/operation/model_numerical_analysis_utils.jl +++ b/src/operation/model_numerical_analysis_utils.jl @@ -106,19 +106,19 @@ function get_constraint_numerical_bounds(model::OperationModel) error("Model not built, can't calculate constraint numerical bounds") end bounds = ConstraintBounds() - for (const_key, constriant_array) in get_constraints(get_optimization_container(model)) + for (const_key, constraint_array) in get_constraints(get_optimization_container(model)) # TODO: handle this at compile and not at run time - if isa(constriant_array, SparseAxisArray) - for idx in eachindex(constriant_array) - constriant_array[idx] == 0.0 && continue - con_obj = JuMP.constraint_object(constriant_array[idx]) + if isa(constraint_array, SparseAxisArray) + for idx in eachindex(constraint_array) + constraint_array[idx] == 0.0 && continue + con_obj = JuMP.constraint_object(constraint_array[idx]) update_coefficient_bounds(bounds, con_obj, (const_key, idx)) update_rhs_bounds(bounds, con_obj, (const_key, idx)) end else - for idx in Iterators.product(constriant_array.axes...) - !isassigned(constriant_array, idx...) && continue - con_obj = JuMP.constraint_object(constriant_array[idx...]) + for idx in Iterators.product(constraint_array.axes...) + !isassigned(constraint_array, idx...) && continue + con_obj = JuMP.constraint_object(constraint_array[idx...]) update_coefficient_bounds(bounds, con_obj, (const_key, idx)) update_rhs_bounds(bounds, con_obj, (const_key, idx)) end diff --git a/src/operation/optimization_debugging.jl b/src/operation/optimization_debugging.jl index 08a569e4ab..b67d7b1e96 100644 --- a/src/operation/optimization_debugging.jl +++ b/src/operation/optimization_debugging.jl @@ -62,20 +62,20 @@ function get_detailed_constraint_numerical_bounds(model::OperationModel) error("Model not built, can't calculate constraint numerical bounds") end constraint_bounds = Dict() - for (const_key, constriant_array) in get_constraints(get_optimization_container(model)) - if isa(constriant_array, SparseAxisArray) + for (const_key, constraint_array) in get_constraints(get_optimization_container(model)) + if isa(constraint_array, SparseAxisArray) bounds = ConstraintBounds() - for idx in eachindex(constriant_array) - constriant_array[idx] == 0.0 && continue - con_obj = JuMP.constraint_object(constriant_array[idx]) + for idx in eachindex(constraint_array) + constraint_array[idx] == 0.0 && continue + con_obj = JuMP.constraint_object(constraint_array[idx]) update_coefficient_bounds(bounds, con_obj, idx) update_rhs_bounds(bounds, con_obj, idx) end constraint_bounds[const_key] = bounds else bounds = ConstraintBounds() - for idx in Iterators.product(constriant_array.axes...) - con_obj = JuMP.constraint_object(constriant_array[idx...]) + for idx in Iterators.product(constraint_array.axes...) + con_obj = JuMP.constraint_object(constraint_array[idx...]) update_coefficient_bounds(bounds, con_obj, idx) update_rhs_bounds(bounds, con_obj, idx) end diff --git a/src/parameters/add_parameters.jl b/src/parameters/add_parameters.jl index 47bf59b346..76800cae3b 100644 --- a/src/parameters/add_parameters.jl +++ b/src/parameters/add_parameters.jl @@ -247,7 +247,7 @@ function add_parameters!( time_series_mult_id = create_time_series_multiplier_index(model, T) time_steps = get_time_steps(container) name = PSY.get_name(service) - @debug "adding" parameter_type U _group = LOG_GROUP_OPTIMIZATION_CONTAINER + @debug "adding" T U _group = LOG_GROUP_OPTIMIZATION_CONTAINER parameter_container = add_param_container!( container, T(), diff --git a/src/parameters/update_parameters.jl b/src/parameters/update_parameters.jl index f518fa9fd7..cce4443b29 100644 --- a/src/parameters/update_parameters.jl +++ b/src/parameters/update_parameters.jl @@ -2,11 +2,11 @@ function _update_parameter_values!( ::AbstractArray{T}, ::NoAttributes, args..., -) where {T <: Union{Float64, PJ.ParameterRef}} end +) where {T <: Union{Float64, JuMP.VariableRef}} end ######################## Methods to update Parameters from Time Series ##################### -function _set_param_value!(param::JuMPParamArray, value::Float64, name::String, t::Int) - JuMP.set_value(param[name, t], value) +function _set_param_value!(param::JuMPVariableMatrix, value::Float64, name::String, t::Int) + fix_parameter_value(param[name, t], value) return end @@ -26,23 +26,24 @@ function _set_param_value!(param::JuMPFloatArray, value::Float64, name::String, end function _set_param_value!( - param::SparseAxisArray, + param::SparseAxisArray{Union{Nothing, JuMP.VariableRef}}, value::Float64, name::String, subcomp::String, t::Int, ) - _set_parameter_value_sparse_array!(param[name, subcomp, t], value) + fix_parameter_value(param[name, subcomp, t], value) return end -function _set_parameter_value_sparse_array!(parameter::Float64, value::Float64) - parameter = value - return -end - -function _set_parameter_value_sparse_array!(parameter::PJ.ParameterRef, value::Float64) - JuMP.set_value(parameter, value) +function _set_param_value!( + param::SparseAxisArray{Float64}, + value::Float64, + name::String, + subcomp::String, + t::Int, +) + param[name, subcomp, t] = value return end @@ -53,7 +54,7 @@ function _update_parameter_values!( model::DecisionModel, ::DatasetContainer{DataFrameDataset}, ) where { - T <: Union{PJ.ParameterRef, Float64}, + T <: Union{JuMP.VariableRef, Float64}, U <: PSY.AbstractDeterministic, V <: PSY.Component, } @@ -113,7 +114,7 @@ function _update_parameter_values!( model::DecisionModel, ::DatasetContainer{DataFrameDataset}, ) where { - T <: Union{PJ.ParameterRef, Float64}, + T <: Union{JuMP.VariableRef, Float64}, U <: PSY.AbstractDeterministic, V <: PSY.Service, } @@ -140,7 +141,7 @@ function _update_parameter_values!( ::Type{V}, model::EmulationModel, ::DatasetContainer{DataFrameDataset}, -) where {T <: Union{PJ.ParameterRef, Float64}, U <: PSY.SingleTimeSeries, V <: PSY.Device} +) where {T <: Union{JuMP.VariableRef, Float64}, U <: PSY.SingleTimeSeries, V <: PSY.Device} initial_forecast_time = get_current_time(model) components = get_available_components(V, get_system(model)) for component in components @@ -164,7 +165,7 @@ function _update_parameter_values!( ::Type{<:PSY.Component}, model::DecisionModel, state::DatasetContainer{DataFrameDataset}, -) where {T <: Union{PJ.ParameterRef, Float64}} +) where {T <: Union{JuMP.VariableRef, Float64}} current_time = get_current_time(model) state_values = get_dataset_values(state, get_attribute_key(attributes)) component_names, time = axes(param_array) @@ -185,7 +186,13 @@ function _update_parameter_values!( end for name in component_names # Pass indices in this way since JuMP DenseAxisArray don't support view() - _set_param_value!(param_array, state_values[state_data_index, name], name, t) + _set_param_value!( + get_jump_model(model), + param_array, + state_values[state_data_index, name], + name, + t, + ) end end return @@ -197,7 +204,7 @@ function _update_parameter_values!( ::Type{U}, model::DecisionModel, state::DatasetContainer{DataFrameDataset}, -) where {T <: Union{PJ.ParameterRef, Float64}, U <: PSY.Component} +) where {T <: Union{JuMP.VariableRef, Float64}, U <: PSY.Component} current_time = get_current_time(model) state_values = get_dataset_values(state, get_attribute_key(attributes)) component_names, time = axes(param_array) @@ -232,7 +239,7 @@ function _update_parameter_values!( ::Type{<:PSY.Component}, model::EmulationModel, state::DatasetContainer{DataFrameDataset}, -) where {T <: Union{PJ.ParameterRef, Float64}} +) where {T <: Union{JuMP.VariableRef, Float64}} current_time = get_current_time(model) state_values = get_dataset_values(state, get_attribute_key(attributes)) component_names, _ = axes(param_array) @@ -252,7 +259,7 @@ function _update_parameter_values!( ::Type{<:PSY.Component}, model::EmulationModel, state::DatasetContainer{DataFrameDataset}, -) where {T <: Union{PJ.ParameterRef, Float64}, U <: PSY.Component} +) where {T <: Union{JuMP.VariableRef, Float64}, U <: PSY.Component} current_time = get_current_time(model) state_values = get_dataset_values(state, get_attribute_key(attributes)) component_names, _ = axes(param_array) @@ -263,7 +270,7 @@ function _update_parameter_values!( # Pass indices in this way since JuMP DenseAxisArray don't support view() val = round(state_values[state_data_index, name]) @assert 0.0 <= val <= 1.0 - _set_param_value!(param_array, val, name, 1) + _set_param_value!(get_jump_model(model), param_array, val, name, 1) end return end @@ -274,7 +281,7 @@ function _update_parameter_values!( ::Type{<:PSY.Component}, ::EmulationModel, ::EmulationModelStore, -) where {T <: Union{PJ.ParameterRef, Float64}} +) where {T <: Union{JuMP.VariableRef, Float64}} error("The emulation model has parameters that can't be updated from its results") return end @@ -331,7 +338,7 @@ function update_parameter_values!( state_data_index = find_timestamp_index(state_timestamps, current_time) sim_timestamps = range(current_time, step=resolution, length=time[end]) - old_parameter_values = JuMP.value.(parameter_array) + old_parameter_values = jump_value.(parameter_array) # The current method uses older parameter values because when passing the energy output from one stage # to the next, the aux variable values gets over-written by the lower level model after its solve. # This approach is a temporary hack and will be replaced in future versions. diff --git a/src/simulation/initial_condition_update_simulation.jl b/src/simulation/initial_condition_update_simulation.jl index 0b187ee73a..dc30b2487f 100644 --- a/src/simulation/initial_condition_update_simulation.jl +++ b/src/simulation/initial_condition_update_simulation.jl @@ -10,8 +10,8 @@ function update_initial_conditions!( end function update_initial_conditions!( - model::OperationModel, - state::SimulationState, + ::OperationModel, + ::SimulationState, ::IntraProblemChronology, ) #for key in keys(get_initial_conditions(model)) @@ -27,7 +27,7 @@ function update_initial_conditions!( model_resolution::Dates.Millisecond, ) where { T <: InitialCondition{InitialTimeDurationOn, S}, -} where {S <: Union{Float64, PJ.ParameterRef}} +} where {S <: Union{Float64, JuMP.VariableRef}} for ic in ics var_val = get_system_state_value(state, TimeDurationOn(), get_component_type(ic)) state_resolution = get_data_resolution( @@ -47,7 +47,7 @@ function update_initial_conditions!( model_resolution::Dates.Millisecond, ) where { T <: InitialCondition{InitialTimeDurationOff, S}, -} where {S <: Union{Float64, PJ.ParameterRef}} +} where {S <: Union{Float64, JuMP.VariableRef}} for ic in ics var_val = get_system_state_value(state, TimeDurationOff(), get_component_type(ic)) state_resolution = get_data_resolution( @@ -65,7 +65,9 @@ function update_initial_conditions!( ics::Vector{T}, state::SimulationState, ::Dates.Millisecond, -) where {T <: InitialCondition{DevicePower, S}} where {S <: Union{Float64, PJ.ParameterRef}} +) where { + T <: InitialCondition{DevicePower, S}, +} where {S <: Union{Float64, JuMP.VariableRef}} for ic in ics comp_name = get_component_name(ic) comp_type = get_component_type(ic) @@ -100,7 +102,7 @@ function update_initial_conditions!( ::Dates.Millisecond, ) where { T <: InitialCondition{DeviceStatus, S}, -} where {S <: Union{Float64, PJ.ParameterRef}} +} where {S <: Union{Float64, JuMP.VariableRef}} for ic in ics var_val = get_system_state_value(state, OnVariable(), get_component_type(ic)) set_ic_quantity!(ic, var_val[get_component_name(ic)]) @@ -114,7 +116,7 @@ function update_initial_conditions!( ::Dates.Millisecond, ) where { T <: InitialCondition{DeviceAboveMinPower, S}, -} where {S <: Union{Float64, PJ.ParameterRef}} +} where {S <: Union{Float64, JuMP.VariableRef}} for ic in ics var_val = get_system_state_value( state, @@ -132,7 +134,7 @@ function update_initial_conditions!( ::Dates.Millisecond, ) where { T <: InitialCondition{InitialEnergyLevel, S}, -} where {S <: Union{Float64, PJ.ParameterRef}} +} where {S <: Union{Float64, JuMP.VariableRef}} for ic in ics var_val = get_system_state_value(state, EnergyVariable(), get_component_type(ic)) set_ic_quantity!(ic, var_val[get_component_name(ic)]) @@ -146,7 +148,7 @@ function update_initial_conditions!( ::Dates.Millisecond, ) where { T <: InitialCondition{InitialEnergyLevelUp, S}, -} where {S <: Union{Float64, PJ.ParameterRef}} +} where {S <: Union{Float64, JuMP.VariableRef}} for ic in ics var_val = get_system_state_value(state, EnergyVariableUp(), get_component_type(ic)) set_ic_quantity!(ic, var_val[get_component_name(ic)]) @@ -160,7 +162,7 @@ function update_initial_conditions!( ::Dates.Millisecond, ) where { T <: InitialCondition{InitialEnergyLevelDown, S}, -} where {S <: Union{Float64, PJ.ParameterRef}} +} where {S <: Union{Float64, JuMP.VariableRef}} for ic in ics var_val = get_system_state_value(state, EnergyVariableDown(), get_component_type(ic)) diff --git a/src/simulation/simulation_internal.jl b/src/simulation/simulation_internal.jl index f2d8ff3601..b484926837 100644 --- a/src/simulation/simulation_internal.jl +++ b/src/simulation/simulation_internal.jl @@ -32,7 +32,7 @@ function SimulationInternal( cache_size_mib=1024, min_cache_flush_size_mib=MIN_CACHE_FLUSH_SIZE_MiB, ) - count_dict = OrderedDict{Int, Dict{Int, Int}}() + count_dict = OrderedDict{Int, OrderedDict{Int, Int}}() for s in 1:steps count_dict[s] = OrderedDict{Int, Int}() diff --git a/src/utils/jump_utils.jl b/src/utils/jump_utils.jl index 36d18493ff..03de0ad2d1 100644 --- a/src/utils/jump_utils.jl +++ b/src/utils/jump_utils.jl @@ -1,7 +1,7 @@ #Given the changes in syntax in ParameterJuMP and the new format to create anonymous parameters function add_jump_parameter(jump_model::JuMP.Model, val::Number) - param = JuMP.@variable(jump_model, variable_type = PJ.Param()) - PJ.set_value(param, val) + param = JuMP.@variable(jump_model) + JuMP.fix(param, val; force=true) return param end @@ -11,17 +11,19 @@ function write_data(base_power::Float64, save_path::String) end function jump_value(input::JuMP.VariableRef)::Float64 - return JuMP.value(input) + if JuMP.has_values(input.model) + return JuMP.value(input) + elseif JuMP.is_fixed(input) + return JuMP.fix_value(input) + else + return NaN + end end function jump_value(input::T)::Float64 where {T <: JuMP.AbstractJuMPScalar} return JuMP.value(input) end -function jump_value(input::PJ.ParameterRef)::Float64 - return PJ.value(input) -end - function jump_value(input::JuMP.ConstraintRef)::Float64 return JuMP.dual(input) end @@ -34,6 +36,11 @@ function jump_value(input::Vector{Tuple{Float64, Float64}})::Vector{Tuple{Float6 return input end +function fix_parameter_value(input::JuMP.VariableRef, value::Float64) + JuMP.fix(input, value; force=true) + return +end + function to_matrix(array::DenseAxisArray{T, 1, K}) where {T, K <: NTuple{1, Any}} data = jump_value.(array.data) data = reshape(data, length(data), 1) @@ -164,13 +171,25 @@ Returns the correct container specification for the selected type of JuMP Model """ function sparse_container_spec(::Type{T}, axs...) where {T <: JuMP.AbstractJuMPScalar} indexes = Base.Iterators.product(axs...) - contents = Dict{eltype(indexes), Any}(indexes .=> zero(T)) + contents = Dict{eltype(indexes), T}(indexes .=> zero(T)) + return SparseAxisArray(contents) +end + +function sparse_container_spec(::Type{T}, axs...) where {T <: JuMP.VariableRef} + indexes = Base.Iterators.product(axs...) + contents = Dict{eltype(indexes), Union{Nothing, T}}(indexes .=> nothing) + return SparseAxisArray(contents) +end + +function sparse_container_spec(::Type{T}, axs...) where {T <: JuMP.ConstraintRef} + indexes = Base.Iterators.product(axs...) + contents = Dict{eltype(indexes), Union{Nothing, T}}(indexes .=> nothing) return SparseAxisArray(contents) end -function sparse_container_spec(::Type{T}, axs...) where {T <: Any} +function sparse_container_spec(::Type{T}, axs...) where {T <: Number} indexes = Base.Iterators.product(axs...) - contents = Dict{eltype(indexes), Any}(indexes .=> 0.0) + contents = Dict{eltype(indexes), T}(indexes .=> zero(T)) return SparseAxisArray(contents) end diff --git a/test/Project.toml b/test/Project.toml index e53b4d4c17..2e4166dd76 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -13,7 +13,6 @@ JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1" JuMP = "4076af6c-e467-56ae-b986-b466b2749572" Logging = "56ddb016-857b-54e1-b83d-db4d58db5568" Memento = "f28f55f0-a522-5efc-85c2-fe41dfb9b2d9" -ParameterJuMP = "774612a8-9878-5177-865a-ca53ae2495f9" Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" PowerModels = "c36e90e8-916a-50a6-bd94-075b64ef4655" PowerSimulations = "e690365d-45e2-57bb-ac84-44ba829e73c4" diff --git a/test/performance/performance_test.jl b/test/performance/performance_test.jl new file mode 100644 index 0000000000..5525521bc9 --- /dev/null +++ b/test/performance/performance_test.jl @@ -0,0 +1,140 @@ +precompile_time = @timed using PowerSimulations + +using PowerSimulations +const PSI = PowerSimulations +using PowerSystems +const PSY = PowerSystems +using Logging +using PowerSystemCaseBuilder +using HiGHS +using Dates + +open("precompile_time.txt", "a") do io + write(io, "| $(ARGS[1]) | $(precompile_time.time) |\n") +end + +try + sys_rts_da = build_system(PSITestSystems, "modified_RTS_GMLC_DA_sys") + sys_rts_rt = build_system(PSITestSystems, "modified_RTS_GMLC_RT_sys") + sys_rts_realization = build_system(PSITestSystems, "modified_RTS_GMLC_realization_sys") + + for i in 1:2 + template_uc = ProblemTemplate( + NetworkModel( + StandardPTDFModel, + use_slacks=true, + PTDF=PTDF(sys_rts_da), + duals=[CopperPlateBalanceConstraint], + ), + ) + + set_device_model!(template_uc, ThermalMultiStart, ThermalCompactUnitCommitment) + set_device_model!(template_uc, ThermalStandard, ThermalCompactUnitCommitment) + set_device_model!(template_uc, RenewableDispatch, RenewableFullDispatch) + set_device_model!(template_uc, PowerLoad, StaticPowerLoad) + set_device_model!(template_uc, DeviceModel(Line, StaticBranch)) + set_device_model!(template_uc, Transformer2W, StaticBranchUnbounded) + set_device_model!(template_uc, TapTransformer, StaticBranchUnbounded) + set_device_model!(template_uc, HydroDispatch, FixedOutput) + set_device_model!(template_uc, HydroEnergyReservoir, HydroDispatchRunOfRiver) + set_service_model!( + template_uc, + ServiceModel(VariableReserve{ReserveUp}, RangeReserve), + ) + set_service_model!( + template_uc, + ServiceModel(VariableReserve{ReserveDown}, RangeReserve), + ) + + template_ed = deepcopy(template_uc) + set_device_model!(template_ed, ThermalMultiStart, ThermalStandardDispatch) + set_device_model!(template_ed, ThermalStandard, ThermalBasicDispatch) + set_device_model!(template_ed, HydroDispatch, HydroDispatchRunOfRiver) + set_device_model!(template_ed, HydroEnergyReservoir, HydroDispatchRunOfRiver) + + template_em = deepcopy(template_ed) + set_device_model!(template_ed, Line, StaticBranchUnbounded) + empty!(template_em.services) + + models = SimulationModels( + decision_models=[ + DecisionModel( + template_uc, + sys_rts_da; + name="UC", + optimizer=optimizer_with_attributes(HiGHS.Optimizer), + system_to_file=false, + initialize_model=true, + optimizer_solve_log_print=true, + direct_mode_optimizer=true, + check_numerical_bounds=false, + ), + DecisionModel( + template_ed, + sys_rts_rt; + name="ED", + optimizer=optimizer_with_attributes(HiGHS.Optimizer), + system_to_file=false, + initialize_model=true, + check_numerical_bounds=false, + #export_pwl_vars = true, + ), + ], + emulation_model=EmulationModel( + template_em, + sys_rts_realization; + name="PF", + optimizer=optimizer_with_attributes(HiGHS.Optimizer), + ), + ) + + sequence = SimulationSequence( + models=models, + feedforwards=Dict( + "ED" => [ + SemiContinuousFeedforward( + component_type=ThermalStandard, + source=OnVariable, + affected_values=[ActivePowerVariable], + ), + ], + "PF" => [ + SemiContinuousFeedforward( + component_type=ThermalStandard, + source=OnVariable, + affected_values=[ActivePowerVariable], + ), + ], + ), + ini_cond_chronology=InterProblemChronology(), + ) + + sim = Simulation( + name="compact_sim", + steps=3, + models=models, + sequence=sequence, + initial_time=DateTime("2020-01-01T00:00:00"), + simulation_folder=mktempdir(cleanup=true), + ) + + build_out, time_build, _, _ = + @timed build!(sim; console_level=Logging.Error, serialize=false) + + if build_out == PSI.BuildStatus.BUILT + name = i > 1 ? "Postcompile" : "Precompile" + open("build_time.txt", "a") do io + write(io, "| $(ARGS[1])-Build Time $name | $(time_build) |\n") + end + else + open("build_time.txt", "a") do io + write(io, "| $(ARGS[1])- Build Time $name | FAILED TO TEST |\n") + end + end + end +catch e + rethrow(e) + open("build_time.txt", "a") do io + write(io, "| $(ARGS[1])- Build Time | FAILED TO TEST |\n") + end +end diff --git a/test/run_partitioned_simulation.jl b/test/run_partitioned_simulation.jl index 8d71dfda68..363d5f4da0 100644 --- a/test/run_partitioned_simulation.jl +++ b/test/run_partitioned_simulation.jl @@ -11,7 +11,6 @@ using DataFrames using Dates using JuMP using TimeSeries -using ParameterJuMP using CSV using DataFrames using DataStructures @@ -24,7 +23,6 @@ const PSY = PowerSystems const PSI = PowerSimulations const PSB = PowerSystemCaseBuilder -const PJ = ParameterJuMP const IS = InfrastructureSystems const BASE_DIR = string(dirname(dirname(pathof(PowerSimulations)))) const DATA_DIR = joinpath(BASE_DIR, "test/test_data") @@ -98,8 +96,16 @@ function build_simulation( c.shut_down = 1500 end - to_json(c_sys5_pjm_da, "PSI-5-BUS-UC-ED/c_sys5_pjm_da.json"; force=true) - to_json(c_sys5_pjm_rt, "PSI-5-BUS-UC-ED/c_sys5_pjm_rt.json"; force=true) + to_json( + c_sys5_pjm_da, + joinpath(output_dir, "PSI-5-BUS-UC-ED/c_sys5_pjm_da.json"); + force=true, + ) + to_json( + c_sys5_pjm_rt, + joinpath(output_dir, "PSI-5-BUS-UC-ED/c_sys5_pjm_rt.json"); + force=true, + ) HiGHSoptimizer = optimizer_with_attributes(HiGHS.Optimizer) diff --git a/test/runtests.jl b/test/runtests.jl index bd58c4f447..53091fad4d 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -15,7 +15,6 @@ using DataFrames using Dates using JuMP using TimeSeries -using ParameterJuMP using CSV import JSON3 using DataFrames @@ -35,7 +34,6 @@ const PSY = PowerSystems const PSI = PowerSimulations const PSB = PowerSystemCaseBuilder -const PJ = ParameterJuMP const IS = InfrastructureSystems const BASE_DIR = string(dirname(dirname(pathof(PowerSimulations)))) const DATA_DIR = joinpath(BASE_DIR, "test/test_data") @@ -51,28 +49,28 @@ const LOG_FILE = "power-simulations-test.log" ENV["RUNNING_PSI_TESTS"] = "true" const DISABLED_TEST_FILES = [ -# "test_basic_model_structs.jl", -# "test_device_branch_constructors.jl", -# "test_device_hydro_generation_constructors.jl", -# "test_device_load_constructors.jl", -# "test_device_renewable_generation_constructors.jl", -# "test_device_storage_constructors.jl", -# "test_device_thermal_generation_constructors.jl", -# "test_jump_model_utils.jl", -# "test_model_decision.jl", -# "test_problem_template.jl", -# "test_model_emulation.jl", -# "test_network_constructors.jl", -# "test_services_constructor.jl", -# "test_simulation_models.jl", -# "test_simulation_sequence.jl", -# "test_simulation_build.jl", -# "test_device_hybrid_generation_constructors.jl", -# "test_initialization_problem.jl", -# "test_simulation_execute.jl", -# "test_simulation_results.jl", -# "test_simulation_results_export.jl", -# "test_simulation_store.jl", + # "test_basic_model_structs.jl", + # "test_device_branch_constructors.jl", + # "test_device_hydro_generation_constructors.jl", + # "test_device_load_constructors.jl", + "test_device_hybrid_generation_constructors.jl", + # "test_device_renewable_generation_constructors.jl", + # "test_device_storage_constructors.jl", + # "test_device_thermal_generation_constructors.jl", + # "test_jump_model_utils.jl", + # "test_model_decision.jl", + # "test_problem_template.jl", + # "test_model_emulation.jl", + # "test_network_constructors.jl", + # "test_services_constructor.jl", + # "test_simulation_models.jl", + # "test_simulation_sequence.jl", + # "test_simulation_build.jl", + # "test_initialization_problem.jl", + # "test_simulation_execute.jl", + # "test_simulation_results.jl", + # "test_simulation_results_export.jl", + # "test_simulation_store.jl", ] LOG_LEVELS = Dict( diff --git a/test/test_device_hybrid_generation_constructors.jl b/test/test_device_hybrid_generation_constructors.jl index f59f50788d..2cefa8a10e 100644 --- a/test/test_device_hybrid_generation_constructors.jl +++ b/test/test_device_hybrid_generation_constructors.jl @@ -5,7 +5,7 @@ # Parameters Testing model = DecisionModel(MockOperationProblem, DCPPowerModel, sys) mock_construct_device!(model, device_model) - moi_tests(model, false, 672, 0, 384, 336, 192, true) + moi_tests(model, 672, 0, 384, 336, 192, true) psi_checkobjfun_test(model, GAEVF) end @@ -16,7 +16,7 @@ end # No Parameters Testing model = DecisionModel(MockOperationProblem, ACPPowerModel, sys) mock_construct_device!(model, device_model) - moi_tests(model, false, 864, 0, 672, 624, 288, true) + moi_tests(model, 864, 0, 672, 624, 288, true) psi_checkobjfun_test(model, GAEVF) end @@ -27,7 +27,7 @@ end # Parameters Testing model = DecisionModel(MockOperationProblem, DCPPowerModel, sys) mock_construct_device!(model, device_model) - moi_tests(model, false, 672, 0, 384, 336, 192, true) + moi_tests(model, 672, 0, 384, 336, 192, true) psi_checkobjfun_test(model, GAEVF) end @@ -38,6 +38,6 @@ end # No Parameters Testing model = DecisionModel(MockOperationProblem, ACPPowerModel, sys) mock_construct_device!(model, device_model) - moi_tests(model, false, 864, 0, 672, 624, 288, true) + moi_tests(model, 864, 0, 672, 624, 288, true) psi_checkobjfun_test(model, GAEVF) end diff --git a/test/test_device_hydro_generation_constructors.jl b/test/test_device_hydro_generation_constructors.jl index d51f14aa14..a9f1b2d9ff 100644 --- a/test/test_device_hydro_generation_constructors.jl +++ b/test/test_device_hydro_generation_constructors.jl @@ -9,7 +9,7 @@ # No Parameters Testing model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5_hy) mock_construct_device!(model, device_model) - moi_tests(model, false, 0, 0, 0, 0, 0, false) + moi_tests(model, 0, 0, 0, 0, 0, false) psi_checkobjfun_test(model, GAEVF) end @@ -20,7 +20,7 @@ end # No Parameters Testing model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5_hyd) mock_construct_device!(model, device_model) - moi_tests(model, false, 0, 0, 0, 0, 0, false) + moi_tests(model, 0, 0, 0, 0, 0, false) psi_checkobjfun_test(model, GAEVF) end @@ -35,7 +35,7 @@ end # No Parameters Testing model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5_hy) mock_construct_device!(model, device_model) - moi_tests(model, false, 24, 0, 48, 24, 0, false) + moi_tests(model, 24, 0, 48, 24, 0, false) psi_checkobjfun_test(model, GAEVF) end @@ -46,7 +46,7 @@ end # No Parameters Testing model = DecisionModel(MockOperationProblem, ACPPowerModel, c_sys5_hy) mock_construct_device!(model, device_model) - moi_tests(model, false, 48, 0, 72, 48, 0, false) + moi_tests(model, 48, 0, 72, 48, 0, false) psi_checkobjfun_test(model, GAEVF) end @@ -57,7 +57,7 @@ end # No Parameters Testing model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5_hyd) mock_construct_device!(model, device_model) - moi_tests(model, false, 24, 0, 48, 24, 0, false) + moi_tests(model, 24, 0, 48, 24, 0, false) psi_checkobjfun_test(model, GAEVF) end @@ -68,7 +68,7 @@ end # No Parameters Testing model = DecisionModel(MockOperationProblem, ACPPowerModel, c_sys5_hyd) mock_construct_device!(model, device_model) - moi_tests(model, false, 48, 0, 72, 48, 0, false) + moi_tests(model, 48, 0, 72, 48, 0, false) psi_checkobjfun_test(model, GAEVF) end @@ -83,7 +83,7 @@ end # No Parameters Testing model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5_hy) mock_construct_device!(model, device_model) - moi_tests(model, false, 48, 0, 48, 24, 0, true) + moi_tests(model, 48, 0, 48, 24, 0, true) psi_checkobjfun_test(model, GAEVF) end @@ -94,7 +94,7 @@ end # No Parameters Testing model = DecisionModel(MockOperationProblem, ACPPowerModel, c_sys5_hy) mock_construct_device!(model, device_model) - moi_tests(model, false, 72, 0, 72, 48, 0, true) + moi_tests(model, 72, 0, 72, 48, 0, true) psi_checkobjfun_test(model, GAEVF) end @@ -105,7 +105,7 @@ end # No Parameters Testing model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5_hyd) mock_construct_device!(model, device_model) - moi_tests(model, false, 48, 0, 48, 24, 0, true) + moi_tests(model, 48, 0, 48, 24, 0, true) psi_checkobjfun_test(model, GAEVF) end @@ -116,7 +116,7 @@ end # No Parameters Testing model = DecisionModel(MockOperationProblem, ACPPowerModel, c_sys5_hyd) mock_construct_device!(model, device_model) - moi_tests(model, false, 72, 0, 72, 48, 0, true) + moi_tests(model, 72, 0, 72, 48, 0, true) psi_checkobjfun_test(model, GAEVF) end @@ -131,7 +131,7 @@ end # No Parameters Testing model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5_hyd) mock_construct_device!(model, device_model) - moi_tests(model, false, 24, 0, 25, 24, 0, false) + moi_tests(model, 24, 0, 25, 24, 0, false) psi_checkobjfun_test(model, GAEVF) end @@ -142,7 +142,7 @@ end # No Parameters Testing model = DecisionModel(MockOperationProblem, ACPPowerModel, c_sys5_hyd) mock_construct_device!(model, device_model) - moi_tests(model, false, 48, 0, 49, 48, 0, false) + moi_tests(model, 48, 0, 49, 48, 0, false) psi_checkobjfun_test(model, GAEVF) end @@ -161,7 +161,7 @@ end # No Parameters Testing model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5_phes_ed) mock_construct_device!(model, device_model) - moi_tests(model, false, 60, 0, 24, 24, 24, false) + moi_tests(model, 60, 0, 24, 24, 24, false) psi_checkobjfun_test(model, GAEVF) end @@ -172,7 +172,7 @@ end # No Parameters Testing model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5_phes_ed) mock_construct_device!(model, device_model) - moi_tests(model, false, 72, 0, 24, 24, 24, true) + moi_tests(model, 72, 0, 24, 24, 24, true) psi_checkobjfun_test(model, GAEVF) end @@ -187,7 +187,7 @@ end # No Parameters Testing model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5_hyd) mock_construct_device!(model, device_model) - moi_tests(model, false, 48, 0, 25, 24, 0, true) + moi_tests(model, 48, 0, 25, 24, 0, true) psi_checkobjfun_test(model, GAEVF) end @@ -198,7 +198,7 @@ end # No Parameters Testing model = DecisionModel(MockOperationProblem, ACPPowerModel, c_sys5_hyd) mock_construct_device!(model, device_model) - moi_tests(model, false, 72, 0, 49, 48, 0, true) + moi_tests(model, 72, 0, 49, 48, 0, true) psi_checkobjfun_test(model, GAEVF) end @@ -213,7 +213,7 @@ end # No Parameters Testing model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5_hyd) mock_construct_device!(model, device_model) - moi_tests(model, false, 120, 0, 24, 24, 48, false) + moi_tests(model, 120, 0, 24, 24, 48, false) psi_checkobjfun_test(model, GAEVF) end @@ -224,7 +224,7 @@ end # No Parameters Testing model = DecisionModel(MockOperationProblem, ACPPowerModel, c_sys5_hyd) mock_construct_device!(model, device_model) - moi_tests(model, false, 144, 0, 48, 48, 48, false) + moi_tests(model, 144, 0, 48, 48, 48, false) psi_checkobjfun_test(model, GAEVF) end @@ -239,7 +239,7 @@ end # No Parameters Testing model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5_hyd) mock_construct_device!(model, device_model) - moi_tests(model, false, 144, 0, 24, 24, 48, true) + moi_tests(model, 144, 0, 24, 24, 48, true) psi_checkobjfun_test(model, GAEVF) end @@ -250,7 +250,7 @@ end # No Parameters Testing model = DecisionModel(MockOperationProblem, ACPPowerModel, c_sys5_hyd) mock_construct_device!(model, device_model) - moi_tests(model, false, 168, 0, 48, 48, 48, true) + moi_tests(model, 168, 0, 48, 48, 48, true) psi_checkobjfun_test(model, GAEVF) end @@ -378,7 +378,7 @@ end optimizer=HiGHS_optimizer, ) @test build!(model; output_dir=mktempdir(cleanup=true)) == PSI.BuildStatus.BUILT - moi_tests(model, false, 15, 0, 3, 3, 9, false) + moi_tests(model, 15, 0, 3, 3, 9, false) psi_checksolve_test(model, [MOI.OPTIMAL], 5621.0, 10.0) end @@ -395,7 +395,7 @@ end optimizer=HiGHS_optimizer, ) @test build!(model; output_dir=mktempdir(cleanup=true)) == PSI.BuildStatus.BUILT - moi_tests(model, false, 15, 0, 3, 3, 9, false) + moi_tests(model, 15, 0, 3, 3, 9, false) psi_checksolve_test(model, [MOI.OPTIMAL], 21.0) end @@ -412,7 +412,7 @@ end optimizer=HiGHS_optimizer, ) @test build!(model; output_dir=mktempdir(cleanup=true)) == PSI.BuildStatus.BUILT - moi_tests(model, false, 15, 0, 3, 3, 9, false) + moi_tests(model, 15, 0, 3, 3, 9, false) psi_checksolve_test(model, [MOI.OPTIMAL], -5429.0, 10.0) end @@ -429,7 +429,7 @@ end optimizer=HiGHS_optimizer, ) @test build!(model; output_dir=mktempdir(cleanup=true)) == PSI.BuildStatus.BUILT - moi_tests(model, false, 15, 0, 3, 3, 9, false) + moi_tests(model, 15, 0, 3, 3, 9, false) psi_checksolve_test(model, [MOI.OPTIMAL], 21.0, 10.0) end @@ -446,7 +446,7 @@ end optimizer=HiGHS_optimizer, ) @test build!(model; output_dir=mktempdir(cleanup=true)) == PSI.BuildStatus.BUILT - moi_tests(model, false, 15, 0, 3, 3, 9, false) + moi_tests(model, 15, 0, 3, 3, 9, false) psi_checksolve_test(model, [MOI.OPTIMAL], -17179.0) end @@ -464,7 +464,7 @@ end c_sys5_hy = PSB.build_system(PSITestSystems, "c_sys5_hy") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5_hy) mock_construct_device!(model, device_model; built_for_recurrent_solves=true) - moi_tests(model, true, 48, 0, 72, 48, 0, true) + moi_tests(model, 96, 0, 72, 48, 0, true) end @testset "Test UpperBoundFeedforward to HydroDispatch with HydroCommitmentRunOfRiver model" begin @@ -478,7 +478,7 @@ end c_sys5_hy = PSB.build_system(PSITestSystems, "c_sys5_hy") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5_hy) mock_construct_device!(model, device_model; built_for_recurrent_solves=true) - moi_tests(model, true, 48, 0, 72, 24, 0, true) + moi_tests(model, 96, 0, 72, 24, 0, true) end @testset "Test LowerBoundFeedforward to HydroDispatch with HydroCommitmentRunOfRiver model" begin @@ -492,7 +492,7 @@ end c_sys5_hy = PSB.build_system(PSITestSystems, "c_sys5_hy") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5_hy) mock_construct_device!(model, device_model; built_for_recurrent_solves=true) - moi_tests(model, true, 48, 0, 48, 48, 0, true) + moi_tests(model, 96, 0, 48, 48, 0, true) end @testset "Test UpperBoundFeedforward to HydroDispatch with HydroDispatchRunOfRiver model" begin @@ -508,7 +508,7 @@ end c_sys5_hy = PSB.build_system(PSITestSystems, "c_sys5_hy") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5_hy) mock_construct_device!(model, device_model; built_for_recurrent_solves=true) - moi_tests(model, true, 24, 0, 72, 24, 0, false) + moi_tests(model, 72, 0, 72, 24, 0, false) end @testset "Test LowerBoundFeedforward to HydroDispatch with HydroDispatchRunOfRiver model" begin @@ -524,7 +524,7 @@ end c_sys5_hy = PSB.build_system(PSITestSystems, "c_sys5_hy") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5_hy) mock_construct_device!(model, device_model; built_for_recurrent_solves=true) - moi_tests(model, true, 24, 0, 48, 48, 0, false) + moi_tests(model, 72, 0, 48, 48, 0, false) end @testset "Test EnergyLimitFeedforward to HydroEnergyReservoir with HydroDispatchReservoirBudget model" begin @@ -540,7 +540,7 @@ end c_sys5_hy = PSB.build_system(PSITestSystems, "c_sys5_hyd") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5_hy) mock_construct_device!(model, device_model; built_for_recurrent_solves=true) - moi_tests(model, true, 24, 0, 27, 24, 0, false) + moi_tests(model, 72, 0, 27, 24, 0, false) end @testset "Test EnergyLimitFeedforward to HydroEnergyReservoir with HydroDispatchReservoirStorage model" begin @@ -556,7 +556,7 @@ end c_sys5_hy = PSB.build_system(PSITestSystems, "c_sys5_hyd_ems") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5_hy) mock_construct_device!(model, device_model; built_for_recurrent_solves=true) - moi_tests(model, true, 120, 0, 26, 24, 48, false) + moi_tests(model, 193, 0, 26, 24, 48, false) end @testset "Test LowerBoundFeedforward to HydroEnergyReservoir with HydroDispatchReservoirStorage model" begin @@ -571,7 +571,7 @@ end c_sys5_hy = PSB.build_system(PSITestSystems, "c_sys5_hyd_ems") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5_hy) mock_construct_device!(model, device_model; built_for_recurrent_solves=true) - moi_tests(model, true, 120, 0, 24, 48, 48, false) + moi_tests(model, 193, 0, 24, 48, 48, false) end @testset "Test EnergyLimitFeedforward to HydroEnergyReservoir with HydroCommitmentReservoirStorage model" begin @@ -586,7 +586,7 @@ end c_sys5_hy = PSB.build_system(PSITestSystems, "c_sys5_hyd_ems") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5_hy) mock_construct_device!(model, device_model; built_for_recurrent_solves=true) - moi_tests(model, true, 144, 0, 26, 24, 48, true) + moi_tests(model, 217, 0, 26, 24, 48, true) end @testset "Test SemiContinuousFeedforward to HydroEnergyReservoir with HydroCommitmentReservoirStorage model" begin @@ -600,7 +600,7 @@ end c_sys5_hy = PSB.build_system(PSITestSystems, "c_sys5_hyd_ems") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5_hy) mock_construct_device!(model, device_model; built_for_recurrent_solves=true) - moi_tests(model, true, 144, 0, 48, 48, 48, true) + moi_tests(model, 217, 0, 48, 48, 48, true) end @testset "Test EnergyLimitFeedforward to HydroEnergyReservoir models" begin @@ -617,7 +617,7 @@ end c_sys5_hy = PSB.build_system(PSITestSystems, "c_sys5_phes_ed") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5_hy) mock_construct_device!(model, device_model; built_for_recurrent_solves=true) - moi_tests(model, true, 72, 0, 25, 24, 24, true) + moi_tests(model, 110, 0, 25, 24, 24, true) end @testset "Test EnergyTargetFeedforward to HydroEnergyReservoir models" begin @@ -635,5 +635,5 @@ end c_sys5_hy = PSB.build_system(PSITestSystems, "c_sys5_phes_ed") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5_hy) mock_construct_device!(model, device_model; built_for_recurrent_solves=true) - moi_tests(model, true, 84, 0, 24, 25, 24, true) + moi_tests(model, 122, 0, 24, 25, 24, true) end diff --git a/test/test_device_load_constructors.jl b/test/test_device_load_constructors.jl index 0adaf063b8..4b7cf69c73 100644 --- a/test/test_device_load_constructors.jl +++ b/test/test_device_load_constructors.jl @@ -6,7 +6,7 @@ device_model = DeviceModel(PowerLoad, m) model = DecisionModel(MockOperationProblem, n, c_sys5_il) mock_construct_device!(model, device_model) - moi_tests(model, false, 0, 0, 0, 0, 0, false) + moi_tests(model, 0, 0, 0, 0, 0, false) psi_checkobjfun_test(model, GAEVF) end end @@ -19,7 +19,7 @@ end device_model = DeviceModel(InterruptibleLoad, m) model = DecisionModel(MockOperationProblem, n, c_sys5_il) mock_construct_device!(model, device_model) - moi_tests(model, false, 24, 0, 24, 0, 0, false) + moi_tests(model, 24, 0, 24, 0, 0, false) psi_checkobjfun_test(model, GAEVF) end end @@ -32,7 +32,7 @@ end device_model = DeviceModel(InterruptibleLoad, m) model = DecisionModel(MockOperationProblem, n, c_sys5_il) mock_construct_device!(model, device_model) - moi_tests(model, false, 48, 0, 24, 0, 24, false) + moi_tests(model, 48, 0, 24, 0, 24, false) psi_checkobjfun_test(model, GAEVF) end end @@ -45,7 +45,7 @@ end device_model = DeviceModel(InterruptibleLoad, m) model = DecisionModel(MockOperationProblem, n, c_sys5_il) mock_construct_device!(model, device_model) - moi_tests(model, false, 48, 0, 24, 0, 0, true) + moi_tests(model, 48, 0, 24, 0, 0, true) psi_checkobjfun_test(model, GAEVF) end end @@ -58,7 +58,7 @@ end device_model = DeviceModel(InterruptibleLoad, m) model = DecisionModel(MockOperationProblem, n, c_sys5_il) mock_construct_device!(model, device_model) - moi_tests(model, false, 72, 0, 24, 0, 24, true) + moi_tests(model, 72, 0, 24, 0, 24, true) psi_checkobjfun_test(model, GAEVF) end end diff --git a/test/test_device_renewable_generation_constructors.jl b/test/test_device_renewable_generation_constructors.jl index 41a0dab83f..6e9114bac6 100644 --- a/test/test_device_renewable_generation_constructors.jl +++ b/test/test_device_renewable_generation_constructors.jl @@ -3,7 +3,7 @@ c_sys5_re = PSB.build_system(PSITestSystems, "c_sys5_re") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5_re) mock_construct_device!(model, device_model) - moi_tests(model, false, 72, 0, 72, 0, 0, false) + moi_tests(model, 72, 0, 72, 0, 0, false) psi_checkobjfun_test(model, GAEVF) end @@ -12,7 +12,7 @@ end c_sys5_re = PSB.build_system(PSITestSystems, "c_sys5_re") model = DecisionModel(MockOperationProblem, ACPPowerModel, c_sys5_re;) mock_construct_device!(model, device_model) - moi_tests(model, false, 144, 0, 144, 72, 0, false) + moi_tests(model, 144, 0, 144, 72, 0, false) psi_checkobjfun_test(model, GAEVF) end @@ -21,7 +21,7 @@ end c_sys5_re = PSB.build_system(PSITestSystems, "c_sys5_re") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5_re) mock_construct_device!(model, device_model) - moi_tests(model, false, 72, 0, 72, 0, 0, false) + moi_tests(model, 72, 0, 72, 0, 0, false) psi_checkobjfun_test(model, GAEVF) end @@ -30,7 +30,7 @@ end c_sys5_re = PSB.build_system(PSITestSystems, "c_sys5_re") model = DecisionModel(MockOperationProblem, ACPPowerModel, c_sys5_re;) mock_construct_device!(model, device_model) - moi_tests(model, false, 144, 0, 72, 0, 72, false) + moi_tests(model, 144, 0, 72, 0, 72, false) psi_checkobjfun_test(model, GAEVF) end @@ -39,7 +39,7 @@ end c_sys5_re = PSB.build_system(PSITestSystems, "c_sys5_re") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5_re;) mock_construct_device!(model, device_model) - moi_tests(model, false, 0, 0, 0, 0, 0, false) + moi_tests(model, 0, 0, 0, 0, 0, false) psi_checkobjfun_test(model, GAEVF) end @@ -48,6 +48,6 @@ end c_sys5_re = PSB.build_system(PSITestSystems, "c_sys5_re") model = DecisionModel(MockOperationProblem, ACPPowerModel, c_sys5_re;) mock_construct_device!(model, device_model) - moi_tests(model, false, 0, 0, 0, 0, 0, false) + moi_tests(model, 0, 0, 0, 0, 0, false) psi_checkobjfun_test(model, GAEVF) end diff --git a/test/test_device_storage_constructors.jl b/test/test_device_storage_constructors.jl index ff1e7755cc..3c8bd1766b 100644 --- a/test/test_device_storage_constructors.jl +++ b/test/test_device_storage_constructors.jl @@ -7,7 +7,7 @@ c_sys5_bat = PSB.build_system(PSITestSystems, "c_sys5_bat") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5_bat) mock_construct_device!(model, device_model) - moi_tests(model, false, 72, 0, 72, 72, 24, false) + moi_tests(model, 72, 0, 72, 72, 24, false) psi_checkobjfun_test(model, GAEVF) end @@ -20,7 +20,7 @@ end c_sys5_bat = PSB.build_system(PSITestSystems, "c_sys5_bat") model = DecisionModel(MockOperationProblem, ACPPowerModel, c_sys5_bat) mock_construct_device!(model, device_model) - moi_tests(model, false, 96, 0, 96, 96, 24, false) + moi_tests(model, 96, 0, 96, 96, 24, false) psi_checkobjfun_test(model, GAEVF) end @@ -29,7 +29,7 @@ end c_sys5_bat = PSB.build_system(PSITestSystems, "c_sys5_bat") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5_bat) mock_construct_device!(model, device_model) - moi_tests(model, false, 96, 0, 72, 72, 24, true) + moi_tests(model, 96, 0, 72, 72, 24, true) psi_checkobjfun_test(model, GAEVF) end @@ -38,7 +38,7 @@ end c_sys5_bat = PSB.build_system(PSITestSystems, "c_sys5_bat") model = DecisionModel(MockOperationProblem, ACPPowerModel, c_sys5_bat) mock_construct_device!(model, device_model) - moi_tests(model, false, 120, 0, 96, 96, 24, true) + moi_tests(model, 120, 0, 96, 96, 24, true) psi_checkobjfun_test(model, GAEVF) end @@ -47,7 +47,7 @@ end c_sys5_bat = PSB.build_system(PSITestSystems, "c_sys5_bat") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5_bat) mock_construct_device!(model, device_model) - moi_tests(model, false, 96, 0, 72, 72, 24, true) + moi_tests(model, 96, 0, 72, 72, 24, true) psi_checkobjfun_test(model, GAEVF) end @@ -56,7 +56,7 @@ end c_sys5_bat = PSB.build_system(PSITestSystems, "c_sys5_bat") model = DecisionModel(MockOperationProblem, ACPPowerModel, c_sys5_bat) mock_construct_device!(model, device_model) - moi_tests(model, false, 120, 0, 96, 96, 24, true) + moi_tests(model, 120, 0, 96, 96, 24, true) psi_checkobjfun_test(model, GAEVF) end @@ -65,7 +65,7 @@ end c_sys5_bat = PSB.build_system(PSITestSystems, "c_sys5_bat_ems") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5_bat) mock_construct_device!(model, device_model) - moi_tests(model, false, 144, 0, 72, 72, 48, true) + moi_tests(model, 144, 0, 72, 72, 48, true) psi_checkobjfun_test(model, GAEVF) end @@ -74,7 +74,7 @@ end c_sys5_bat = PSB.build_system(PSITestSystems, "c_sys5_bat_ems") model = DecisionModel(MockOperationProblem, ACPPowerModel, c_sys5_bat) mock_construct_device!(model, device_model) - moi_tests(model, false, 168, 0, 96, 96, 48, true) + moi_tests(model, 168, 0, 96, 96, 48, true) psi_checkobjfun_test(model, GAEVF) end @@ -87,7 +87,7 @@ end model = DecisionModel(EconomicDispatchProblem, template, c_sys5; optimizer=HiGHS_optimizer) @test build!(model; output_dir=mktempdir(cleanup=true)) == PSI.BuildStatus.BUILT - moi_tests(model, false, 21, 0, 12, 9, 9, true) + moi_tests(model, 21, 0, 12, 9, 9, true) psi_checksolve_test(model, [MOI.OPTIMAL], 5811.0, 10.0) end @@ -101,7 +101,7 @@ end model = DecisionModel(EconomicDispatchProblem, template, c_sys5; optimizer=HiGHS_optimizer) @test build!(model; output_dir=mktempdir(cleanup=true)) == PSI.BuildStatus.BUILT - moi_tests(model, false, 21, 0, 12, 9, 9, true) + moi_tests(model, 21, 0, 12, 9, 9, true) psi_checksolve_test(model, [MOI.OPTIMAL], -63.0, 10.0) end @@ -115,7 +115,7 @@ end model = DecisionModel(EconomicDispatchProblem, template, c_sys5; optimizer=HiGHS_optimizer) @test build!(model; output_dir=mktempdir(cleanup=true)) == PSI.BuildStatus.BUILT - moi_tests(model, false, 28, 0, 16, 12, 12, true) + moi_tests(model, 28, 0, 16, 12, 12, true) psi_checksolve_test(model, [MOI.OPTIMAL], -11118.0, 10.0) end @@ -128,7 +128,7 @@ end model = DecisionModel(EconomicDispatchProblem, template, c_sys5; optimizer=HiGHS_optimizer) @test build!(model; output_dir=mktempdir(cleanup=true)) == PSI.BuildStatus.BUILT - moi_tests(model, false, 21, 0, 12, 9, 9, true) + moi_tests(model, 21, 0, 12, 9, 9, true) psi_checksolve_test(model, [MOI.OPTIMAL], 5547.0, 10.0) end @@ -142,7 +142,7 @@ end model = DecisionModel(EconomicDispatchProblem, template, c_sys5; optimizer=HiGHS_optimizer) @test build!(model; output_dir=mktempdir(cleanup=true)) == PSI.BuildStatus.BUILT - moi_tests(model, false, 21, 0, 12, 9, 9, true) + moi_tests(model, 21, 0, 12, 9, 9, true) psi_checksolve_test(model, [MOI.OPTIMAL], -1825.0, 10.0) end @@ -163,7 +163,7 @@ end sys = PSB.build_system(PSITestSystems, "c_sys5_bat") model = DecisionModel(MockOperationProblem, DCPPowerModel, sys) mock_construct_device!(model, device_model; built_for_recurrent_solves=true) - moi_tests(model, true, 120, 0, 72, 73, 24, true) + moi_tests(model, 145, 0, 72, 73, 24, true) end @testset "Test EnergyLimitFeedforward to GenericBattery with BookKeeping model" begin @@ -180,7 +180,7 @@ end sys = PSB.build_system(PSITestSystems, "c_sys5_bat") model = DecisionModel(MockOperationProblem, DCPPowerModel, sys) mock_construct_device!(model, device_model; built_for_recurrent_solves=true) - moi_tests(model, true, 96, 0, 74, 72, 24, true) + moi_tests(model, 121, 0, 74, 72, 24, true) end @testset "Test EnergyTargetFeedforward to GenericBattery with BookKeeping model" begin @@ -198,7 +198,7 @@ end sys = PSB.build_system(PSITestSystems, "c_sys5_bat") model = DecisionModel(MockOperationProblem, DCPPowerModel, sys) mock_construct_device!(model, device_model; built_for_recurrent_solves=true) - moi_tests(model, true, 120, 0, 72, 73, 24, true) + moi_tests(model, 145, 0, 72, 73, 24, true) end @testset "Test EnergyLimitFeedforward to GenericBattery with BatteryAncillaryServices model" begin @@ -215,7 +215,7 @@ end sys = PSB.build_system(PSITestSystems, "c_sys5_bat") model = DecisionModel(MockOperationProblem, DCPPowerModel, sys) mock_construct_device!(model, device_model; built_for_recurrent_solves=true) - moi_tests(model, true, 96, 0, 74, 72, 24, true) + moi_tests(model, 121, 0, 74, 72, 24, true) end @testset "Test EnergyTargetFeedforward to GenericBattery with BookKeeping model" begin @@ -233,7 +233,7 @@ end sys = PSB.build_system(PSITestSystems, "c_sys5_bat_ems") model = DecisionModel(MockOperationProblem, DCPPowerModel, sys) mock_construct_device!(model, device_model; built_for_recurrent_solves=true) - moi_tests(model, true, 120, 0, 72, 73, 24, true) + moi_tests(model, 145, 0, 72, 73, 24, true) end @testset "Test EnergyLimitFeedforward to BatteryEMS with BookKeeping model" begin @@ -250,7 +250,7 @@ end sys = PSB.build_system(PSITestSystems, "c_sys5_bat_ems") model = DecisionModel(MockOperationProblem, DCPPowerModel, sys) mock_construct_device!(model, device_model; built_for_recurrent_solves=true) - moi_tests(model, true, 96, 0, 74, 72, 24, true) + moi_tests(model, 121, 0, 74, 72, 24, true) end @testset "Test EnergyTargetFeedforward to GenericBattery with BatteryAncillaryServices model" begin @@ -268,7 +268,7 @@ end sys = PSB.build_system(PSITestSystems, "c_sys5_bat_ems") model = DecisionModel(MockOperationProblem, DCPPowerModel, sys) mock_construct_device!(model, device_model; built_for_recurrent_solves=true) - moi_tests(model, true, 120, 0, 72, 73, 24, true) + moi_tests(model, 145, 0, 72, 73, 24, true) end @testset "Test EnergyLimitFeedforward to BatteryEMS with BatteryAncillaryServices model" begin @@ -285,5 +285,5 @@ end sys = PSB.build_system(PSITestSystems, "c_sys5_bat_ems") model = DecisionModel(MockOperationProblem, DCPPowerModel, sys) mock_construct_device!(model, device_model; built_for_recurrent_solves=true) - moi_tests(model, true, 96, 0, 74, 72, 24, true) + moi_tests(model, 121, 0, 74, 72, 24, true) end diff --git a/test/test_device_thermal_generation_constructors.jl b/test/test_device_thermal_generation_constructors.jl index 5b79a46aeb..c2fe4efe8c 100644 --- a/test/test_device_thermal_generation_constructors.jl +++ b/test/test_device_thermal_generation_constructors.jl @@ -23,7 +23,7 @@ test_path = mktempdir() c_sys5_uc = PSB.build_system(PSITestSystems, "c_sys5_uc") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5_uc) mock_construct_device!(model, device_model) - moi_tests(model, false, 480, 0, 480, 120, 120, true) + moi_tests(model, 480, 0, 480, 120, 120, true) psi_constraint_test(model, uc_constraint_keys) psi_checkbinvar_test(model, bin_variable_keys) psi_checkobjfun_test(model, GAEVF) @@ -32,7 +32,7 @@ test_path = mktempdir() c_sys14 = PSB.build_system(PSITestSystems, "c_sys14") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys14) mock_construct_device!(model, device_model) - moi_tests(model, false, 480, 0, 240, 120, 120, true) + moi_tests(model, 480, 0, 240, 120, 120, true) psi_checkbinvar_test(model, bin_variable_keys) psi_checkobjfun_test(model, GQEVF) end @@ -60,7 +60,7 @@ end c_sys5_uc = PSB.build_system(PSITestSystems, "c_sys5_uc") model = DecisionModel(MockOperationProblem, ACPPowerModel, c_sys5_uc) mock_construct_device!(model, device_model) - moi_tests(model, false, 600, 0, 600, 240, 120, true) + moi_tests(model, 600, 0, 600, 240, 120, true) psi_constraint_test(model, uc_constraint_keys) psi_checkbinvar_test(model, bin_variable_keys) psi_checkobjfun_test(model, GAEVF) @@ -69,7 +69,7 @@ end c_sys14 = PSB.build_system(PSITestSystems, "c_sys14") model = DecisionModel(MockOperationProblem, ACPPowerModel, c_sys14;) mock_construct_device!(model, device_model) - moi_tests(model, false, 600, 0, 360, 240, 120, true) + moi_tests(model, 600, 0, 360, 240, 120, true) psi_checkbinvar_test(model, bin_variable_keys) psi_checkobjfun_test(model, GQEVF) end @@ -91,7 +91,7 @@ end c_sys5_uc = PSB.build_system(PSITestSystems, "c_sys5_pglib") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5_uc;) mock_construct_device!(model, device_model) - moi_tests(model, false, 384, 0, 240, 48, 144, true) + moi_tests(model, 384, 0, 240, 48, 144, true) psi_constraint_test(model, uc_constraint_keys) psi_checkbinvar_test(model, bin_variable_keys) psi_checkobjfun_test(model, GAEVF) @@ -114,7 +114,7 @@ end c_sys5_uc = PSB.build_system(PSITestSystems, "c_sys5_pglib") model = DecisionModel(MockOperationProblem, ACPPowerModel, c_sys5_uc;) mock_construct_device!(model, device_model) - moi_tests(model, false, 432, 0, 288, 96, 144, true) + moi_tests(model, 432, 0, 288, 96, 144, true) psi_constraint_test(model, uc_constraint_keys) psi_checkbinvar_test(model, bin_variable_keys) psi_checkobjfun_test(model, GAEVF) @@ -132,14 +132,14 @@ end c_sys5_uc = PSB.build_system(PSITestSystems, "c_sys5_uc") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5_uc) mock_construct_device!(model, device_model) - moi_tests(model, false, 480, 0, 240, 120, 120, true) + moi_tests(model, 480, 0, 240, 120, 120, true) psi_checkbinvar_test(model, bin_variable_keys) psi_checkobjfun_test(model, GAEVF) c_sys14 = PSB.build_system(PSITestSystems, "c_sys14") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys14;) mock_construct_device!(model, device_model) - moi_tests(model, false, 480, 0, 240, 120, 120, true) + moi_tests(model, 480, 0, 240, 120, 120, true) psi_checkbinvar_test(model, bin_variable_keys) psi_checkobjfun_test(model, GQEVF) end @@ -155,14 +155,14 @@ end c_sys5_uc = PSB.build_system(PSITestSystems, "c_sys5_uc") model = DecisionModel(MockOperationProblem, ACPPowerModel, c_sys5_uc) mock_construct_device!(model, device_model) - moi_tests(model, false, 600, 0, 360, 240, 120, true) + moi_tests(model, 600, 0, 360, 240, 120, true) psi_checkbinvar_test(model, bin_variable_keys) psi_checkobjfun_test(model, GAEVF) c_sys14 = PSB.build_system(PSITestSystems, "c_sys14") model = DecisionModel(MockOperationProblem, ACPPowerModel, c_sys14;) mock_construct_device!(model, device_model) - moi_tests(model, false, 600, 0, 360, 240, 120, true) + moi_tests(model, 600, 0, 360, 240, 120, true) psi_checkbinvar_test(model, bin_variable_keys) psi_checkobjfun_test(model, GQEVF) end @@ -178,7 +178,7 @@ end c_sys5_uc = PSB.build_system(PSITestSystems, "c_sys5_pglib") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5_uc;) mock_construct_device!(model, device_model) - moi_tests(model, false, 384, 0, 96, 48, 144, true) + moi_tests(model, 384, 0, 96, 48, 144, true) psi_checkbinvar_test(model, bin_variable_keys) psi_checkobjfun_test(model, GAEVF) end @@ -194,7 +194,7 @@ end c_sys5_uc = PSB.build_system(PSITestSystems, "c_sys5_pglib") model = DecisionModel(MockOperationProblem, ACPPowerModel, c_sys5_uc;) mock_construct_device!(model, device_model) - moi_tests(model, false, 432, 0, 144, 96, 144, true) + moi_tests(model, 432, 0, 144, 96, 144, true) psi_checkbinvar_test(model, bin_variable_keys) psi_checkobjfun_test(model, GAEVF) end @@ -205,13 +205,13 @@ end c_sys5 = PSB.build_system(PSITestSystems, "c_sys5") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5) mock_construct_device!(model, device_model) - moi_tests(model, false, 120, 0, 120, 120, 0, false) + moi_tests(model, 120, 0, 120, 120, 0, false) psi_checkobjfun_test(model, GAEVF) c_sys14 = PSB.build_system(PSITestSystems, "c_sys14") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys14) mock_construct_device!(model, device_model) - moi_tests(model, false, 120, 0, 120, 120, 0, false) + moi_tests(model, 120, 0, 120, 120, 0, false) psi_checkobjfun_test(model, GQEVF) end @@ -221,13 +221,13 @@ end model = DecisionModel(MockOperationProblem, ACPPowerModel, c_sys5) mock_construct_device!(model, device_model) - moi_tests(model, false, 240, 0, 240, 240, 0, false) + moi_tests(model, 240, 0, 240, 240, 0, false) psi_checkobjfun_test(model, GAEVF) c_sys14 = PSB.build_system(PSITestSystems, "c_sys14") model = DecisionModel(MockOperationProblem, ACPPowerModel, c_sys14;) mock_construct_device!(model, device_model) - moi_tests(model, false, 240, 0, 240, 240, 0, false) + moi_tests(model, 240, 0, 240, 240, 0, false) psi_checkobjfun_test(model, GQEVF) end @@ -237,7 +237,7 @@ end c_sys5 = PSB.build_system(PSITestSystems, "c_sys5_pglib") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5) mock_construct_device!(model, device_model) - moi_tests(model, false, 240, 0, 48, 48, 96, false) + moi_tests(model, 240, 0, 48, 48, 96, false) psi_checkobjfun_test(model, GAEVF) end @@ -246,7 +246,7 @@ end c_sys5 = PSB.build_system(PSITestSystems, "c_sys5_pglib") model = DecisionModel(MockOperationProblem, ACPPowerModel, c_sys5) mock_construct_device!(model, device_model) - moi_tests(model, false, 288, 0, 96, 96, 96, false) + moi_tests(model, 288, 0, 96, 96, 96, false) psi_checkobjfun_test(model, GAEVF) end @@ -256,7 +256,7 @@ end c_sys5 = PSB.build_system(PSITestSystems, "c_sys5") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5) mock_construct_device!(model, device_model) - moi_tests(model, false, 120, 0, 120, 120, 0, false) + moi_tests(model, 120, 0, 120, 120, 0, false) key = PSI.ConstraintKey(ActivePowerVariableLimitsConstraint, ThermalStandard, "lb") moi_lbvalue_test(model, key, 0.0) psi_checkobjfun_test(model, GAEVF) @@ -265,7 +265,7 @@ end model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys14) mock_construct_device!(model, device_model) - moi_tests(model, false, 120, 0, 120, 120, 0, false) + moi_tests(model, 120, 0, 120, 120, 0, false) key = PSI.ConstraintKey(ActivePowerVariableLimitsConstraint, ThermalStandard, "lb") moi_lbvalue_test(model, key, 0.0) psi_checkobjfun_test(model, GQEVF) @@ -276,7 +276,7 @@ end c_sys5 = PSB.build_system(PSITestSystems, "c_sys5") model = DecisionModel(MockOperationProblem, ACPPowerModel, c_sys5) mock_construct_device!(model, device_model) - moi_tests(model, false, 240, 0, 240, 240, 0, false) + moi_tests(model, 240, 0, 240, 240, 0, false) key = PSI.ConstraintKey(ActivePowerVariableLimitsConstraint, ThermalStandard, "lb") moi_lbvalue_test(model, key, 0.0) psi_checkobjfun_test(model, GAEVF) @@ -285,7 +285,7 @@ end model = DecisionModel(MockOperationProblem, ACPPowerModel, c_sys14;) mock_construct_device!(model, device_model) - moi_tests(model, false, 240, 0, 240, 240, 0, false) + moi_tests(model, 240, 0, 240, 240, 0, false) key = PSI.ConstraintKey(ActivePowerVariableLimitsConstraint, ThermalStandard, "lb") moi_lbvalue_test(model, key, 0.0) psi_checkobjfun_test(model, GQEVF) @@ -332,14 +332,14 @@ end c_sys5_uc = PSB.build_system(PSITestSystems, "c_sys5_uc") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5_uc;) mock_construct_device!(model, device_model) - moi_tests(model, false, 120, 0, 168, 168, 0, false) + moi_tests(model, 120, 0, 168, 168, 0, false) psi_constraint_test(model, constraint_keys) psi_checkobjfun_test(model, GAEVF) c_sys14 = PSB.build_system(PSITestSystems, "c_sys14") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys14;) mock_construct_device!(model, device_model) - moi_tests(model, false, 120, 0, 120, 120, 0, false) + moi_tests(model, 120, 0, 120, 120, 0, false) psi_checkobjfun_test(model, GQEVF) end @@ -352,14 +352,14 @@ end c_sys5_uc = PSB.build_system(PSITestSystems, "c_sys5_uc") model = DecisionModel(MockOperationProblem, ACPPowerModel, c_sys5_uc;) mock_construct_device!(model, device_model) - moi_tests(model, false, 240, 0, 288, 288, 0, false) + moi_tests(model, 240, 0, 288, 288, 0, false) psi_constraint_test(model, constraint_keys) psi_checkobjfun_test(model, GAEVF) c_sys14 = PSB.build_system(PSITestSystems, "c_sys14") model = DecisionModel(MockOperationProblem, ACPPowerModel, c_sys14;) mock_construct_device!(model, device_model) - moi_tests(model, false, 240, 0, 240, 240, 0, false) + moi_tests(model, 240, 0, 240, 240, 0, false) psi_checkobjfun_test(model, GQEVF) end @@ -372,7 +372,7 @@ end c_sys5_uc = PSB.build_system(PSITestSystems, "c_sys5_pglib") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5_uc;) mock_construct_device!(model, device_model) - moi_tests(model, false, 240, 0, 96, 96, 96, false) + moi_tests(model, 240, 0, 96, 96, 96, false) psi_constraint_test(model, constraint_keys) psi_checkobjfun_test(model, GAEVF) end @@ -386,7 +386,7 @@ end c_sys5_uc = PSB.build_system(PSITestSystems, "c_sys5_pglib") model = DecisionModel(MockOperationProblem, ACPPowerModel, c_sys5_uc;) mock_construct_device!(model, device_model) - moi_tests(model, false, 288, 0, 144, 144, 96, false) + moi_tests(model, 288, 0, 144, 144, 96, false) psi_constraint_test(model, constraint_keys) psi_checkobjfun_test(model, GAEVF) end @@ -416,7 +416,7 @@ end c_sys5_pglib = PSB.build_system(PSITestSystems, "c_sys5_pglib") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5_pglib;) mock_construct_device!(model, device_model) - moi_tests(model, false, 528, 0, no_less_than[false], 108, 192, true) + moi_tests(model, 528, 0, no_less_than[false], 108, 192, true) psi_constraint_test(model, constraint_keys) psi_checkobjfun_test(model, GAEVF) end @@ -444,7 +444,7 @@ end c_sys5_pglib = PSB.build_system(PSITestSystems, "c_sys5_pglib") model = DecisionModel(MockOperationProblem, ACPPowerModel, c_sys5_pglib;) mock_construct_device!(model, device_model) - moi_tests(model, false, 576, 0, no_less_than[false], 156, 192, true) + moi_tests(model, 576, 0, no_less_than[false], 156, 192, true) psi_constraint_test(model, constraint_keys) psi_checkobjfun_test(model, GAEVF) end @@ -455,7 +455,7 @@ end c_sys5 = PSB.build_system(PSITestSystems, "c_sys5") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5) mock_construct_device!(model, device_model) - moi_tests(model, false, 480, 0, 480, 120, 120, true) + moi_tests(model, 480, 0, 480, 120, 120, true) psi_checkobjfun_test(model, GAEVF) end @@ -464,7 +464,7 @@ end c_sys5_pglib = PSB.build_system(PSITestSystems, "c_sys5_pglib") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5_pglib;) mock_construct_device!(model, device_model) - moi_tests(model, false, 384, 0, 240, 48, 144, true) + moi_tests(model, 384, 0, 240, 48, 144, true) psi_checkobjfun_test(model, GAEVF) end @@ -473,7 +473,7 @@ end c_sys5 = PSB.build_system(PSITestSystems, "c_sys5") model = DecisionModel(MockOperationProblem, ACPPowerModel, c_sys5) mock_construct_device!(model, device_model) - moi_tests(model, false, 600, 0, 600, 240, 120, true) + moi_tests(model, 600, 0, 600, 240, 120, true) psi_checkobjfun_test(model, GAEVF) end @@ -482,7 +482,7 @@ end c_sys5_pglib = PSB.build_system(PSITestSystems, "c_sys5_pglib") model = DecisionModel(MockOperationProblem, ACPPowerModel, c_sys5_pglib;) mock_construct_device!(model, device_model) - moi_tests(model, false, 432, 0, 288, 96, 144, true) + moi_tests(model, 432, 0, 288, 96, 144, true) psi_checkobjfun_test(model, GAEVF) end @@ -492,7 +492,7 @@ end c_sys5 = PSB.build_system(PSITestSystems, "c_sys5") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5) mock_construct_device!(model, device_model) - moi_tests(model, false, 480, 0, 240, 120, 120, true) + moi_tests(model, 480, 0, 240, 120, 120, true) psi_checkobjfun_test(model, GAEVF) end @@ -501,7 +501,7 @@ end c_sys5_pglib = PSB.build_system(PSITestSystems, "c_sys5_pglib") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5_pglib;) mock_construct_device!(model, device_model) - moi_tests(model, false, 384, 0, 96, 48, 144, true) + moi_tests(model, 384, 0, 96, 48, 144, true) psi_checkobjfun_test(model, GAEVF) end @@ -510,7 +510,7 @@ end c_sys5 = PSB.build_system(PSITestSystems, "c_sys5") model = DecisionModel(MockOperationProblem, ACPPowerModel, c_sys5) mock_construct_device!(model, device_model) - moi_tests(model, false, 600, 0, 360, 240, 120, true) + moi_tests(model, 600, 0, 360, 240, 120, true) psi_checkobjfun_test(model, GAEVF) end @@ -519,7 +519,7 @@ end c_sys5_pglib = PSB.build_system(PSITestSystems, "c_sys5_pglib") model = DecisionModel(MockOperationProblem, ACPPowerModel, c_sys5_pglib;) mock_construct_device!(model, device_model) - moi_tests(model, false, 432, 0, 144, 96, 144, true) + moi_tests(model, 432, 0, 144, 96, 144, true) psi_checkobjfun_test(model, GAEVF) end @@ -529,7 +529,7 @@ end c_sys5 = PSB.build_system(PSITestSystems, "c_sys5") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5) mock_construct_device!(model, device_model; built_for_recurrent_solves=true) - moi_tests(model, true, 120, 0, 144, 144, 0, false) + moi_tests(model, 245, 0, 144, 144, 0, false) psi_checkobjfun_test(model, GAEVF) end @@ -538,7 +538,7 @@ end c_sys5_pglib = PSB.build_system(PSITestSystems, "c_sys5_pglib") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5_pglib) mock_construct_device!(model, device_model; built_for_recurrent_solves=true) - moi_tests(model, true, 240, 0, 96, 96, 96, false) + moi_tests(model, 290, 0, 96, 96, 96, false) psi_checkobjfun_test(model, GAEVF) end @@ -547,7 +547,7 @@ end c_sys5 = PSB.build_system(PSITestSystems, "c_sys5") model = DecisionModel(MockOperationProblem, ACPPowerModel, c_sys5) mock_construct_device!(model, device_model; built_for_recurrent_solves=true) - moi_tests(model, true, 240, 0, 264, 264, 0, false) + moi_tests(model, 365, 0, 264, 264, 0, false) psi_checkobjfun_test(model, GAEVF) end @@ -556,7 +556,7 @@ end c_sys5_pglib = PSB.build_system(PSITestSystems, "c_sys5_pglib") model = DecisionModel(MockOperationProblem, ACPPowerModel, c_sys5_pglib) mock_construct_device!(model, device_model; built_for_recurrent_solves=true) - moi_tests(model, true, 288, 0, 144, 144, 96, false) + moi_tests(model, 338, 0, 144, 144, 96, false) psi_checkobjfun_test(model, GAEVF) end @@ -574,7 +574,7 @@ end initialize_model=false, ) @test build!(ED; output_dir=mktempdir(cleanup=true)) == PSI.BuildStatus.BUILT - moi_tests(ED, false, 10, 0, 15, 15, 5, false) + moi_tests(ED, 10, 0, 15, 15, 5, false) psi_checksolve_test(ED, [MOI.OPTIMAL], 11191.00) end @@ -589,7 +589,7 @@ end initialize_model=false, ) @test build!(UC; output_dir=mktempdir(cleanup=true)) == PSI.BuildStatus.BUILT - moi_tests(UC, false, 56, 0, 56, 14, 21, true) + moi_tests(UC, 56, 0, 56, 14, 21, true) psi_checksolve_test(UC, [MOI.OPTIMAL], 8223.50) end @@ -604,7 +604,7 @@ end initialize_model=false, ) @test build!(UC; output_dir=mktempdir(cleanup=true)) == PSI.BuildStatus.BUILT - moi_tests(UC, false, 32, 0, 8, 4, 14, true) + moi_tests(UC, 32, 0, 8, 4, 14, true) psi_checksolve_test(UC, [MOI.OPTIMAL], 9336.736919354838) end @@ -618,7 +618,7 @@ end initialize_model=false, ) @test build!(UC; output_dir=mktempdir(cleanup=true)) == PSI.BuildStatus.BUILT - moi_tests(UC, false, 32, 0, 8, 4, 14, true) + moi_tests(UC, 32, 0, 8, 4, 14, true) # Cbc can have reliability issues with SoS. The objective function target in the this # test was calculated with CPLEX do not change if Cbc gets a bad result psi_checksolve_test(UC, [MOI.OPTIMAL], 8500.0, 10.0) @@ -638,7 +638,7 @@ end initialize_model=false, ) @test build!(UC; output_dir=mktempdir(cleanup=true)) == PSI.BuildStatus.BUILT - moi_tests(UC, false, 38, 0, 16, 8, 16, true) + moi_tests(UC, 38, 0, 16, 8, 16, true) end @testset "Solving UC Models with Linear Networks" begin @@ -678,7 +678,7 @@ end c_sys5 = PSB.build_system(PSITestSystems, "c_sys5") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5) mock_construct_device!(model, device_model; built_for_recurrent_solves=true) - moi_tests(model, true, 120, 0, 264, 144, 0, false) + moi_tests(model, 365, 0, 264, 144, 0, false) end @testset "Test Feedforwards to ThermalStandard with ThermalBasicDispatch" begin @@ -700,7 +700,7 @@ end c_sys5 = PSB.build_system(PSITestSystems, "c_sys5") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5) mock_construct_device!(model, device_model; built_for_recurrent_solves=true) - moi_tests(model, true, 120, 0, 240, 120, 0, false) + moi_tests(model, 360, 0, 240, 120, 0, false) end @testset "Test Feedforwards to ThermalStandard with ThermalCompactDispatch" begin @@ -722,7 +722,7 @@ end c_sys5 = PSB.build_system(PSITestSystems, "c_sys5") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5) mock_construct_device!(model, device_model; built_for_recurrent_solves=true) - moi_tests(model, true, 120, 0, 264, 144, 0, false) + moi_tests(model, 365, 0, 264, 144, 0, false) end @testset "Test Feedforwards to ThermalMultiStart with ThermalStandardDispatch" begin @@ -744,7 +744,7 @@ end c_sys5 = PSB.build_system(PSITestSystems, "c_sys5_pglib") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5) mock_construct_device!(model, device_model; built_for_recurrent_solves=true) - moi_tests(model, true, 240, 0, 144, 96, 96, false) + moi_tests(model, 338, 0, 144, 96, 96, false) end @testset "Test Feedforwards to ThermalMultiStart with ThermalBasicDispatch" begin @@ -766,7 +766,7 @@ end c_sys5 = PSB.build_system(PSITestSystems, "c_sys5_pglib") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5) mock_construct_device!(model, device_model; built_for_recurrent_solves=true) - moi_tests(model, true, 240, 0, 96, 48, 96, false) + moi_tests(model, 336, 0, 96, 48, 96, false) end @testset "Test Feedforwards to ThermalMultiStart with ThermalCompactDispatch" begin @@ -788,5 +788,5 @@ end c_sys5 = PSB.build_system(PSITestSystems, "c_sys5_pglib") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5) mock_construct_device!(model, device_model; built_for_recurrent_solves=true) - moi_tests(model, true, 240, 0, 144, 96, 96, false) + moi_tests(model, 338, 0, 144, 96, 96, false) end diff --git a/test/test_model_decision.jl b/test/test_model_decision.jl index 11f65f12cd..14723e8a8f 100644 --- a/test/test_model_decision.jl +++ b/test/test_model_decision.jl @@ -36,8 +36,6 @@ ) @test build!(model; output_dir=mktempdir(cleanup=true)) == PSI.BuildStatus.BUILT @test haskey(PSI.get_optimization_container(model).JuMPmodel.ext, :PSI_Testing) - @test (:ParameterJuMP in keys(PSI.get_optimization_container(model).JuMPmodel.ext)) == - false end @testset "Set optimizer at solve call" begin @@ -139,10 +137,10 @@ end c_sys5 = PSB.build_system(PSITestSystems, "c_sys5") model_ed = EconomicDispatchProblem(c_sys5; output_dir=mktempdir(), optimizer=HiGHS_optimizer) - moi_tests(model_ed, false, 120, 0, 120, 120, 24, false) + moi_tests(model_ed, 120, 0, 120, 120, 24, false) model_uc = UnitCommitmentProblem(c_sys5; output_dir=mktempdir(), optimizer=HiGHS_optimizer) - moi_tests(model_uc, false, 480, 0, 240, 120, 144, true) + moi_tests(model_uc, 480, 0, 240, 120, 144, true) ED_output = run_economic_dispatch(c_sys5; output_dir=mktempdir(), optimizer=HiGHS_optimizer) UC_output = @@ -379,10 +377,10 @@ end :ActivePowerVariableLimitsConstraint__ThermalStandard__ub => (coefficient=(min=1.0, max=1.0), rhs=(min=0.4, max=6.0)), ) - for (constriant_key, constriant_bounds) in model_bounds + for (constraint_key, constraint_bounds) in model_bounds _check_constraint_bounds( - constriant_bounds, - valid_model_bounds[PSI.encode_key(constriant_key)], + constraint_bounds, + valid_model_bounds[PSI.encode_key(constraint_key)], ) end end diff --git a/test/test_model_emulation.jl b/test/test_model_emulation.jl index eed753a302..0ad3cd6613 100644 --- a/test/test_model_emulation.jl +++ b/test/test_model_emulation.jl @@ -117,7 +117,7 @@ end ) for ic in ic_data name = PSY.get_name(ic.component) - e_var = JuMP.value(PSI.get_value(ic)) + e_var = PSI.jump_value(PSI.get_value(ic)) @test PSY.get_initial_energy(ic.component) == e_var end @test run!(model) == RunStatus.SUCCESSFUL @@ -141,7 +141,7 @@ end ) for ic in ic_data name = PSY.get_name(ic.component) - e_var = JuMP.value(PSI.get_value(ic)) + e_var = PSI.jump_value(PSI.get_value(ic)) @test PSY.get_initial_energy(ic.component) == e_var end @test run!(model) == RunStatus.SUCCESSFUL @@ -165,7 +165,7 @@ end ) for ic in ic_data name = PSY.get_name(ic.component) - e_var = JuMP.value(PSI.get_value(ic)) + e_var = PSI.jump_value(PSI.get_value(ic)) @test PSY.get_initial_energy(ic.component) == e_var end @test run!(model) == RunStatus.SUCCESSFUL @@ -285,7 +285,7 @@ end ) for ic in ic_data name = PSY.get_name(ic.component) - e_var = JuMP.value(PSI.get_value(ic)) + e_var = PSI.jump_value(PSI.get_value(ic)) @test PSY.get_initial_storage(ic.component) == e_var end @test run!(model) == RunStatus.SUCCESSFUL @@ -316,7 +316,7 @@ end ) for ic in ic_data name = PSY.get_name(ic.component) - e_var = JuMP.value(PSI.get_value(ic)) + e_var = PSI.jump_value(PSI.get_value(ic)) @test PSY.get_initial_storage(ic.component) == e_var end @test run!(model) == RunStatus.SUCCESSFUL @@ -474,7 +474,7 @@ end # Deserialize with different optimizer attributes. optimizer = JuMP.optimizer_with_attributes(HiGHS.Optimizer, "time_limit" => 110.0) - @test_logs (:warn, r"Different optimizer attributes are set") match_mode = :any EmulationModel( + @test_logs (:warn, r"Original solver was .*, new solver is") match_mode = :any EmulationModel( path, optimizer, ) diff --git a/test/test_network_constructors.jl b/test/test_network_constructors.jl index e320fed9e1..0e73a3c8bd 100644 --- a/test/test_network_constructors.jl +++ b/test/test_network_constructors.jl @@ -61,7 +61,6 @@ end psi_constraint_test(ps_model, constraint_keys) moi_tests( ps_model, - false, test_results[sys][1], test_results[sys][2], test_results[sys][3], @@ -122,7 +121,6 @@ end psi_constraint_test(ps_model, constraint_keys) moi_tests( ps_model, - false, test_results[sys][1], test_results[sys][2], test_results[sys][3], @@ -177,7 +175,6 @@ end psi_constraint_test(ps_model, constraint_keys) moi_tests( ps_model, - false, test_results[sys][1], test_results[sys][2], test_results[sys][3], @@ -223,7 +220,6 @@ end psi_constraint_test(ps_model, constraint_keys) moi_tests( ps_model, - false, test_results[sys][1], test_results[sys][2], test_results[sys][3], @@ -271,7 +267,6 @@ end psi_constraint_test(ps_model, constraint_keys) moi_tests( ps_model, - false, test_results[sys][1], test_results[sys][2], test_results[sys][3], @@ -314,7 +309,6 @@ end psi_constraint_test(ps_model, constraint_keys) moi_tests( ps_model, - false, test_results[sys][1], test_results[sys][2], test_results[sys][3], @@ -365,7 +359,6 @@ end psi_constraint_test(ps_model, constraint_keys) moi_tests( ps_model, - false, test_results[network][sys][1], test_results[network][sys][2], test_results[network][sys][3], @@ -409,7 +402,6 @@ end psi_constraint_test(ps_model, constraint_keys) moi_tests( ps_model, - false, test_results[network][sys][1], test_results[network][sys][2], test_results[network][sys][3], diff --git a/test/test_services_constructor.jl b/test/test_services_constructor.jl index d207b6e9a2..dda94fc38e 100644 --- a/test/test_services_constructor.jl +++ b/test/test_services_constructor.jl @@ -20,7 +20,7 @@ c_sys5_uc = PSB.build_system(PSITestSystems, "c_sys5_uc"; add_reserves=true) model = DecisionModel(template, c_sys5_uc) @test build!(model; output_dir=mktempdir(cleanup=true)) == PSI.BuildStatus.BUILT - moi_tests(model, false, 648, 0, 120, 216, 72, false) + moi_tests(model, 648, 0, 120, 216, 72, false) reserve_variables = [ :ActivePowerReserveVariable__VariableReserve_ReserveUp_Reserve1 :ActivePowerReserveVariable__ReserveDemandCurve_ReserveUp_ORDC1 @@ -55,7 +55,7 @@ end c_sys5_uc = PSB.build_system(PSITestSystems, "c_sys5_uc"; add_reserves=true) model = DecisionModel(template, c_sys5_uc) @test build!(model; output_dir=mktempdir(cleanup=true)) == PSI.BuildStatus.BUILT - moi_tests(model, false, 384, 0, 336, 192, 24, false) + moi_tests(model, 384, 0, 336, 192, 24, false) reserve_variables = [ :ActivePowerReserveVariable__VariableReserve_ReserveDown_Reserve2, :ActivePowerReserveVariable__VariableReserve_ReserveUp_Reserve1, @@ -93,7 +93,7 @@ end model = DecisionModel(template, c_sys5_uc; optimizer=cbc_optimizer) @test build!(model; output_dir=mktempdir(cleanup=true)) == PSI.BuildStatus.BUILT - moi_tests(model, false, 1008, 0, 480, 216, 192, true) + moi_tests(model, 1008, 0, 480, 216, 192, true) end @testset "Test Reserves from Thermal Standard UC with NonSpinningReserve" begin @@ -110,7 +110,7 @@ end c_sys5_uc = PSB.build_system(PSITestSystems, "c_sys5_uc_non_spin"; add_reserves=true) model = DecisionModel(template, c_sys5_uc; optimizer=HiGHS_optimizer) @test build!(model; output_dir=mktempdir(cleanup=true)) == PSI.BuildStatus.BUILT - moi_tests(model, false, 1032, 0, 888, 192, 288, true) + moi_tests(model, 1032, 0, 888, 192, 288, true) end @testset "Test Upwards Reserves from Renewable Dispatch" begin @@ -129,7 +129,7 @@ end c_sys5_re = PSB.build_system(PSITestSystems, "c_sys5_re"; add_reserves=true) model = DecisionModel(template, c_sys5_re) @test build!(model; output_dir=mktempdir(cleanup=true)) == PSI.BuildStatus.BUILT - moi_tests(model, false, 360, 0, 72, 48, 72, false) + moi_tests(model, 360, 0, 72, 48, 72, false) end @testset "Test Reserves from Storage" begin @@ -152,7 +152,7 @@ end c_sys5_bat = PSB.build_system(PSITestSystems, "c_sys5_bat"; add_reserves=true) model = DecisionModel(template, c_sys5_bat) @test build!(model; output_dir=mktempdir(cleanup=true)) == PSI.BuildStatus.BUILT - moi_tests(model, false, 432, 0, 288, 264, 96, true) + moi_tests(model, 432, 0, 288, 264, 96, true) end @testset "Test Reserves from Hydro" begin @@ -175,7 +175,7 @@ end c_sys5_hyd = PSB.build_system(PSITestSystems, "c_sys5_hyd"; add_reserves=true) model = DecisionModel(template, c_sys5_hyd) @test build!(model; output_dir=mktempdir(cleanup=true)) == PSI.BuildStatus.BUILT - moi_tests(model, false, 240, 0, 48, 96, 72, false) + moi_tests(model, 240, 0, 48, 96, 72, false) end @testset "Test Reserves from with slack variables" begin @@ -208,7 +208,7 @@ end c_sys5_uc = PSB.build_system(PSITestSystems, "c_sys5_uc"; add_reserves=true) model = DecisionModel(template, c_sys5_uc;) @test build!(model; output_dir=mktempdir(cleanup=true)) == PSI.BuildStatus.BUILT - moi_tests(model, false, 504, 0, 120, 192, 24, false) + moi_tests(model, 504, 0, 120, 192, 24, false) end @testset "Test AGC" begin @@ -220,7 +220,7 @@ end agc_problem = DecisionModel(AGCReserveDeployment, template_agc, c_sys5_reg) @test build!(agc_problem; output_dir=mktempdir(cleanup=true)) == PSI.BuildStatus.BUILT # These values might change as the AGC model is refined - moi_tests(agc_problem, false, 696, 0, 480, 0, 384, false) + moi_tests(agc_problem, 696, 0, 480, 0, 384, false) end @testset "Test GroupReserve from Thermal Dispatch" begin @@ -264,7 +264,7 @@ end model = DecisionModel(template, c_sys5_uc) @test build!(model; output_dir=mktempdir(cleanup=true)) == PSI.BuildStatus.BUILT - moi_tests(model, false, 648, 0, 120, 240, 72, false) + moi_tests(model, 648, 0, 120, 240, 72, false) end @testset "Test GroupReserve Errors" begin @@ -338,5 +338,5 @@ end c_sys5_uc = PSB.build_system(PSITestSystems, "c_sys5_uc"; add_reserves=true) model = DecisionModel(template, c_sys5_uc; optimizer=HiGHS_optimizer) @test build!(model; output_dir=mktempdir(cleanup=true)) == PSI.BuildStatus.BUILT - moi_tests(model, false, 240, 0, 120, 264, 24, false) + moi_tests(model, 240, 0, 120, 264, 24, false) end diff --git a/test/test_utils/model_checks.jl b/test/test_utils/model_checks.jl index bb53f0887d..3a38166dcd 100644 --- a/test/test_utils/model_checks.jl +++ b/test/test_utils/model_checks.jl @@ -3,7 +3,6 @@ const GQEVF = JuMP.GenericQuadExpr{Float64, VariableRef} function moi_tests( model::DecisionModel, - params::Bool, vars::Int, interval::Int, lessthan::Int, @@ -12,7 +11,6 @@ function moi_tests( binary::Bool, ) JuMPmodel = PSI.get_jump_model(model) - @test (:ParameterJuMP in keys(JuMPmodel.ext)) == params @test JuMP.num_variables(JuMPmodel) == vars @test JuMP.num_constraints(JuMPmodel, GAEVF, MOI.Interval{Float64}) == interval @test JuMP.num_constraints(JuMPmodel, GAEVF, MOI.LessThan{Float64}) == lessthan @@ -151,7 +149,7 @@ function check_flow_variable_values( psi_cont = PSI.get_optimization_container(model) variable = PSI.get_variable(psi_cont, T(), U) for var in variable[device_name, :] - if !(JuMP.value(var) <= (limit + 1e-2)) + if !(PSI.jump_value(var) <= (limit + 1e-2)) return false end end @@ -169,8 +167,8 @@ function check_flow_variable_values( psi_cont = PSI.get_optimization_container(model) variable = PSI.get_variable(psi_cont, T(), U) for var in variable[device_name, :] - if !(JuMP.value(var) <= (limit_max + 1e-2)) || - !(JuMP.value(var) >= (limit_min - 1e-2)) + if !(PSI.jump_value(var) <= (limit_max + 1e-2)) || + !(PSI.jump_value(var) >= (limit_min - 1e-2)) return false end end @@ -191,8 +189,8 @@ function check_flow_variable_values( pvariable = PSI.get_variable(psi_cont, T(), V) qvariable = PSI.get_variable(psi_cont, U(), V) for t in time_steps - fp = JuMP.value(pvariable[device_name, t]) - fq = JuMP.value(qvariable[device_name, t]) + fp = PSI.jump_value(pvariable[device_name, t]) + fq = PSI.jump_value(qvariable[device_name, t]) flow = sqrt((fp)^2 + (fq)^2) if !(flow <= (limit_max + 1e-2)^2) || !(flow >= (limit_min - 1e-2)^2) return false @@ -214,8 +212,8 @@ function check_flow_variable_values( pvariable = PSI.get_variable(psi_cont, T(), V) qvariable = PSI.get_variable(psi_cont, U(), V) for t in time_steps - fp = JuMP.value(pvariable[device_name, t]) - fq = JuMP.value(qvariable[device_name, t]) + fp = PSI.jump_value(pvariable[device_name, t]) + fq = PSI.jump_value(qvariable[device_name, t]) flow = sqrt((fp)^2 + (fq)^2) if !(flow <= (limit + 1e-2)^2) return false @@ -258,7 +256,7 @@ function check_duration_on_initial_conditions_values( 1, name, ] - duration_on = JuMP.value(PSI.get_value(ic)) + duration_on = PSI.jump_value(PSI.get_value(ic)) if on_var == 1.0 && PSY.get_status(ic.component) @test duration_on == PSY.get_time_at_status(ic.component) elseif on_var == 1.0 && !PSY.get_status(ic.component) @@ -284,7 +282,7 @@ function check_duration_off_initial_conditions_values( 1, name, ] - duration_off = JuMP.value(PSI.get_value(ic)) + duration_off = PSI.jump_value(PSI.get_value(ic)) if on_var == 0.0 && !PSY.get_status(ic.component) @test duration_off == PSY.get_time_at_status(ic.component) elseif on_var == 0.0 && PSY.get_status(ic.component) @@ -301,7 +299,7 @@ function check_energy_initial_conditions_values(model, ::Type{T}) where {T <: PS ) for ic in ic_data name = PSY.get_name(ic.component) - e_value = JuMP.value(PSI.get_value(ic)) + e_value = PSI.jump_value(PSI.get_value(ic)) @test PSY.get_initial_energy(ic.component) == e_value end end @@ -314,7 +312,7 @@ function check_energy_initial_conditions_values(model, ::Type{T}) where {T <: PS ) for ic in ic_data name = PSY.get_name(ic.component) - e_value = JuMP.value(PSI.get_value(ic)) + e_value = PSI.jump_value(PSI.get_value(ic)) @test PSY.get_initial_storage(ic.component) == e_value end end @@ -330,7 +328,7 @@ function check_status_initial_conditions_values(model, ::Type{T}) where {T <: PS 1, name, ] - @test JuMP.value(PSI.get_value(ic)) == status + @test PSI.jump_value(PSI.get_value(ic)) == status end end @@ -352,7 +350,7 @@ function check_active_power_initial_condition_values( 1, name, ] - @test JuMP.value(PSI.get_value(ic)) == power + @test PSI.jump_value(PSI.get_value(ic)) == power end end @@ -377,7 +375,7 @@ function check_active_power_abovemin_initial_condition_values( 1, name, ] - @test JuMP.value(PSI.get_value(ic)) == power + @test PSI.jump_value(PSI.get_value(ic)) == power end end