Handling optimization problems with Python and R
As you’ve probably noticed, the large community that develops Python packages never stands still. Even in this case, it has provided a module that helps us solve linear optimization problems. Its name is PuLP (https://github.com/coin-or/pulp) and it is an LP modeler written in Python. It interfaces with the most common free and non-free engines that solve LP, Mixed-Integer Programming (MIP), and other related problems, such as the GNU Linear Programming Kit (GLPK), COIN-OR Branch and Cut (CBC), which is the default one, and IBM ILOG CPLEX. Using PuLP is fairly straightforward. Let’s put it into practice right away with the problem from the previous section.
Solving the LP problem in Python
The code that will be explained to you in this section can be found in the Python\01-linear-optimization-in-python.py
file in the Chapter 14
folder of the repository.
First, you have to install the PuLP module in your environment...