Linear Programming

THIS IS NOT A COURSE IN LINEAR PROGRAMMING. THIS IS A DEMONSTRATION OF LINEAR PROGRAMMING USING VERY SIMPLE PROBLEMS.

ALL OF THE NECESSARY CODE IS GIVEN TO YOU. YOUR PROJECT IS TO MODIFY THE EXAMPLE CODE SLIGHTLY.

(COPY-AND-PASTE THE CODE TO TEST IT. IT IS WORKING CODE.)

Introduction

Linear programming is a method to achieve the best outcome (such as maximum profit or lowest cost) in a mathematical model whose requirements are represented by linear relationships (straight lines). (Wikipedia)

linear programming, mathematical modeling technique in which a linear function is maximized or minimized when subjected to various constraints. This technique has been useful for guiding quantitative decisions in business planning, in industrial engineering, and—to a lesser extent—in the social and physical sciences. (Britannica)

In Python, there are different libraries for linear programming such as the multi-purposed SciPy, the beginner-friendly PuLP, the exhaustive Pyomo, and many others.

Examples of Problems that Can Be Solved Using Linear Programming

From LibreText: Linear Programming (An Example)

Solomon manufactures parabolic skis and conventional skis. The manufacturing process is done first at the fabricating department and then at the finishing department. The fabricating department has at most 108 labor hours per day available while the finishing department has at most 24 labor hours available per day. The parabolic ski requires 6 labor hours at the fabricating department and one labor hour at the finishing department. The conventional ski requires 4 labor hours at the fabricating department and one labor hour at the finishing department. Solomon makes a $40 profit on its parabolic skis and $30 on its conventional skis. How many of each type of ski should be manufactured each day to realize a maximum profit.

Harveys is planning to add an additional room to its casino. The casino consists of card tables and slot machines. On an average day, a slot machine makes $2,000, while a card table makes $30,000. The total square feet available at Harveys' new casino room for gaming is 3,000 square feet and the total number of additional employees allowed by the gaming commission is 45. If a slot machine occupies 6 square feet and requires one employee per 12 machines and a card table occupies 54 square feet and requires three employees per two tables, how many slot machines and how many card tables should be put into the new casino room in order to maximize profit? What is the maximum Profit? (Smaller tables are permitted)

A veterinarian wishes to prepare a supply of dog food by mixing Purina Big chunks and Alpo Meaties. The mixture is to contain at least 50 units of carbohydrates, at least 36 units of protein, and at least 40 units of fat. The Big Chunks contain 3 units of carbohydrates per pound, 3 units of protein per pound, and 2 units of fat per pound. The Meaties contain 5 units of carbohydrates per pound, 4 units of protein per pound, and 8 units of fat per pound. The veterinarian can purchase the Big Chunks for 44 cents per pound and the Meaties for 80 cents per pound. How many pounds of each dog food should be mixed in order to meet the dietary requirements at the least cost?

Do One or More of These Problems

Project #1

Project #2

Project #3

Next, Try One or More of These Problems

1. The ski manufacturing problem for the examples above. Click HERE

2. and 3. Casino expansion problem and dog food problem from the examples above:

  1. define the problem (convert the problem description into numbers and equations)
    # x = .... # .... # .... # y = .... # .... # .... # .... # ....
  2. define LP variables (LpVariable)
  3. define LP problem (LpProblem)
  4. define objective function
    # for example 20*x + 45*y
  5. define constraints
    # for example x + y <= 100 .... ....
  6. solve problem
  7. display solution

A Few More Problems

Click HERE

Links

PuLP 2.8 (home)
PuLP 2.8 Classes
PuLP 2.8 User Guide
Optimization with PuLP 2.8
Linear Programming in Python using Pulp (YouTube)
Linear Optimization with Python (PuLP) | Linear Programming Problem(LPP) (YouTube)
What is the GLPK solver in Python PuLP?

Solving your first linear program in Python

The Art of Linear Programming (YouTube)

Intro to Linear Programming (YouTube)

4 Ways to Solve Linear Programming in Python

Graphical Method of Solving Linear Programming Problems

Linear Programming

Linear Programming in Python

LINEAR PROGRAMMING IN PYTHON (FULL COURSE) (YouTube) (50 min)

Linear Programming Problems and Solutions

Linear Programming (Optimization) 2 Examples Minimize & Maximize (YouTube)

Hands-On Linear Programming: Optimization With Python