odow / SDDP.jl

A JuMP extension for Stochastic Dual Dynamic Programming
https://sddp.dev
Other
293 stars 62 forks source link

Numerical Stability Issues #316

Closed marykh162 closed 4 years ago

marykh162 commented 4 years ago

Hello,

Could you please help me with numerical stability issues? I improved problem scaling. Now, my model does not include too large or too small coefficients (e-1 smallest and e+2 largest). Still a subproblem gets infeasible due to numerical stability issues after 300 iterations. Is there any way to resolve this?

Thanks!

odow commented 4 years ago

Please post the log output.

Also, are you using SDDiP?

marykh162 commented 4 years ago

Please post the log output.

Also, are you using SDDiP?

Thanks for your response. The log output is in the following. I am using SDDP.jl.

julia> include("newInstance.jl")
--------------------------------------------------------------------------------

                      SDDP.jl (c) Oscar Dowson, 2017-20

Numerical stability report
  Non-zero Matrix range     [4e-01, 1e+01]
  Non-zero Objective range  [3e-01, 1e+01]
  Non-zero Bounds range     [1e+00, 9e+00]
  Non-zero RHS range        [5e+00, 5e+01]
No problems detected

Solver: serial mode

 Iteration    Simulation       Bound         Time (s)    Proc. ID   # Solves
        1    1.368785e+03   2.289503e+00   1.035870e+02          1      27115
        2    1.129686e+03   1.501646e+02   1.196620e+02          1      54230
        3    9.295711e+02   6.113937e+02   1.333010e+02          1      81345
        4    7.118275e+02   6.304907e+02   1.469720e+02          1     108460
        5    8.589298e+02   6.422077e+02   1.606580e+02          1     135575
        6    7.776602e+02   6.798232e+02   1.743640e+02          1     162690
        7    1.042816e+03   6.798669e+02   1.881780e+02          1     189805
        8    7.998214e+02   6.800097e+02   2.020860e+02          1     216920
        9    7.707946e+02   6.800374e+02   2.160110e+02          1     244035
       10    8.157445e+02   6.801030e+02   2.301660e+02          1     271150
       11    8.697057e+02   6.801428e+02   2.440520e+02          1     298265
       12    8.441508e+02   6.802952e+02   2.579990e+02          1     325380
       13    7.891361e+02   6.805912e+02   2.720210e+02          1     352495
       14    8.193576e+02   6.808979e+02   2.870680e+02          1     379610
       15    7.983270e+02   6.917325e+02   3.022330e+02          1     406725
       16    7.526611e+02   7.042911e+02   3.172810e+02          1     433840
       17    7.869930e+02   7.045021e+02   3.337790e+02          1     460955
       18    8.018672e+02   7.045982e+02   3.508040e+02          1     488070
       19    8.879957e+02   7.046085e+02   3.667190e+02          1     515185
       20    6.930191e+02   7.071210e+02   3.820540e+02          1     542300
       21    7.924199e+02   7.071646e+02   3.979260e+02          1     569415
       22    7.753449e+02   7.073116e+02   4.133580e+02          1     596530
       23    8.011449e+02   7.073671e+02   4.285850e+02          1     623645
       24    7.913690e+02   7.073924e+02   4.442120e+02          1     650760
       25    7.964434e+02   7.085687e+02   4.615950e+02          1     677875
       26    7.927780e+02   7.085983e+02   4.778610e+02          1     704990
       27    7.586227e+02   7.095726e+02   4.998800e+02          1     732105
       28    7.485157e+02   7.119955e+02   8.895870e+02          1     759220
       29    7.796134e+02   7.167270e+02   9.070520e+02          1     786335
       30    7.494539e+02   7.168145e+02   9.235980e+02          1     813450
       31    7.099768e+02   7.168378e+02   9.407590e+02          1     840565
       32    7.777759e+02   7.176598e+02   9.851360e+02          1     867680
       33    7.900490e+02   7.177162e+02   1.005886e+03          1     894795
       34    7.367887e+02   7.178017e+02   1.024880e+03          1     921910
       35    8.638228e+02   7.178064e+02   1.044835e+03          1     949025
       36    8.019116e+02   7.178035e+02   1.063762e+03          1     976140
       37    7.846494e+02   7.178213e+02   1.080586e+03          1    1003255
       38    7.379732e+02   7.243232e+02   1.096420e+03          1    1030370
       39    6.808814e+02   7.245888e+02   1.111971e+03          1    1057485
Simulated policy value: [ 7.622408e+02,  7.695928e+02]
       40    7.422554e+02   7.246748e+02   1.127517e+03          1    1084600
       41    7.110308e+02   7.246931e+02   1.239280e+03          1    1231715
       42    7.623942e+02   7.247905e+02   1.256218e+03          1    1258830
       43    8.504059e+02   7.248446e+02   1.273196e+03          1    1285945
       44    7.630481e+02   7.267855e+02   1.289582e+03          1    1313060
       45    7.358561e+02   7.299500e+02   1.306422e+03          1    1340175
       46    7.006043e+02   7.300424e+02   1.322146e+03          1    1367290
       47    8.570409e+02   7.300649e+02   1.337594e+03          1    1394405
       48    8.758504e+02   7.301137e+02   1.353969e+03          1    1421520
       49    7.088738e+02   7.301510e+02   1.369828e+03          1    1448635
       50    7.381272e+02   7.302312e+02   1.387901e+03          1    1475750
       51    7.056554e+02   7.302568e+02   1.406100e+03          1    1502865
       52    7.578900e+02   7.302637e+02   1.422605e+03          1    1529980
       53    8.602204e+02   7.306767e+02   1.440044e+03          1    1557095
       54    7.990342e+02   7.307346e+02   1.458301e+03          1    1584210
       55    7.504240e+02   7.307911e+02   1.476433e+03          1    1611325
       56    8.577737e+02   7.307747e+02   1.494176e+03          1    1638440
       57    7.233957e+02   7.308166e+02   1.512892e+03          1    1665555
       58    7.325052e+02   7.311768e+02   1.532988e+03          1    1692670
       59    6.772250e+02   7.312116e+02   1.550552e+03          1    1719785
       60    7.272706e+02   7.312459e+02   1.568076e+03          1    1746900
       61    7.536970e+02   7.317084e+02   1.585378e+03          1    1774015
       62    7.474399e+02   7.317085e+02   1.602379e+03          1    1801130
       63    7.459270e+02   7.317086e+02   1.620228e+03          1    1828245
       64    7.291467e+02   7.317086e+02   1.639336e+03          1    1855360
       65    6.928615e+02   7.317571e+02   1.659074e+03          1    1882475
       66    7.180894e+02   7.319928e+02   1.677177e+03          1    1909590
       67    6.632541e+02   7.320157e+02   1.694473e+03          1    1936705
       68    7.629619e+02   7.320268e+02   1.711354e+03          1    1963820
       69    7.045834e+02   7.320442e+02   1.728037e+03          1    1990935
       70    6.637730e+02   7.320667e+02   1.744882e+03          1    2018050
       71    7.761900e+02   7.320879e+02   1.762010e+03          1    2045165
       72    8.274282e+02   7.322043e+02   1.780533e+03          1    2072280
       73    8.336435e+02   7.322126e+02   1.799804e+03          1    2099395
       74    7.698823e+02   7.322150e+02   1.818606e+03          1    2126510
       75    6.676093e+02   7.322410e+02   1.836071e+03          1    2153625
       76    7.515114e+02   7.322520e+02   1.853788e+03          1    2180740
       77    7.410438e+02   7.322762e+02   1.871554e+03          1    2207855
       78    7.072782e+02   7.323069e+02   1.890767e+03          1    2234970
       79    7.438463e+02   7.323896e+02   1.911474e+03          1    2262085
Simulated policy value: [ 7.445021e+02,  7.517240e+02]
       80    7.367528e+02   7.324096e+02   1.929680e+03          1    2289200
       81    7.666365e+02   7.324135e+02   2.050685e+03          1    2436315
       82    6.666074e+02   7.324429e+02   2.069823e+03          1    2463430
       83    7.503249e+02   7.324782e+02   2.090472e+03          1    2490545
       84    7.432092e+02   7.324823e+02   2.106832e+03          1    2517660
       85    6.661745e+02   7.324873e+02   2.124750e+03          1    2544775
       86    8.746547e+02   7.324998e+02   2.142936e+03          1    2571890
       87    6.953625e+02   7.325092e+02   2.160454e+03          1    2599005
       88    7.717288e+02   7.325190e+02   2.176790e+03          1    2626120
       89    8.129808e+02   7.325230e+02   2.193192e+03          1    2653235
       90    7.080666e+02   7.325259e+02   2.211094e+03          1    2680350
       91    7.215493e+02   7.325296e+02   2.228406e+03          1    2707465
       92    7.415472e+02   7.326112e+02   2.246406e+03          1    2734580
       93    7.012487e+02   7.329371e+02   2.264180e+03          1    2761695
       94    8.902601e+02   7.334098e+02   2.280843e+03          1    2788810
       95    6.662334e+02   7.334762e+02   2.297741e+03          1    2815925
       96    8.142280e+02   7.335027e+02   2.314908e+03          1    2843040
       97    7.464664e+02   7.335303e+02   2.332576e+03          1    2870155
       98    8.169926e+02   7.335336e+02   2.349635e+03          1    2897270
       99    6.868146e+02   7.335333e+02   2.366311e+03          1    2924385
      100    6.748144e+02   7.335444e+02   2.383543e+03          1    2951500
      101    6.930404e+02   7.335645e+02   2.399835e+03          1    2978615
      102    9.077952e+02   7.335948e+02   2.416394e+03          1    3005730
      103    8.349327e+02   7.336244e+02   2.433005e+03          1    3032845
      104    7.249516e+02   7.336248e+02   2.450947e+03          1    3059960
      105    7.475424e+02   7.342530e+02   2.469834e+03          1    3087075
      106    6.805292e+02   7.342607e+02   2.489597e+03          1    3114190
      107    7.474638e+02   7.342891e+02   2.507983e+03          1    3141305
      108    7.311466e+02   7.343592e+02   2.527510e+03          1    3168420
      109    6.966533e+02   7.344016e+02   2.544307e+03          1    3195535
      110    7.754728e+02   7.344027e+02   2.561337e+03          1    3222650
      111    7.049707e+02   7.347519e+02   2.579455e+03          1    3249765
      112    6.978061e+02   7.348471e+02   2.597355e+03          1    3276880
      113    6.836717e+02   7.348579e+02   2.614559e+03          1    3303995
      114    6.412311e+02   7.348700e+02   2.631760e+03          1    3331110
      115    7.031596e+02   7.348823e+02   2.649548e+03          1    3358225
      116    6.736201e+02   7.349061e+02   2.666302e+03          1    3385340
      117    6.681099e+02   7.349272e+02   2.683688e+03          1    3412455
      118    6.988740e+02   7.350174e+02   2.701373e+03          1    3439570
      119    7.687199e+02   7.350727e+02   2.718534e+03          1    3466685
Simulated policy value: [ 7.389909e+02,  7.457714e+02]
      120    6.445804e+02   7.350748e+02   2.736335e+03          1    3493800
      121    6.951717e+02   7.352234e+02   2.855200e+03          1    3640915
      122    7.059373e+02   7.352446e+02   2.873341e+03          1    3668030
      123    7.375614e+02   7.353142e+02   2.890999e+03          1    3695145
      124    6.661080e+02   7.354183e+02   2.909009e+03          1    3722260
      125    7.035324e+02   7.354461e+02   2.925851e+03          1    3749375
      126    7.632121e+02   7.354517e+02   2.942899e+03          1    3776490
      127    7.940707e+02   7.355032e+02   2.961506e+03          1    3803605
      128    7.168763e+02   7.355192e+02   2.979306e+03          1    3830720
      129    6.666821e+02   7.355267e+02   2.997101e+03          1    3857835
      130    7.807894e+02   7.355525e+02   3.014550e+03          1    3884950
      131    6.838248e+02   7.355947e+02   3.031631e+03          1    3912065
      132    7.504930e+02   7.356664e+02   3.049782e+03          1    3939180
      133    7.722921e+02   7.356775e+02   3.067612e+03          1    3966295
      134    8.373518e+02   7.356965e+02   3.085031e+03          1    3993410
      135    7.332315e+02   7.357131e+02   3.103282e+03          1    4020525
      136    7.494435e+02   7.357842e+02   3.121075e+03          1    4047640
      137    6.465675e+02   7.357982e+02   3.140909e+03          1    4074755
      138    7.155033e+02   7.358101e+02   3.159240e+03          1    4101870
      139    8.215473e+02   7.358305e+02   3.176269e+03          1    4128985
      140    8.098432e+02   7.359115e+02   3.194250e+03          1    4156100
      141    6.461376e+02   7.360733e+02   3.211915e+03          1    4183215
      142    7.275538e+02   7.360900e+02   3.229684e+03          1    4210330
      143    7.052368e+02   7.361184e+02   3.247116e+03          1    4237445
      144    6.479342e+02   7.361277e+02   3.265642e+03          1    4264560
      145    7.071188e+02   7.361391e+02   3.283483e+03          1    4291675
      146    6.600062e+02   7.361972e+02   3.302111e+03          1    4318790
      147    6.498091e+02   7.362045e+02   3.319477e+03          1    4345905
      148    7.764166e+02   7.362331e+02   3.337519e+03          1    4373020
      149    8.502364e+02   7.362345e+02   3.355445e+03          1    4400135
      150    6.659192e+02   7.362737e+02   3.372969e+03          1    4427250
      151    7.597835e+02   7.362824e+02   3.393062e+03          1    4454365
      152    6.734595e+02   7.362916e+02   3.412392e+03          1    4481480
      153    7.356105e+02   7.363694e+02   3.429649e+03          1    4508595
      154    7.182594e+02   7.363795e+02   3.447547e+03          1    4535710
      155    7.807170e+02   7.363980e+02   3.465519e+03          1    4562825
      156    7.413135e+02   7.364112e+02   3.485086e+03          1    4589940
      157    6.893388e+02   7.364163e+02   3.505010e+03          1    4617055
      158    8.470386e+02   7.364396e+02   3.524134e+03          1    4644170
      159    7.415482e+02   7.364459e+02   3.542492e+03          1    4671285
ERROR: LoadError: Unable to retrieve solution from 117.
  Termination status: INFEASIBLE
  Primal status:      NO_SOLUTION
  Dual status:        INFEASIBILITY_CERTIFICATE.
A MathOptFormat file was written to `subproblem_117.mof.json`.
See https://odow.github.io/SDDP.jl/latest/tutorial/06_warnings/#Numerical-stabil
ity-1
for more information.
Stacktrace:
 [1] error(::String, ::String, ::String, ::String, ::String, ::String, ::String)
 at .\error.jl:42
 [2] #write_subproblem_to_file#42(::Bool, ::Function, ::SDDP.Node{Int64}, ::Stri
ng) at C:\Users\user\.julia\packages\SDDP\E7RLj\src\algorithm.jl:221
 [3] #write_subproblem_to_file at .\none:0 [inlined]
 [4] #solve_subproblem#43(::Bool, ::Function, ::SDDP.PolicyGraph{Int64}, ::SDDP.
Node{Int64}, ::Dict{Symbol,Float64}, ::NamedTuple{(:EC, :transfer, :direct),Tupl
e{Int64,Int64,Int64}}, ::Array{Tuple{Int64,Any},1}) at C:\Users\user\.julia\pack
ages\SDDP\E7RLj\src\algorithm.jl:278
 [5] (::getfield(SDDP, Symbol("#kw##solve_subproblem")))(::NamedTuple{(:require_
duals,),Tuple{Bool}}, ::typeof(SDDP.solve_subproblem), ::SDDP.PolicyGraph{Int64}
, ::SDDP.Node{Int64}, ::Dict{Symbol,Float64}, ::NamedTuple{(:EC, :transfer, :dir
ect),Tuple{Int64,Int64,Int64}}, ::Array{Tuple{Int64,Any},1}) at .\none:0
 [6] #_simulate#56(::SDDP.InSampleMonteCarlo, ::Dict{Symbol,Function}, ::Bool, :
:Bool, ::Function, ::SDDP.PolicyGraph{Int64}, ::Array{Symbol,1}) at C:\Users\use
r\.julia\packages\SDDP\E7RLj\src\algorithm.jl:1033
 [7] #_simulate at .\none:0 [inlined]
 [8] #142 at C:\Users\user\.julia\packages\SDDP\E7RLj\src\plugins\parallel_schem
es.jl:39 [inlined]
 [9] iterate at .\generator.jl:47 [inlined]
 [10] collect_to! at .\array.jl:656 [inlined]
 [11] collect_to_with_first!(::Array{Array{Dict{Symbol,Any},1},1}, ::Array{Dict{
Symbol,Any},1}, ::Base.Generator{UnitRange{Int64},getfield(SDDP, Symbol("##142#1
43")){Base.Iterators.Pairs{Symbol,Any,NTuple{4,Symbol},NamedTuple{(:sampling_sch
eme, :custom_recorders, :require_duals, :skip_undefined_variables),Tuple{SDDP.In
SampleMonteCarlo,Dict{Symbol,Function},Bool,Bool}}},SDDP.PolicyGraph{Int64},Arra
y{Symbol,1}}}, ::Int64) at .\array.jl:643
 [12] _collect(::UnitRange{Int64}, ::Base.Generator{UnitRange{Int64},getfield(SD
DP, Symbol("##142#143")){Base.Iterators.Pairs{Symbol,Any,NTuple{4,Symbol},NamedT
uple{(:sampling_scheme, :custom_recorders, :require_duals, :skip_undefined_varia
bles),Tuple{SDDP.InSampleMonteCarlo,Dict{Symbol,Function},Bool,Bool}}},SDDP.Poli
cyGraph{Int64},Array{Symbol,1}}}, ::Base.EltypeUnknown, ::Base.HasShape{1}) at .
\array.jl:637
 [13] map at .\array.jl:561 [inlined]
 [14] #_simulate#141 at C:\Users\user\.julia\packages\SDDP\E7RLj\src\plugins\par
allel_schemes.jl:39 [inlined]
 [15] #_simulate at .\none:0 [inlined]
 [16] #simulate#57 at C:\Users\user\.julia\packages\SDDP\E7RLj\src\algorithm.jl:
1164 [inlined]
 [17] simulate at C:\Users\user\.julia\packages\SDDP\E7RLj\src\algorithm.jl:1164
 [inlined] (repeats 2 times)
 [18] convergence_test(::SDDP.PolicyGraph{Int64}, ::Array{SDDP.Log,1}, ::SDDP.St
atistical) at C:\Users\user\.julia\packages\SDDP\E7RLj\src\plugins\stopping_rule
s.jl:78
 [19] convergence_test(::SDDP.PolicyGraph{Int64}, ::Array{SDDP.Log,1}, ::Array{S
DDP.AbstractStoppingRule,1}) at C:\Users\user\.julia\packages\SDDP\E7RLj\src\plu
gins\headers.jl:133
 [20] iteration(::SDDP.PolicyGraph{Int64}, ::SDDP.Options{Int64}) at C:\Users\us
er\.julia\packages\SDDP\E7RLj\src\algorithm.jl:789
 [21] master_loop at C:\Users\user\.julia\packages\SDDP\E7RLj\src\plugins\parall
el_schemes.jl:24 [inlined]
 [22] #train#49(::Int64, ::Nothing, ::Int64, ::String, ::Bool, ::Array{SDDP.Stat
istical,1}, ::SDDP.Expectation, ::SDDP.InSampleMonteCarlo, ::SDDP.CutType, ::Flo
at64, ::Bool, ::Int64, ::SDDP.CompleteSampler, ::Bool, ::SDDP.Serial, ::typeof(S
DDP.train), ::SDDP.PolicyGraph{Int64}) at C:\Users\user\.julia\packages\SDDP\E7R
Lj\src\algorithm.jl:962
 [23] (::getfield(SDDP, Symbol("#kw##train")))(::NamedTuple{(:stopping_rules, :i
teration_limit),Tuple{Array{SDDP.Statistical,1},Int64}}, ::typeof(SDDP.train), :
:SDDP.PolicyGraph{Int64}) at .\none:0
 [24] top-level scope at none:0
 [25] include at .\boot.jl:317 [inlined]
 [26] include_relative(::Module, ::String) at .\loading.jl:1044
 [27] include(::Module, ::String) at .\sysimg.jl:29
 [28] include(::String) at .\client.jl:392
 [29] top-level scope at none:0
in expression starting at C:\Users\user\AppData\Local\Julia-1.0.5\newInstance.jl
:118
marykh162 commented 4 years ago

Please post the log output.

Also, are you using SDDiP?

I tried to use SDDiP. I actually was not aware of this package, and I am happy you mentioned that. I was trying to solve linear relaxation of my model. I could not find an updated documentation for SDDiP. jl which is compatible with the latest version of SDDP.jl. I am getting the following error. I would appreciate if you could help me with that.

ERROR: LoadError: MethodError: no method matching SDDP.PolicyGraph(::getfield(Ma
in, Symbol("##1185#1191")), ::SDDP.Graph{Int64}; sense=:Min, lower_bound=0.0, so
lver=GLPKMathProgInterface.GLPKInterfaceMIP.GLPKSolverMIP(false, Base.Iterators.
Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}()))
Closest candidates are:
  SDDP.PolicyGraph(::Function, ::SDDP.Graph{T}; sense, lower_bound, upper_bound,
 optimizer, bellman_function, direct_mode, integrality_handler) where T at C:\Us
ers\user\.julia\packages\SDDP\E7RLj\src\user_interface.jl:573 got unsupported ke
yword argument "solver"
  SDDP.PolicyGraph(::Symbol, ::T) where T at C:\Users\user\.julia\packages\SDDP\
E7RLj\src\user_interface.jl:430 got unsupported keyword arguments "sense", "lowe
r_bound", "solver"
Stacktrace:
 [1] kwerr(::NamedTuple{(:sense, :lower_bound, :solver),Tuple{Symbol,Float64,GLP
KMathProgInterface.GLPKInterfaceMIP.GLPKSolverMIP}}, ::Type, ::Function, ::SDDP.
Graph{Int64}) at .\error.jl:97
 [2] (::getfield(Core, Symbol("#kw#Type")))(::NamedTuple{(:sense, :lower_bound,
:solver),Tuple{Symbol,Float64,GLPKMathProgInterface.GLPKInterfaceMIP.GLPKSolverM
IP}}, ::Type{SDDP.PolicyGraph}, ::Function, ::SDDP.Graph{Int64}) at .\none:0
 [3] #LinearPolicyGraph#11(::Int64, ::Base.Iterators.Pairs{Symbol,Any,Tuple{Symb
ol,Symbol,Symbol},NamedTuple{(:sense, :lower_bound, :solver),Tuple{Symbol,Float6
4,GLPKMathProgInterface.GLPKInterfaceMIP.GLPKSolverMIP}}}, ::Function, ::Functio
n) at C:\Users\user\.julia\packages\SDDP\E7RLj\src\user_interface.jl:489
 [4] (::getfield(SDDP, Symbol("#kw##LinearPolicyGraph")))(::NamedTuple{(:stages,
 :sense, :lower_bound, :solver),Tuple{Int64,Symbol,Float64,GLPKMathProgInterface
.GLPKInterfaceMIP.GLPKSolverMIP}}, ::typeof(SDDP.LinearPolicyGraph), ::Function)
 at .\none:0
 [5] top-level scope at none:0
 [6] include at .\boot.jl:317 [inlined]
 [7] include_relative(::Module, ::String) at .\loading.jl:1044
 [8] include(::Module, ::String) at .\sysimg.jl:29
 [9] include(::String) at .\client.jl:392
 [10] top-level scope at none:0
in expression starting at C:\Users\user\AppData\Local\Julia-1.0.5\IntInstance.jl
:9

Also, could you please let me know if the following works to define integer state variables?

@variable(sp, w >= 0, SDDP.State, initial_value = 0, Int)

Thanks!

odow commented 4 years ago

Answers to your questions a little out-of-order:

  1. @variable(sp, w >= 0, SDDP.State, Int, initial_value = 0) You need to pass positional arguments first, then keyword arguments.

  2. The SDDiP.jl package has been integrated into SDDP.jl. For now, declare your state variables as integer above, and SDDP.jl will JustWork™. (We solve the continuous relaxation on the backward pass, and simulate using the proper integer decisions.)

  3. You need to use GLPK.jl, not GLPKMathProgInterface.jl, and the syntax is

    using GLPK
    using SDDP
    model = SDDP.LinearPolicyGraph(
    optimizer = GLPK.Optimizer, 
    # ... other args ...
    ) do sp, node
    set_silent(sp)  # To disable printing, if any.
    # model definition
  4. Which solver were you using? You probably need to use a commercial LP solver like CPLEX or Gurobi. For tricky problems like this, I recommend Gurobi. We're pushing the limits of that general purpose solvers can do; they aren't designed for situations like SDDP.jl.

  5. How big is this model??? It seems pretty large.

marykh162 commented 4 years ago

Answers to your questions a little out-of-order:

  1. @variable(sp, w >= 0, SDDP.State, Int, initial_value = 0) You need to pass positional arguments first, then keyword arguments.
  2. The SDDiP.jl package has been integrated into SDDP.jl. For now, declare your state variables as integer above, and SDDP.jl will JustWork™. (We solve the continuous relaxation on the backward pass, and simulate using the proper integer decisions.)
  3. You need to use GLPK.jl, not GLPKMathProgInterface.jl, and the syntax is
using GLPK
using SDDP
model = SDDP.LinearPolicyGraph(
    optimizer = GLPK.Optimizer, 
    # ... other args ...
) do sp, node
    set_silent(sp)  # To disable printing, if any.
    # model definition
  1. Which solver were you using? You probably need to use a commercial LP solver like CPLEX or Gurobi. For tricky problems like this, I recommend Gurobi. We're pushing the limits of that general purpose solvers can do; they aren't designed for situations like SDDP.jl.
  2. How big is this model??? It seems pretty large.

Thank you so much for your response. Yes, that is a large model with 120 stages!:) I was using GLPK. I want to give Gurobi a try, but now I am getting the following error: ERROR: LoadError: Invalid Gurobi license I had used Gurobi through JuMP when I had an older Julia version. I don't know why I am getting this error. I tried your solution in the following link:, but it is not working either. https://github.com/JuliaOpt/Gurobi.jl/issues/299 Any idea?

Thanks!

odow commented 4 years ago

The open-source solvers work fine for small problems, but they struggle numerically on larger problems. The issue happens infrequently though, so it is hard, if not impossible, to debug (you got one false positive infeasibility in 4.7 million LPs!).

The Gurobi license is either

a) You need to update your license b) You have a valid license, but Gurobi can't find it because of the environment variable issue c) You have what looks like a valid license, but you used the wrong version of grbgetkey to install it, so it doesn't actually support Gurobi 9. What's the contents of the gurobi.lic file in the location of your environment variable? d) You have the wrong type of license (you say server, what license do you have)

marykh162 commented 4 years ago

The open-source solvers work fine for small problems, but they struggle numerically on larger problems. The issue happens infrequently though, so it is hard, if not impossible, to debug (you got one false positive infeasibility in 4.7 million LPs!).

The Gurobi license is either

a) You need to update your license b) You have a valid license, but Gurobi can't find it because of the environment variable issue c) You have what looks like a valid license, but you used the wrong version of grbgetkey to install it, so it doesn't actually support Gurobi 9. What's the contents of the gurobi.lic file in the location of your environment variable? d) You have the wrong type of license (you say server, what license do you have)

Thank you so much for the helpful information. I updated my license and it is now working.

I am giving Gurobi a try. Hopefully, it will resolve the issue.

Thanks again!

marykh162 commented 4 years ago

Answers to your questions a little out-of-order:

  1. @variable(sp, w >= 0, SDDP.State, Int, initial_value = 0) You need to pass positional arguments first, then keyword arguments.
  2. The SDDiP.jl package has been integrated into SDDP.jl. For now, declare your state variables as integer above, and SDDP.jl will JustWork™. (We solve the continuous relaxation on the backward pass, and simulate using the proper integer decisions.)
  3. You need to use GLPK.jl, not GLPKMathProgInterface.jl, and the syntax is
using GLPK
using SDDP
model = SDDP.LinearPolicyGraph(
    optimizer = GLPK.Optimizer, 
    # ... other args ...
) do sp, node
    set_silent(sp)  # To disable printing, if any.
    # model definition
  1. Which solver were you using? You probably need to use a commercial LP solver like CPLEX or Gurobi. For tricky problems like this, I recommend Gurobi. We're pushing the limits of that general purpose solvers can do; they aren't designed for situations like SDDP.jl.
  2. How big is this model??? It seems pretty large.

Thank you Oscar! No more numerical stability issues with Gurobi. I would appreciate if you could help me better understand the SDDiP. I was thinking that integer subproblems are solved in the forward pass and their continuous relaxations are solved on backward pass. I was doing some testing, and I intentionally defined an infeasible first-stage model (in case variables are integer). The SDDP did not detect infeasibility while training, but I got an error during simulation. So, my question is do you solve the continuous relaxation on both forward and backward pass and use integer solution only for simulation?

Thanks!

odow commented 4 years ago

Yes, I think the current version does continuous during training, integer during simulation.

At some point I had integer on forward pass of training as well, but I lost some performance constantly switching between integer/continuous. I should re-enable it as an option.

odow commented 4 years ago

I'm going to close this since it appears to be resolved. Please re-open if that isn't the case.

marykh162 commented 4 years ago

Yes, you helped a lot. Thanks!

Maryam Khatami

Ph.D. Candidate

Department of Industrial and Systems Engineering

4050 ETB, 3131 TAMU

Texas A&M University

College Station, TX 77843

On Mon, May 4, 2020 at 9:41 AM Oscar Dowson notifications@github.com wrote:

I'm going to close this since it appears to be resolved. Please re-open if that isn't the case.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_odow_SDDP.jl_issues_316-23issuecomment-2D623505094&d=DwMCaQ&c=u6LDEWzohnDQ01ySGnxMzg&r=opgqi01kN3MAVu515OpsDQBlZOy2scZhBwzF5pUcWWc&m=VB3030wQNEJyChbRhlzGxVcsP2Y1DGZPWvT3VaanLiI&s=YModNjYo_iTPV0O8PHKe7vehMxKH4dl9NN-zuXHfQDw&e=, or unsubscribe https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AOZKHKUUEYRW3BJOOIIZ2NLRP3HYNANCNFSM4MNPCP2A&d=DwMCaQ&c=u6LDEWzohnDQ01ySGnxMzg&r=opgqi01kN3MAVu515OpsDQBlZOy2scZhBwzF5pUcWWc&m=VB3030wQNEJyChbRhlzGxVcsP2Y1DGZPWvT3VaanLiI&s=6GcQcHc9sVRMuU6YPcoq5KFavufh-vmIeiplKxRjKmU&e= .