leopoldcambier / FAST

FAST (Finally An SDDP Toolbox) is an SDDP toolbox for Matlab
https://web.stanford.edu/~lcambier/fast/
GNU General Public License v3.0
21 stars 6 forks source link

Retreive wait and see solution #14

Closed narjad closed 8 years ago

narjad commented 8 years ago

Hello,

To retreive the solution for one variable we use the following piece of code as explained in the tutorial:

...
output = sddp(lattice,settings) ;
lattice = output.lattice;
path = ...
[~,~,~,solution] = forwardPass(lattice, path, settings);
xVal = lattice.getPrimalSolution(var.x, solution);

Actually we want to retreive the wait and see solution, so we tried:

[~,~,solution_WS] = waitAndSee(lattice, path, settings);
xValWS = lattice.getPrimalSolution(var.p, solution_WS) ;

but it raises the following error:

Error using NldsModel/updatePrimalSolution (line 221)
solution should be a struct() with field primal

Error in Lattice/getPrimalSolution (line 441)
                primalSolution =
                model.updatePrimalSolution(primalSolution,
                variable, solutionForward{t}) ;

if we inspect each structure for example we see:

>> solution{1}

ans =

              primal: [88x1 double]
              trials: [44x1 double]
       costWithTheta: 4.3620e+05
    costWithoutTheta: 4.3061e+04
            dualCntr: [383x1 double]
            dualCuts: 1

>> solution_WS{1}

ans =

                   x: [88x1 double]
              xTrial: [44x1 double]
    costWithoutTheta: 4.3061e+04

Is it correct to rename these fields in /fast/src/auxprobs/waitAndSee.m line 132 and 133 ?

Best,

Arnaud

leopoldcambier commented 8 years ago

Yep, it is. Would be more consistent. I just fixed it in the last commit (84b2c3d646652cbadcf4698f9ef52965759cd8b9)

Leopold