A manufacturing company operates three production facilities (1, 2, and 3) that produce two types of components (X and Y). Each facility generates waste during production, which can be treated to reduce environmental impact. Treating the waste incurs a cost and reduces the amount of pollutants emitted. It costs $12 to treat a ton of waste from facility 1, and each ton treated reduces the amount of pollutant X by 0.15 ton and the amount of pollutant Y by 0.35 ton. It costs $8 to treat a ton of waste from facility 2, and each ton treated reduces the amount of pollutant X by 0.25 ton and the amount of pollutant Y by 0.20 ton. It costs $18 to treat a ton of waste from facility 3, and each ton treated reduces the amount of pollutant X by 0.30 ton and the amount of pollutant Y by 0.40 ton. The company aims to reduce the amount of pollutant X by at least 25 tons and the amount of pollutant Y by at least 35 tons. How to minimize the total cost of treating waste while meeting the pollution reduction targets?

Problem type: LP (Toy: 3 variables, 2 constraints, 6 nonzeros)

Mathematical model:
Set:
1. facility
The set of production facilities, \( F = \{1, 2, 3\} \)
2. pollutant
The set of pollutants, \( P = \{1, 2\} \)  # 1: pollutant X, 2: pollutant Y

Parameter:
1. TreatmentCost
[12, 8, 18]
2. PollutantReduction
[
    [0.15, 0.35],  # facility 1
    [0.25, 0.20],  # facility 2
    [0.30, 0.40]   # facility 3
]
3. PollutionTarget
[25, 35]

Decision variable:
1. TreatmentAmount
Continuous variable, \( TreatmentAmount[f] \forall f \in F \), where \( TreatmentAmount[f] \) is the amount of waste treated at facility \( f \).

Objective:
1. Minimize the total cost of treating waste.
min: \sum_{f \in F} TreatmentCost[f] * TreatmentAmount[f]

Constraint:
1. Pollution reduction constraint.
PollutantReduction[f][p] * TreatmentAmount[f] \geq PollutionTarget[p] \forall p \in P, f \in F
2. Treatment amount non-negativity constraint.
TreatmentAmount[f] \geq 0 \forall f \in F

Type:
Continuous, Linear, Linear
LP

Gurobi implementation:
import gurobipy as gp
from gurobipy import GRB

def solve_waste_treatment_optimization(
    TreatmentCost=[12, 8, 18],
    PollutantReduction=[
        [0.15, 0.35],
        [0.25, 0.20],
        [0.30, 0.40]
    ],
    PollutionTarget=[25, 35]
):
    # Create a new model
    model = gp.Model("Waste Treatment Optimization")

    # Sets
    Facilities = range(len(TreatmentCost))
    Pollutants = range(len(PollutionTarget))

    # Decision Variables
    TreatmentAmount = model.addVars(Facilities, vtype=GRB.CONTINUOUS, name="TreatmentAmount")

    # Objective: Minimize total treatment cost
    obj = gp.quicksum(TreatmentCost[f] * TreatmentAmount[f] for f in Facilities)
    model.setObjective(obj, GRB.MINIMIZE)

    # Constraint 1: Pollution reduction constraint
    for p in Pollutants:
        model.addConstr(
            gp.quicksum(PollutantReduction[f][p] * TreatmentAmount[f] for f in Facilities) >= PollutionTarget[p],
            f"PollutionReduction_{p+1}"
        )

    # Optimize the model
    model.optimize()

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


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

Solution status: OPTIMAL
Optimal objective value: 1269.5652173913045