Skip to content

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.

License

Notifications You must be signed in to change notification settings

maomaokong/python_linear_programming_samples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

python_linear_programming_samples

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.

Objective

Implementing Linear Programming using Python with Pulp library.

Prerequisites

Download following libraries to your environment:

  1. Download "pulp" in terminal
$ pip install pulp --user

How to run the script

Use the following command to execute the script under the src folder:

$ python linear_programming.py

Problems

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?

Result

  1. The result will be generated and display on your terminal/console after the script has been executed.
  2. Referring test folder for the result screens.

Setting Configuration

Nil.

Language

Python 3.7.0

Libraries

  1. Pulp

Others

Nil.

About

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.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages