Closed blegat closed 8 years ago
I think the first solution that you implemented seems more natural. A few minor points:
same_children_as
rather than same_children_than
?if same_children_than !== nothing
line? To make sure that isa(same_children_than, JuMP.Model)
and that haskey(same_children_than, :Stochastic)
, and give a nicer error if not.Is it better to check with isa
or to specify the type Nullable{JuMP.Model}
in the signature ?
AFAICT that would mean that a caller to StructuredModel
would have to wrap same_children_than=Nullable(model)
in a Nullable, which is a bit noisier:
julia> function foo(x; y::Nullable{Int}=Nullable(1))
y
end
foo (generic function with 1 method)
julia> foo(1, y=2)
ERROR: TypeError: foo: in typeassert, expected Nullable{Int64}, got Int64
julia> foo(1)
Nullable(1)
julia> foo(1, y=Nullable(2))
Nullable(2)
Done :)
Thanks!
The first commit is a small fix for the previous pull request. The second commit is more important. For the SDDP package, I allow to either supply the data using a low level interface using matrices or to use StructJuMP. The issue is that usually, the number of stages is like 48 with 3 scenarios at each stages which makes 3^48 possible realization of the uncertainty. However the uncertainty at each stages are usually independant which is called "serial independance" so instead of having to do
we could do something like
where basically, each of the 3 scenarios has the same 3 children which are the 3 scenarios at the next stage.
To add this functionality to
StructJuMP
, I see 2 options.What do you think ?