Linear programming (LP) 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 using Python with Pulp library.
Implementing Linear Programming using Python with Pulp library.
Download following libraries to your environment:
- Download "pulp" in terminal
$ pip install pulp --user
Use the following command to execute the script under the src folder:
$ python linear_programming.py
1. Use Case:
a. A factory can produce 2 products: screws and nails
b. Profit $20/ton for screws and $30/ton for nails
c. Maximum market demand/day: 400 tons for screws and 300 tons for nails
d. Production rate: 60 tons/hour for screws and 50 tons/hour for nails
e. Working days has 8 hours
Question: How many tons of each product should be factory produce per day to maximise profit?
2. Use Case:
a. An advertising agency wants to run a campaign for a new product on print media and TV.
b. A print advertisement cost $20,000 and can reach 1 million people
c. A TV advertisement costs $50,000 and can reach 2 million people
d. Assume for simplicity that different advertisements reach different people
e. There can be at most 40 advertisements on print and 15 advertisements on TV
f. The agency has a budget of $1 million for the campaign
Question: What is the best campaign that will reach the maximum number of people?
- The result will be generated and display on your terminal/console after the script has been executed.
- Referring test folder for the result screens.
Nil.
Python 3.7.0
- Pulp
Nil.