Hi Henrique,
Thank so much for your previous assistance I have managed to compute all the constraints for this model. I am currently having problems with the objective function that is returning a key error.
@objective example2_netprofit Max begin
NetP == sum(price[s] * sum(ST[s,n] + sum(rho[i,s]*bs[i,np,n] for i in 1:length(Ips4) for np in (n-d):n ) for n in 1:length(n) if n != 1:length(n)-1) for s in Sp)
end
Here is the error returned
KeyError: key (1, βs4β) not found
Stacktrace:
[1] getindex at C:\Users\glmab.julia\packages\OrderedCollections\DqfZ7\src\ordered_dict.jl:346 [inlined]
[2] getindex(::OrderedDict{Tuple{String,String},Int64}, ::Int64, ::String) at .\abstractdict.jl:499
[3] (::var"#435#441"{Int64,Int64,String})(::Int64) at .\none:0
[4] MappingRF at .\reduce.jl:93 [inlined]
[5] _foldl_impl(::Base.MappingRF{var"#435#441"{Int64,Int64,String},Base.BottomRF{typeof(Base.add_sum)}}, ::Base._InitialValue, ::UnitRange{Int64}) at .\reduce.jl:58
[6] FlatteningRF at .\reduce.jl:119 [inlined]
[7] MappingRF at .\reduce.jl:93 [inlined]
[8] _foldl_impl(::Base.MappingRF{var"#436#440"{Int64,String},Base.FlatteningRF{Base.BottomRF{typeof(Base.add_sum)}}}, ::Base._InitialValue, ::UnitRange{Int64}) at .\reduce.jl:58
[9] foldl_impl at .\reduce.jl:48 [inlined]
[10] mapfoldl_impl at .\reduce.jl:44 [inlined]
[11] #mapfoldl#204 at .\reduce.jl:160 [inlined]
[12] mapfoldl at .\reduce.jl:160 [inlined]
[13] #mapreduce#208 at .\reduce.jl:287 [inlined]
[14] mapreduce at .\reduce.jl:287 [inlined]
[15] sum at .\reduce.jl:494 [inlined]
[16] sum(::Base.Iterators.Flatten{Base.Generator{UnitRange{Int64},var"#436#440"{Int64,String}}}) at .\reduce.jl:511
[17] (::var"#434#439"{String})(::Int64) at .\none:0
[18] MappingRF at .\reduce.jl:93 [inlined]
[19] FilteringRF at .\reduce.jl:105 [inlined]
[20] _foldl_impl(::Base.FilteringRF{var"#437#442",Base.MappingRF{var"#434#439"{String},Base.BottomRF{typeof(Base.add_sum)}}}, ::Base._InitialValue, ::UnitRange{Int64}) at .\reduce.jl:58
[21] foldl_impl at .\reduce.jl:48 [inlined]
[22] mapfoldl_impl at .\reduce.jl:44 [inlined]
[23] #mapfoldl#204 at .\reduce.jl:160 [inlined]
[24] mapfoldl at .\reduce.jl:160 [inlined]
[25] #mapreduce#208 at .\reduce.jl:287 [inlined]
[26] mapreduce at .\reduce.jl:287 [inlined]
[27] sum at .\reduce.jl:494 [inlined]
[28] sum(::Base.Generator{Base.Iterators.Filter{var"#437#442",UnitRange{Int64}},var"#434#439"{String}}) at .\reduce.jl:511
[29] (::var"#433#438")(::String) at .\none:0
[30] MappingRF at .\reduce.jl:93 [inlined]
[31] _foldl_impl(::Base.MappingRF{var"#433#438",Base.BottomRF{typeof(Base.add_sum)}}, ::Base._InitialValue, ::Array{String,1}) at .\reduce.jl:58
[32] foldl_impl at .\reduce.jl:48 [inlined]
[33] mapfoldl_impl(::typeof(identity), ::typeof(Base.add_sum), ::NamedTuple{(),Tuple{}}, ::Base.Generator{Array{String,1},var"#433#438"}) at .\reduce.jl:44
[34] mapfoldl(::Function, ::Function, ::Base.Generator{Array{String,1},var"#433#438"}; kw::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at .\reduce.jl:160
[35] mapfoldl at .\reduce.jl:160 [inlined]
[36] mapreduce(::Function, ::Function, ::Base.Generator{Array{String,1},var"#433#438"}; kw::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at .\reduce.jl:287
[37] mapreduce at .\reduce.jl:287 [inlined]
[38] sum at .\reduce.jl:494 [inlined]
[39] sum(::Base.Generator{Array{String,1},var"#433#438"}) at .\reduce.jl:511
[40] top-level scope at In[33]:4
[41] top-level scope at C:\Users\glmab.julia\packages\MutableArithmetics\bPWR4\src\rewrite.jl:276
[42] top-level scope at C:\Users\glmab.julia\packages\JuMP\y5vgk\src\macros.jl:928
[43] top-level scope at In[33]:3
[44] include_string(::Function, ::Module, ::String, ::String) at .\loading.jl:1091
When I change the one component giving therror to for i in Ips4 see code below
@objective example2_netprofit Max begin
NetP == sum(price[s] * sum(ST[s,n] + sum(rho[i,s]*bs[i,np,n] for i in Ips4 for np in (n-d):n ) for n in 1:length(n) if n != 1:length(n)-1) for s in Sp)
end
It returns the following error
KeyError: key ([βt4β, βt5β], βs4β) not found
Stacktrace:
[1] getindex at C:\Users\glmab.julia\packages\OrderedCollections\DqfZ7\src\ordered_dict.jl:346 [inlined]
[2] getindex(::OrderedDict{Tuple{String,String},Int64}, ::Array{String,1}, ::String) at .\abstractdict.jl:499
[3] (::var"#445#451"{Array{String,1},Int64,String})(::Int64) at .\none:0
[4] MappingRF at .\reduce.jl:93 [inlined]
[5] _foldl_impl(::Base.MappingRF{var"#445#451"{Array{String,1},Int64,String},Base.BottomRF{typeof(Base.add_sum)}}, ::Base._InitialValue, ::UnitRange{Int64}) at .\reduce.jl:58
[6] FlatteningRF at .\reduce.jl:119 [inlined]
[7] MappingRF at .\reduce.jl:93 [inlined]
[8] _foldl_impl(::Base.MappingRF{var"#446#450"{Int64,String},Base.FlatteningRF{Base.BottomRF{typeof(Base.add_sum)}}}, ::Base._InitialValue, ::Array{Array{String,1},1}) at .\reduce.jl:58
[9] foldl_impl at .\reduce.jl:48 [inlined]
[10] mapfoldl_impl at .\reduce.jl:44 [inlined]
[11] #mapfoldl#204 at .\reduce.jl:160 [inlined]
[12] mapfoldl at .\reduce.jl:160 [inlined]
[13] #mapreduce#208 at .\reduce.jl:287 [inlined]
[14] mapreduce at .\reduce.jl:287 [inlined]
[15] sum at .\reduce.jl:494 [inlined]
[16] sum(::Base.Iterators.Flatten{Base.Generator{Array{Array{String,1},1},var"#446#450"{Int64,String}}}) at .\reduce.jl:511
[17] (::var"#444#449"{String})(::Int64) at .\none:0
[18] MappingRF at .\reduce.jl:93 [inlined]
[19] FilteringRF at .\reduce.jl:105 [inlined]
[20] _foldl_impl(::Base.FilteringRF{var"#447#452",Base.MappingRF{var"#444#449"{String},Base.BottomRF{typeof(Base.add_sum)}}}, ::Base._InitialValue, ::UnitRange{Int64}) at .\reduce.jl:58
[21] foldl_impl at .\reduce.jl:48 [inlined]
[22] mapfoldl_impl at .\reduce.jl:44 [inlined]
[23] #mapfoldl#204 at .\reduce.jl:160 [inlined]
[24] mapfoldl at .\reduce.jl:160 [inlined]
[25] #mapreduce#208 at .\reduce.jl:287 [inlined]
[26] mapreduce at .\reduce.jl:287 [inlined]
[27] sum at .\reduce.jl:494 [inlined]
[28] sum(::Base.Generator{Base.Iterators.Filter{var"#447#452",UnitRange{Int64}},var"#444#449"{String}}) at .\reduce.jl:511
[29] (::var"#443#448")(::String) at .\none:0
[30] MappingRF at .\reduce.jl:93 [inlined]
[31] _foldl_impl(::Base.MappingRF{var"#443#448",Base.BottomRF{typeof(Base.add_sum)}}, ::Base._InitialValue, ::Array{String,1}) at .\reduce.jl:58
[32] foldl_impl at .\reduce.jl:48 [inlined]
[33] mapfoldl_impl(::typeof(identity), ::typeof(Base.add_sum), ::NamedTuple{(),Tuple{}}, ::Base.Generator{Array{String,1},var"#443#448"}) at .\reduce.jl:44
[34] mapfoldl(::Function, ::Function, ::Base.Generator{Array{String,1},var"#443#448"}; kw::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at .\reduce.jl:160
[35] mapfoldl at .\reduce.jl:160 [inlined]
[36] mapreduce(::Function, ::Function, ::Base.Generator{Array{String,1},var"#443#448"}; kw::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at .\reduce.jl:287
[37] mapreduce at .\reduce.jl:287 [inlined]
[38] sum at .\reduce.jl:494 [inlined]
[39] sum(::Base.Generator{Array{String,1},var"#443#448"}) at .\reduce.jl:511
[40] top-level scope at In[34]:4
[41] top-level scope at C:\Users\glmab.julia\packages\MutableArithmetics\bPWR4\src\rewrite.jl:276
[42] top-level scope at C:\Users\glmab.julia\packages\JuMP\y5vgk\src\macros.jl:928
[43] top-level scope at In[34]:3
[44] include_string(::Function, ::Module, ::String, ::String) at .\loading.jl:1091
I am looking for it to be indexed as (βt4β, βs4β) and (βt5β, βs4β)
Hope you can assist in this. The above information can be utilised.
Thank you in advance