solve#

solve(model, **kwargs)#

Solve a DOcplex model with additional logging output for problem and solution statistics.

This function is a simple wrapper around docplex.mp.model.Model’s solve method and takes the same keyword arguments.

Parameters:
modeldocplex.mp.model.Model

DOcplex model.

log_outputbool or str or stream object, optional

Log output switch, in one of the following forms:

  • True or '1' or 'stdout' or 'sys.stdout': Log is output to stdout.

  • 'stderr' or 'sys.stderr': Log is output to stderr.

  • False or '0' or None: 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 the value of context.solver.log_output setting. Specifying this argument overwrites that setting.

clean_before_solvebool, optional

By default, solve typically resumes from the point where the previous optimizer solve ended, if any. Setting this flag to True forces a clean restart.

contextdocplex.mp.context.Context, optional

Context instance to be used in instead of the context the model was built with.

cplex_parametersdocplex.mp.params.parameters.RootParameterGroup or dict, optional:

A set of CPLEX parameters to use instead of the parameters defined as context.cplex_parameters, in one of the following forms:

  • RootParameterGroup: This can obtained by cloning the model’s parameters

  • dict of parameter names and values.

checkerstr, optional

Type of checks performed, in one of the following forms:

  • 'std': Perform type checks on arguments to methods, check whether numerical arguments are valid numbers (but no check for NaN and infinity).

  • 'numeric': Check whether numerical arguments are valid numbers, and not NaN or infinity.

  • 'full': Perform all possible checks (combination of 'std' and 'numeric').

  • 'off': Perform no checks at all. Disabling all checks might speed up model build time, but recommended only when the model has been thoroughly tested.

Default is 'std'.

parameter_setsIterable[ParameterSet], optional:

An iterable of ParameterSet to be used with multi-objective optimization only. See the create_parameter_sets method of docplex.mp.model.Model.

Returns:
docplex.mp.solution.SolveSolution or None

DOcplex model solution if the optimizer managed to find a feasible solution, else None.

See also

print_problem_stats

For printing problem statistics separately.

print_solution_quality_stats

For printing quality statistics of the incumbent solution separately.