Python API of DOcplex for solving linear programming problems

Dr. Soumen Atta, Ph.D.
Analytics Vidhya
Published in
3 min readMay 26, 2020

--

In this tutorial, we will learn how to write a model for linear programming problems (LPPs) using Python API and solve the model using IBM Decision Optimization CPLEX (DOcplex) Modeling for Python on your computer with IBM ILOG CPLEX Optimization Studio. Here, we will assume that Python3 and IBM ILOG CPLEX Optimization Studio v12.8 or later are installed on your machine.

Example problem

Consider a chocolate manufacturing company that produces only two types of chocolate — A and B. Both the chocolates require Milk and Choco only. To manufacture each unit of A and B, the following quantities are required:

  • Each unit of A requires 1 unit of Milk and 3 units of Choco,
  • Each unit of B requires 1 unit of Milk and 2 units of Choco.

The company kitchen has a total of 5 units of Milk and 12 units of Choco. On each sale, the company makes a profit of

  • Rs 6 per unit A sold,
  • Rs 5 per unit B sold.

Now, the company wishes to maximize its profit. How many units of A and B should it produce, respectively?

Model this problem by using the Python API and solve it using IBM Decision Optimization CPLEX (DOcplex) Modeling for Python on your computer…

--

--

Dr. Soumen Atta, Ph.D.
Analytics Vidhya

I am a Postdoctoral Researcher at the Faculty of IT, University of Jyväskylä, Finland. You can find more about me on my homepage: https://www.soumenatta.com/