No strong duality

This tutorial was generated using Literate.jl. Download the source as a .jl file. Download the source as a .ipynb file.

This example is interesting, because strong duality doesn't hold for the extensive form (see if you can show why!), but we still converge.

using SDDP, HiGHS, Test

function no_strong_duality()
    model = SDDP.PolicyGraph(
        SDDP.Graph(
            :root,
            [:node],
            [(:root => :node, 1.0), (:node => :node, 0.5)],
        ),
        optimizer = HiGHS.Optimizer,
        lower_bound = 0.0,
    ) do sp, t
        @variable(sp, x, SDDP.State, initial_value = 1.0)
        @stageobjective(sp, x.out)
        @constraint(sp, x.in == x.out)
    end
    SDDP.train(model)
    @test SDDP.calculate_bound(model) ≈ 2.0 atol = 1e-5
    return
end

no_strong_duality()
-------------------------------------------------------------------
         SDDP.jl (c) Oscar Dowson and contributors, 2017-23
-------------------------------------------------------------------
problem
  nodes           : 1
  state variables : 1
  scenarios       : Inf
  existing cuts   : false
options
  solver          : serial mode
  risk measure    : SDDP.Expectation()
  sampling scheme : SDDP.InSampleMonteCarlo
subproblem structure
  VariableRef                             : [3, 3]
  AffExpr in MOI.EqualTo{Float64}         : [1, 1]
  VariableRef in MOI.GreaterThan{Float64} : [1, 1]
numerical stability report
  matrix range     [1e+00, 1e+00]
  objective range  [1e+00, 1e+00]
  bounds range     [0e+00, 0e+00]
  rhs range        [0e+00, 0e+00]
-------------------------------------------------------------------
 iteration    simulation      bound        time (s)     solves  pid
-------------------------------------------------------------------
         1   1.000000e+00  1.500000e+00  1.671076e-03         3   1
        40   4.000000e+00  2.000000e+00  4.156113e-02       578   1
-------------------------------------------------------------------
status         : simulation_stopping
total time (s) : 4.156113e-02
total solves   : 578
best bound     :  2.000000e+00
simulation ci  :  1.950000e+00 ± 5.568095e-01
numeric issues : 0
-------------------------------------------------------------------