Introduction to Linear Programming in Python


Linear programming is a technique to optimize any problem with multiple variables and constraints. It’s a simple but powerful tool every data scientist should master.

Imagine you are a strategist recruiting an army. You have:

  • Three resources: 🌾food, 🪵wood, and 🪙gold
  • Three units: 🗡️swordsmen, 🏹bowmen, and 🐎horsemen.

Horsemen are stronger than bowmen, who are in turn stronger than swordsmen. The following table provides the cost and power of each unit:

🗡️Swordsman 60 20 0 70
🏹Bowman 80 10 40 95
🐎Horseman 140 0 100 230

Now we have 1200 🌾food, 800 🪵wood, and 600 🪙gold. How should we maximize the power of our army considering these resources?

We could simply find the unit

 

 

 

To finish reading, please visit source site