← Back to Handbooks

Simple LP Tutorial - Handbook

Type: LP (Linear Programming)

Welcome to LP Black Box! This handbook will teach you the fundamentals of Linear Programming (LP) and guide you through solving your first optimization problem using our web interface.

No prior knowledge of Linear Programming is required. By the end of this tutorial, you'll understand what LP is and how to use our platform to solve optimization problems.


Table of Contents

  1. What is Linear Programming?
  2. Key Concepts & Terminology
  3. A Simple Example: The Coffee Shop
  4. How to Use the LP Black Box Form
  5. Try It Yourself
  6. Common Patterns
  7. What's Next?

1. What is Linear Programming?

Linear Programming (LP) is a mathematical method for finding the best outcome (like maximum profit or minimum cost) given a set of constraints.

Think of it like this: You have limited resources, and you want to maximize or minimize something. LP helps you find the optimal combination.

Real-World Examples

ProblemWhat to MaximizeWhat to MinimizeConstraints
Production planningProfit-Machine time, materials
Delivery routesDelivery speedFuel costTime windows, truck capacity
Diet planningNutritionCostCalorie limits, food preferences
Portfolio investmentReturnRiskBudget, number of investments

The Core Idea

You want to make the best decision possible.
↓ 
There are rules (constraints) you must follow.
↓
There's something you want to optimize (maximize or minimize).
↓
LP finds the optimal solution that satisfies all rules.

2. Key Concepts & Terminology

Before we proceed, let's understand the basic building blocks of an LP problem:

2.1 Variables

Decision variables represent the choices you can control. These are the "unknowns" that the solver determines.

Example: How many cups of Latte and Mocha to make?

Variable types in the form:

In the form, you set lower_bound to define the minimum value (usually 0).

2.2 Objective Function

This is what you want to optimize (either maximize or minimize).

Example: Maximize 3x + 4y (profit equation)

In the form, you enter each variable's coefficient in the objective function section.

2.3 Constraints

Constraints are the rules or limitations that your solution must satisfy.

Types of constraints in the form:

Example: The budget cannot exceed $1000

In the form, you specify:

Note: rhs stands for "Right Hand Side" - it's the number on the right side of the inequality.


3. A Simple Example: The Coffee Shop

Let's walk through a practical example together.

The Scenario

You own a coffee shop and sell two drinks:

The Constraints

  1. Time constraint: You can only make 40 drinks total per day.

    latte + mocha ≤ 40

  2. Milk constraint: Each latte needs 1 unit of milk, each mocha needs 2 units. You have 50 units of milk available.

    latte + 2 × mocha ≤ 50

  3. Demand constraint: You must make at least 10 lattes due to a standing order.

    latte ≥ 10

  4. Non-negativity: You can't make negative drinks!

    latte ≥ 0, mocha ≥ 0

The Objective

Maximize profit: 3 × latte + 4 × mocha


4. How to Use the LP Black Box Form

Here's how to input our coffee shop problem into the web form:

Step 1: Access the Form

  1. Open your browser and go to http://localhost:3070
  2. Click Admin Dashboard or navigate to the admin login
  3. Login with: admin@test.com / password123
  4. Click on the Operation tab

Step 2: Enter Problem Details

  1. Problem Name: Enter "Coffee Shop Optimization"
  2. Objective Type: Select Maximize from the dropdown

Step 3: Add Variables

Click + Add Variable twice to create two variables:

VariableTypeLower Bound
latteContinuous0
mochaContinuous0

Step 4: Define the Objective Function

The form automatically adds objective terms for each variable. Set the coefficients:

This creates the objective: 3 × latte + 4 × mocha

Step 5: Add Constraints

Click + Add Constraint three times to create three constraints:

Constraint 1: Time Limit

Constraint 2: Milk Limit

Constraint 3: Minimum Lattes

Step 6: Solve

Click the Solve LP button.

Step 7: View Results

The results will appear on the right side of the screen. Look for:


5. Try It Yourself

Now it's your turn! Try modifying the problem:

Exercise 1: Change the Objective

What if you want to minimize cost instead? Let's say:

  1. Change Objective Type to Minimize
  2. Change the coefficients to: latte = 2, mocha = 3

Exercise 2: Add a New Constraint

Add a constraint that you can only make at most 25 mochas:

  1. Click + Add Constraint
  2. Name: max_mocha
  3. Coefficients: mocha = 1
  4. Type: LessThanOrEqual
  5. RHS: 25

Click Solve again and see how the result changes.

Exercise 3: Use Integer Variables

What if you can only make whole drinks (no half lattes)?

  1. Change both variables to Integer type instead of Continuous
  2. Click Solve and observe the difference

6. Common Patterns

Here are some common LP patterns you can adapt:

6.1 Resource Allocation

Maximize: profit per unit × quantity
Subject to:
  - Total resource used ≤ available
  - Quantity ≥ 0

6.2 Production Planning

Minimize: production cost
Subject to:
  - Meet demand requirements
  - Respect capacity limits
  - Quantity ≥ 0

6.3 Budget Optimization

Maximize: benefit score
Subject to:
  - Total cost ≤ budget
  - Each item selected = 0 or 1 (use Binary type)

6.4 Transportation

Minimize: shipping cost × quantity
Subject to:
  - Supply at each source = available
  - Demand at each destination = required

7. What's Next?

Congratulations! You've completed the Simple LP Tutorial. You now understand:

Where to Go from Here

  1. Try Other Samples: Use the "Load Sample Problem" dropdown to try different problem types like:

    • Material Procurement
    • Production Planning
    • Diet Optimization
    • Portfolio Optimization
    • And more!
  2. Experiment: Modify the sample problems to learn how changes affect the solution

  3. Learn More: Once you're comfortable, explore:

    • Binary variables for yes/no decisions
    • Integer variables for whole number solutions
    • More complex constraint combinations

Tips for Success


Quick Reference

Form Fields

FieldDescriptionExample
Problem NameA descriptive name for your problem"Coffee Shop Optimization"
Objective TypeMaximize or MinimizeMaximize
VariablesThe decisions you're optimizinglatte, mocha
Objective CoefficientsHow much each variable contributes3 for latte, 4 for mocha
ConstraintsThe rules/limitationstime limit, milk limit
RHSThe right-hand side value40, 50

Variable Types

TypeDescriptionUse Case
ContinuousAny numberProduction quantities, amounts
IntegerWhole numbersNumber of items, people
Binary0 or 1Yes/no decisions, selections

Constraint Types

TypeSymbolExample
LessThanOrEqualBudget ≤ $1000
GreaterThanOrEqualProduction ≥ 100 units
Equal=Exactly 50% mix

Happy Optimizing! 🚀