Obtaining Suboptimal Solutions with Benders in GAMS - optimization
I have the following Benders code for a maximization problem on GAMS. It happens that sometimes GAMS give an suboptimal solution even though it should find the exact solution, since no heuristics exist and Benders tolerance (BdTol= Upper Bound - Lower Bound) is 0. I ensure that both the subproblem and the master problem are solved to optimality and optcr and optca values are taken as 0, too. I realized it as follows: for a dataset I solved the problem without enforcing any variable to take any value, and it provided an objective value. Then, I enforced a variable to take a certain value, and it provided a higher objective value. Shouldn't GAMS find the highest possible value automatically as it is a maximization problem? Do you think there is something wrong with the code?
Sets
i /1*100/
j /1*10/;
Parameters
p /4/
m /1/
BdTol /0/;
Table a(i,j) DATA;
Table b(i,j) DATA;
variables
q 'cut set variable'
z;
binary variables
y(j)
x(i,j);
positive variables
w(j);
scalar UB 'upperbound' /INF/;
scalar LB 'lowerbound' /-INF/;
set iter /iter1*iter1000000/;
set cutset(iter) 'dynamic set';
cutset(iter)=no;
variable z0 'relaxed master objective variable'
q 'cut set variable';
parameters
cutcoeff(iter,i,j);
*---------------------------------------------------------------------
* Benders Algorithm
*---------------------------------------------------------------------
loop(iter$((abs(UB-LB)> BdTol)),
option lp=CPLEX, optcr=0, optca=0, reslim=1000000, iterlim=1000000;
solve subproblem maximizing z using lp;
abort$(subproblem.modelstat>=2) "Subproblem not solved to optimality";
cutset(iter) = yes;
cutcoeff(iter,i,j) = b(i,j)*w.l(j);
option mip=CPLEX, optcr=0, optca=0, reslim=1000000, iterlim=1000000;
solve master maximizing z0 using mip;
abort$(master.modelstat>=2) "Masterproblem not solved to optimality";
UB = min(UB, sum((i,j),a(i,j)*x.l(i,j))+q.l);
LB = max(LB, sum((i,j),a(i,j)*x.l(i,j))+z.l);
display x.l, y.l, z0.l, w.l, UB, LB;
);
Since I believe the problem is related to the algorithm, I only share that part.
Edit: New information are added.
What really interesting is, it finds suboptimal solutions only for some instances, not all the time.
The runs for a dataset is given below. The upper ones does not involve any enforcing constraints for a variable to take a certain value. The lower one involves a single variable to take a specific value.
The following is the log output for the one without the enforced variable.
IBM ILOG CPLEX Jul 4, 2012 23.9.5 WEX 36376.36401 WEI x86_64/MS Windows
Cplex 12.4.0.1
Reading data...
Starting Cplex...
Tried aggregator 1 time.
LP Presolve eliminated 12 rows and 11 columns.
All rows and columns eliminated.
Presolve time = 0.00 sec.
LP status(1): optimal
Optimal solution found.
Objective : -12.203660
--- Reading solution for model subproblem
--- Executing after solve: elapsed 0:00:04.895
--- benders3.gms(358) 88 Mb
--- Generating MIP model master
--- benders3.gms(367) 89 Mb
--- LOOPS iter = iter1
--- 4,107 rows 4,016 columns 9,820 non-zeroes
--- 1,010 discrete-columns
--- Executing CPLEX: elapsed 0:00:04.902
IBM ILOG CPLEX Jul 4, 2012 23.9.5 WEX 36376.36401 WEI x86_64/MS Windows
--- GAMS/Cplex licensed for continuous and discrete problems.
Cplex 12.4.0.1
Reading data...
Starting Cplex...
Tried aggregator 1 time.
MIP Presolve eliminated 3387 rows and 3387 columns.
Reduced MIP has 720 rows, 629 columns, and 1867 nonzeros.
Reduced MIP has 629 binaries, 0 generals, 0 SOSs, and 0 indicators.
Probing time = 0.00 sec.
Tried aggregator 1 time.
Presolve time = 0.00 sec.
Found feasible solution after 0.00 sec. Objective = 0.0000
Probing time = 0.00 sec.
Clique table members: 719.
MIP emphasis: balance optimality and feasibility.
MIP search method: dynamic search.
Parallel mode: none, using 1 thread.
Tried aggregator 1 time.
No LP presolve or aggregator reductions.
Presolve time = 0.00 sec.
Initializing dual steep norms . . .
Iteration log . . .
Iteration: 1 Dual objective = 362.425771
Iteration: 129 Dual objective = 96.848559
Iteration: 198 Dual objective = 94.968744
Root relaxation solution time = 0.00 sec.
Nodes Cuts/
Node Left Objective IInf Best Integer Best Bound ItCnt Gap
* 0+ 0 0.0000 249 ---
* 0 0 integral 0 93.1164 93.1164 249 0.00%
Elapsed real time = 0.00 sec. (tree size = 0.00 MB, solutions = 2)
Root node processing (before b&c):
Real time = 0.00
Sequential b&c:
Real time = 0.00
-------
Total (root+branch&cut) = 0.00 sec.
MIP status(101): integer optimal solution
Fixing integer variables, and solving final LP...
Tried aggregator 1 time.
LP Presolve eliminated 4107 rows and 4016 columns.
All rows and columns eliminated.
Presolve time = 0.00 sec.
Fixed MIP status(1): optimal
Proven optimal solution.
MIP Solution: 93.116376 (249 iterations, 0 nodes)
Final Solve: 93.116376 (0 iterations)
Best possible: 93.116376
Absolute gap: 0.000000
Relative gap: 0.000000
--- Reading solution for model master
--- Executing after solve: elapsed 0:00:04.954
--- benders3.gms(358) 89 Mb
--- Generating LP model subproblem
--- benders3.gms(360) 89 Mb
--- LOOPS iter = iter2
--- 12 rows 11 columns 25 non-zeroes
--- Executing CPLEX: elapsed 0:00:04.959
IBM ILOG CPLEX Jul 4, 2012 23.9.5 WEX 36376.36401 WEI x86_64/MS Windows
Cplex 12.4.0.1
Reading data...
Starting Cplex...
Tried aggregator 1 time.
LP Presolve eliminated 12 rows and 11 columns.
All rows and columns eliminated.
Presolve time = 0.00 sec.
LP status(1): optimal
Optimal solution found.
Objective : -2.121247
--- Reading solution for model subproblem
--- Executing after solve: elapsed 0:00:04.974
--- benders3.gms(358) 89 Mb
--- Generating MIP model master
--- benders3.gms(367) 89 Mb
--- LOOPS iter = iter2
--- 4,108 rows 4,016 columns 9,863 non-zeroes
--- 1,010 discrete-columns
--- Executing CPLEX: elapsed 0:00:04.982
IBM ILOG CPLEX Jul 4, 2012 23.9.5 WEX 36376.36401 WEI x86_64/MS Windows
--- GAMS/Cplex licensed for continuous and discrete problems.
Cplex 12.4.0.1
Reading data...
Starting Cplex...
Tried aggregator 1 time.
MIP Presolve eliminated 3354 rows and 3354 columns.
Reduced MIP has 754 rows, 662 columns, and 2034 nonzeros.
Reduced MIP has 661 binaries, 0 generals, 0 SOSs, and 0 indicators.
Probing time = 0.00 sec.
Tried aggregator 1 time.
Reduced MIP has 754 rows, 662 columns, and 2034 nonzeros.
Reduced MIP has 661 binaries, 0 generals, 0 SOSs, and 0 indicators.
Presolve time = 0.09 sec.
Found feasible solution after 0.09 sec. Objective = -13.6132
Probing time = 0.00 sec.
Clique table members: 751.
MIP emphasis: balance optimality and feasibility.
MIP search method: dynamic search.
Parallel mode: none, using 1 thread.
Tried aggregator 1 time.
No LP presolve or aggregator reductions.
Presolve time = 0.00 sec.
Initializing dual steep norms . . .
Iteration log . . .
Iteration: 1 Dual objective = 365.039800
Iteration: 141 Dual objective = 96.728338
Iteration: 211 Dual objective = 94.098252
Root relaxation solution time = 0.01 sec.
Nodes Cuts/
Node Left Objective IInf Best Integer Best Bound ItCnt Gap
* 0+ 0 -13.6132 246 ---
* 0 0 integral 0 93.0748 93.0748 246 0.00%
Elapsed real time = 0.11 sec. (tree size = 0.00 MB, solutions = 2)
Root node processing (before b&c):
Real time = 0.01
Sequential b&c:
Real time = 0.00
-------
Total (root+branch&cut) = 0.01 sec.
MIP status(101): integer optimal solution
Fixing integer variables, and solving final LP...
Tried aggregator 1 time.
LP Presolve eliminated 4108 rows and 4016 columns.
All rows and columns eliminated.
Presolve time = 0.00 sec.
Fixed MIP status(1): optimal
Proven optimal solution.
MIP Solution: 93.074808 (246 iterations, 0 nodes)
Final Solve: 93.074808 (0 iterations)
Best possible: 93.074808
Absolute gap: 0.000000
Relative gap: 0.000000
--- Reading solution for model master
--- Executing after solve: elapsed 0:00:05.115
--- benders3.gms(358) 89 Mb
--- Generating LP model subproblem
--- benders3.gms(360) 89 Mb
--- LOOPS iter = iter3
--- 12 rows 11 columns 25 non-zeroes
--- Executing CPLEX: elapsed 0:00:05.120
IBM ILOG CPLEX Jul 4, 2012 23.9.5 WEX 36376.36401 WEI x86_64/MS Windows
Cplex 12.4.0.1
Reading data...
Starting Cplex...
Tried aggregator 1 time.
LP Presolve eliminated 12 rows and 11 columns.
All rows and columns eliminated.
Presolve time = 0.00 sec.
LP status(1): optimal
Optimal solution found.
Objective : -2.847644
--- Reading solution for model subproblem
--- Executing after solve: elapsed 0:00:05.132
--- benders3.gms(358) 89 Mb
--- Generating MIP model master
--- benders3.gms(367) 89 Mb
--- LOOPS iter = iter3
--- 4,109 rows 4,016 columns 9,967 non-zeroes
--- 1,010 discrete-columns
--- Executing CPLEX: elapsed 0:00:05.141
IBM ILOG CPLEX Jul 4, 2012 23.9.5 WEX 36376.36401 WEI x86_64/MS Windows
--- GAMS/Cplex licensed for continuous and discrete problems.
Cplex 12.4.0.1
Reading data...
Starting Cplex...
Tried aggregator 1 time.
MIP Presolve eliminated 3354 rows and 3354 columns.
Reduced MIP has 755 rows, 662 columns, and 2105 nonzeros.
Reduced MIP has 661 binaries, 0 generals, 0 SOSs, and 0 indicators.
Probing time = 0.00 sec.
Tried aggregator 1 time.
Reduced MIP has 755 rows, 662 columns, and 2105 nonzeros.
Reduced MIP has 661 binaries, 0 generals, 0 SOSs, and 0 indicators.
Presolve time = 0.00 sec.
Found feasible solution after 0.00 sec. Objective = -32.0161
Probing time = 0.00 sec.
Clique table members: 751.
MIP emphasis: balance optimality and feasibility.
MIP search method: dynamic search.
Parallel mode: none, using 1 thread.
Tried aggregator 1 time.
No LP presolve or aggregator reductions.
Presolve time = 0.00 sec.
Initializing dual steep norms . . .
Iteration log . . .
Iteration: 1 Dual objective = 346.636915
Iteration: 142 Dual objective = 96.564506
Iteration: 214 Dual objective = 93.644333
Root relaxation solution time = 0.02 sec.
Nodes Cuts/
Node Left Objective IInf Best Integer Best Bound ItCnt Gap
* 0+ 0 -32.0161 252 ---
* 0 0 integral 0 92.6192 92.6192 252 0.00%
Elapsed real time = 0.09 sec. (tree size = 0.00 MB, solutions = 2)
Root node processing (before b&c):
Real time = 0.09
Sequential b&c:
Real time = 0.00
-------
Total (root+branch&cut) = 0.09 sec.
MIP status(101): integer optimal solution
Fixing integer variables, and solving final LP...
Tried aggregator 1 time.
LP Presolve eliminated 4109 rows and 4016 columns.
All rows and columns eliminated.
Presolve time = 0.01 sec.
Fixed MIP status(1): optimal
Proven optimal solution.
MIP Solution: 92.619154 (252 iterations, 0 nodes)
Final Solve: 92.619154 (0 iterations)
Best possible: 92.619154
Absolute gap: 0.000000
Relative gap: 0.000000
--- Reading solution for model master
--- Executing after solve: elapsed 0:00:05.283
--- benders3.gms(358) 89 Mb
--- Generating LP model subproblem
--- benders3.gms(360) 89 Mb
--- LOOPS iter = iter4
--- 12 rows 11 columns 24 non-zeroes
--- Executing CPLEX: elapsed 0:00:05.290
IBM ILOG CPLEX Jul 4, 2012 23.9.5 WEX 36376.36401 WEI x86_64/MS Windows
Cplex 12.4.0.1
Reading data...
Starting Cplex...
Tried aggregator 1 time.
LP Presolve eliminated 12 rows and 11 columns.
All rows and columns eliminated.
Presolve time = 0.00 sec.
LP status(1): optimal
Optimal solution found.
Objective : 0.000000
--- Reading solution for model subproblem
--- Executing after solve: elapsed 0:00:05.304
--- benders3.gms(358) 89 Mb
--- Generating MIP model master
--- benders3.gms(367) 89 Mb
--- LOOPS iter = iter4
--- 4,110 rows 4,016 columns 10,038 non-zeroes
--- 1,010 discrete-columns
--- Executing CPLEX: elapsed 0:00:05.311
IBM ILOG CPLEX Jul 4, 2012 23.9.5 WEX 36376.36401 WEI x86_64/MS Windows
--- GAMS/Cplex licensed for continuous and discrete problems.
Cplex 12.4.0.1
Reading data...
Starting Cplex...
Tried aggregator 1 time.
MIP Presolve eliminated 3355 rows and 3354 columns.
Reduced MIP has 755 rows, 662 columns, and 2105 nonzeros.
Reduced MIP has 661 binaries, 0 generals, 0 SOSs, and 0 indicators.
Probing time = 0.02 sec.
Tried aggregator 1 time.
Reduced MIP has 755 rows, 662 columns, and 2105 nonzeros.
Reduced MIP has 661 binaries, 0 generals, 0 SOSs, and 0 indicators.
Presolve time = 0.09 sec.
Found feasible solution after 0.09 sec. Objective = -32.0161
Probing time = 0.00 sec.
Clique table members: 751.
MIP emphasis: balance optimality and feasibility.
MIP search method: dynamic search.
Parallel mode: none, using 1 thread.
Tried aggregator 1 time.
No LP presolve or aggregator reductions.
Presolve time = 0.00 sec.
Initializing dual steep norms . . .
Iteration log . . .
Iteration: 1 Dual objective = 346.636915
Iteration: 142 Dual objective = 96.564506
Iteration: 214 Dual objective = 93.644333
Root relaxation solution time = 0.00 sec.
Nodes Cuts/
Node Left Objective IInf Best Integer Best Bound ItCnt Gap
* 0+ 0 -32.0161 252 ---
* 0 0 integral 0 92.6192 92.6192 252 0.00%
Elapsed real time = 0.09 sec. (tree size = 0.00 MB, solutions = 2)
Root node processing (before b&c):
Real time = 0.02
Sequential b&c:
Real time = 0.00
-------
Total (root+branch&cut) = 0.02 sec.
MIP status(101): integer optimal solution
Fixing integer variables, and solving final LP...
Tried aggregator 1 time.
LP Presolve eliminated 4110 rows and 4016 columns.
All rows and columns eliminated.
Presolve time = 0.00 sec.
Fixed MIP status(1): optimal
Proven optimal solution.
MIP Solution: 92.619154 (252 iterations, 0 nodes)
Final Solve: 92.619154 (0 iterations)
Best possible: 92.619154
Absolute gap: 0.000000
Relative gap: 0.000000
--- Reading solution for model master
--- Executing after solve: elapsed 0:00:05.434
--- benders3.gms(358) 89 Mb
*** Status: Normal completion
--- Job benders3.gms Stop 12/10/22 14:37:01 elapsed 0:00:05.481
The following is the log output for the one with the enforced variable.
--- benders3.gms(151) 86 Mb
--- Starting execution: elapsed 0:00:04.400
--- benders3.gms(358) 88 Mb
--- Generating LP model subproblem
--- benders3.gms(360) 88 Mb
--- LOOPS iter = iter1
--- 12 rows 11 columns 31 non-zeroes
--- Executing CPLEX: elapsed 0:00:04.406
IBM ILOG CPLEX Jul 4, 2012 23.9.5 WEX 36376.36401 WEI x86_64/MS Windows
Cplex 12.4.0.1
Reading data...
Starting Cplex...
Tried aggregator 1 time.
LP Presolve eliminated 12 rows and 11 columns.
All rows and columns eliminated.
Presolve time = 0.00 sec.
LP status(1): optimal
Optimal solution found.
Objective : -12.203660
--- Reading solution for model subproblem
--- Executing after solve: elapsed 0:00:04.417
--- benders3.gms(358) 88 Mb
--- Generating MIP model master
--- benders3.gms(367) 89 Mb
--- LOOPS iter = iter1
--- 4,107 rows 4,016 columns 9,820 non-zeroes
--- 1,009 discrete-columns
--- Executing CPLEX: elapsed 0:00:04.425
IBM ILOG CPLEX Jul 4, 2012 23.9.5 WEX 36376.36401 WEI x86_64/MS Windows
--- GAMS/Cplex licensed for continuous and discrete problems.
Cplex 12.4.0.1
Reading data...
Starting Cplex...
Tried aggregator 1 time.
MIP Presolve eliminated 3547 rows and 3500 columns.
Reduced MIP has 560 rows, 516 columns, and 1458 nonzeros.
Reduced MIP has 516 binaries, 0 generals, 0 SOSs, and 0 indicators.
Probing time = 0.00 sec.
Tried aggregator 2 times.
MIP Presolve eliminated 1 rows and 1 columns.
Aggregator did 1 substitutions.
Reduced MIP has 558 rows, 514 columns, and 1454 nonzeros.
Reduced MIP has 514 binaries, 0 generals, 0 SOSs, and 0 indicators.
Presolve time = 0.01 sec.
Found feasible solution after 0.01 sec. Objective = 25.1590
Probing time = 0.00 sec.
Clique table members: 557.
MIP emphasis: balance optimality and feasibility.
MIP search method: dynamic search.
Parallel mode: none, using 1 thread.
Tried aggregator 1 time.
No LP presolve or aggregator reductions.
Presolve time = 0.00 sec.
Initializing dual steep norms . . .
Iteration log . . .
Iteration: 1 Dual objective = 213.565458
Iteration: 77 Dual objective = 96.476340
Iteration: 150 Dual objective = 93.814763
Root relaxation solution time = 0.00 sec.
Nodes Cuts/
Node Left Objective IInf Best Integer Best Bound ItCnt Gap
* 0+ 0 25.1590 193 ---
* 0 0 integral 0 93.1164 93.1164 193 0.00%
Elapsed real time = 0.01 sec. (tree size = 0.00 MB, solutions = 2)
Root node processing (before b&c):
Real time = 0.00
Sequential b&c:
Real time = 0.00
-------
Total (root+branch&cut) = 0.00 sec.
MIP status(101): integer optimal solution
Fixing integer variables, and solving final LP...
Tried aggregator 1 time.
LP Presolve eliminated 4107 rows and 4016 columns.
All rows and columns eliminated.
Presolve time = 0.00 sec.
Fixed MIP status(1): optimal
Proven optimal solution.
MIP Solution: 93.116376 (193 iterations, 0 nodes)
Final Solve: 93.116376 (0 iterations)
Best possible: 93.116376
Absolute gap: 0.000000
Relative gap: 0.000000
--- Reading solution for model master
--- Executing after solve: elapsed 0:00:04.551
--- benders3.gms(358) 89 Mb
--- Generating LP model subproblem
--- benders3.gms(360) 89 Mb
--- LOOPS iter = iter2
--- 12 rows 11 columns 25 non-zeroes
--- Executing CPLEX: elapsed 0:00:04.555
IBM ILOG CPLEX Jul 4, 2012 23.9.5 WEX 36376.36401 WEI x86_64/MS Windows
Cplex 12.4.0.1
Reading data...
Starting Cplex...
Tried aggregator 1 time.
LP Presolve eliminated 12 rows and 11 columns.
All rows and columns eliminated.
Presolve time = 0.00 sec.
LP status(1): optimal
Optimal solution found.
Objective : -2.121247
--- Reading solution for model subproblem
--- Executing after solve: elapsed 0:00:04.568
--- benders3.gms(358) 89 Mb
--- Generating MIP model master
--- benders3.gms(367) 89 Mb
--- LOOPS iter = iter2
--- 4,108 rows 4,016 columns 9,863 non-zeroes
--- 1,009 discrete-columns
--- Executing CPLEX: elapsed 0:00:04.576
IBM ILOG CPLEX Jul 4, 2012 23.9.5 WEX 36376.36401 WEI x86_64/MS Windows
--- GAMS/Cplex licensed for continuous and discrete problems.
Cplex 12.4.0.1
Reading data...
Starting Cplex...
Tried aggregator 1 time.
MIP Presolve eliminated 3460 rows and 3413 columns.
Reduced MIP has 648 rows, 603 columns, and 1781 nonzeros.
Reduced MIP has 602 binaries, 0 generals, 0 SOSs, and 0 indicators.
Probing time = 0.00 sec.
Tried aggregator 1 time.
Reduced MIP has 648 rows, 603 columns, and 1781 nonzeros.
Reduced MIP has 602 binaries, 0 generals, 0 SOSs, and 0 indicators.
Presolve time = 0.00 sec.
Found feasible solution after 0.00 sec. Objective = -2.6132
Probing time = 0.00 sec.
Clique table members: 645.
MIP emphasis: balance optimality and feasibility.
MIP search method: dynamic search.
Parallel mode: none, using 1 thread.
Tried aggregator 1 time.
No LP presolve or aggregator reductions.
Presolve time = 0.00 sec.
Initializing dual steep norms . . .
Iteration log . . .
Iteration: 1 Dual objective = 339.579984
Iteration: 130 Dual objective = 96.654157
Iteration: 208 Dual objective = 93.001859
Root relaxation solution time = 0.09 sec.
Nodes Cuts/
Node Left Objective IInf Best Integer Best Bound ItCnt Gap
* 0+ 0 -2.6132 213 ---
* 0 0 integral 0 92.8258 92.8258 213 0.00%
Elapsed real time = 0.09 sec. (tree size = 0.00 MB, solutions = 2)
Root node processing (before b&c):
Real time = 0.09
Sequential b&c:
Real time = 0.00
-------
Total (root+branch&cut) = 0.09 sec.
MIP status(101): integer optimal solution
Fixing integer variables, and solving final LP...
Tried aggregator 1 time.
LP Presolve eliminated 4108 rows and 4016 columns.
All rows and columns eliminated.
Presolve time = 0.00 sec.
Fixed MIP status(1): optimal
Proven optimal solution.
MIP Solution: 92.825775 (213 iterations, 0 nodes)
Final Solve: 92.825775 (0 iterations)
Best possible: 92.825775
Absolute gap: 0.000000
Relative gap: 0.000000
--- Reading solution for model master
--- Executing after solve: elapsed 0:00:04.703
--- benders3.gms(358) 89 Mb
--- Generating LP model subproblem
--- benders3.gms(360) 89 Mb
--- LOOPS iter = iter3
--- 12 rows 11 columns 24 non-zeroes
--- Executing CPLEX: elapsed 0:00:04.707
IBM ILOG CPLEX Jul 4, 2012 23.9.5 WEX 36376.36401 WEI x86_64/MS Windows
Cplex 12.4.0.1
Reading data...
Starting Cplex...
Tried aggregator 1 time.
LP Presolve eliminated 12 rows and 11 columns.
All rows and columns eliminated.
Presolve time = 0.00 sec.
LP status(1): optimal
Optimal solution found.
Objective : 0.000000
--- Reading solution for model subproblem
--- Executing after solve: elapsed 0:00:04.720
--- benders3.gms(358) 89 Mb
--- Generating MIP model master
--- benders3.gms(367) 89 Mb
--- LOOPS iter = iter3
--- 4,109 rows 4,016 columns 9,901 non-zeroes
--- 1,009 discrete-columns
--- Executing CPLEX: elapsed 0:00:04.727
IBM ILOG CPLEX Jul 4, 2012 23.9.5 WEX 36376.36401 WEI x86_64/MS Windows
--- GAMS/Cplex licensed for continuous and discrete problems.
Cplex 12.4.0.1
Reading data...
Starting Cplex...
Tried aggregator 1 time.
MIP Presolve eliminated 3461 rows and 3413 columns.
Reduced MIP has 648 rows, 603 columns, and 1781 nonzeros.
Reduced MIP has 602 binaries, 0 generals, 0 SOSs, and 0 indicators.
Probing time = 0.01 sec.
Tried aggregator 1 time.
Reduced MIP has 648 rows, 603 columns, and 1781 nonzeros.
Reduced MIP has 602 binaries, 0 generals, 0 SOSs, and 0 indicators.
Presolve time = 0.09 sec.
Found feasible solution after 0.09 sec. Objective = -2.6132
Probing time = 0.00 sec.
Clique table members: 645.
MIP emphasis: balance optimality and feasibility.
MIP search method: dynamic search.
Parallel mode: none, using 1 thread.
Tried aggregator 1 time.
No LP presolve or aggregator reductions.
Presolve time = 0.00 sec.
Initializing dual steep norms . . .
Iteration log . . .
Iteration: 1 Dual objective = 339.579984
Iteration: 130 Dual objective = 96.654157
Iteration: 208 Dual objective = 93.001859
Root relaxation solution time = 0.00 sec.
Nodes Cuts/
Node Left Objective IInf Best Integer Best Bound ItCnt Gap
* 0+ 0 -2.6132 213 ---
* 0 0 integral 0 92.8258 92.8258 213 0.00%
Elapsed real time = 0.11 sec. (tree size = 0.00 MB, solutions = 2)
Root node processing (before b&c):
Real time = 0.02
Sequential b&c:
Real time = 0.00
-------
Total (root+branch&cut) = 0.02 sec.
MIP status(101): integer optimal solution
Fixing integer variables, and solving final LP...
Tried aggregator 1 time.
LP Presolve eliminated 4109 rows and 4016 columns.
All rows and columns eliminated.
Presolve time = 0.00 sec.
Fixed MIP status(1): optimal
Proven optimal solution.
MIP Solution: 92.825775 (213 iterations, 0 nodes)
Final Solve: 92.825775 (0 iterations)
Best possible: 92.825775
Absolute gap: 0.000000
Relative gap: 0.000000
--- Reading solution for model master
--- Executing after solve: elapsed 0:00:04.861
--- benders3.gms(358) 89 Mb
*** Status: Normal completion
--- Job benders3.gms Stop 12/10/22 14:25:56 elapsed 0:00:04.910
Related
Julia - Understanding JuMP Gurobi outputs
I am often using Gurobi with JuMP and I noticed that there are still parts of its outputs that I don't understand. Unless it is documented somewhere and the link would be most welcome, could you help understand the following? :) Found heuristic solution: objective 5820.0000000 Presolve removed 33 rows and 11 columns Presolve time: 0.00s Presolved: 607 rows, 331 columns, 2445 nonzeros Variable types: 111 continuous, 220 integer (220 binary) Root relaxation: objective 1.157500e+03, 64 iterations, 0.00 seconds Nodes | Current Node | Objective Bounds | Work Expl Unexpl | Obj Depth IntInf | Incumbent BestBd Gap | It/Node Time 0 0 1157.50000 0 25 5820.00000 1157.50000 80.1% - 0s H 0 0 2535.0000000 1157.50000 54.3% - 0s 0 0 1236.00000 0 23 2535.00000 1236.00000 51.2% - 0s 0 0 1273.65351 0 41 2535.00000 1273.65351 49.8% - 0s 0 0 1274.59375 0 41 2535.00000 1274.59375 49.7% - 0s 0 0 1274.69841 0 42 2535.00000 1274.69841 49.7% - 0s 0 0 1309.98305 0 42 2535.00000 1309.98305 48.3% - 0s 0 0 1310.26027 0 42 2535.00000 1310.26027 48.3% - 0s 0 0 1340.01176 0 47 2535.00000 1340.01176 47.1% - 0s 0 0 1342.47826 0 49 2535.00000 1342.47826 47.0% - 0s 0 0 1342.60000 0 49 2535.00000 1342.60000 47.0% - 0s 0 0 1362.32468 0 50 2535.00000 1362.32468 46.3% - 0s 0 0 1363.08000 0 49 2535.00000 1363.08000 46.2% - 0s 0 0 1363.13077 0 49 2535.00000 1363.13077 46.2% - 0s 0 0 1370.79545 0 53 2535.00000 1370.79545 45.9% - 0s 0 0 1375.50000 0 52 2535.00000 1375.50000 45.7% - 0s 0 0 1375.50000 0 52 2535.00000 1375.50000 45.7% - 0s 0 0 1376.70025 0 52 2535.00000 1376.70025 45.7% - 0s 0 0 1376.70122 0 53 2535.00000 1376.70122 45.7% - 0s 0 0 1376.70122 0 53 2535.00000 1376.70122 45.7% - 0s 0 2 1376.98418 0 53 2535.00000 1376.98418 45.7% - 0s * 255 157 14 2457.0000000 1473.00000 40.0% 22.5 0s H 407 223 2397.0000000 1548.00000 35.4% 20.3 0s * 1962 758 22 2355.0000000 1772.85714 24.7% 16.8 0s *14326 2205 27 2343.0000000 2088.50000 10.9% 15.7 3s From what I think I already know, in order of apparition: Presolve Found heuristic solution: objective 5820, Gurobi launched a presolve and found a solution of value 5820 Presolve removed 33 redundant or useless variables as well as 11 constraints? Presvoled: sizes of the model presolved Types of variables: some are binary and some are continuous. Root relaxation: LP relaxation has an objective of 1 157.5 Nodes Expl (1): * empty or H, I don't know the difference when there is these symbols but I noticed all rows with a given symbol (H, *, or empty) will have same outputs. Expl and Unexpl number of explored nodes and unexplored nodes in the solving tree. Current Node Obj: objective of current node being explored? Depth: tree's depth where solving is currently IntInf: I have no idea for this one Objective Bounds Incumbent: current value of best valid solution found BestBd: Best lower bound currently found Gap: This is probably a gap between current best solution and best bound but I couldn't deduce how it is computed. Work It/Node: Here we need to find what is an iteration Time: Time spent in solving until then.
The details can be found at https://www.gurobi.com/documentation/9.1/refman/mip_logging.html. Let me just cite those that answer your question: The Nodes section (the first two columns) provides general quantitative information on the progress of the search. The first column shows the number of branch-and-cut nodes that have been explored to that point, while the second shows the number of leaf nodes in the search tree that remain unexplored. At times, there will be an H or * character at the beginning of the output line. These indicate that a new feasible solution has been found, either by a MIP heuristic (H) or by branching (*). The Current Node section provides information on the specific node that was explored at that point in the branch-and-cut tree. It shows the objective of the associated relaxation, the depth of that node in the branch-and-cut tree, and the number of integer variables that have non-integral values in the associated relaxation. The Objective Bounds section provides information on the best known objective value for a feasible solution (i.e., the objective value of the current incumbent), and the current objective bound provided by leaf nodes of the search tree. The optimal objective value is always between these two values. The third column in this section (Gap) shows the relative gap between the two objective bounds. When this gap is smaller than the MIPGap parameter, optimization terminates. The Work section of the log provides information on how much work has been performed to that point. The first column shows the average number of simplex iterations performed per node in the branch-and-cut tree. The final column shows the elapsed time since the solve began. Looking at your log you are approaching very quickly to optimality and you get the Gap=0.01% solution in probably half minute or so.
How to deal with the error when using Gurobi with cvxpy :Unable to retrieve attribute 'BarIterCount'
How to deal with the error when using Gurobi with cvxpy :AttributeError: Unable to retrieve attribute 'BarIterCount'. I have an Integer programming problem, using cvxpy and set gurobi as a solver. When the number of variables is small, the result is ok. After the number of variables reaches a level of like 43*13*6, then the error occurred. I suppose it may be caused by the scale of the problem, in which the gurobi solver can not estimate the BarIterCount, which is the max Iterations needed. Thus, I wonder, is there any way to manually set the BarItercount attribute of gurobi through the interface of the CVX? Or whether there exists another way to solve this problem? Thanks for any suggestions you may provide for me. The trace log is as follows: If my model is small, like I set a number which indicates the scale of model as 3, then the program is ok. The trace is : Using license file D:\software\lib\site-packages\gurobipy\gurobi.lic Restricted license - for non-production use only - expires 2022-01-13 Parameter OutputFlag unchanged Value: 1 Min: 0 Max: 1 Default: 1 D:\software\lib\site-packages\cvxpy\reductions\solvers\solving_chain.py:326: DeprecationWarning: Deprecated, use Model.addMConstr() instead solver_opts, problem._solver_cache) Changed value of parameter QCPDual to 1 Prev: 0 Min: 0 Max: 1 Default: 0 Gurobi Optimizer version 9.1.0 build v9.1.0rc0 (win64) Thread count: 16 physical cores, 32 logical processors, using up to 32 threads Optimize a model with 126 rows, 370 columns and 2689 nonzeros Model fingerprint: 0x70d49530 Variable types: 0 continuous, 370 integer (369 binary) Coefficient statistics: Matrix range [1e+00, 7e+00] Objective range [1e+00, 1e+00] Bounds range [1e+00, 1e+00] RHS range [1e+00, 6e+00] Found heuristic solution: objective 7.0000000 Presolve removed 4 rows and 90 columns Presolve time: 0.01s Presolved: 122 rows, 280 columns, 1882 nonzeros Variable types: 0 continuous, 280 integer (279 binary) Root relaxation: objective 4.307692e+00, 216 iterations, 0.00 seconds Nodes | Current Node | Objective Bounds | Work Expl Unexpl | Obj Depth IntInf | Incumbent BestBd Gap | It/Node Time 0 0 4.30769 0 49 7.00000 4.30769 38.5% - 0s H 0 0 6.0000000 4.30769 28.2% - 0s 0 0 5.00000 0 35 6.00000 5.00000 16.7% - 0s 0 0 5.00000 0 37 6.00000 5.00000 16.7% - 0s 0 0 5.00000 0 7 6.00000 5.00000 16.7% - 0s Cutting planes: Gomory: 4 Cover: 9 MIR: 4 StrongCG: 1 GUB cover: 9 Zero half: 1 RLT: 1 Explored 1 nodes (849 simplex iterations) in 0.12 seconds Thread count was 32 (of 32 available processors) Solution count 2: 6 7 Optimal solution found (tolerance 1.00e-04) Best objective 6.000000000000e+00, best bound 6.000000000000e+00, gap 0.0000% If the number is 6, then error occurs: ------------------------------------------------------- Using license file D:\software\lib\site-packages\gurobipy\gurobi.lic Restricted license - for non-production use only - expires 2022-01-13 Parameter OutputFlag unchanged Value: 1 Min: 0 Max: 1 Default: 1 D:\software\lib\site-packages\cvxpy\reductions\solvers\solving_chain.py:326: DeprecationWarning: Deprecated, use Model.addMConstr() instead solver_opts, problem._solver_cache) Changed value of parameter QCPDual to 1 Prev: 0 Min: 0 Max: 1 Default: 0 Gurobi Optimizer version 9.1.0 build v9.1.0rc0 (win64) Thread count: 16 physical cores, 32 logical processors, using up to 32 threads Traceback (most recent call last): File "model.py", line 274, in <module> problem.solve(solver=cp.GUROBI,verbose=True) File "D:\software\lib\site-packages\cvxpy\problems\problem.py", line 396, in solve return solve_func(self, *args, **kwargs) File "D:\software\lib\site-packages\cvxpy\problems\problem.py", line 754, in _solve self.unpack_results(solution, solving_chain, inverse_data) File "D:\software\lib\site-packages\cvxpy\problems\problem.py", line 1058, in unpack_results solution = chain.invert(solution, inverse_data) File "D:\software\lib\site-packages\cvxpy\reductions\chain.py", line 79, in invert solution = r.invert(solution, inv) File "D:\software\lib\site-packages\cvxpy\reductions\solvers\qp_solvers\gurobi_qpif.py", line 59, in invert s.NUM_ITERS: model.BarIterCount, File "src\gurobipy\model.pxi", line 343, in gurobipy.gurobipy.Model.__getattr__ File "src\gurobipy\model.pxi", line 1842, in gurobipy.gurobipy.Model.getAttr File "src\gurobipy\attrutil.pxi", line 100, in gurobipy.gurobipy.__getattr AttributeError: Unable to retrieve attribute 'BarIterCount' Hopefully this can provide more hint for solution.
BarIterCount is the number of barrier iterations performed to solve an LP. This is not a limit on the number of iterations and it should only be queried when the current optimization process has been finished. You cannot set this attribute either, of course. To actually limit the number of iterations the barrier algorithm is allowed to take, you can use the parameter BarIterLimit. Please inspect your log file for further information about the solver's behavior.
TEZ mapper resource request
We recently migrated from MapReduce to TEZ for executing Hive queries on EMR. We are seeing cases where for the exact hive query launches very different number of mappers. See Map 3 phase below. On the first run it requested for 305 resources and on another run it requested for 4534 mappers. ( Please ignore the KILLED status because I manually killed the query.) Why does this happen ? How can we change it to be based on underlying data size instead ? Run 1 ---------------------------------------------------------------------------------------------- VERTICES MODE STATUS TOTAL COMPLETED RUNNING PENDING FAILED KILLED ---------------------------------------------------------------------------------------------- Map 1 container KILLED 5 0 0 5 0 0 Map 3 container KILLED 305 0 0 305 0 0 Map 5 container KILLED 16 0 0 16 0 0 Map 6 container KILLED 1 0 0 1 0 0 Reducer 2 container KILLED 333 0 0 333 0 0 Reducer 4 container KILLED 796 0 0 796 0 0 ---------------------------------------------------------------------------------------------- VERTICES: 00/06 [>>--------------------------] 0% ELAPSED TIME: 14.16 s ---------------------------------------------------------------------------------------------- Run 2 ---------------------------------------------------------------------------------------------- VERTICES MODE STATUS TOTAL COMPLETED RUNNING PENDING FAILED KILLED ---------------------------------------------------------------------------------------------- Map 1 .......... container SUCCEEDED 5 5 0 0 0 0 Map 3 container KILLED 4534 0 0 4534 0 0 Map 5 .......... container SUCCEEDED 325 325 0 0 0 0 Map 6 .......... container SUCCEEDED 1 1 0 0 0 0 Reducer 2 container KILLED 333 0 0 333 0 0 Reducer 4 container KILLED 796 0 0 796 0 0 ---------------------------------------------------------------------------------------------- VERTICES: 03/06 [=>>-------------------------] 5% ELAPSED TIME: 527.16 s ----------------------------------------------------------------------------------------------
This article explains the process in which Tez allocates resources. https://cwiki.apache.org/confluence/display/TEZ/How+initial+task+parallelism+works If Tez grouping is enabled for the splits, then a generic grouping logic is run on these splits to group them into larger splits. The idea is to strike a balance between how parallel the processing is and how much work is being done in each parallel process. First, Tez tries to find out the resource availability in the cluster for these tasks. For that, YARN provides a headroom value (and in future other attributes may be used). Lets say this value is T. Next, Tez divides T with the resource per task (say M) to find out how many tasks can run in parallel at one (ie in a single wave). W = T/M. Next W is multiplied by a wave factor (from configuration - tez.grouping.split-waves) to determine the number of tasks to be used. Lets say this value is N. If there are a total of X splits (input shards) and N tasks then this would group X/N splits per task. Tez then estimates the size of data per task based on the number of splits per task. If this value is between tez.grouping.max-size & tez.grouping.min-size then N is accepted as the number of tasks. If not, then N is adjusted to bring the data per task in line with the max/min depending on which threshold was crossed. For experimental purposes tez.grouping.split-count can be set in configuration to specify the desired number of groups. If this config is specified then the above logic is ignored and Tez tries to group splits into the specified number of groups. This is best effort. After this the grouping algorithm is executed. It groups splits by node locality, then rack locality, while respecting the group size limits.
AMPL Non-Linear least Square
Could anyone help me to find the error in this AMPL's code for a simple least-square error base on the function: F(X)=1/1+e^-x param N>=1;# N Number of simulations param M>=1;# Number of inputs param simulations {1..N}; param training{1..N,1..M}; var W{1..10}; minimize obj: sum{i in simulations , j in 1..4} (1/(1+exp-(W[9]/(1+exp(- W[j]/(1+exp(-training[i][j]))))+ W[10]/(1+exp(-W[2*j]/(1+exp(-training[i][j]))))))-training[i][5])^2; '###### DATA param N:=6; param M:=4; param training: 1 2 3 4 5 := 1 0.209 0.555 0.644 0.355 0.0 2 0.707 0.450 0.587 0.305 1.0 3 0.579 0.521 0.745 0.394 1.0 4 0.574 0.883 0.211 0.550 1.0 5 0.797 0.055 0.430 0.937 1.0 6 0.782 0.865 0.114 0.317 1.0 ; Thank you!
A couple of things: is that quote mark before ###### DATA meant to be there? You have specified that training has dimension N x M, and your data specifies that N=6, M=4, but you then define training as 6 x 5 and your objective function also refers to column 5. If that doesn't answer your question, you might want to give more information about what error messages you're getting.
Is DNNClassifier unstable compared with TensorFlowDNNClassifier?
I'm building a DNN predicted (0 or 1) model based on skflow with TF v0.9. My code with TensorFlowDNNClassifier is like this. I train about 26,000 records and test 6,500 one. classifier = learn.TensorFlowDNNClassifier(hidden_units=[64, 128, 64], n_classes=2) classifier.fit(features, labels, steps=50000) test_pred = classifier.predict(test_features) print(classification_report(test_labels, test_pred)) It takes about 1 minute and gets a result. precision recall f1-score support 0 0.77 0.92 0.84 4265 1 0.75 0.47 0.58 2231 avg / total 0.76 0.76 0.75 6496 But I got WARNING:tensorflow:TensorFlowDNNClassifier class is deprecated. Please consider using DNNClassifier as an alternative. So I updated my code with DNNClassifier simply. classifier = learn.DNNClassifier(hidden_units=[64, 128, 64], n_classes=2) classifier.fit(features, labels, steps=50000) It also works well. But result was not the same. precision recall f1-score support 0 0.77 0.96 0.86 4265 1 0.86 0.45 0.59 2231 avg / total 0.80 0.79 0.76 6496 1 's precision is improved. Of course this is a good for me, but why it is improved? And It takes about 2 hours. This is about 120 times slower than previous example. Do I have something wrong? or miss some parameters? Or is DNNClassifier unstable with TF v0.9?
I give the same answer as here. You might experience that because you used the steps parameter instead of max_steps. It was just steps on TensorFlowDNNClassifier that in reality did max_steps. Now you can decide if you really want that in your case 50000 steps or auto abort earlier.