tune#
- tune(model, *, log_output=True, overall_timelimit_sec=None, tuning_timelimit_sec=None, overall_timelimit_det=None, tuning_timelimit_det=None, display_level=None, repeat=None, fixed_params_and_values=None)[source]#
Run tuning tests on a DOcplex model to search for performance-improving parameter settings.
This function is a wrapper around CPLEX’s tuning tool. Refer to the CPLEX user manual for more details about this functionality.
- Parameters:
- modeldocplex.mp.model.Model
DOcplex model.
- log_outputbool or str or stream object, optional
Log output switch, in one of the following forms:
Trueor'1'or'stdout'or'sys.stdout': Log is output to stdout.'stderr'or'sys.stderr': Log is output to stderr.Falseor'0'orNone: No log output.File path (in form of str): Log is output to the file.
Stream object (a file-like object with a write method and a flush method): Log is output to the stream object.
Default is
True.- overall_timelimit_secint or float or str, optional
Time limit for the tuning tool, in terms of seconds. Corresponds to the CPLEX parameter timelimit.
- tuning_timelimit_secint or float or str, optional
Time limit for each test of the tuning tool, in terms of seconds. Corresponds to the CPLEX parameter tune.timelimit.
- overall_timelimit_detint or float or str, optional
Time limit for the tuning tool, in terms of deterministic ticks. Corresponds to the CPLEX parameter dettimelimit.
- tuning_timelimit_detint or float or str, optional
Time limit for each test of the tuning tool, in terms of deterministic ticks. Corresponds to the CPLEX parameter tune.dettimelimit.
- display_levelint, optional
Level of information reported by the tuning tool as it works. Corresponds to the CPLEX parameter tune.display.
- repeatint, optional
Number of times tuning is to be repeated on reordered versions of a given model. Corresponds to the CPLEX parameter tune.repeat.
- fixed_params_and_valuesdict, optional
Set of parameters and their values that should be respected by the tuning tool, in form of a dict having parameter names (as str such as ‘lpmethod’, ‘mip.limits.cutpasses’, etc.) as keys and parameter values as values. Default is
None.
- Returns:
- dict
Set of performance-improving parameters and their values identified by tuning tool, in form of a dict having parameter names (as str such as ‘lpmethod’, ‘mip.limits.cutpasses’, etc.) as keys and parameter values as values.
- Raises:
- ValueError
If both overall_timelimit_sec and overall_timelimit_det are specified.
- ValueError
If both tuning_timelimit_sec and tuning_timelimit_det are specified.
- ValueError
If an invalid value is specified for any tuning parameter in function arguments: overall_timelimit_sec, tuning_timelimit_sec, overall_timelimit_det, tuning_timelimit_det, display_level, repeat.
- ValueError
If an invalid parameter or value is specified is fixed_params_and_values.
See also
batch_tuneFor tuning a batch of models (stored as files).
Notes
Any CPLEX parameters set for the model before passing it to this function will be disregarded.