Closed thvo1304 closed 3 years ago
It is a type inference issue, your sampled_d = []
gives an Array{Any,1}
which is not recognized as an array of scenarios. Inititializing it as sampled_d = SampleScenario[]
should fix it.
Note, that with the latest release you can safely rely on the fallback scenario structure for implementations like this:
SAA_model = @stochastic_model begin
@stage 1 begin
@decision(model, x[i in loc], Bin)
@objective(model, Min, sum(f[i]*x[i] for i in loc))
@constraint(model, max_d <= sum(q[i]*x[i] for i in loc))
end
@stage 2 begin
@uncertain d[j in cust]
@variable(model, y[i in loc, j in cust] >= 0)
@objective(model, Min, sum(c[i,j]*y[i,j] for i in loc, j in cust))
for j in cust
@constraint(m, sum(y[i,j] for i in loc) == 1)
end
@constraint(model, sum(d[j]*y[i,j] for i in loc, j in cust) <= (q[i]*x[i] for i in loc))
end
end
sampled_d = Scenario[]
for i in 1:size(new_d,2)
scen_d = @scenario d[j in cust] = new_d[:,i] probability = 1/s
push!(sampled_d, scen_d)
end
Note the @uncertain
declaration and the matching @scenario
instantiation. The above code is not tested since I do not know what new_d
and s
etc are.
Hello, I'm trying to create a stochastic model with a defined scenario using the instantiate function. However, I'm being stuck at the step of generating the model.
This is the errors that i got :
This is a scenario that I created - I created 10 scenarios and stored them in sampled_d
I don't know how to solve this problem. Hope you can help! Thank you.