Thursday, 9 October 2025

Linear Programming for Inventory Scenario Which Maximize Profit While Facing Constraints

Problem Statement

A retail store stocks two products: Product A (tablets) and Product B (smartwatches). The objective is to maximize profit by determining the optimal number of units to stock, subject to storage and budget constraints.Decision Variables
  • ( x ): Number of units of Product A.
  • ( y ): Number of units of Product B.
Objective FunctionMaximize profit, where each unit of Product A and Product B yields $300:
Maximize Z = 300x + 300yConstraintsStorage Constraint: The warehouse has 600 square feet. Product A requires 4 square feet per unit, and Product B requires 6 square feet per unit.                          
    
4x+6y600

Budget Constraint: The budget is $30,000. Product A costs $300 per unit, and Product B costs $200 per unit.

x+200y30,000

Non-negativity Constraints:

x0,y0
Step-by-Step SolutionWe’ll solve this using the graphical method by identifying the feasible region, finding its vertices, and evaluating the objective function at each vertex to determine the maximum profit.Step 1: Graph the ConstraintsConvert the inequalities to equalities to find the boundary lines:
  1. Storage Constraint:
    2x + 3y = 300
    • When
      x = 0
      :
      3y = 300 \implies y = 100
      . Point: ( (0, 100) ).
    • When
      y = 0
      :
      2x = 300 \implies x = 150
      . Point: ( (150, 0) ).
  2. Budget Constraint:
    3x + 2y = 300
    • When
      x = 0
      :
      2y = 300 \implies y = 150
      . Point: ( (0, 150) ).
    • When
      y = 0
      :
      3x = 300 \implies x = 100
      . Point: ( (100, 0) ).
Step 2: Find the Intersection of ConstraintsTo find the "middle" point where the constraints intersect:




2x+3y=300
3x+2y=300

Solve simultaneously:
  • Multiply (1) by 2:
    4x + 6y = 600
  • Multiply (2) by 3:
    9x + 6y = 900
  • Subtract:
    (9x + 6y) - (4x + 6y) = 900 - 600
    5x = 300 \implies x = 60
  • Substitute
    x = 60
    into (2):
    3(60) + 2y = 300 \implies 180 + 2y = 300 \implies 2y = 120 \implies y = 60
    .
Intersection point: ( (60, 60) ).Step 3: Define the Feasible RegionThe feasible region is where both constraints and non-negativity conditions are satisfied:
  • 2x + 3y 300
  • 3x + 2y 300
  • x0,y0

  • Find vertices of the feasible region:
    • Origin: ( (0, 0) ).
    • Storage intercept (x = 0): ( (0, 100) ) from
      2(0) + 3y = 300
      .
    • Budget intercept (y = 0): ( (100, 0) ) from
      3x + 2(0) = 300
      .
    • Intersection: ( (60, 60) ).
    The feasible region is a quadrilateral with vertices: ( (0, 0) ), ( (0, 100) ), ( (60, 60) ), ( (100, 0) ).Step 4: Evaluate the Objective FunctionEvaluate
    Z = 300x + 300y
    at each vertex:
    1. (0, 0):
      Z = 300(0) + 300(0) = 0
    2. (0, 100):
      Z = 300(0) + 300(100) = 30,000
    3. (100, 0):
      Z = 300(100) + 300(0) = 30,000
    4. (60, 60):
      Z = 300(60) + 300(60) = 18,000 + 18,000 = 36,000
    The maximum value of
    Z = 36,000
    occurs at ( (60, 60) ).
    Final AnswerThe store should stock 60 units of Product A and 60 units of Product B to maximize profit, yielding a profit of $36,000. This solution is at the intersection of the storage and budget constraints, ensuring the optimal point is in the "middle" and both constraints actively shape the feasible region without the budget constraint being stricter.





    Python Code from Grok
    import numpy as np
    import matplotlib.pyplot as plt
    
    # Define the range for x (Product A)
    x = np.linspace(0, 200, 400)
    
    # Constraint 1: Storage (2x + 3y <= 300)
    y1 = (300 - 2 * x) / 3
    
    # Constraint 2: Budget (3x + 2y <= 300)
    y2 = (300 - 3 * x) / 2
    
    # Objective function at optimal point Z = 36,000 (at x=60, y=60)
    # Z = 300x + 300y => y = -x + Z/300
    y_opt = -x + 36000 / 300  # Z = 36,000
    
    # Plotting
    plt.figure(figsize=(10, 8))
    
    # Plot constraints
    plt.plot(x, y1, label='2x + 3y = 300 (Storage)', color='blue')
    plt.plot(x, y2, label='3x + 2y = 300 (Budget)', color='green')
    
    # Fill feasible region (y <= min(y1, y2) and y >= 0)
    y_feasible = np.minimum(y1, y2)
    plt.fill_between(x, 0, y_feasible, where=(y_feasible >= 0), color='gray', alpha=0.3, label='Feasible Region')
    
    # Plot objective function at optimal point
    plt.plot(x, y_opt, '--', label='Z = 300x + 300y = 36,000 (Optimal)', color='red')
    
    # Plot vertices
    vertices = [(0, 0), (0, 100), (60, 60), (100, 0)]
    for vertex in vertices:
        plt.plot(vertex[0], vertex[1], 'ro')  # Red dots for vertices
        plt.text(vertex[0] + 2, vertex[1] + 2, f'({vertex[0]}, {vertex[1]})', fontsize=10)
    
    # Highlight optimal point
    optimal = (60, 60)
    plt.plot(optimal[0], optimal[1], 'y*', markersize=15, label='Optimal Point (60, 60)')
    
    # Set labels and limits
    plt.xlabel('Units of Product A (x)')
    plt.ylabel('Units of Product B (y)')
    plt.title('Linear Programming: Inventory Management')
    plt.xlim(-10, 160)
    plt.ylim(-10, 160)
    plt.grid(True)
    plt.legend()
    
    # Show plot
    plt.show()












    No comments:

    Post a Comment

    Machine Learning: Nearest Neighbor (NN) algorithm for stock transfers between warehouses

      🏭 Scenario: Nearest Neighbor Algorithm for Warehouse Stock Transfer Background A company, GrapheneTech , distributes graphene sheets a...