A regional grocery chain is launching a new energy drink product and needs to optimally allocate initial stock to its stores. There are 6 stores (S1-S6) with varying characteristics. Each store has a known customer traffic (daily visits: S1-1200, S2-800, S3-1500, S4-900, S5-1100, S6-700), shelf space allocation (units: S1-50, S2-30, S3-60, S4-35, S5-45, S6-25), and historical sales similarity score for similar products (0-1 scale: S1-0.8, S2-0.6, S3-0.9, S4-0.7, S5-0.75, S6-0.5). The warehouse has 300 units available for initial distribution. There are two types of display setups: standard (costs $5 per store) and promotional (costs $15 per store but increases effective shelf space by 20%). The total display budget is $120. The goal is to maximize expected product exposure, calculated as: (customer traffic) × (units allocated) × (sales similarity score).

Problem type: ILP (Small: 12 variables, 8 constraints, 24 nonzeros)

Mathematical model:
Set:
1. Stores
   The set of Stores, \( S = \{S1, S2, S3, S4, S5, S6\} \)

Parameter:
1. CustomerTraffic_s  
   [S1:1200, S2:800, S3:1500, S4:900, S5:1100, S6:700]
2. ShelfSpace_s  
   [S1:50, S2:30, S3:60, S4:35, S5:45, S6:25]
3. SimilarityScore_s  
   [S1:0.8, S2:0.6, S3:0.9, S4:0.7, S5:0.75, S6:0.5]
4. DisplayCost  
   Standard:5, Promotional:15
5. SpaceMultiplier  
   1.2 (for promotional display)
6. TotalInventory  
   300
7. Budget  
   120

Decision variable:
1. AllocateUnits_s  
   Integer variable \( u_s \geq 0 \) for all \( s \in S \), units allocated to store s
2. DisplayType_s  
   Binary variable \( d_s \in \{0,1\} \) for all \( s \in S \), where 1=promotional display

Objective:
Maximize total expected product exposure
max: \( \sum_{s\in S} CustomerTraffic_s \times u_s \times SimilarityScore_s \)

Constraint:
1. Inventory limit  
   \( \sum_{s\in S} u_s \leq TotalInventory \)
2. Budget limit  
   \( \sum_{s\in S} (5(1-d_s) + 15d_s) \leq Budget \)
3. Shelf space constraints  
   \( u_s \leq ShelfSpace_s \times (1 + 0.2d_s), \forall s \in S \)
4. Non-negativity  
   \( u_s \geq 0, \forall s \in S \)

Type:
Integer, Linear, Linear  
ILP

Gurobi implementation:
import gurobipy as gp
from gurobipy import GRB


def solve_energy_drink_allocation(
    stores=['S1', 'S2', 'S3', 'S4', 'S5', 'S6'],
    customer_traffic={
        'S1': 1200,
        'S2': 800,
        'S3': 1500,
        'S4': 900,
        'S5': 1100,
        'S6': 700
    },
    shelf_space={
        'S1': 50,
        'S2': 30,
        'S3': 60,
        'S4': 35,
        'S5': 45,
        'S6': 25
    },
    similarity_score={
        'S1': 0.8,
        'S2': 0.6,
        'S3': 0.9,
        'S4': 0.7,
        'S5': 0.75,
        'S6': 0.5
    },
    total_inventory=300,
    budget=120,
    standard_cost=5,
    promotional_cost=15,
    space_multiplier=1.2
):
    """
    Solves the energy drink allocation problem using Gurobi optimizer.
    Maximizes expected product exposure under inventory, budget, and shelf space constraints.
    """
    # Create model
    model = gp.Model("EnergyDrinkAllocation")

    # Decision variables
    allocate_units = model.addVars(stores, vtype=GRB.INTEGER, name="units")
    display_type = model.addVars(stores, vtype=GRB.BINARY, name="display")

    # Objective: Maximize expected exposure
    exposure = gp.quicksum(customer_traffic[s] * allocate_units[s] *
                           similarity_score[s] for s in stores)
    model.setObjective(exposure, GRB.MAXIMIZE)

    # Constraints
    # Inventory limit
    model.addConstr(
        gp.quicksum(allocate_units[s] for s in stores) <= total_inventory,
        "inventory_limit")

    # Budget constraint
    model.addConstr(
        gp.quicksum(standard_cost * (1 - display_type[s]) +
                    promotional_cost * display_type[s]
                    for s in stores) <= budget, "budget_limit")

    # Shelf space constraints
    for s in stores:
        model.addConstr(
            allocate_units[s] <= shelf_space[s] *
            (1 + (space_multiplier - 1) * display_type[s]),
            f"shelf_space_{s}")

    # Optimize model
    model.optimize()

    # Return results
    if model.status == GRB.OPTIMAL:
        return {"status": "optimal", "obj": model.ObjVal}
    else:
        return {"status": f"{model.status}"}


# Execute the function
if __name__ == "__main__":
    result = solve_energy_drink_allocation()
    print(result)


Solution status: OPTIMAL
Optimal objective value: 253590