StructJuMP / StructJuMP.jl

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

Pull request/ef94d0ee #18

Closed blegat closed 8 years ago

blegat commented 8 years ago

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

for s1 in 1:3
  for s2 in 1:3
    for s3 in 1:3
      ...
        for s48 in 1:3

we could do something like

for stage in 1:48
  for s in 1:3

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 ?

joehuchette commented 8 years ago

I think the first solution that you implemented seems more natural. A few minor points:

blegat commented 8 years ago

Is it better to check with isa or to specify the type Nullable{JuMP.Model} in the signature ?

joehuchette commented 8 years ago

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)
blegat commented 8 years ago

Done :)

joehuchette commented 8 years ago

Thanks!