SECQUOIA / gdplib

An open library of Generalized Disjunctive Programming (GDP) models
BSD 3-Clause "New" or "Revised" License
9 stars 7 forks source link

Refactor `batch_processing` to fix benchmark issues #61

Open tristantc opened 2 weeks ago

tristantc commented 2 weeks ago

Description

This Issue aims to address and refactor the batch_processing model to fix benchmark issues as outlined in Issue #60.

Solution strategy causing issues:

Branch

This PR targets the benchmark_zd branch.

Steps to Reproduce

  1. Run the benchmark tests for the batch_processing module before applying the changes.
  2. Apply the changes from this PR.
  3. Re-run the benchmark tests to verify performance improvements.

Notes


Feel free to adjust any details as necessary before submitting the PR.

tristantc commented 2 weeks ago

GLOA log output:

Starting GDPopt version 22.5.13 using GLOA algorithm
iterlim: None
time_limit: 3600
tee: true
logger: <Logger pyomo.contrib.gdpopt (INFO)>
integer_tolerance: 1e-05
constraint_tolerance: 1e-06
variable_tolerance: 1e-08
subproblem_initialization_method: <function restore_vars_to_original_values at 0x7fd517337ce0>
call_before_subproblem_solve: <class 'pyomo.contrib.gdpopt.util._DoNothing'>
call_after_subproblem_solve: <class 'pyomo.contrib.gdpopt.util._DoNothing'>
call_after_subproblem_feasible: <class 'pyomo.contrib.gdpopt.util._DoNothing'>
force_subproblem_nlp: false
subproblem_presolve: true
tighten_nlp_var_bounds: false
round_discrete_vars: true
max_fbbt_iterations: 3
init_strategy: None
init_algorithm: set_covering
custom_init_disjuncts: []
max_slack: 1000.0
OA_penalty_factor: 1000.0
set_cover_iterlim: 8
discrete_problem_transformation: gdp.bigm
call_before_discrete_problem_solve: <class 'pyomo.contrib.gdpopt.util._DoNothing'>
call_after_discrete_problem_solve: <class 'pyomo.contrib.gdpopt.util._DoNothing'>
call_before_master_solve: <class 'pyomo.contrib.gdpopt.util._DoNothing'>
call_after_master_solve: <class 'pyomo.contrib.gdpopt.util._DoNothing'>
mip_presolve: true
calc_disjunctive_bounds: false
obbt_disjunctive_bounds: false
mip_solver: gams
mip_solver_args:
  add_options: ['option threads=1']
  tee: true
nlp_solver: gams
nlp_solver_args:
  add_options: ['option threads=1;', '$onecho > baron.opt', 'FirstLoc 1', '$offecho', 'GAMS_MODEL.optfile=1', 'option optcr=1e-2;']
  solver: baron
  tee: true
minlp_solver: gams
minlp_solver_args:
  add_options: ['option threads=1;', 'option optcr=1e-6;']
  solver: baron
  tee: true
local_minlp_solver: gams
local_minlp_solver_args:
  add_options: ['option threads=1;', '$onecho > baron.opt', 'FirstLoc 1', '$offecho', 'GAMS_MODEL.optfile=1', 'option optcr=1e-2;']
  solver: baron
  tee: true
small_dual_tolerance: 1e-08
bound_tolerance: 0.01

If you use this software, you may cite the following:
            - Implementation:
            Chen, Q; Johnson, ES; Bernal, DE; Valentin, R; Kale, S;
            Bates, J; Siirola, JD; Grossmann, IE.
            Pyomo.GDP: an ecosystem for logic based modeling and optimization
            development.
            Optimization and Engineering, 2021.

- GLOA algorithm:
        Lee, S; Grossmann, IE.
        A Global Optimization Algorithm for Nonconvex Generalized
        Disjunctive Programming and Applications to Process Systems.
        Comp. and Chem. Eng. 2001, 25, 1675-1697.
        DOI: 10.1016/S0098-1354(01)00732-3.
Original model has 601 constraints (1 nonlinear) and 9 disjunctions, with 287 variables, of which 138 are binary, 0 are integer, and 149 are continuous.
Objective is nonlinear. Moving it to constraint set.
---Starting GDPopt initialization---
Starting set covering initialization.
=============================================================================================
Iteration | Subproblem Type | Lower Bound | Upper Bound |   Gap    | Time(s)

Initialization complete.
Finished discrete problem initialization in 0.06s and 0 iterations 

=============================================================================================
Iteration | Subproblem Type | Lower Bound | Upper Bound |   Gap    | Time(s)

--- Job model.gms Start 10/17/24 19:10:29 47.6.0 c2de9d6d LEX-LEG x86 64bit/Linux
--- Applying:
    /package/gams/47.6.0/gmsprmun.txt
--- GAMS Parameters defined
    Input /tmp/tmpwpsdjb_9/model.gms
    Output /tmp/tmpwpsdjb_9/output.lst
    ScrDir /tmp/tmpwpsdjb_9/225a/
    SysDir /package/gams/47.6.0/
    CurDir /tmp/tmpwpsdjb_9/
    LogOption 3

Processor information: 1 socket(s), 48 core(s), and 96 thread(s) available
GAMS 47.6.0   Copyright (C) 1987-2024 GAMS Development. All rights reserved
--- Starting compilation
--- model.gms(3199) 2 Mb
--- Starting execution: elapsed 0:00:00.019
--- model.gms(2063) 3 Mb
--- Generating MIP model GAMS_MODEL
--- model.gms(2067) 3 Mb
---   790 rows  289 columns  2,480 non-zeroes
---   138 discrete-columns
--- Range statistics (absolute non-zero finite values)
--- RHS       [min, max] : [ 9.531E-02, 1.001E+03] - Zero values observed as well
--- Bound     [min, max] : [ 1.000E+00, 9.010E+04] - Zero values observed as well
--- Matrix    [min, max] : [ 6.931E-01, 1.000E+03]
--- Executing CPLEX (Solvelink=5): elapsed 0:00:00.024

IBM ILOG CPLEX   47.6.0 c2de9d6d Sep 12, 2024          LEG x86 64bit/Linux    

--- GAMS/CPLEX licensed for continuous and discrete problems.
--- GMO setup time: 0.00s
--- Space for names approximately 0.02 Mb
--- Use option 'names no' to turn use of names off
--- GMO memory 0.62 Mb (peak 0.62 Mb)
--- Dictionary memory 0.00 Mb
--- Cplex 22.1.1.0 link memory 0.01 Mb (peak 0.06 Mb)
--- Starting Cplex

Version identifier: 22.1.1.0 | 2022-11-28 | 9160aff4d
CPXPARAM_Advance                                 0
CPXPARAM_Threads                                 1
CPXPARAM_MIP_Display                             4
CPXPARAM_MIP_Pool_Capacity                       0
CPXPARAM_TimeLimit                               3599.5174802988768
CPXPARAM_MIP_Tolerances_AbsMIPGap                0
Generic callback                                 0x50
Tried aggregator 2 times.
MIP Presolve eliminated 125 rows and 101 columns.
MIP Presolve modified 1824 coefficients.
Aggregator did 9 substitutions.
Reduced MIP has 655 rows, 179 columns, and 1750 nonzeros.
Reduced MIP has 69 binaries, 0 generals, 0 SOSs, and 0 indicators.
Presolve time = 0.00 sec. (3.23 ticks)
Found incumbent of value 90097.176570 after 0.00 sec. (3.63 ticks)

Root node processing (before b&c):
  Real time             =    0.00 sec. (3.64 ticks)
Sequential b&c:
  Real time             =    0.00 sec. (0.00 ticks)
                          ------------
Total (root+branch&cut) =    0.00 sec. (3.64 ticks)

--- MIP status (101): integer optimal solution.
--- Cplex Time: 0.00sec (det. 3.64 ticks)

--- Returning a primal only solution to GAMS (marginals all set to NA).
--- Fixing integer variables and solving final LP...

Version identifier: 22.1.1.0 | 2022-11-28 | 9160aff4d
CPXPARAM_Advance                                 2
CPXPARAM_Threads                                 1
CPXPARAM_MIP_Display                             4
CPXPARAM_MIP_Pool_Capacity                       0
CPXPARAM_TimeLimit                               3599.5174802988768
CPXPARAM_MIP_Tolerances_AbsMIPGap                0
Tried aggregator 1 time.
LP Presolve eliminated 789 rows and 289 columns.
All rows and columns eliminated.
Presolve time = 0.00 sec. (0.37 ticks)

--- Fixed MIP status (1): optimal.
--- Cplex Time: 0.00sec (det. 0.65 ticks)

Proven optimal solution
MIP Solution:        90097.176570    (0 iterations, 0 nodes)
Final Solve:         90097.176570    (0 iterations)

Best possible:       90097.176570
Absolute gap:            0.000000
Relative gap:            0.000000

--- Reading solution for model GAMS_MODEL
--- Executing after solve: elapsed 0:00:00.034
--- model.gms(3199) 5 Mb
--- Putfile results /tmp/tmpwpsdjb_9/results.dat
--- Putfile statresults /tmp/tmpwpsdjb_9/resultsstat.dat
*** Status: Normal completion
--- Job model.gms Stop 10/17/24 19:10:29 elapsed 0:00:00.036
        1          discrete   90097.17657           inf       nan%      0.62  
--- Job model.gms Start 10/17/24 19:10:30 47.6.0 c2de9d6d LEX-LEG x86 64bit/Linux
--- Applying:
    /package/gams/47.6.0/gmsprmun.txt
--- GAMS Parameters defined
    Input /tmp/tmphtym_mi1/model.gms
    Output /tmp/tmphtym_mi1/output.lst
    ScrDir /tmp/tmphtym_mi1/225a/
    SysDir /package/gams/47.6.0/
    CurDir /tmp/tmphtym_mi1/
    LogOption 3

Processor information: 1 socket(s), 48 core(s), and 96 thread(s) available
GAMS 47.6.0   Copyright (C) 1987-2024 GAMS Development. All rights reserved
--- Starting compilation
--- model.gms(1784) 2 Mb
--- Starting execution: elapsed 0:00:00.005
--- model.gms(1123) 3 Mb
--- Generating MINLP model GAMS_MODEL
--- model.gms(1127) 5 Mb
--- Reset Solvelink = 2
---   333 rows  271 columns  1,072 non-zeroes
---   130 nl-code  49 nl-non-zeroes
---   120 discrete-columns
--- Range statistics (absolute non-zero finite values)
--- RHS       [min, max] : [ 9.531E-02, 6.000E+03] - Zero values observed as well
--- Bound     [min, max] : [ 1.000E+00, 9.010E+04] - Zero values observed as well
--- Matrix    [min, max] : [ 6.931E-01, 2.500E+05]
--- model.gms(1127) 3 Mb
--- Executing BARON (Solvelink=2): elapsed 0:00:00.008

GAMS/BARON       47.6.0 c2de9d6d Sep 12, 2024          LEG x86 64bit/Linux    

===========================================================================
 BARON version 24.5.8. Built: LNX-64 Wed May 8 10:06:40 EDT 2024 
 Running on machine dantzig.ecn.purdue.edu

 BARON is a product of The Optimization Firm.
 For information on BARON, see https://minlp.com/about-baron

 If you publish work using this software, please cite publications from
 https://minlp.com/baron-publications, such as: 

 Kilinc, M. and N. V. Sahinidis, Exploiting integrality in the global
 optimization of mixed-integer nonlinear programming problems in BARON,
 Optimization Methods and Software, 33, 540-562, 2018.
===========================================================================
 This BARON run may utilize the following subsolver(s)
 For LP/MIP/QP: CLP/CBC, ILOG CPLEX                             
 For NLP: MINOS, SNOPT, External NLP, IPOPT, FILTERSQP
===========================================================================
 Doing local search
 Solving bounding LP
 Starting multi-start local search
 Done with local search
===========================================================================
  Iteration    Open nodes         Time (s)    Lower bound      Upper bound
*         1             1             0.68      90097.2          805616.                 
          1             1             0.91      793456.          805616.                 
*        36             2             2.62      793456.          804435.                 
*       121             4             6.00      794553.          802495.                 
        275             0            11.41      802495.          802495.                 

                         *** Normal completion ***            

 Wall clock time:                    11.45
 Total CPU time used:                11.41

 Total no. of BaR iterations:     275
 Best solution found at node:     121
 Max. no. of nodes in memory:       6

 All done
===========================================================================

Solution      = 802494.618296068  found at node 121
Best possible = 802494.618296068
Absolute gap  = 0  optca = 1E-9
Relative gap  = 0  optcr = 1E-6

--- Reading solution for model GAMS_MODEL
***
*** Solver did not provide marginals for model GAMS_MODEL
***
--- Executing after solve: elapsed 0:00:11.489
--- model.gms(1130) 3 Mb
--- model.gms(1784) 5 Mb
--- Putfile results /tmp/tmphtym_mi1/results.dat
--- Putfile statresults /tmp/tmphtym_mi1/resultsstat.dat
*** Status: Normal completion
--- Job model.gms Stop 10/17/24 19:10:41 elapsed 0:00:11.491
        1        subproblem   90097.17657   802494.61830     88.77%     12.44  *

Solved in 1 iterations and 12.44657 seconds
Optimal objective value 802494.6182960678
Relative optimality gap 88.77286%