Tune for a batch of models#

We will tune parameters for the instances mik-250-20-75-1 & mik-250-20-75-2 from MIPLIB 2010 using the docplex-extensions library.

Reference: Koch, Thorsten, Tobias Achterberg, Erling Andersen, Oliver Bastert, Timo Berthold, Robert E. Bixby, Emilie Danna et al. “MIPLIB 2010: Mixed integer programming library version 5.” Mathematical Programming Computation 3 (2011): 103-163.

Ensure DOcplex and its required dependecies are installed correctly#

from docplex.mp.check_list import run_docplex_check_list

run_docplex_check_list()
* system is: Linux 64bit
* Python version 3.10.17, located at: /home/docs/checkouts/readthedocs.org/user_builds/docplex-extensions/envs/stable/bin/python
* docplex is present, version is 2.29.245
* CPLEX library is present, version is 22.1.2.0, located at: /home/docs/checkouts/readthedocs.org/user_builds/docplex-extensions/envs/stable/lib/python3.10/site-packages
* pandas is present, version is 2.2.3
* Your cplex version 22.1.2.0 is the latest available
! Cplex promotional version, limited to 1000 variables, 1000 constraints

* diagnostics: 2
  -- Module cloudpickle is missing, run: pip install cloudpickle
  -- Your local CPLEX edition is limited. Consider purchasing a full license.

Import libraries#

from pathlib import Path
from urllib.request import urlopen

import docplex_extensions as dex

Fetch the instances#

Path('instances').mkdir(exist_ok=True)
names = ('mik-250-20-75-1.mps.gz', 'mik-250-20-75-2.mps.gz')

response_OK = True
for name in names:
    response = urlopen(f'https://miplib.zib.de/WebData/instances/{name}')

    if response.getcode() == 200:
        with open(f'instances/{name}', 'wb') as fp:
            fp.write(response.read())
    else:
        response_OK = False
        print(f'Could not fetch the instance {name} from MIPLIB 2010')

Run the tuning tool#

if response_OK:
    tuned_params = dex.batch_tune(
        'instances/mik-250-20-75-1.mps.gz',
        'instances/mik-250-20-75-2.mps.gz',
        log_output=True,
        overall_timelimit_sec=60,
        fixed_params_and_values={'threads': 2},
    )
Tuning tool parameters:
   timelimit                                60.0
   tune.timelimit                           1e+75
   dettimelimit                             1e+75
   tune.dettimelimit                        1e+75
   tune.display                             1
   tune.measure                             1

Fixed parameters:
   threads                                  2

Reading problem 'instances/mik-250-20-75-1.mps.gz' for tuning.

Selected objective sense:  MINIMIZE
Selected objective  name:  R0196
Selected RHS        name:  B
Selected bound      name:  BOUND

Reading problem 'instances/mik-250-20-75-2.mps.gz' for tuning.

Selected objective sense:  MINIMIZE
Selected objective  name:  R0196
Selected RHS        name:  B
Selected bound      name:  BOUND


Tuning on problem 'instances/mik-250-20-75-1.mps.gz'
Test 'defaults':
   Integer optimal, tolerance.
   Time = 0.54 sec. (853.56 ticks)  Objective = -49716   Best bound = -49720.9


Tuning on problem 'instances/mik-250-20-75-2.mps.gz'
Test 'defaults':
   Integer optimal, tolerance.
   Time = 0.42 sec. (682.04 ticks)  Objective = -50768   Best bound = -50773.1


More tuning on problem 'instances/mik-250-20-75-1.mps.gz'

Tuning progress: 7%

Test 'short1':
   Deterministic time limit exceeded.
   Time = 0.10 sec. (153.62 ticks)  Objective = -49716   Best bound = -51495.5


More tuning on problem 'instances/mik-250-20-75-2.mps.gz'

Tuning progress: 7%

Test 'short1':
   Deterministic time limit exceeded.
   Time = 0.09 sec. (153.82 ticks)  Objective = -50768   Best bound = -51743.2


More tuning on problem 'instances/mik-250-20-75-1.mps.gz'

Tuning progress: 8%

Test 'short_test2':
   Deterministic time limit exceeded.
   Time = 0.10 sec. (153.69 ticks)  Objective = -49716   Best bound = -51387.2

Tuning progress: 9%

Test 'short_test3':
   Deterministic time limit exceeded.
   Time = 0.10 sec. (153.68 ticks)  Objective = -49716   Best bound = -51387.2

Tuning progress: 9%

Test 'short_test4':
   Deterministic time limit exceeded.
   Time = 0.10 sec. (153.97 ticks)  Objective = -49716   Best bound = -50990.4

Tuning progress: 10%

Test 'short_test5':
   Deterministic time limit exceeded.
   Time = 0.10 sec. (153.61 ticks)  Objective = -49716   Best bound = -51061.1

Tuning progress: 11%

Test 'short_test6':
   Deterministic time limit exceeded.
   Time = 0.10 sec. (153.64 ticks)  Objective = -49716   Best bound = -51495.5

Tuning progress: 11%

Test 'short_test7':
   Deterministic time limit exceeded.
   Time = 0.10 sec. (153.72 ticks)  Objective = -49716   Best bound = -50853.5

Tuning progress: 12%

Test 'short_test8':
   Deterministic time limit exceeded.
   Time = 0.10 sec. (153.73 ticks)  Objective = -49716   Best bound = -50820.7


More tuning on problem 'instances/mik-250-20-75-2.mps.gz'

Tuning progress: 12%

Test 'short_test2':
   Deterministic time limit exceeded.
   Time = 0.09 sec. (153.72 ticks)  Objective = -50768   Best bound = -51605.6

Tuning progress: 13%

Test 'short_test3':
   Deterministic time limit exceeded.
   Time = 0.09 sec. (153.69 ticks)  Objective = -50768   Best bound = -51605.6

Tuning progress: 14%

Test 'short_test4':
   Deterministic time limit exceeded.
   Time = 0.10 sec. (153.96 ticks)  Objective = -50768   Best bound = -51847.3

Tuning progress: 14%

Test 'short_test5':
   Deterministic time limit exceeded.
   Time = 0.10 sec. (153.88 ticks)  Objective = -50768   Best bound = -51847.3

Tuning progress: 15%

Test 'short_test6':
   Deterministic time limit exceeded.
   Time = 0.09 sec. (153.65 ticks)  Objective = -50768   Best bound = -51606.6

Tuning progress: 16%

Test 'short_test7':
   Deterministic time limit exceeded.
   Time = 0.10 sec. (153.85 ticks)  Objective = -50768   Best bound = -52058.2

Tuning progress: 16%

Test 'short_test8':
   Deterministic time limit exceeded.
   Time = 0.11 sec. (153.94 ticks)  Objective = -50768   Best bound = -51786.3


More tuning on problem 'instances/mik-250-20-75-1.mps.gz'

Tuning progress: 18%

Test 'short_test9':
   Deterministic time limit exceeded, no integer solution.
   Time = 0.12 sec. (155.83 ticks)  No integer solution.  Best bound = -51355.6

Tuning progress: 19%

Test 'short_test10':
   Deterministic time limit exceeded.
   Time = 0.10 sec. (153.69 ticks)  Objective = -49716   Best bound = -50624.4

Tuning progress: 20%

Test 'short_test11':
   Deterministic time limit exceeded.
   Time = 0.10 sec. (154.26 ticks)  Objective = -49716   Best bound = -50733.7


More tuning on problem 'instances/mik-250-20-75-2.mps.gz'

Tuning progress: 20%

Test 'short_test9':
   Deterministic time limit exceeded, no integer solution.
   Time = 0.12 sec. (153.96 ticks)  No integer solution.  Best bound = -52441

Tuning progress: 21%

Test 'short_test10':
   Deterministic time limit exceeded.
   Time = 0.11 sec. (153.88 ticks)  Objective = -50768   Best bound = -51786.3

Tuning progress: 21%

Test 'short_test11':
   Deterministic time limit exceeded.
   Time = 0.11 sec. (153.88 ticks)  Objective = -50768   Best bound = -51786.3


More tuning on problem 'instances/mik-250-20-75-1.mps.gz'

Tuning progress: 22%

Test 'short_test12':
   Deterministic time limit exceeded.
   Time = 0.10 sec. (153.83 ticks)  Objective = -49716   Best bound = -50703.6

Tuning progress: 23%

Test 'short_test13':
   Deterministic time limit exceeded.
   Time = 0.10 sec. (154.26 ticks)  Objective = -49716   Best bound = -50733.7

Tuning progress: 24%

Test 'short_test14':
   Deterministic time limit exceeded.
   Time = 0.12 sec. (153.71 ticks)  Objective = -49716   Best bound = -50684.8

Tuning progress: 25%

Test 'short_test15':
   Deterministic time limit exceeded.
   Time = 0.12 sec. (153.71 ticks)  Objective = -49716   Best bound = -50684.8


More tuning on problem 'instances/mik-250-20-75-2.mps.gz'

Tuning progress: 25%

Test 'short_test12':
   Deterministic time limit exceeded.
   Time = 0.10 sec. (153.75 ticks)  Objective = -50768   Best bound = -51677.1

Tuning progress: 25%

Test 'short_test13':
   Deterministic time limit exceeded.
   Time = 0.11 sec. (153.88 ticks)  Objective = -50768   Best bound = -51786.3

Tuning progress: 26%

Test 'short_test14':
   Deterministic time limit exceeded.
   Time = 0.11 sec. (153.88 ticks)  Objective = -50768   Best bound = -51786.3

Tuning progress: 27%

Test 'short_test15':
   Deterministic time limit exceeded.
   Time = 0.11 sec. (153.88 ticks)  Objective = -50768   Best bound = -51786.3


More tuning on problem 'instances/mik-250-20-75-1.mps.gz'

Tuning progress: 29%

Test 'short_test16':
   Deterministic time limit exceeded.
   Time = 0.10 sec. (153.71 ticks)  Objective = -49716   Best bound = -50684.8


More tuning on problem 'instances/mik-250-20-75-2.mps.gz'

Tuning progress: 29%

Test 'short_test16':
   Deterministic time limit exceeded.
   Time = 0.11 sec. (153.88 ticks)  Objective = -50768   Best bound = -51786.3


More tuning on problem 'instances/mik-250-20-75-1.mps.gz'

Tuning progress: 35%

Test 'short_test17':
   Deterministic time limit exceeded.
   Time = 0.09 sec. (153.64 ticks)  Objective = -48075   Best bound = -51940.2

Tuning progress: 36%

Test 'short_test18':
   Deterministic time limit exceeded.
   Time = 0.08 sec. (153.60 ticks)  Objective = -49000   Best bound = -52287.4

Tuning progress: 37%

Test 'short_test19':
   Deterministic time limit exceeded.
   Time = 0.09 sec. (153.59 ticks)  Objective = -49716   Best bound = -51443.6

Tuning progress: 38%

Test 'short_test20':
   Deterministic time limit exceeded.
   Time = 0.09 sec. (153.66 ticks)  Objective = -49716   Best bound = -52516.4

Tuning progress: 39%

Test 'short_test21':
   Deterministic time limit exceeded.
   Time = 0.09 sec. (153.65 ticks)  Objective = -49716   Best bound = -51584.2

Tuning progress: 39%

Test 'short_test22':
   Deterministic time limit exceeded.
   Time = 0.12 sec. (153.77 ticks)  Objective = -48499   Best bound = -51375.5

Tuning progress: 40%

Test 'short_test23':
   Deterministic time limit exceeded.
   Time = 0.09 sec. (153.62 ticks)  Objective = -49400   Best bound = -52568.6

Tuning progress: 41%

Test 'short_test24':
   Deterministic time limit exceeded.
   Time = 0.08 sec. (153.66 ticks)  Objective = -49378   Best bound = -51514


More tuning on problem 'instances/mik-250-20-75-2.mps.gz'

Tuning progress: 41%

Test 'short_test17':
   Deterministic time limit exceeded.
   Time = 0.08 sec. (153.64 ticks)  Objective = -49800   Best bound = -53277.6

Tuning progress: 41%

Test 'short_test18':
   Deterministic time limit exceeded.
   Time = 0.08 sec. (153.73 ticks)  Objective = -50027   Best bound = -53490.2

Tuning progress: 41%

Test 'short_test19':
   Deterministic time limit exceeded.
   Time = 0.09 sec. (153.86 ticks)  Objective = -50768   Best bound = -51748.6

Tuning progress: 42%

Test 'short_test20':
   Deterministic time limit exceeded.
   Time = 0.09 sec. (153.63 ticks)  Objective = -50768   Best bound = -53356.9

Tuning progress: 42%

Test 'short_test21':
   Deterministic time limit exceeded.
   Time = 0.09 sec. (153.62 ticks)  Objective = -50768   Best bound = -52624.1

Tuning progress: 43%

Test 'short_test22':
   Deterministic time limit exceeded.
   Time = 0.10 sec. (153.75 ticks)  Objective = -50700   Best bound = -53272.9

Tuning progress: 44%

Test 'short_test23':
   Deterministic time limit exceeded.
   Time = 0.08 sec. (153.62 ticks)  Objective = -50568   Best bound = -53385.2

Tuning progress: 45%

Test 'short_test24':
   Deterministic time limit exceeded.
   Time = 0.08 sec. (153.73 ticks)  Objective = -50668   Best bound = -52760.5


More tuning on problem 'instances/mik-250-20-75-1.mps.gz'

Tuning progress: 63%

Test 'long_test1':
   Deterministic time limit exceeded.
   Time = 0.83 sec. (1689.89 ticks)  Objective = -49716   Best bound = -50167.6

Tuning progress: 75%

Test 'long_test2':
   Integer optimal, tolerance.
   Time = 0.36 sec. (666.25 ticks)  Objective = -49716   Best bound = -49720.9

Tuning progress: 81%

Test 'long_test3':
   Integer optimal, tolerance.
   Time = 0.73 sec. (1451.33 ticks)  Objective = -49716   Best bound = -49720.8


More tuning on problem 'instances/mik-250-20-75-2.mps.gz'

Tuning progress: 92%

Test 'long_test2':
   Integer optimal, tolerance.
   Time = 0.44 sec. (829.43 ticks)  Objective = -50768   Best bound = -50772.8

Tuning progress: 99%

Test 'long_test3':
   Deterministic time limit exceeded.
   Time = 0.07 sec. (92.78 ticks)  Objective = -50768   Best bound = -52071.9

Default test: Deterministic time = 1535.61 ticks
Best test: 'long_test2'  Deterministic time = 1495.67 ticks

Tuning tool status: completed

Tuned parameters:
   mip.cuts.cliques                         2
   mip.cuts.covers                          2
   mip.cuts.flowcovers                      2
   mip.cuts.gomory                          2
   mip.cuts.gubcovers                       2
   mip.cuts.implied                         2
   mip.cuts.mircut                          2
   mip.cuts.pathcut                         2
   mip.limits.cutsfactor                    30.0
   mip.strategy.backtrack                   0.0
   mip.strategy.heuristicfreq               100000
   mip.strategy.probe                       2

Tuned parameters#

if response_OK:
    print(tuned_params)
{'mip.cuts.cliques': 2, 'mip.cuts.covers': 2, 'mip.cuts.flowcovers': 2, 'mip.cuts.gomory': 2, 'mip.cuts.gubcovers': 2, 'mip.cuts.implied': 2, 'mip.cuts.mircut': 2, 'mip.cuts.pathcut': 2, 'mip.limits.cutsfactor': 30.0, 'mip.strategy.backtrack': 0.0, 'mip.strategy.heuristicfreq': 100000, 'mip.strategy.probe': 2}

Total running time of the script: (0 minutes 9.369 seconds)

Gallery generated by Sphinx-Gallery