martinbiel / StochasticPrograms.jl

Julia package for formulating and analyzing stochastic recourse models.
MIT License
75 stars 25 forks source link

Problem in Infinite sample space #22

Closed bigadolfo closed 3 years ago

bigadolfo commented 3 years ago

Hi everyone

I am doing an exercise of Problem in Infinite sample space of

In this code:

@sampler SimpleSampler = begin
    N::StochasticPrograms.MvNormal

    SimpleSampler(μ, Σ) = new(StochasticPrograms.MvNormal(μ, Σ))

    @sample Scenario begin
        x = rand(sampler.N)
        return Scenario(q₁ = x[1], q₂ = x[2], d₁ = x[3], d₂ = x[4])
    end
end

μ = [24, 32, 400, 200]
Σ = [2 0.5 0 0
     0.5 1 0 0
     0 0 50 20
     0 0 20 30]

sampler = SimpleSampler(μ, Σ)

For now, we create a small sampled model of just 5 scenarios:

sampled_sp = instantiate(simple_model, sampler, 5, optimizer = GLPK.Optimizer)

I have a problem in the last line. The error is:

Given scenario Scenario with probability 0.2
  q₁: 25.786120623257716
  q₂: 33.627968929085654
  d₁: 397.440154821561
  d₂: 196.0127389756704 does not match @uncertain declaration.
in top-level scope at EjemploEstocastico2.jl:24
in  at StochasticPrograms\yFtc7\src\methods\api.jl:143
in #instantiate#487 at StochasticPrograms\yFtc7\src\methods\api.jl:158
in generate! at StochasticPrograms\yFtc7\src\methods\generation.jl:96
in generate! at StochasticPrograms\yFtc7\src\methods\deterministic_equivalent\generation.jl:11
in generate! at StochasticPrograms\yFtc7\src\methods\deterministic_equivalent\generation.jl:44
in  at base\none
in #11 at EjemploEstocastico.jl:18 
in error at base\error.jl:33

Can you help me, please?

Thanks in advance, Adolfo

martinbiel commented 3 years ago

What is your @uncertain declaration?

Also, please consider posting on discourse first for usage questions. The issues section should ideally be used for bugs and feature requests.