LogiTrans operates two distribution centers to manage the shipment of three types of goods to various regional hubs. Each distribution center can be staffed by up to seven logistics coordinators at a time. Coordinators are paid $500 per week at distribution center 1 and $900 per week at distribution center 2. Activating a distribution center for a week incurs a fixed cost of $1,000 for center 1 and $2,000 for center 2. During a week at a distribution center, each coordinator can process the number of shipments of each type of goods as shown in Table as follows:

| Goods Type \ Distribution Center | Center 1 | Center 2 |
|----------------------------------|----------|----------|
| Type 1                           | 20       | 25       |
| Type 2                           | 18       | 22       |
| Type 3                           | 15       | 20       |

Each week, LogiTrans must ensure that at least 120 shipments of goods type 1, at least 150 shipments of goods type 2, and at least 200 shipments of goods type 3 are processed. How to minimize the total cost of meeting weekly shipment demands?

Problem type: ILP (Toy: 4 variables, 5 constraints, 10 nonzeros)

Mathematical model:
Set:
1. Center
The set of distribution centers, \( C = \{1, 2\} \)
2. GoodsType
The set of goods types, \( G = \{1, 2, 3\} \)

Parameter:
1. FixedCost
[1000, 2000]
2. StaffCost
[500, 900]
3. MaxStaffNum
[7, 7]
4. ProcessRate
[
    [20, 25],
    [18, 22],
    [15, 20]
]
5. Demand
[120, 150, 200]

Decision variable:
1. ActivatingCenter
Binary variable, \( ActivatingCenter[c] \forall c \in C \), where \( ActivatingCenter[c] = 1 \) if distribution center \( c \) is activated, and 0 otherwise.
2. StaffNum
Integer variable, \( StaffNum[c] \forall c \in C \), where \( StaffNum[c] \) is the number of staff at distribution center \( c \).

Objective:
1. Minimize the total cost of activating distribution centers and paying staff.
min: \sum_{c \in C} (FixedCost[c] * ActivatingCenter[c] + StaffCost[c] * StaffNum[c])

Constraint:
1. Staff number constraint.
StaffNum[c] \leq MaxStaffNum[c] * ActivatingCenter[c] \forall c \in C
2. Demand satisfaction constraint.
\sum_{c \in C} ProcessRate[g][c] * StaffNum[c] \geq Demand[g] \forall g \in G
3. Staff number non-negativity constraint.
StaffNum[c] \geq 0 \forall c \in C

Type:
Integer, Linear, Linear
ILP

Gurobi implementation:
import gurobipy as gp
from gurobipy import GRB


def solve_staffing_optimization(
    FixedCost=[1000, 2000],
    StaffCost=[500, 900],
    MaxStaffNum=[7, 7],
    ProcessRate=[[20, 25], [18, 22], [15, 20]],
    Demand=[120, 150, 200]):
    """
    Solves the distribution center staffing optimization problem.
    """
    # --- 1. Model Creation ---
    model = gp.Model("Distribution Center Staffing")

    # --- 2. Parameters & Sets ---
    Centers = range(len(FixedCost))
    GoodsTypes = range(len(Demand))

    # --- 3. Decision Variables ---
    # ActivatingCenter[c] = 1 if center c is activated, 0 otherwise
    ActivatingCenter = model.addVars(Centers,
                                     vtype=GRB.BINARY,
                                     name="ActivatingCenter")

    # StaffNum[c] = number of staff at center c
    StaffNum = model.addVars(Centers, vtype=GRB.INTEGER, name="StaffNum")

    # --- 4. Objective Function ---
    # Minimize total cost (fixed costs + staff costs)
    obj = gp.quicksum(FixedCost[c] * ActivatingCenter[c] +
                      StaffCost[c] * StaffNum[c] for c in Centers)
    model.setObjective(obj, GRB.MINIMIZE)

    # --- 5. Constraints ---
    # Constraint 1: Staff number constraint
    model.addConstrs(
        (StaffNum[c] <= MaxStaffNum[c] * ActivatingCenter[c] for c in Centers),
        name="StaffLimit")

    # Constraint 2: Demand satisfaction constraint
    model.addConstrs(
        (gp.quicksum(ProcessRate[g][c] * StaffNum[c] for c in Centers) >=
         Demand[g] for g in GoodsTypes),
        name="DemandSatisfaction")

    # --- 6. Solve the Model ---
    model.optimize()

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


if __name__ == "__main__":
    result = solve_staffing_optimization()
    print(result)

Solution status: OPTIMAL
Optimal objective value: 11000