Subject: GAMS Model Becomes Infeasible with Longer Time Horizons - Suspected Cumulative Error Issue

Hello GAMS Community,

I’m working on a cascade reservoir optimization model. The model runs successfully with 500 time periods but becomes infeasible when extended to 750+ periods. The error occurs during the relaxed NLP phase in DICOPT:

** Infeasible solution. Reduced gradient less than tolerance.
--- DICOPT: Relaxed NLP is infeasible

Key observations:

  • Model works fine with 500 time steps

  • Fails with 750+ time steps

  • All input data has sufficient length (2044 periods)

  • Not an initialization issue (tried various initial values)

  • Suspecting cumulative numerical errors in water balance equations

Model Structure:

  • Cascade reservoirs: XJ→FM→SL→JS with diversion to DY and DH

  • Mixed-integer nonlinear programming (MINLP)

  • Water balance, energy production, and operational constraints

  • Uses DICOPT with CONOPT3 and Gurobi

Specific concerns:

  1. Could unit conversions (Secs_hour/1e4) cause cumulative floating-point errors?

  2. Does the cascade structure amplify small errors over long horizons?

  3. Are there numerical stability issues in head-water level calculations?

Has anyone encountered similar issues with long-time-horizon models? Any suggestions for improving numerical stability or debugging strategies would be greatly appreciated.

Thank you!

test.gms (18.2 KB)

Can you provide the data (probably best in form of the GDX files) so one can reproduce?

-Michael

Dear Mr. mbussieck,

I hope this message finds you well. I am writing to express my sincere gratitude for your prompt response to my previous inquiry, and to offer my apologies for the delay in following up.

Regarding the initial issue, a colleague has proposed an alternative solution that eliminates the need for optimization methods. Instead, the problem can be resolved through direct simulation runs, and thus this matter is now considered successfully addressed.

However, I am currently encountering a new challenge related to infeasible Mixed-Integer Programming (MIP) subproblems. Specifically, when implementing the Big M method in conjunction with binary variables to determine the occurrence of spillage at Reservoir A, the resulting MIP subproblems consistently return infeasible solutions.

To facilitate your understanding, I have provided the relevant details below, including model constraints, solver logs, and technical specifications:
1. Big M Method Constraint Equations
Spillage detection constraints using binary variables
judge_r_spill_1(time_long)..Spill(time_long,‘A’) =l= 3600abandon_or_not(time_long,‘A’);
judge_r_spill_2(time_long)..Spill(time_long,‘A’) =g= 1e-4
abandon_or_not(time_long,‘A’);
2. Excerpt from DICOPT Solver Log

plaintext

--- DICOPT: Checking convergence

--- NOTICE : Too many infeasible NLP subproblems consider the use of infeasder option

--- DICOPT: Setting up next MIP
--- DICOPT: Log File:
 Major Major     Objective    CPU time  Itera- Evaluation Solver
 Step  Iter       Function     (Sec)    tions   Errors
  NLP    1    171333.97516     33.22     1158      0      conopt3
  MIP    1    171256.94194      3.64    17182      0      gurobi
  NLP    2        *Infeas*      1.98       12      0      conopt3
  MIP    2    171256.94194      3.38    17182      0      gurobi
  NLP    3        *Infeas*      1.97       12      0      conopt3
  MIP    3    171256.94194      3.16    17184      0      gurobi
  NLP    4        *Infeas*      1.91       12      0      conopt3
  MIP    4    171256.94194      3.19    17184      0      gurobi
  NLP    5        *Infeas*      1.94       12      0      conopt3
  MIP    5    171256.94194      2.94    17040      0      gurobi
  NLP    6        *Infeas*      1.97       12      0      conopt3
  MIP    6    171256.94194      3.03    17040      0      gurobi
  NLP    7        *Infeas*      2.05       12      0      conopt3
  MIP    7    171256.94194      3.02    17040      0      gurobi
  NLP    8        *Infeas*      1.95       12      0      conopt3
  MIP    8    171256.94194      2.92    17040      0      gurobi
  NLP    9        *Infeas*      2.17       12      0      conopt3
  MIP    9    171256.94194      2.95    17040      0      gurobi
  NLP   10        *Infeas*      1.97       12      0      conopt3
  MIP   10    171256.94194      4.05    17040      0      gurobi
  NLP   11        *Infeas*      2.58       12      0      conopt3
  MIP   11    171256.94194      3.14    17040      0      gurobi
  NLP   12        *Infeas*      2.08       12      0      conopt3
  MIP   12    171256.94194      3.13    17184      0      gurobi
  NLP   13        *Infeas*      2.42       12      0      conopt3
  MIP   13    171256.94194      3.23    17184      0      gurobi
  NLP   14        *Infeas*      1.98       12      0      conopt3
  MIP   14    171256.94194      3.16    17184      0      gurobi
  NLP   15        *Infeas*      1.99       12      0      conopt3
  MIP   15    171256.94194      3.28    17184      0      gurobi
  NLP   16        *Infeas*      1.95       12      0      conopt3
  MIP   16    171256.94194      3.05    17184      0      gurobi
  NLP   17        *Infeas*      1.97       12      0      conopt3
  MIP   17    171256.94194      3.25    17184      0      gurobi
  NLP   18        *Infeas*      2.00       12      0      conopt3
  MIP   18    171256.94194      3.34    17184      0      gurobi
  NLP   19        *Infeas*      2.27       12      0      conopt3
  MIP   19    171256.94194      3.64    17184      0      gurobi
  NLP   20        *Infeas*      2.03       12      0      conopt3
  MIP   20    171256.94194      3.45    17184      0      gurobi
  NLP   21        *Infeas*      1.95       12      0      conopt3
  MIP   21    171256.94194      3.31    17184      0      gurobi
  NLP   22        *Infeas*      2.00       12      0      conopt3
  MIP   22    171256.94194      3.11    17184      0      gurobi
  NLP   23        *Infeas*      1.91       12      0      conopt3
  MIP   23    171256.94194      3.34    17040      0      gurobi
  NLP   24        *Infeas*      2.20       12      0      conopt3
  MIP   24    171256.94194      3.17    17182      0      gurobi
  NLP   25        *Infeas*      2.03       12      0      conopt3
  MIP   25    171256.94194      3.27    17182      0      gurobi
  NLP   26        *Infeas*      2.05       12      0      conopt3
  MIP   26    171256.94194      3.16    17182      0      gurobi
  NLP   27        *Infeas*      1.97       12      0      conopt3
  MIP   27    171256.94194      3.19    17182      0      gurobi
  NLP   28        *Infeas*      2.13       12      0      conopt3
  MIP   28    171256.94194      3.19    17182      0      gurobi
  NLP   29        *Infeas*      2.05       12      0      conopt3
  MIP   29    171256.94194      3.22    17182      0      gurobi
  NLP   30        *Infeas*      2.08       12      0      conopt3
  MIP   30    171256.94194      3.48    17182      0      gurobi
  NLP   31        *Infeas*      2.09       12      0      conopt3
  MIP   31    171256.94194      3.17    17182      0      gurobi
  NLP   32        *Infeas*      2.14       12      0      conopt3
  MIP   32    171256.94194      3.13    17182      0      gurobi
  NLP   33        *Infeas*      2.06       12      0      conopt3
  MIP   33    171256.94194      3.20    17182      0      gurobi
  NLP   34        *Infeas*      2.14       12      0      conopt3
  MIP   34    171256.94194      3.36    17182      0      gurobi
  NLP   35        *Infeas*      2.00       12      0      conopt3
  MIP   35    171256.94194      3.16    17182      0      gurobi
  NLP   36        *Infeas*      2.05       12      0      conopt3
  MIP   36    171256.94194      3.39    17182      0      gurobi
  NLP   37        *Infeas*      2.00       12      0      conopt3
  MIP   37    171256.94194      3.28    17182      0      gurobi
  NLP   38        *Infeas*      2.03       12      0      conopt3
  MIP   38    171256.94194      3.14    16960      0      gurobi
  NLP   39        *Infeas*      1.97       12      0      conopt3
  MIP   39    171256.94194      2.98    16960      0      gurobi
  NLP   40        *Infeas*      1.95       12      0      conopt3
  MIP   40    171256.94194      3.06    16960      0      gurobi
  NLP   41        *Infeas*      1.95       12      0      conopt3
  MIP   41    171256.94194      2.89    16960      0      gurobi
  NLP   42        *Infeas*      2.14       12      0      conopt3
  MIP   42    171256.94194      3.17    16960      0      gurobi
  NLP   43        *Infeas*      2.16       12      0      conopt3
  MIP   43    171256.94194      3.06    16960      0      gurobi
  NLP   44        *Infeas*      2.30       12      0      conopt3
  MIP   44    171256.94194      3.02    16960      0      gurobi
  NLP   45        *Infeas*      2.31       12      0      conopt3
  MIP   45    171256.94194      3.20    17182      0      gurobi
  NLP   46        *Infeas*      1.94       12      0      conopt3
  MIP   46    171256.94194      3.14    17182      0      gurobi
  NLP   47        *Infeas*      2.16       12      0      conopt3

3. Gurobi Solver Technical Output

plaintext

Use option 'names no' to turn use of names off
Warning: loading a model with small (< 1e-13) coefficients, ignored
Starting Gurobi...
Optimize a model with 65847 rows, 78949 columns and 283592 nonzeros
Variable types: 76756 continuous, 2193 integer (2193 binary)
Coefficient statistics:
  Matrix range     [2e-13, 4e+03]
  Objective range  [3e-01, 8e+04]
  Bounds range     [1e+00, 1e+00]
  RHS range        [1e-05, 2e+05]
Warning: Model contains large matrix coefficient range
         Consider reformulating model or setting NumericFocus parameter
         to avoid numerical issues.
Presolve removed 58237 rows and 68491 columns
Presolve time: 0.14s
Presolved: 7610 rows, 10458 columns, 24525 nonzeros
Variable types: 9057 continuous, 1401 integer (1401 binary)

Root relaxation: objective 1.712621e+05, 7077 iterations, 0.07 seconds

4. Supporting Materials

I have attached the complete GAMS model code (model.gms) and corresponding input data files (data.inc) for your review. These files include the full implementation of the Big M method and all relevant constraints related to reservoir operations.
I suspect there might be a numerical instability issue. I have adjusted the Big M value—even when reducing it to 500, the infeasibility persists. Notably, a Big M value of 3600 is still insufficient, as the maximum possible spillage could reach 5500. Therefore, the Big M parameter ideally needs to be set to a value that satisfies the constraint for all time periods.

file.zip (146.3 KB)