Minwei Kong commited on
Fix Gurobi runtime start-time initialization
Browse filesMove _GUROBI_CODE_START_TIME assignments out of module docstrings in 13 affected Gurobi reference scripts so runtime serialization cannot raise NameError.
Files changed (13)
- tasks/bode2012/gurobi_code.py+1-1
- tasks/bodur2017/gurobi_code.py+1-1
- tasks/bragin2022/gurobi_code.py+1-1
- tasks/buchheim2018/gurobi_code.py+1-1
- tasks/chen1999/gurobi_code.py+1-1
- tasks/cote2018/gurobi_code.py+1-1
- tasks/furini2021/gurobi_code.py+1-1
- tasks/garcia2011/gurobi_code.py+1-1
- tasks/hoffman1993/gurobi_code.py+1-1
- tasks/kowalczyk2018/gurobi_code.py+1-1
- tasks/kreter2018/gurobi_code.py+1-1
- tasks/letelier2022/gurobi_code.py+1-1
- tasks/roshanaei2017/gurobi_code.py+1-1
123456720 unmodified lines282930313233r"""Gurobi implementation of the Two-Index CARP Formulation (Equations 1-6)from Bode & Irnich (2012), "Cut-First Branch-and-Price-Second for the CARP",_GUROBI_CODE_START_TIME = time.time()Operations Research 60(5):1167-1182.The CARP is modeled as:20 unmodified linesimport jsonimport argparseimport timeimport mathfrom itertools import combinations12345620 unmodified lines27282930313233r"""Gurobi implementation of the Two-Index CARP Formulation (Equations 1-6)from Bode & Irnich (2012), "Cut-First Branch-and-Price-Second for the CARP",Operations Research 60(5):1167-1182.The CARP is modeled as:20 unmodified linesimport jsonimport argparseimport time_GUROBI_CODE_START_TIME = time.time()import mathfrom itertools import combinations
12345678 unmodified lines161718192021"""Gurobi implementation of the Stochastic Capacitated Facility Location Problem (CAP)from Bodur, Dash, Günlük, Luedtke (2017), "Strengthened Benders Cuts for Stochastic_GUROBI_CODE_START_TIME = time.time()Integer Programs with Continuous Recourse", INFORMS Journal on Computing, 29(1):77-91.Implements formulation (15) directly as an extensive MIP.8 unmodified linesfrom gurobipy import GRBimport os as _os, sys as _sysimport time# Walk up from this file's directory to find repo root (containing scripts/)._repo = _os.path.dirname(_os.path.abspath(__file__))while _repo != _os.path.dirname(_repo) and not _os.path.isdir(_os.path.join(_repo, 'scripts', 'utils')):1234568 unmodified lines15161718192021"""Gurobi implementation of the Stochastic Capacitated Facility Location Problem (CAP)from Bodur, Dash, Günlük, Luedtke (2017), "Strengthened Benders Cuts for StochasticInteger Programs with Continuous Recourse", INFORMS Journal on Computing, 29(1):77-91.Implements formulation (15) directly as an extensive MIP.8 unmodified linesfrom gurobipy import GRBimport os as _os, sys as _sysimport time_GUROBI_CODE_START_TIME = time.time()# Walk up from this file's directory to find repo root (containing scripts/)._repo = _os.path.dirname(_os.path.abspath(__file__))while _repo != _os.path.dirname(_repo) and not _os.path.isdir(_os.path.join(_repo, 'scripts', 'utils')):
1 unmodified line23456789 unmodified lines1819202122231 unmodified line"""Gurobi implementation of the Generalized Assignment Problem (GAP)from Bragin & Tucker (2022), "Surrogate 'Level-Based' Lagrangian Relaxation_GUROBI_CODE_START_TIME = time.time()for Mixed-Integer Linear Programming," Scientific Reports 12:22417.The GAP formulation:9 unmodified linesfrom gurobipy import GRBimport os as _os, sys as _sysimport time# Walk up from this file's directory to find repo root (containing scripts/)._repo = _os.path.dirname(_os.path.abspath(__file__))while _repo != _os.path.dirname(_repo) and not _os.path.isdir(_os.path.join(_repo, 'scripts', 'utils')):1 unmodified line2345679 unmodified lines171819202122231 unmodified line"""Gurobi implementation of the Generalized Assignment Problem (GAP)from Bragin & Tucker (2022), "Surrogate 'Level-Based' Lagrangian Relaxationfor Mixed-Integer Linear Programming," Scientific Reports 12:22417.The GAP formulation:9 unmodified linesfrom gurobipy import GRBimport os as _os, sys as _sysimport time_GUROBI_CODE_START_TIME = time.time()# Walk up from this file's directory to find repo root (containing scripts/)._repo = _os.path.dirname(_os.path.abspath(__file__))while _repo != _os.path.dirname(_repo) and not _os.path.isdir(_os.path.join(_repo, 'scripts', 'utils')):
1 unmodified line234567814 unmodified lines2324252627281 unmodified line"""Gurobi implementation of the Quadratic Shortest Path Problem (QSPP)from Buchheim & Traversi (2018), "Quadratic Combinatorial Optimization_GUROBI_CODE_START_TIME = time.time()Using Separable Underestimators", INFORMS J. Computing 30(3):424-437.Model (19):14 unmodified linesfrom gurobipy import GRBimport os as _os, sys as _sysimport time# Walk up from this file's directory to find repo root (containing scripts/)._repo = _os.path.dirname(_os.path.abspath(__file__))while _repo != _os.path.dirname(_repo) and not _os.path.isdir(_os.path.join(_repo, 'scripts', 'utils')):1 unmodified line23456714 unmodified lines222324252627281 unmodified line"""Gurobi implementation of the Quadratic Shortest Path Problem (QSPP)from Buchheim & Traversi (2018), "Quadratic Combinatorial OptimizationUsing Separable Underestimators", INFORMS J. Computing 30(3):424-437.Model (19):14 unmodified linesfrom gurobipy import GRBimport os as _os, sys as _sysimport time_GUROBI_CODE_START_TIME = time.time()# Walk up from this file's directory to find repo root (containing scripts/)._repo = _os.path.dirname(_os.path.abspath(__file__))while _repo != _os.path.dirname(_repo) and not _os.path.isdir(_os.path.join(_repo, 'scripts', 'utils')):
123456713 unmodified lines212223242526"""Gurobi MIP implementation for the Parallel Machine Scheduling Problemfrom Chen & Powell (1999), "Solving Parallel Machine Scheduling Problems_GUROBI_CODE_START_TIME = time.time()by Column Generation", INFORMS Journal on Computing, 11(1):78-94.This implements the IP2 formulation (for identical machines P||sum w_j C_j)13 unmodified linesfrom gurobipy import GRBimport os as _os, sys as _sysimport time# Walk up from this file's directory to find repo root (containing scripts/)._repo = _os.path.dirname(_os.path.abspath(__file__))while _repo != _os.path.dirname(_repo) and not _os.path.isdir(_os.path.join(_repo, 'scripts', 'utils')):12345613 unmodified lines20212223242526"""Gurobi MIP implementation for the Parallel Machine Scheduling Problemfrom Chen & Powell (1999), "Solving Parallel Machine Scheduling Problemsby Column Generation", INFORMS Journal on Computing, 11(1):78-94.This implements the IP2 formulation (for identical machines P||sum w_j C_j)13 unmodified linesfrom gurobipy import GRBimport os as _os, sys as _sysimport time_GUROBI_CODE_START_TIME = time.time()# Walk up from this file's directory to find repo root (containing scripts/)._repo = _os.path.dirname(_os.path.abspath(__file__))while _repo != _os.path.dirname(_repo) and not _os.path.isdir(_os.path.join(_repo, 'scripts', 'utils')):
1 unmodified line23456784 unmodified lines1314151617181 unmodified lineGurobi implementation of the Arc-Flow formulation for the Cutting Stock Problem (CSP)from Côté & Iori (2018) "The Meet-in-the-Middle Principle for Cutting and Packing Problems"_GUROBI_CODE_START_TIME = time.time()This implements the arc-flow model (equations 11-14) using normal patterns (eq. 15)for the arc set construction, as described in Section 4."""4 unmodified linesfrom gurobipy import GRBimport os as _os, sys as _sysimport time# Walk up from this file's directory to find repo root (containing scripts/)._repo = _os.path.dirname(_os.path.abspath(__file__))while _repo != _os.path.dirname(_repo) and not _os.path.isdir(_os.path.join(_repo, 'scripts', 'utils')):1 unmodified line2345674 unmodified lines121314151617181 unmodified lineGurobi implementation of the Arc-Flow formulation for the Cutting Stock Problem (CSP)from Côté & Iori (2018) "The Meet-in-the-Middle Principle for Cutting and Packing Problems"This implements the arc-flow model (equations 11-14) using normal patterns (eq. 15)for the arc set construction, as described in Section 4."""4 unmodified linesfrom gurobipy import GRBimport os as _os, sys as _sysimport time_GUROBI_CODE_START_TIME = time.time()# Walk up from this file's directory to find repo root (containing scripts/)._repo = _os.path.dirname(_os.path.abspath(__file__))while _repo != _os.path.dirname(_repo) and not _os.path.isdir(_os.path.join(_repo, 'scripts', 'utils')):
2 unmodified lines345678922 unmodified lines3233343536372 unmodified linesGurobi implementation of the Edge Interdiction Clique Problem (EICP)using the set-covering ILP formulation (4) with clique-covering inequalities (5)from Furini et al. (2021) "A branch-and-cut algorithm for the Edge Interdiction_GUROBI_CODE_START_TIME = time.time()Clique Problem", EJOR 294, 54-69.The formulation:22 unmodified linesfrom gurobipy import GRBimport os as _os, sys as _sysimport time# Walk up from this file's directory to find repo root (containing scripts/)._repo = _os.path.dirname(_os.path.abspath(__file__))while _repo != _os.path.dirname(_repo) and not _os.path.isdir(_os.path.join(_repo, 'scripts', 'utils')):2 unmodified lines34567822 unmodified lines313233343536372 unmodified linesGurobi implementation of the Edge Interdiction Clique Problem (EICP)using the set-covering ILP formulation (4) with clique-covering inequalities (5)from Furini et al. (2021) "A branch-and-cut algorithm for the Edge InterdictionClique Problem", EJOR 294, 54-69.The formulation:22 unmodified linesfrom gurobipy import GRBimport os as _os, sys as _sysimport time_GUROBI_CODE_START_TIME = time.time()# Walk up from this file's directory to find repo root (containing scripts/)._repo = _os.path.dirname(_os.path.abspath(__file__))while _repo != _os.path.dirname(_repo) and not _os.path.isdir(_os.path.join(_repo, 'scripts', 'utils')):
2 unmodified lines34567895 unmodified lines1516171819202 unmodified linesSolve the p-median problem using the CR (Canonical Representation) formulationfrom Garcia-Quiles et al. (2011) with Gurobi._GUROBI_CODE_START_TIME = time.time()CR Formulation:min sum_i sum_{k=2}^{G_i} (D_{ik} - D_{i,k-1}) * z_{ik}s.t. sum_i y_i = p5 unmodified linesimport jsonimport mathimport timeimport gurobipy as gpfrom gurobipy import GRB2 unmodified lines3456785 unmodified lines141516171819202 unmodified linesSolve the p-median problem using the CR (Canonical Representation) formulationfrom Garcia-Quiles et al. (2011) with Gurobi.CR Formulation:min sum_i sum_{k=2}^{G_i} (D_{ik} - D_{i,k-1}) * z_{ik}s.t. sum_i y_i = p5 unmodified linesimport jsonimport mathimport time_GUROBI_CODE_START_TIME = time.time()import gurobipy as gpfrom gurobipy import GRB
1 unmodified line23456789 unmodified lines1819202122231 unmodified lineGurobi implementation of the Set Partitioning Problem with Base Constraints (SPB)from Hoffman & Padberg (1993) "Solving Airline Crew Scheduling Problems by Branch-and-Cut"_GUROBI_CODE_START_TIME = time.time()Formulation (SPB):min sum_{j=1}^{n} c_j x_js.t. A x = e_m (each flight leg covered exactly once)9 unmodified linesfrom gurobipy import GRBimport os as _os, sys as _sysimport time# Walk up from this file's directory to find repo root (containing scripts/)._repo = _os.path.dirname(_os.path.abspath(__file__))while _repo != _os.path.dirname(_repo) and not _os.path.isdir(_os.path.join(_repo, 'scripts', 'utils')):1 unmodified line2345679 unmodified lines171819202122231 unmodified lineGurobi implementation of the Set Partitioning Problem with Base Constraints (SPB)from Hoffman & Padberg (1993) "Solving Airline Crew Scheduling Problems by Branch-and-Cut"Formulation (SPB):min sum_{j=1}^{n} c_j x_js.t. A x = e_m (each flight leg covered exactly once)9 unmodified linesfrom gurobipy import GRBimport os as _os, sys as _sysimport time_GUROBI_CODE_START_TIME = time.time()# Walk up from this file's directory to find repo root (containing scripts/)._repo = _os.path.dirname(_os.path.abspath(__file__))while _repo != _os.path.dirname(_repo) and not _os.path.isdir(_os.path.join(_repo, 'scripts', 'utils')):
123456728 unmodified lines363738394041r"""Gurobi implementation of the Set Covering ILP for Pm||sum w_j C_jfrom Kowalczyk & Leus (2018), "A Branch-and-Price Algorithm for Parallel_GUROBI_CODE_START_TIME = time.time()Machine Scheduling Using ZDDs and Generic Branching",INFORMS Journal on Computing 30(4):768-782.28 unmodified linesfrom gurobipy import GRBimport os as _os, sys as _sysimport time# Walk up from this file's directory to find repo root (containing scripts/)._repo = _os.path.dirname(_os.path.abspath(__file__))while _repo != _os.path.dirname(_repo) and not _os.path.isdir(_os.path.join(_repo, 'scripts', 'utils')):12345628 unmodified lines35363738394041r"""Gurobi implementation of the Set Covering ILP for Pm||sum w_j C_jfrom Kowalczyk & Leus (2018), "A Branch-and-Price Algorithm for ParallelMachine Scheduling Using ZDDs and Generic Branching",INFORMS Journal on Computing 30(4):768-782.28 unmodified linesfrom gurobipy import GRBimport os as _os, sys as _sysimport time_GUROBI_CODE_START_TIME = time.time()# Walk up from this file's directory to find repo root (containing scripts/)._repo = _os.path.dirname(_os.path.abspath(__file__))while _repo != _os.path.dirname(_repo) and not _os.path.isdir(_os.path.join(_repo, 'scripts', 'utils')):
2 unmodified lines345678917 unmodified lines2728293031322 unmodified linesGurobi implementation of the Start-based MILP model for RACPfrom Kreter et al. (2018), Section 4.1.1._GUROBI_CODE_START_TIME = time.time()"Mixed-Integer Linear Programming and Constraint Programming Formulationsfor Solving Resource Availability Cost Problems"European Journal of Operational Research.17 unmodified linesimport jsonimport sysimport timefrom collections import dequeimport os as _os, sys as _sys# Walk up from this file's directory to find repo root (containing scripts/).2 unmodified lines34567817 unmodified lines262728293031322 unmodified linesGurobi implementation of the Start-based MILP model for RACPfrom Kreter et al. (2018), Section 4.1.1."Mixed-Integer Linear Programming and Constraint Programming Formulationsfor Solving Resource Availability Cost Problems"European Journal of Operational Research.17 unmodified linesimport jsonimport sysimport time_GUROBI_CODE_START_TIME = time.time()from collections import dequeimport os as _os, sys as _sys# Walk up from this file's directory to find repo root (containing scripts/).
1 unmodified line23456788 unmodified lines1718192021221 unmodified lineBPPTL (Bin Packing Problem with Time Lags) - Compact Formulation (Model 2)from Letelier et al. (2022), solved with Gurobi._GUROBI_CODE_START_TIME = time.time()Minimize the total number of non-empty bin-period pairs subject to:- Each real item assigned to exactly one bin in one period- Bin capacity respected per (bin, period) pair8 unmodified linesfrom gurobipy import GRBimport os as _os, sys as _sysimport time# Walk up from this file's directory to find repo root (containing scripts/)._repo = _os.path.dirname(_os.path.abspath(__file__))while _repo != _os.path.dirname(_repo) and not _os.path.isdir(_os.path.join(_repo, 'scripts', 'utils')):1 unmodified line2345678 unmodified lines161718192021221 unmodified lineBPPTL (Bin Packing Problem with Time Lags) - Compact Formulation (Model 2)from Letelier et al. (2022), solved with Gurobi.Minimize the total number of non-empty bin-period pairs subject to:- Each real item assigned to exactly one bin in one period- Bin capacity respected per (bin, period) pair8 unmodified linesfrom gurobipy import GRBimport os as _os, sys as _sysimport time_GUROBI_CODE_START_TIME = time.time()# Walk up from this file's directory to find repo root (containing scripts/)._repo = _os.path.dirname(_os.path.abspath(__file__))while _repo != _os.path.dirname(_repo) and not _os.path.isdir(_os.path.join(_repo, 'scripts', 'utils')):
1 unmodified line23456787 unmodified lines1617181920211 unmodified lineCORPS (Collaborative Operating Room Planning and Scheduling) modelfrom Roshanaei et al. (2017), implemented as a monolithic MIP solved by Gurobi._GUROBI_CODE_START_TIME = time.time()This implements the FULL original problem:- Allocation Master Problem (MP), constraints (1)-(8)- Sequencing Subproblem (SP), constraints (9)-(22)7 unmodified linesimport argparseimport jsonimport timeimport gurobipy as gpfrom gurobipy import GRB1 unmodified line2345677 unmodified lines151617181920211 unmodified lineCORPS (Collaborative Operating Room Planning and Scheduling) modelfrom Roshanaei et al. (2017), implemented as a monolithic MIP solved by Gurobi.This implements the FULL original problem:- Allocation Master Problem (MP), constraints (1)-(8)- Sequencing Subproblem (SP), constraints (9)-(22)7 unmodified linesimport argparseimport jsonimport time_GUROBI_CODE_START_TIME = time.time()import gurobipy as gpfrom gurobipy import GRB
tasks/bode2012/gurobi_code.py+1-1
tasks/bodur2017/gurobi_code.py+1-1
tasks/bragin2022/gurobi_code.py+1-1
tasks/buchheim2018/gurobi_code.py+1-1
tasks/chen1999/gurobi_code.py+1-1
tasks/cote2018/gurobi_code.py+1-1
tasks/furini2021/gurobi_code.py+1-1
tasks/garcia2011/gurobi_code.py+1-1
tasks/hoffman1993/gurobi_code.py+1-1
tasks/kowalczyk2018/gurobi_code.py+1-1
tasks/kreter2018/gurobi_code.py+1-1
tasks/letelier2022/gurobi_code.py+1-1
tasks/roshanaei2017/gurobi_code.py+1-1