Note
Go to the end to download the full example code.
Tune for a DOcplex model#
We will tune parameters for the instance p0033 from MIPLIB 3.0 using the docplex-extensions library.
Reference: Bixby, Robert E., Sebastian Ceria, Cassandra M. McZeal, and Martin WP Savelsbergh. “An updated mixed integer programming library: MIPLIB 3.0.” Optima 58, no. June (1998): 12-15.
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
from docplex.mp.model_reader import ModelReader
import docplex_extensions as dex
Fetch the instance#
Path('instances').mkdir(exist_ok=True)
name = 'p0033.mps.gz'
response = urlopen(f'https://miplib2010.zib.de/miplib3/miplib3/{name}')
response_OK = True
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 3.0')
Run the tuning tool#
if response_OK:
model = ModelReader.read('instances/p0033.mps.gz')
tuned_params = dex.tune(model, log_output=True, overall_timelimit_sec=10, repeat=3)
Tuning tool parameters:
timelimit 10.0
tune.timelimit 1e+75
dettimelimit 1e+75
tune.dettimelimit 1e+75
tune.display 1
tune.repeat 3
Fixed parameters:
None
Tuning on problem 'p0033'
Test 'defaults':
Integer optimal solution.
Time = 0.01 sec. (2.27 ticks) Objective = 3089 Best bound = 3089
Tuning on problem 'copy1'
Test 'defaults':
Integer optimal solution.
Time = 0.00 sec. (1.78 ticks) Objective = 3089 Best bound = 3089
Tuning on problem 'copy2'
Test 'defaults':
Integer optimal solution.
Time = 0.00 sec. (1.77 ticks) Objective = 3089 Best bound = 3089
More tuning on problem 'p0033'
Tuning progress: 18%
Test 'no_cuts':
Integer optimal solution.
Time = 0.00 sec. (1.30 ticks) Objective = 3089 Best bound = 3089
Tuning progress: 22%
Test 'less_cuts':
Integer optimal solution.
Time = 0.00 sec. (1.48 ticks) Objective = 3089 Best bound = 3089
Tuning progress: 27%
Test 'no_Gomory_cuts':
Integer optimal solution.
Time = 0.01 sec. (2.62 ticks) Objective = 3089 Best bound = 3089
Tuning progress: 36%
Test 'no_heuristic':
Integer optimal solution.
Time = 0.00 sec. (2.18 ticks) Objective = 3089 Best bound = 3089
More tuning on problem 'copy1'
Tuning progress: 43%
Test 'no_cuts':
Integer optimal solution.
Time = 0.00 sec. (1.41 ticks) Objective = 3089 Best bound = 3089
Tuning progress: 48%
Test 'less_cuts':
Integer optimal solution.
Time = 0.00 sec. (1.58 ticks) Objective = 3089 Best bound = 3089
Tuning progress: 53%
Test 'no_Gomory_cuts':
Integer optimal solution.
Time = 0.01 sec. (2.99 ticks) Objective = 3089 Best bound = 3089
Tuning progress: 64%
Test 'no_heuristic':
Integer optimal solution.
Time = 0.00 sec. (2.00 ticks) Objective = 3089 Best bound = 3089
More tuning on problem 'copy2'
Tuning progress: 71%
Test 'no_cuts':
Integer optimal solution.
Time = 0.00 sec. (1.19 ticks) Objective = 3089 Best bound = 3089
Tuning progress: 75%
Test 'less_cuts':
Integer optimal solution.
Time = 0.00 sec. (1.58 ticks) Objective = 3089 Best bound = 3089
Tuning progress: 81%
Test 'no_Gomory_cuts':
Deterministic time limit exceeded, no integer solution.
Time = 0.00 sec. (0.23 ticks) No integer solution. Best bound = 346
Tuning progress: 82%
Test 'no_heuristic':
Deterministic time limit exceeded, no integer solution.
Time = 0.00 sec. (1.81 ticks) No integer solution. Best bound = 3017.5
Default test: Deterministic time = 5.81 ticks
Best test: 'no_cuts' Deterministic time = 3.90 ticks
Tuning tool status: completed
Tuned parameters:
mip.limits.cutpasses -1
Tuned parameters#
if response_OK:
print(tuned_params)
{'mip.limits.cutpasses': -1}
Total running time of the script: (0 minutes 0.527 seconds)