JuliaStochOpt / StructDualDynProg.jl

Implementation of SDDP (Stochastic Dual Dynamic Programming) using the StructJuMP modeling interface
Other
23 stars 8 forks source link

UndefVarError: SOI not defined #23

Open Esnilg opened 5 years ago

Esnilg commented 5 years ago

Hello, I have been trying to run the example model but I have this error when running

const SOI = StructDualDynProg.SOI

what I need to do

blegat commented 5 years ago

Which version of StructDualDynProg are you using ?

Esnilg commented 5 years ago

Hi

I Have

Pkg.status("StructDualDynProg")

blegat commented 5 years ago

You need to use at lease version 0.2 to have the SOI constant defined. I would recommend updating the package

Esnilg commented 5 years ago

Thanks, today update and now works, but as I do to know the status, objective value, solution x?

blegat commented 5 years ago

You need to do

sol = SOI.optimize!(...)
SOI.last_result(sol).lowerbound
SOI.last_result(sol).upperbound
...

You can see the other fields of the result here.

Esnilg commented 5 years ago

Thank you very much for all your help, I found what I want but I wanted one last question, how do I better understand this data structure of SOI.last_result (sun) .paths? for example I want to know the solution of the master node, x1, after x2, ...., xT

captura de pantalla 2019-01-10 07 07 51

blegat commented 5 years ago

SOI.last_result(sol).paths gives this structure: https://github.com/JuliaStochOpt/StructDualDynProg.jl/blob/349c9bcc3bb7338390b9293de408d70dc818fada/src/SDDP/algorithm.jl#L61-L63 As explained here: https://github.com/JuliaStochOpt/StructDualDynProg.jl/blob/349c9bcc3bb7338390b9293de408d70dc818fada/src/SDDP/algorithm.jl#L65-L70 To get the path for the master node you need to do

SOI.last_result(sol).paths.paths[1][1][2][1]

Then you will have this structure https://github.com/JuliaStochOpt/StructDualDynProg.jl/blob/349c9bcc3bb7338390b9293de408d70dc818fada/src/SDDP/path.jl#L36-L53 and the solution is in the pool field. I agree that we should add a more user friendly way to access it

Esnilg commented 5 years ago

Hello, I wanted to thank you, I was able to better understand the data structure with typeof and fieldnames. But I have a question, how do I use model2lattice

blegat commented 5 years ago

It doesn't exist anymore. I assume you read it from the README, I just fixed it: https://github.com/JuliaStochOpt/StructDualDynProg.jl/commit/ac3b1d0e50a129db7c460d0f637c480e597848ec