Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UndefVarError: SOI not defined #23

Open
Esnilg opened this issue Jan 8, 2019 · 9 comments
Open

UndefVarError: SOI not defined #23

Esnilg opened this issue Jan 8, 2019 · 9 comments

Comments

@Esnilg
Copy link

Esnilg commented Jan 8, 2019

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
Copy link
Member

blegat commented Jan 8, 2019

Which version of StructDualDynProg are you using ?

@Esnilg
Copy link
Author

Esnilg commented Jan 8, 2019

Hi

I Have

Pkg.status("StructDualDynProg")

  • StructDualDynProg 0.0.1

@blegat
Copy link
Member

blegat commented Jan 8, 2019

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

@Esnilg
Copy link
Author

Esnilg commented Jan 9, 2019

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

@blegat
Copy link
Member

blegat commented Jan 9, 2019

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
Copy link
Author

Esnilg commented Jan 10, 2019

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
Copy link
Member

blegat commented Jan 10, 2019

SOI.last_result(sol).paths gives this structure:

struct Paths{NodeT, TT, SolT} <: SOI.AbstractPaths
paths::Vector{Vector{Tuple{NodeT, Vector{SDDPPath{TT, SolT}}}}}
end

As explained here:
# At the master node, all paths are still concentrated in the same one
node_paths = paths.paths[1]
@assert length(node_paths) == 1
paths_vec = node_paths[1][2]
@assert length(paths_vec) == 1
Ks = paths_vec[1].K

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

mutable struct SDDPPath{TT<:SOI.AbstractTransition, SolT<:SOI.AbstractSolution}
# Solution pool for the last node of the path
pool::SolutionPool{TT, SolT}
# The three following arguments are vectors since when we merge paths,
# we need to keep track of the difference of `z` that they have accumulated
# while diverging for computing the variance `σ^2` in [`meanstdpaths`](@ref) at the end.
# Sum of the objective solution (without θ) at each node of the path
z::Vector{Float64}
# Probability of the path
proba::Vector{Float64}
# Number of walks in the path
K::Vector{Int}
function SDDPPath{TT}(sol::SolT, z, proba, K) where {TT, SolT}
new{TT, SolT}(SolutionPool{TT}(sol), z, proba, K)
end
end

and the solution is in the pool field.
I agree that we should add a more user friendly way to access it

@Esnilg
Copy link
Author

Esnilg commented Mar 5, 2019

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
Copy link
Member

blegat commented Mar 6, 2019

It doesn't exist anymore. I assume you read it from the README, I just fixed it:
ac3b1d0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants