Hi,
My equation g below is a function of the variable d
which is indexed by s,n
. I would like to sampling points to be of d[s,n]. how do I create the correct lb and ub.
using DataStructures
using JuMP
using Surrogates
S = ["s1","s2","s3","s4"]
N = [1:10]
price = OrderedDict(
"s1" => 0,
"s2" => 0,
"s3" => 0,
"s4" => 5
)
m = Model()
@variables m begin
d[s in S, n in N] >= 0
end
g= d ->
@objective m Max begin
sum((price[s]*d[s,n]) for n in N for s in S)
end
lb = [S[1],1]
ub = [S[4],10]
x_train = sample(10, lb,ub, SobolSample())
y_train = g.(x_train);
This is my attempt but it is not working out when inputting into x_train.
This is the error being returned:
MethodError: no method matching +(::String, ::Int64)
Closest candidates are:
+(::Any, ::Any, ::Any, ::Any…) at operators.jl:538
+(::ChainRulesCore.DoesNotExist, ::Any) at C:\Users\glmab.julia\packages\ChainRulesCore\D0go7\src\differential_arithmetic.jl:23
+(::Complex{Bool}, ::Real) at complex.jl:301
…
Stacktrace:
[1] add_sum(::String, ::Int64) at .\reduce.jl:24
[2] _mapreduce(::typeof(identity), ::typeof(Base.add_sum), ::IndexLinear, ::Array{Any,1}) at .\reduce.jl:408
[3] _mapreduce_dim at .\reducedim.jl:318 [inlined]
[4] #mapreduce#620 at .\reducedim.jl:310 [inlined]
[5] mapreduce at .\reducedim.jl:310 [inlined]
[6] _sum at .\reducedim.jl:727 [inlined]
[7] _sum at .\reducedim.jl:726 [inlined]
[8] #sum#627 at .\reducedim.jl:722 [inlined]
[9] sum at .\reducedim.jl:722 [inlined]
[10] Sobol.SobolSeq(::Int64, ::Array{Any,1}, ::Array{Any,1}) at C:\Users\glmab.julia\packages\Sobol\l4iL1\src\Sobol.jl:121
[11] SobolSeq at C:\Users\glmab.julia\packages\Sobol\l4iL1\src\Sobol.jl:124 [inlined]
[12] sample(::Int64, ::Array{Any,1}, ::Array{Any,1}, ::SobolSample) at C:\Users\glmab.julia\packages\Surrogates\wJbFN\src\Sampling.jl:77
[13] top-level scope at In[66]:1
[14] include_string(::Function, ::Module, ::String, ::String) at .\loading.jl:1091