Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docplex vs CPLEX Python API

Tags:

cplex

docplex

What is the difference between Docplex and CPLEX Python API? Is any of them faster than the other?

like image 328
Snochacz Avatar asked Feb 26 '19 17:02

Snochacz


People also ask

What is the difference between cplex and DOcplex?

It is usually faster to build the model directly with the CPLEX Python API as it is a lower-level API. However, docplex can take care of some of the intricacies of getting the best performance when building a model while only incurring a relatively low overhead. The actual solve time should be more or less identical.

What is Python DOcplex?

DOcplex is a native Python modeling library for optimization. It's compatible with the NumPy and pandas libraries and available from the PyPI or conda package managers. For more about DOcplex, see the DOcplex landing page.

Is cplex free for Python?

Yes, CPLEX is free to install the library on Python. However, you need to have CPLEX runtime installed in order to run it. There is the free version of runtime with a limited size of 1000 variables and 1000 constraints.

How does Python connect to cplex?

To start using the CPLEX Python API, set the Python path environment variable PYTHONPATH to the value of yourCplexhome/python/VERSION/PLATFORM. Setting this environment variable enables that version of Python to find the CPLEX modules that it needs to run Python commands and scripts that use the CPLEX Python API.


1 Answers

The CPLEX Python API is a lightweight wrapper around the C API (aka, the C Callable Library). As such, it provides access to nearly all of the functionality CPLEX has to offer. Variables and constraints are identified by their indices in the matrix.

docplex is an object oriented modeling API that is numpy/pandas friendly, which may be more natural to work with. The model can be solved locally (using the CPLEX Python API under the hood), or on the cloud. In addition to providing access to CPLEX for mathematical programming, it can also be used to access the CP Optimizer constraint programming engine.

It is usually faster to build the model directly with the CPLEX Python API as it is a lower-level API. However, docplex can take care of some of the intricacies of getting the best performance when building a model while only incurring a relatively low overhead. The actual solve time should be more or less identical.

like image 133
rkersh Avatar answered Sep 23 '22 15:09

rkersh