StructJuMP / StructJuMP.jl

A block-structured optimization framework for JuMP
Other
54 stars 19 forks source link

creating stochastic model with fix number scenarios reports error. #12

Closed fqiang closed 8 years ago

fqiang commented 8 years ago

julia> firststage = StochasticModel(2) ERROR: MethodError: StochasticModel has no method matching StochasticModel(::Int64) Closest candidates are: StochasticModel(::Any, ::Any) StochasticModel(::Any, ::Any, ::Any)


Or how about to auto increment the number for each adding of the children stochastic block?

fqiang commented 8 years ago
function StochasticModel(nscen::Int)
    m = JuMP.Model(solver=JuMP.UnsetSolver())
    m.ext[:Stochastic] = StochasticData(JuMP.Model[],nothing,nscen)
    return m
end

adding explicit constructor works.

joehuchette commented 8 years ago

You need to specify this with a keyword argument:

firststage = StochasticModel(num_scenarios=2)