NREL-Sienna / PowerSimulations.jl

Julia for optimization simulation and modeling of PowerSystems. Part of the Scalable Integrated Infrastructure Planning Initiative at the National Renewable Energy Lab.
https://nrel-sienna.github.io/PowerSimulations.jl/latest/
BSD 3-Clause "New" or "Revised" License
282 stars 55 forks source link

UnitCommitment not working on RTS #130

Closed claytonpbarrows closed 5 years ago

claytonpbarrows commented 5 years ago
UC = PSI.UnitCommitment(sys_rts, PSI.CopperPlatePowerModel; optimizer = xpress_optimizer, parameters=false)

KeyError: key 0.7999999999999998 not found

Stacktrace:
 [1] getindex at ./dict.jl:478 [inlined]
 [2] lookup_index at /Users/cbarrows/.julia/packages/JuMP/amunB/src/Containers/DenseAxisArray.jl:136 [inlined]
 [3] _to_index_tuple at /Users/cbarrows/.julia/packages/JuMP/amunB/src/Containers/DenseAxisArray.jl:145 [inlined] (repeats 2 times)
 [4] to_index at /Users/cbarrows/.julia/packages/JuMP/amunB/src/Containers/DenseAxisArray.jl:163 [inlined]
 [5] getindex(::JuMP.Containers.DenseAxisArray{VariableRef,2,Tuple{Array{String,1},UnitRange{Int64}},Tuple{Dict{String,Int64},Dict{Int64,Int64}}}, ::String, ::Float64) at /Users/cbarrows/.julia/packages/JuMP/amunB/src/Containers/DenseAxisArray.jl:177
 [6] (::getfield(PowerSimulations, Symbol("##29#33")){PowerSimulations.CanonicalModel,Tuple{Symbol,Symbol,Symbol}})(::Float64) at ./none:0
 [7] iterate at ./generator.jl:47 [inlined]
 [8] grow_to!(::Array{Any,1}, ::Base.Generator{Base.Iterators.Filter{getfield(PowerSimulations, Symbol("##30#34")),StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}},getfield(PowerSimulations, Symbol("##29#33")){PowerSimulations.CanonicalModel,Tuple{Symbol,Symbol,Symbol}}}) at ./array.jl:666
 [9] collect at ./array.jl:604 [inlined]
 [10] macro expansion at /Users/cbarrows/.julia/packages/JuMP/amunB/src/macros.jl:380 [inlined]
 [11] device_duration_retrospective(::PowerSimulations.CanonicalModel, ::Tuple{Array{String,1},Array{NamedTuple{(:up, :down),Tuple{Float64,Float64}},1}}, ::Array{PowerSimulations.InitialCondition,1}, ::Array{PowerSimulations.InitialCondition,1}, ::UnitRange{Int64}, ::Symbol, ::Tuple{Symbol,Symbol,Symbol}) at /Users/cbarrows/.julia/packages/PowerSimulations/Oz0EG/src/devices/device_models/common/duration_constraints.jl:36
 [12] time_constraints(::PowerSimulations.CanonicalModel, ::Array{ThermalDispatch,1}, ::Type{PowerSimulations.ThermalUnitCommitment}, ::Type{CopperPlatePowerModel}, ::UnitRange{Int64}, ::Bool) at /Users/cbarrows/.julia/packages/PowerSimulations/Oz0EG/src/devices/device_models/thermal_generation.jl:407
 [13] #construct_device!#104(::Base.Iterators.Pairs{Symbol,Bool,Tuple{Symbol},NamedTuple{(:parameters,),Tuple{Bool}}}, ::Function, ::PowerSimulations.CanonicalModel, ::Type{ThermalGen}, ::Type{PowerSimulations.ThermalUnitCommitment}, ::Type{CopperPlatePowerModel}, ::PowerSystem{ElectricLoad,Array{Branch,1},Array{Storage,1}}, ::UnitRange{Int64}) at /Users/cbarrows/.julia/packages/PowerSimulations/Oz0EG/src/devices/device_constructors/thermalgeneration_constructor.jl:77
 [14] #construct_device! at ./none:0 [inlined]
 [15] #construct_device!#4 at /Users/cbarrows/.julia/packages/PowerSimulations/Oz0EG/src/core/device_constructor.jl:8 [inlined]
 [16] (::getfield(PowerSimulations, Symbol("#kw##construct_device!")))(::NamedTuple{(:parameters,),Tuple{Bool}}, ::typeof(PowerSimulations.construct_device!), ::PowerSimulations.CanonicalModel, ::PowerSimulations.DeviceModel{ThermalGen,PowerSimulations.ThermalUnitCommitment}, ::Type{CopperPlatePowerModel}, ::PowerSystem{ElectricLoad,Array{Branch,1},Array{Storage,1}}, ::UnitRange{Int64}) at ./none:0
 [17] #build_canonical_model#8(::Base.Iterators.Pairs{Symbol,Bool,Tuple{Symbol},NamedTuple{(:parameters,),Tuple{Bool}}}, ::Function, ::Type{CopperPlatePowerModel}, ::Dict{Symbol,PowerSimulations.DeviceModel}, ::Dict{Symbol,PowerSimulations.DeviceModel}, ::Dict{Symbol,PowerSimulations.ServiceModel}, ::PowerSystem{ElectricLoad,Array{Branch,1},Array{Storage,1}}, ::OptimizerFactory) at /Users/cbarrows/.julia/packages/PowerSimulations/Oz0EG/src/core/canonical_constructor.jl:90
 [18] #build_canonical_model at ./none:0 [inlined]
 [19] #PowerOperationModel#2 at /Users/cbarrows/.julia/packages/PowerSimulations/Oz0EG/src/core/core_structs/operation_model.jl:23 [inlined]
 [20] Type at ./none:0 [inlined]
 [21] #UnitCommitment#161(::OptimizerFactory, ::Base.Iterators.Pairs{Symbol,Bool,Tuple{Symbol},NamedTuple{(:parameters,),Tuple{Bool}}}, ::Type, ::PowerSystem{ElectricLoad,Array{Branch,1},Array{Storage,1}}, ::Type{CopperPlatePowerModel}) at /Users/cbarrows/.julia/packages/PowerSimulations/Oz0EG/src/operation_models/unit_commitment.jl:11
 [22] (::getfield(Core, Symbol("#kw#Type")))(::NamedTuple{(:optimizer, :parameters),Tuple{OptimizerFactory,Bool}}, ::Type{UnitCommitment}, ::PowerSystem{ElectricLoad,Array{Branch,1},Array{Storage,1}}, ::Type{CopperPlatePowerModel}) at ./none:0
 [23] top-level scope at In[33]:1
jd-lara commented 5 years ago

This is a data input problem, the data needs to be parsed consistently such that the parameters of the duration constraints are integers as the number of periods.

jd-lara commented 5 years ago

Since this is a parsing problem I will close the issue and add a warning when making the UC constraints.

claytonpbarrows commented 5 years ago

is it though? Should min up/down times be int values? I'd argue that power simulations should do the conversion depending on the resolution of the simulation

jd-lara commented 5 years ago

Then we need to have a specific unit for this parameter in PowerSystems, is it pu/min?

claytonpbarrows commented 5 years ago

I think it should be: