odow / SDDP.jl

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

Document how to access individual subproblems #435

Closed BYS543 closed 3 years ago

BYS543 commented 3 years ago

Hi, Oscar! I want to print a model, however, i find print function doesn't work when I express this

ini_x=zeros(10);
index=[5,6]
model=SDDP.LinearPolicyGraph(
stages=10,
sense=:Min,
lower_bound=0.0,
optimizer=Gurobi.Optimizer,
integrality_handler=SDDP.SDDiP(),
)do sp1,stage
    @variable(sp1,0<=x[i in 1:10]<=1,SDDP.State,initial_value=ini_x[i])
    @constraint(sp1,[i in index],x[i].out>=0.5)
end
print(model[1].sp1)

it tells me type PolicyGraph has no field sp1 However when i write print(model) and print(model[1]), it can show some information ,but I still cannot see the constraints of subproblems in every stages. Thank you!

BYS543 commented 3 years ago

One more question, if I want to print a named constraint

ini_x=zeros(10);
index=[5,6]
model=SDDP.LinearPolicyGraph(
stages=10,
sense=:Min,
lower_bound=0.0,
optimizer=Gurobi.Optimizer,
integrality_handler=SDDP.SDDiP(),
)do sp1,stage
    @variable(sp1,0<=x[i in 1:10]<=1,SDDP.State,initial_value=ini_x[i])
    @constraint(sp1,x_out[i in index],x[i].out>=0.5)
end
print(model[1].x_out)

can I use something like above?

odow commented 3 years ago
print(model[1].subproblem)

and

print(model[1].subproblem[:x_out])

See fieldnames(typeof(model[1]).

Julia documentation: https://docs.julialang.org/en/v1/devdocs/reflection/#DataType-fields

BYS543 commented 3 years ago

ok, thank you, Oscar, I just misunderstood the use of model[1].subproblem, it is the specified name subproblem, not the name user defined.

odow commented 3 years ago

Correct. I'll leave this issue open as a reminder to better document this.

BYS543 commented 3 years ago

I have another problem of print function in SDDP, Oscar

ini_x=zeros(10);
index=[5,6]
model=SDDP.LinearPolicyGraph(
stages=10,
sense=:Min,
lower_bound=0.0,
optimizer=Gurobi.Optimizer,
integrality_handler=SDDP.SDDiP(),
)do sp1,stage
    @variable(sp1,0<=x[i in 1:10]<=1,SDDP.State,initial_value=ini_x[i])
    @constraint(sp1,x_out[i in index],x[i].out>=0.5)
    @stageobjective(sp1,sum([x[i].out for i in 1:10]))
end

When I print the objective function, I find the stageobjective is 0, After using objective_function(model[1].subproblem),I still find the result is 0. why the stage objective is 0, i am a little confused about that.

odow commented 3 years ago

It isn't set yet. You need to call parameterize(node::Node, noise) first (in your case SDDP.parameterize(model[1], nothing)). But this is undocumented and pretty internal.

In general, you should not expect things in the subproblems to represent the actual model at a point in time, and there isn't support for people digging into the internal data structures.

What are you trying to achieve?

BYS543 commented 3 years ago

well, I just want to check my objective whether it is right, now i know it may not be the problem of objective. Because my model is based on periods, and it is intractable, so i just consider to use SDDP, which it can decompose my model based on period, however, when i use SDDP.ContinuousRelaxation, it shows

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

Problem
  Nodes           : 20
  State variables : 210
  Scenarios       : 1.00000e+00
  Solver          : serial mode

Numerical stability report
  Non-zero Matrix range     [1e-02, 2e+03]
  Non-zero Objective range  [8e-01, 2e+02]
  Non-zero Bounds range     [1e+00, 1e+03]
  Non-zero RHS range        [9e-01, 6e+03]
No problems detected

 Iteration    Simulation       Bound         Time (s)    Proc. ID   # Solves
Gurobi Optimizer version 9.1.0 build v9.1.0rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 1287 rows, 843 columns and 3500 nonzeros
Model fingerprint: 0x59f69554
Coefficient statistics:
  Matrix range     [1e-02, 2e+03]
  Objective range  [8e-01, 2e+02]
  Bounds range     [1e+00, 1e+03]
  RHS range        [9e-01, 6e+03]
Presolve removed 1287 rows and 843 columns
Presolve time: 0.00s
Presolve: All rows and columns removed
Iteration    Objective       Primal Inf.    Dual Inf.      Time
       0    5.9545300e+03   0.000000e+00   4.000000e-05      0s
Extra simplex iterations after uncrush: 38
      38    5.9545300e+03   0.000000e+00   0.000000e+00      0s

Solved in 38 iterations and 0.00 seconds
Optimal objective  5.954530000e+03

User-callback calls 73, time in user-callback 0.00 sec
Gurobi Optimizer version 9.1.0 build v9.1.0rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 1287 rows, 843 columns and 3539 nonzeros
Model fingerprint: 0x39dbcab5
Coefficient statistics:
  Matrix range     [1e-02, 2e+03]
  Objective range  [8e-01, 2e+02]
  Bounds range     [1e+00, 1e+03]
  RHS range        [9e-01, 1e+03]
Presolve removed 1203 rows and 787 columns
Presolve time: 0.01s
Presolved: 84 rows, 134 columns, 370 nonzeros

Iteration    Objective       Primal Inf.    Dual Inf.      Time
       0      handle free variables                          0s
      44    5.8528800e+03   0.000000e+00   0.000000e+00      0s

Solved in 44 iterations and 0.01 seconds
Optimal objective  5.852880000e+03

User-callback calls 91, time in user-callback 0.00 sec
Gurobi Optimizer version 9.1.0 build v9.1.0rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 1287 rows, 843 columns and 3539 nonzeros
Model fingerprint: 0xf7d5d5a5
Coefficient statistics:
  Matrix range     [1e-02, 2e+03]
  Objective range  [8e-01, 2e+02]
  Bounds range     [3e-02, 1e+03]
  RHS range        [9e-01, 1e+03]
Presolve removed 1178 rows and 778 columns
Presolve time: 0.01s
Presolved: 109 rows, 141 columns, 472 nonzeros

Iteration    Objective       Primal Inf.    Dual Inf.      Time
       0      handle free variables                          0s
      55    5.5957600e+03   0.000000e+00   0.000000e+00      0s

Solved in 55 iterations and 0.01 seconds
Optimal objective  5.595760000e+03

User-callback calls 103, time in user-callback 0.00 sec
Gurobi Optimizer version 9.1.0 build v9.1.0rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 1287 rows, 843 columns and 3539 nonzeros
Model fingerprint: 0xf82b5b94
Coefficient statistics:
  Matrix range     [1e-02, 2e+03]
  Objective range  [8e-01, 2e+02]
  Bounds range     [3e-02, 1e+03]
  RHS range        [9e-01, 1e+03]
Presolve removed 1148 rows and 764 columns
Presolve time: 0.01s
Presolved: 139 rows, 147 columns, 627 nonzeros

Iteration    Objective       Primal Inf.    Dual Inf.      Time
       0      handle free variables                          0s
      64    5.2990000e+03   0.000000e+00   0.000000e+00      0s

Solved in 64 iterations and 0.01 seconds
Optimal objective  5.299000000e+03

User-callback calls 113, time in user-callback 0.00 sec
Gurobi Optimizer version 9.1.0 build v9.1.0rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 1287 rows, 843 columns and 3539 nonzeros
Model fingerprint: 0xdd3878b1
Coefficient statistics:
  Matrix range     [1e-02, 2e+03]
  Objective range  [8e-01, 2e+02]
  Bounds range     [1e-02, 1e+03]
  RHS range        [9e-01, 1e+03]
Presolve removed 1106 rows and 739 columns
Presolve time: 0.00s
Presolved: 181 rows, 163 columns, 786 nonzeros

Iteration    Objective       Primal Inf.    Dual Inf.      Time
       0      handle free variables                          0s
      80    4.7597038e+03   0.000000e+00   0.000000e+00      0s

Solved in 80 iterations and 0.01 seconds
Optimal objective  4.759703805e+03

User-callback calls 131, time in user-callback 0.00 sec
Gurobi Optimizer version 9.1.0 build v9.1.0rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 1287 rows, 843 columns and 3539 nonzeros
Model fingerprint: 0x25610c84
Coefficient statistics:
  Matrix range     [1e-02, 2e+03]
  Objective range  [8e-01, 2e+02]
  Bounds range     [1e-02, 1e+03]
  RHS range        [9e-01, 1e+03]
Presolve removed 1031 rows and 713 columns
Presolve time: 0.00s
Presolved: 256 rows, 180 columns, 1161 nonzeros

Iteration    Objective       Primal Inf.    Dual Inf.      Time
       0      handle free variables                          0s
      95    4.2477400e+03   0.000000e+00   0.000000e+00      0s

Solved in 95 iterations and 0.01 seconds
Optimal objective  4.247740000e+03

User-callback calls 140, time in user-callback 0.00 sec
Gurobi Optimizer version 9.1.0 build v9.1.0rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 1287 rows, 843 columns and 3539 nonzeros
Model fingerprint: 0xa5be7780
Coefficient statistics:
  Matrix range     [1e-02, 2e+03]
  Objective range  [8e-01, 2e+02]
  Bounds range     [3e-02, 1e+03]
  RHS range        [9e-01, 1e+03]
Presolve removed 970 rows and 686 columns
Presolve time: 0.01s
Presolved: 317 rows, 193 columns, 1459 nonzeros

Iteration    Objective       Primal Inf.    Dual Inf.      Time
       0      handle free variables                          0s
     127    3.7968600e+03   0.000000e+00   0.000000e+00      0s

Solved in 127 iterations and 0.01 seconds
Optimal objective  3.796860000e+03

User-callback calls 172, time in user-callback 0.00 sec
Gurobi Optimizer version 9.1.0 build v9.1.0rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 1287 rows, 843 columns and 3539 nonzeros
Model fingerprint: 0xe8d0dd87
Coefficient statistics:
  Matrix range     [1e-02, 2e+03]
  Objective range  [8e-01, 2e+02]
  Bounds range     [3e-02, 1e+03]
  RHS range        [9e-01, 1e+03]
Presolve removed 928 rows and 664 columns
Presolve time: 0.01s
Presolved: 359 rows, 209 columns, 1597 nonzeros

Iteration    Objective       Primal Inf.    Dual Inf.      Time
       0      handle free variables                          0s
     167    3.5932100e+03   0.000000e+00   0.000000e+00      0s

Solved in 167 iterations and 0.01 seconds
Optimal objective  3.593210000e+03

User-callback calls 214, time in user-callback 0.00 sec
Gurobi Optimizer version 9.1.0 build v9.1.0rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 1287 rows, 843 columns and 3539 nonzeros
Model fingerprint: 0x6e5843a5
Coefficient statistics:
  Matrix range     [1e-02, 2e+03]
  Objective range  [8e-01, 2e+02]
  Bounds range     [3e-02, 1e+03]
  RHS range        [9e-01, 1e+03]
Presolve removed 897 rows and 649 columns
Presolve time: 0.00s
Presolved: 390 rows, 223 columns, 1733 nonzeros

Iteration    Objective       Primal Inf.    Dual Inf.      Time
       0      handle free variables                          0s
     160    3.5797100e+03   0.000000e+00   0.000000e+00      0s

Solved in 160 iterations and 0.01 seconds
Optimal objective  3.579710000e+03

User-callback calls 207, time in user-callback 0.00 sec
Gurobi Optimizer version 9.1.0 build v9.1.0rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 1287 rows, 843 columns and 3539 nonzeros
Model fingerprint: 0xa6f3882d
Coefficient statistics:
  Matrix range     [1e-02, 2e+03]
  Objective range  [8e-01, 2e+02]
  Bounds range     [3e-02, 1e+03]
  RHS range        [9e-01, 1e+03]
Presolve removed 897 rows and 649 columns
Presolve time: 0.01s
Presolved: 390 rows, 223 columns, 1733 nonzeros

Iteration    Objective       Primal Inf.    Dual Inf.      Time
       0      handle free variables                          0s
     172    3.5662100e+03   0.000000e+00   0.000000e+00      0s

Solved in 172 iterations and 0.01 seconds
Optimal objective  3.566210000e+03

User-callback calls 219, time in user-callback 0.00 sec
Gurobi Optimizer version 9.1.0 build v9.1.0rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 1287 rows, 843 columns and 3539 nonzeros
Model fingerprint: 0x965ee0c1
Coefficient statistics:
  Matrix range     [1e-02, 2e+03]
  Objective range  [8e-01, 2e+02]
  Bounds range     [3e-02, 1e+03]
  RHS range        [9e-01, 1e+03]
Presolve removed 897 rows and 649 columns
Presolve time: 0.01s
Presolved: 390 rows, 223 columns, 1733 nonzeros

Iteration    Objective       Primal Inf.    Dual Inf.      Time
       0      handle free variables                          0s
     174    3.5527100e+03   0.000000e+00   0.000000e+00      0s

Solved in 174 iterations and 0.01 seconds
Optimal objective  3.552710000e+03

User-callback calls 221, time in user-callback 0.00 sec
Gurobi Optimizer version 9.1.0 build v9.1.0rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 1287 rows, 843 columns and 3539 nonzeros
Model fingerprint: 0x106d7055
Coefficient statistics:
  Matrix range     [1e-02, 2e+03]
  Objective range  [8e-01, 2e+02]
  Bounds range     [3e-02, 1e+03]
  RHS range        [9e-01, 1e+03]
Presolve removed 898 rows and 649 columns
Presolve time: 0.01s
Presolved: 389 rows, 223 columns, 1730 nonzeros

Iteration    Objective       Primal Inf.    Dual Inf.      Time
       0      handle free variables                          0s
     149    3.5392100e+03   0.000000e+00   0.000000e+00      0s

Solved in 149 iterations and 0.01 seconds
Optimal objective  3.539210000e+03

User-callback calls 196, time in user-callback 0.00 sec
Gurobi Optimizer version 9.1.0 build v9.1.0rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 1287 rows, 843 columns and 3539 nonzeros
Model fingerprint: 0xab285fca
Coefficient statistics:
  Matrix range     [1e-02, 2e+03]
  Objective range  [8e-01, 2e+02]
  Bounds range     [3e-02, 1e+03]
  RHS range        [9e-01, 1e+03]
Presolve removed 904 rows and 649 columns
Presolve time: 0.00s
Presolved: 383 rows, 223 columns, 1695 nonzeros

Iteration    Objective       Primal Inf.    Dual Inf.      Time
       0      handle free variables                          0s
     145    3.5257100e+03   0.000000e+00   0.000000e+00      0s

Solved in 145 iterations and 0.01 seconds
Optimal objective  3.525710000e+03

User-callback calls 192, time in user-callback 0.00 sec
Gurobi Optimizer version 9.1.0 build v9.1.0rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 1287 rows, 843 columns and 3539 nonzeros
Model fingerprint: 0xb3bcd67b
Coefficient statistics:
  Matrix range     [1e-02, 2e+03]
  Objective range  [8e-01, 2e+02]
  Bounds range     [3e-02, 1e+03]
  RHS range        [9e-01, 1e+03]
Presolve removed 913 rows and 650 columns
Presolve time: 0.00s
Presolved: 374 rows, 222 columns, 1682 nonzeros

Iteration    Objective       Primal Inf.    Dual Inf.      Time
       0      handle free variables                          0s
     143    3.5122100e+03   0.000000e+00   0.000000e+00      0s

Solved in 143 iterations and 0.02 seconds
Optimal objective  3.512210000e+03

User-callback calls 190, time in user-callback 0.00 sec
Gurobi Optimizer version 9.1.0 build v9.1.0rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 1287 rows, 843 columns and 3539 nonzeros
Model fingerprint: 0x10ec62ed
Coefficient statistics:
  Matrix range     [1e-02, 2e+03]
  Objective range  [8e-01, 2e+02]
  Bounds range     [3e-02, 1e+03]
  RHS range        [9e-01, 1e+03]
Presolve removed 913 rows and 650 columns
Presolve time: 0.01s
Presolved: 374 rows, 222 columns, 1682 nonzeros

Iteration    Objective       Primal Inf.    Dual Inf.      Time
       0      handle free variables                          0s
     142    3.4987100e+03   0.000000e+00   0.000000e+00      0s

Solved in 142 iterations and 0.02 seconds
Optimal objective  3.498710000e+03

User-callback calls 189, time in user-callback 0.00 sec
Gurobi Optimizer version 9.1.0 build v9.1.0rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 1287 rows, 843 columns and 3539 nonzeros
Model fingerprint: 0x20612815
Coefficient statistics:
  Matrix range     [1e-02, 2e+03]
  Objective range  [8e-01, 2e+02]
  Bounds range     [3e-02, 1e+03]
  RHS range        [9e-01, 1e+03]
Presolve removed 913 rows and 651 columns
Presolve time: 0.01s
Presolved: 374 rows, 221 columns, 1671 nonzeros

Iteration    Objective       Primal Inf.    Dual Inf.      Time
       0      handle free variables                          0s
     138    3.4852100e+03   0.000000e+00   0.000000e+00      0s

Solved in 138 iterations and 0.02 seconds
Optimal objective  3.485210000e+03

User-callback calls 185, time in user-callback 0.00 sec
Gurobi Optimizer version 9.1.0 build v9.1.0rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 1287 rows, 843 columns and 3539 nonzeros
Model fingerprint: 0x7b242f3c
Coefficient statistics:
  Matrix range     [1e-02, 2e+03]
  Objective range  [8e-01, 2e+02]
  Bounds range     [3e-02, 1e+03]
  RHS range        [9e-01, 1e+03]
Presolve removed 919 rows and 652 columns
Presolve time: 0.01s
Presolved: 368 rows, 220 columns, 1640 nonzeros

Iteration    Objective       Primal Inf.    Dual Inf.      Time
       0      handle free variables                          0s
     170    3.4717100e+03   0.000000e+00   0.000000e+00      0s

Solved in 170 iterations and 0.01 seconds
Optimal objective  3.471710000e+03

User-callback calls 217, time in user-callback 0.00 sec
Gurobi Optimizer version 9.1.0 build v9.1.0rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 1287 rows, 843 columns and 3539 nonzeros
Model fingerprint: 0x198d053c
Coefficient statistics:
  Matrix range     [1e-02, 2e+03]
  Objective range  [8e-01, 2e+02]
  Bounds range     [2e-02, 1e+03]
  RHS range        [9e-01, 1e+03]
Presolve removed 926 rows and 652 columns
Presolve time: 0.00s
Presolved: 361 rows, 220 columns, 1600 nonzeros

Iteration    Objective       Primal Inf.    Dual Inf.      Time
       0      handle free variables                          0s
     160    3.4582100e+03   0.000000e+00   0.000000e+00      0s

Solved in 160 iterations and 0.01 seconds
Optimal objective  3.458210000e+03

User-callback calls 207, time in user-callback 0.00 sec
Gurobi Optimizer version 9.1.0 build v9.1.0rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 1287 rows, 843 columns and 3539 nonzeros
Model fingerprint: 0x38b3368f
Coefficient statistics:
  Matrix range     [1e-02, 2e+03]
  Objective range  [8e-01, 2e+02]
  Bounds range     [3e-02, 1e+03]
  RHS range        [9e-01, 1e+03]
Presolve removed 932 rows and 651 columns
Presolve time: 0.01s
Presolved: 355 rows, 221 columns, 1569 nonzeros

Iteration    Objective       Primal Inf.    Dual Inf.      Time
       0      handle free variables                          0s
     155    3.4447100e+03   0.000000e+00   0.000000e+00      0s

Solved in 155 iterations and 0.02 seconds
Optimal objective  3.444710000e+03

User-callback calls 202, time in user-callback 0.00 sec
Gurobi Optimizer version 9.1.0 build v9.1.0rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 1287 rows, 843 columns and 3539 nonzeros
Model fingerprint: 0x0bbcf698
Coefficient statistics:
  Matrix range     [1e-02, 2e+03]
  Objective range  [8e-01, 2e+02]
  Bounds range     [3e-02, 1e+03]
  RHS range        [9e-01, 1e+03]
Presolve removed 932 rows and 651 columns
Presolve time: 0.01s
Presolved: 355 rows, 221 columns, 1569 nonzeros

Iteration    Objective       Primal Inf.    Dual Inf.      Time
       0      handle free variables                          0s
     139    3.4312100e+03   0.000000e+00   0.000000e+00      0s

Solved in 139 iterations and 0.01 seconds
Optimal objective  3.431210000e+03

User-callback calls 186, time in user-callback 0.00 sec
Gurobi Optimizer version 9.1.0 build v9.1.0rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 1287 rows, 843 columns and 3539 nonzeros
Coefficient statistics:
  Matrix range     [1e-02, 2e+03]
  Objective range  [8e-01, 2e+02]
  Bounds range     [3e-02, 1e+03]
  RHS range        [9e-01, 1e+03]
       0      handle free variables                          0s

Solved in 0 iterations and 0.00 seconds
Optimal objective  3.431210000e+03

User-callback calls 202, time in user-callback 0.00 sec
Gurobi Optimizer version 9.1.0 build v9.1.0rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 1288 rows, 843 columns and 3584 nonzeros
Coefficient statistics:
  Matrix range     [1e-02, 2e+03]
  Objective range  [8e-01, 2e+02]
  Bounds range     [3e-02, 1e+03]
  RHS range        [9e-01, 4e+03]
Iteration    Objective       Primal Inf.    Dual Inf.      Time
       0      handle free variables                          0s
      10    6.8759200e+03   0.000000e+00   0.000000e+00      0s

Solved in 10 iterations and 0.00 seconds
Optimal objective  6.875920000e+03

User-callback calls 231, time in user-callback 0.00 sec
Gurobi Optimizer version 9.1.0 build v9.1.0rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 1288 rows, 843 columns and 3593 nonzeros
Coefficient statistics:
  Matrix range     [1e-02, 2e+03]
  Objective range  [8e-01, 2e+02]
  Bounds range     [2e-02, 1e+03]
  RHS range        [9e-01, 8e+03]
Iteration    Objective       Primal Inf.    Dual Inf.      Time
       0      handle free variables                          0s
      10    1.0334130e+04   0.000000e+00   0.000000e+00      0s

Solved in 10 iterations and 0.01 seconds
Optimal objective  1.033413000e+04

User-callback calls 236, time in user-callback 0.00 sec
Gurobi Optimizer version 9.1.0 build v9.1.0rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 1288 rows, 843 columns and 3602 nonzeros
Coefficient statistics:
  Matrix range     [1e-02, 2e+03]
  Objective range  [8e-01, 2e+02]
  Bounds range     [3e-02, 1e+03]
  RHS range        [9e-01, 1e+04]
Iteration    Objective       Primal Inf.    Dual Inf.      Time
       0      handle free variables                          0s
      10    1.3805840e+04   0.000000e+00   0.000000e+00      0s

Solved in 10 iterations and 0.01 seconds
Optimal objective  1.380584000e+04

User-callback calls 246, time in user-callback 0.00 sec
Gurobi Optimizer version 9.1.0 build v9.1.0rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 1288 rows, 843 columns and 3611 nonzeros
Coefficient statistics:
  Matrix range     [1e-02, 2e+03]
  Objective range  [8e-01, 2e+02]
  Bounds range     [3e-02, 1e+03]
  RHS range        [9e-01, 2e+04]
Iteration    Objective       Primal Inf.    Dual Inf.      Time
       0      handle free variables                          0s
      10    1.7291050e+04   0.000000e+00   0.000000e+00      0s

Solved in 10 iterations and 0.00 seconds
Optimal objective  1.729105000e+04

User-callback calls 214, time in user-callback 0.00 sec
Gurobi Optimizer version 9.1.0 build v9.1.0rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 1288 rows, 843 columns and 3620 nonzeros
Coefficient statistics:
  Matrix range     [1e-02, 2e+03]
  Objective range  [8e-01, 2e+02]
  Bounds range     [3e-02, 1e+03]
  RHS range        [9e-01, 2e+04]
Iteration    Objective       Primal Inf.    Dual Inf.      Time
       0      handle free variables                          0s
      10    2.0789760e+04   0.000000e+00   0.000000e+00      0s

Solved in 10 iterations and 0.01 seconds
Optimal objective  2.078976000e+04

User-callback calls 218, time in user-callback 0.00 sec
Gurobi Optimizer version 9.1.0 build v9.1.0rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 1288 rows, 843 columns and 3629 nonzeros
Coefficient statistics:
  Matrix range     [1e-02, 2e+03]
  Objective range  [8e-01, 2e+02]
  Bounds range     [3e-02, 1e+03]
  RHS range        [9e-01, 2e+04]
Iteration    Objective       Primal Inf.    Dual Inf.      Time
       0      handle free variables                          0s
      33    2.4275923e+04   0.000000e+00   0.000000e+00      0s

Solved in 33 iterations and 0.01 seconds
Optimal objective  2.427592335e+04

User-callback calls 242, time in user-callback 0.00 sec
Gurobi Optimizer version 9.1.0 build v9.1.0rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 1288 rows, 843 columns and 3679 nonzeros
Coefficient statistics:
  Matrix range     [1e-02, 2e+03]
  Objective range  [8e-01, 2e+02]
  Bounds range     [3e-02, 1e+03]
  RHS range        [9e-01, 3e+04]
Iteration    Objective       Primal Inf.    Dual Inf.      Time
       0      handle free variables                          0s
     111    2.7712727e+04   0.000000e+00   0.000000e+00      0s

Solved in 111 iterations and 0.01 seconds
Optimal objective  2.771272672e+04

User-callback calls 323, time in user-callback 0.00 sec
Gurobi Optimizer version 9.1.0 build v9.1.0rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 1288 rows, 843 columns and 3679 nonzeros
Coefficient statistics:
  Matrix range     [1e-02, 6e+03]
  Objective range  [8e-01, 2e+02]
  Bounds range     [3e-02, 1e+03]
  RHS range        [9e-01, 5e+04]
Iteration    Objective       Primal Inf.    Dual Inf.      Time
       0      handle free variables                          0s
     150    3.1066209e+04   0.000000e+00   0.000000e+00      0s

Solved in 150 iterations and 0.01 seconds
Optimal objective  3.106620900e+04

User-callback calls 366, time in user-callback 0.00 sec
Gurobi Optimizer version 9.1.0 build v9.1.0rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 1288 rows, 843 columns and 3679 nonzeros
Coefficient statistics:
  Matrix range     [1e-02, 1e+04]
  Objective range  [8e-01, 2e+02]
  Bounds range     [3e-02, 1e+03]
  RHS range        [9e-01, 7e+04]
Iteration    Objective       Primal Inf.    Dual Inf.      Time
       0      handle free variables                          0s
      95    3.4302409e+04   0.000000e+00   0.000000e+00      0s

Solved in 95 iterations and 0.01 seconds
Optimal objective  3.430240910e+04

User-callback calls 336, time in user-callback 0.00 sec
Gurobi Optimizer version 9.1.0 build v9.1.0rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 1288 rows, 843 columns and 3680 nonzeros
Coefficient statistics:
  Matrix range     [7e-13, 2e+04]
  Objective range  [8e-01, 2e+02]
  Bounds range     [3e-02, 1e+03]
  RHS range        [9e-01, 1e+05]
Warning: Model contains large matrix coefficient range
         Consider reformulating model or setting NumericFocus parameter
         to avoid numerical issues.
Iteration    Objective       Primal Inf.    Dual Inf.      Time
       0      handle free variables                          0s
      90    3.7387366e+04   0.000000e+00   0.000000e+00      0s

Solved in 90 iterations and 0.01 seconds
Optimal objective  3.738736590e+04

User-callback calls 331, time in user-callback 0.00 sec
Gurobi Optimizer version 9.1.0 build v9.1.0rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 1288 rows, 843 columns and 3680 nonzeros
Coefficient statistics:
  Matrix range     [7e-13, 3e+04]
  Objective range  [8e-01, 2e+02]
  Bounds range     [3e-02, 1e+03]
  RHS range        [9e-01, 1e+05]
Warning: Model contains large matrix coefficient range
         Consider reformulating model or setting NumericFocus parameter
         to avoid numerical issues.
Iteration    Objective       Primal Inf.    Dual Inf.      Time
       0      handle free variables                          0s
     127    4.0287118e+04   0.000000e+00   0.000000e+00      0s

Solved in 127 iterations and 0.01 seconds
Optimal objective  4.028711832e+04

User-callback calls 357, time in user-callback 0.00 sec
Gurobi Optimizer version 9.1.0 build v9.1.0rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 1288 rows, 843 columns and 3679 nonzeros
Coefficient statistics:
  Matrix range     [7e-13, 4e+04]
  Objective range  [8e-01, 2e+02]
  Bounds range     [3e-02, 1e+03]
  RHS range        [9e-01, 2e+05]
Warning: Model contains large matrix coefficient range
         Consider reformulating model or setting NumericFocus parameter
         to avoid numerical issues.
Iteration    Objective       Primal Inf.    Dual Inf.      Time
       0      handle free variables                          0s
     105    4.0897627e+04   0.000000e+00   0.000000e+00      0s

Solved in 105 iterations and 0.01 seconds
Optimal objective  4.089762693e+04

User-callback calls 342, time in user-callback 0.00 sec
Gurobi Optimizer version 9.1.0 build v9.1.0rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 1288 rows, 843 columns and 3682 nonzeros
Coefficient statistics:
  Matrix range     [7e-13, 3e+05]
  Objective range  [8e-01, 2e+02]
  Bounds range     [3e-02, 1e+03]
  RHS range        [9e-01, 6e+05]
Warning: Model contains large matrix coefficient range
         Consider reformulating model or setting NumericFocus parameter
         to avoid numerical issues.
Iteration    Objective       Primal Inf.    Dual Inf.      Time
       0      handle free variables                          0s
     180    5.1429419e+03   0.000000e+00   0.000000e+00      0s

Solved in 180 iterations and 0.01 seconds
Optimal objective  5.142941862e+03

User-callback calls 375, time in user-callback 0.00 sec
Gurobi Optimizer version 9.1.0 build v9.1.0rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 1288 rows, 843 columns and 3680 nonzeros
Coefficient statistics:
  Matrix range     [7e-13, 2e+07]
  Objective range  [8e-01, 2e+02]
  Bounds range     [1e-02, 1e+03]
  RHS range        [9e-01, 2e+06]
Warning: Model contains large matrix coefficient range
         Consider reformulating model or setting NumericFocus parameter
         to avoid numerical issues.
Iteration    Objective       Primal Inf.    Dual Inf.      Time
       0      handle free variables                          0s
       2    4.2477400e+03   0.000000e+00   0.000000e+00      0s

Solved in 2 iterations and 0.00 seconds
Optimal objective  4.247740000e+03

User-callback calls 164, time in user-callback 0.00 sec
Gurobi Optimizer version 9.1.0 build v9.1.0rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 1288 rows, 843 columns and 3582 nonzeros
Coefficient statistics:
  Matrix range     [1e-02, 8e+03]
  Objective range  [8e-01, 2e+02]
  Bounds range     [1e-02, 1e+03]
  RHS range        [9e-01, 5e+03]
Iteration    Objective       Primal Inf.    Dual Inf.      Time
       0      handle free variables                          0s
      22    9.0074438e+03   0.000000e+00   0.000000e+00      0s

Solved in 22 iterations and 0.01 seconds
Optimal objective  9.007443805e+03

User-callback calls 172, time in user-callback 0.00 sec
Gurobi Optimizer version 9.1.0 build v9.1.0rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 1288 rows, 843 columns and 3594 nonzeros
Coefficient statistics:
  Matrix range     [1e-02, 1e+06]
  Objective range  [8e-01, 2e+02]
  Bounds range     [3e-02, 1e+03]
  RHS range        [9e-01, 9e+03]
Iteration    Objective       Primal Inf.    Dual Inf.      Time
       0      handle free variables                          0s
      38    1.2243110e+04   0.000000e+00   0.000000e+00      0s

Solved in 38 iterations and 0.01 seconds
Optimal objective  1.224311000e+04

User-callback calls 170, time in user-callback 0.00 sec
Gurobi Optimizer version 9.1.0 build v9.1.0rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 1288 rows, 843 columns and 3602 nonzeros
Coefficient statistics:
  Matrix range     [1e-02, 2e+08]
  Objective range  [8e-01, 2e+02]
  Bounds range     [3e-02, 1e+03]
  RHS range        [9e-01, 1e+04]
Warning: Model contains large matrix coefficients
         Consider reformulating model or setting NumericFocus parameter
         to avoid numerical issues.
Iteration    Objective       Primal Inf.    Dual Inf.      Time
       0      handle free variables                          0s
      50    1.7838870e+04   0.000000e+00   0.000000e+00      0s

Solved in 50 iterations and 0.01 seconds
Optimal objective  1.783887000e+04

User-callback calls 175, time in user-callback 0.00 sec
Gurobi Optimizer version 9.1.0 build v9.1.0rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 1288 rows, 843 columns and 3608 nonzeros
Coefficient statistics:
  Matrix range     [1e-02, 2e+10]
  Objective range  [8e-01, 2e+02]
  Bounds range     [1e+00, 1e+03]
  RHS range        [9e-01, 2e+04]
Warning: Model contains large matrix coefficient range
         Consider reformulating model or setting NumericFocus parameter
         to avoid numerical issues.
Iteration    Objective       Primal Inf.    Dual Inf.      Time
       0      handle free variables                          0s
       2    5.8528800e+03   0.000000e+00   0.000000e+00      0s

Solved in 2 iterations and 0.00 seconds
Optimal objective  5.852880000e+03

User-callback calls 115, time in user-callback 0.00 sec
Gurobi Optimizer version 9.1.0 build v9.1.0rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 1288 rows, 843 columns and 3570 nonzeros
Coefficient statistics:
  Matrix range     [1e-02, 1e+04]
  Objective range  [8e-01, 2e+02]
  Bounds range     [1e+00, 1e+03]
  RHS range        [9e-01, 6e+03]
Iteration    Objective       Primal Inf.    Dual Inf.      Time
       0      handle free variables                          0s
      46    1.1807410e+04   0.000000e+00   0.000000e+00      0s

Solved in 46 iterations and 0.01 seconds
Optimal objective  1.180741000e+04

User-callback calls 139, time in user-callback 0.00 sec
        1    8.116520e+04   1.180741e+04   7.190001e-01          1         40
Gurobi Optimizer version 9.1.0 build v9.1.0rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 1288 rows, 843 columns and 3570 nonzeros
Coefficient statistics:
  Matrix range     [1e-02, 1e+04]
  Objective range  [8e-01, 2e+02]
  Bounds range     [1e+00, 1e+03]
  RHS range        [9e-01, 6e+03]
       0      handle free variables                          0s

Solved in 0 iterations and 0.01 seconds
Optimal objective  1.180741000e+04

User-callback calls 155, time in user-callback 0.00 sec
Gurobi Optimizer version 9.1.0 build v9.1.0rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 1288 rows, 843 columns and 3608 nonzeros
Coefficient statistics:
  Matrix range     [1e-02, 2e+10]
  Objective range  [8e-01, 2e+02]
  Bounds range     [1e+00, 1e+03]
  RHS range        [9e-01, 2e+04]
Warning: Model contains large matrix coefficient range
         Consider reformulating model or setting NumericFocus parameter
         to avoid numerical issues.
       0    5.8528800e+03   0.000000e+00   0.000000e+00      0s

Solved in 0 iterations and 0.00 seconds
Optimal objective  5.852880000e+03

User-callback calls 133, time in user-callback 0.00 sec
Gurobi Optimizer version 9.1.0 build v9.1.0rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 1288 rows, 843 columns and 3602 nonzeros
Coefficient statistics:
  Matrix range     [1e-02, 2e+08]
  Objective range  [8e-01, 2e+02]
  Bounds range     [1e-05, 1e+03]
  RHS range        [9e-01, 1e+04]
Warning: Model contains large matrix coefficients
         Consider reformulating model or setting NumericFocus parameter
         to avoid numerical issues.
       0    2.7284841e-12   6.472519e-02   0.000000e+00      0s

Solved in 6 iterations and 0.00 seconds
Infeasible model

User-callback calls 200, time in user-callback 0.00 sec
┌ Warning: Attempting to recover from serious numerical issues...
└ @ SDDP C:\Users\Lenovo\.julia\packages\SDDP\yCJkk\src\algorithm.jl:245
Gurobi Optimizer version 9.1.0 build v9.1.0rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 1288 rows, 843 columns and 3602 nonzeros
Model fingerprint: 0xba2a6fdb
Coefficient statistics:
  Matrix range     [1e-02, 2e+08]
  Objective range  [8e-01, 2e+02]
  Bounds range     [1e-05, 1e+03]
  RHS range        [9e-01, 1e+04]
Warning: Model contains large matrix coefficients
         Consider reformulating model or setting NumericFocus parameter
         to avoid numerical issues.
Presolve removed 1009 rows and 757 columns
Presolve time: 0.01s

Solved in 0 iterations and 0.01 seconds
Infeasible model

User-callback calls 34, time in user-callback 0.00 sec
ERROR: LoadError: Unable to retrieve solution from 3.
  Termination status: INFEASIBLE
  Primal status:      NO_SOLUTION
  Dual status:        NO_SOLUTION.
A MathOptFormat file was written to `subproblem_3.mof.json`.
See https://odow.github.io/SDDP.jl/latest/tutorial/06_warnings/#Numerical-stability-1
for more information.

If I solve my model in the whole period, it can be solved although it may take a long time. For dynamic programming problems with strong coupling during process(e.g. some examples in graph theory,), does SDDP have good effect?

odow commented 3 years ago

This type of time-staged linear problem can be decomposed and solved with SDDP.jl.

But SDDP.jl doesn't implement Benders feasibility cuts, so your model must have relatively complete recourse. That means, the decision you take in one stage can't lead to an infeasibility in a future stage. The easiest way around this is to relax some of the constraints and add penalty terms to the objective for violating those constraints.

BYS543 commented 3 years ago

Thank you for your prompt reply. I have tried to relax some of my constraints, which may be infeasible, however, iteration still stop with the infeasibility,

User-callback calls 163, time in user-callback 0.00 sec
┌ Warning: Attempting to recover from serious numerical issues...
└ @ SDDP C:\Users\Lenovo\.julia\packages\SDDP\yCJkk\src\algorithm.jl:245
Gurobi Optimizer version 9.1.0 build v9.1.0rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 1288 rows, 843 columns and 3796 nonzeros
Model fingerprint: 0x9b6eb2d5
Coefficient statistics:
  Matrix range     [1e-02, 4e+07]
  Objective range  [8e-01, 2e+02]
  Bounds range     [3e-05, 1e+03]
  RHS range        [9e-01, 1e+06]
Presolve removed 1026 rows and 755 columns
Presolve time: 0.00s

Solved in 0 iterations and 0.00 seconds
Infeasible model

User-callback calls 29, time in user-callback 0.00 sec
ERROR: LoadError: Unable to retrieve solution from 2.
  Termination status: INFEASIBLE
  Primal status:      NO_SOLUTION
 ee https://odow.github.io/SDDP.jl/latest/tutorial/06_warnings/#Numerical-stability-1
for more information. Dual status:        NO_SOLUTION.
A MathOptFormat file was written to `subproblem_2.mof.json`.
See https://odow.github.io/SDDP.jl/latest/tutorial/06_warnings/#Numerical-stability-1
for more information.
odow commented 3 years ago

I have tried to relax some of my constraints, which may be infeasible, however, iteration still stop with the infeasibility,

Then the problem is infeasible due to some other constraints.

Also. Please use set_silent(sp1) in your model to turn off alll that printing...

BYS543 commented 3 years ago

thank you, @odow, i will check the infeasible constraints carefully.

BYS543 commented 3 years ago

@odow ,i feel it might not be the infeasibility(I've relaxed constraints that may lead to infeasibility),which interrupts the solving process,because it has completed one iteration,

 Iteration    Simulation       Bound         Time (s)    Proc. ID   # Solves
        1    8.124707e+04   5.954530e+03   2.840002e-01          1         40
┌ Warning: Attempting to recover from serious numerical issues...
└ @ SDDP C:\Users\Lenovo\.julia\packages\SDDP\yCJkk\src\algorithm.jl:245
ERROR: LoadError: Unable to retrieve solution from 2.
  Termination status: INFEASIBLE
  Primal status:      NO_SOLUTION
  Dual status:        NO_SOLUTION.
A MathOptFormat file was written to `subproblem_2.mof.json`.
See https://odow.github.io/SDDP.jl/latest/tutorial/06_warnings/#Numerical-stability-1
for more information.

When the second iteration, the solving process terminates. And the prompt shows that the constraint is infeasible due to numerical problems.

odow commented 3 years ago

The warning is misleading. Read this: https://github.com/odow/SDDP.jl/issues/436

odow commented 3 years ago

Closing because I don't want to document this.

Future readers: you're welcome to access the nodes via model[1] (if linear) or model[(2, 3)] (if Markovian) and access fields like model[1].subproblem, but this is undocumented and may break in any future release.