Green Energy Solutions specializes in producing two types of renewable fuel: bioethanol and biodiesel. The company has 8,000 liters of feedstock A and 12,000 liters of feedstock B in stock. The quality rating of each feedstock is as follows: feedstock A—12; feedstock B—6. Bioethanol must have an average quality rating of at least 10, while biodiesel must have an average quality rating of at least 8. The demand for each product is driven by marketing efforts. Each dollar spent on marketing bioethanol generates 8 liters of demand, and each dollar spent on marketing biodiesel generates 15 liters of demand. Bioethanol is sold for $30 per liter, and biodiesel is sold for $25 per liter. Help Green Energy Solutions maximize its profit. Assume that the company cannot purchase additional feedstock of either type.

Problem type: LP (Small: 6 variables, 6 constraints, 14 nonzeros)

Mathematical model:
Set:
1. Fuel
The set of fuels, \( F = \{1, 2\} \)  # 1: gasoline, 2: diesel
2. Feedstock
The set of feedstocks, \( S = \{1, 2\} \)  # 1: feedstock A, 2: feedstock B

Parameter:
1. Inventory
[8000, 12000]
2. QualityRating
[12, 6]
3. Revenue
[30, 25]
4. DemandperMarketingDollar
[8, 15]
5. MinQualityRating
[10, 8]

Decision variable:
1. ProductionAmount
Continuous variable, \( ProductionAmount[f][s] \forall f \in F, s \in S \), where \( ProductionAmount[f][s] \) is the amount of fuel \( f \) produced from feedstock \( s \).
2. MarketingBudget
Continuous variable, \( MarketingBudget[f] \forall f \in F \), where \( MarketingBudget[f] \) is the marketing budget for fuel \( f \).

Objective:
1. Maximize the profit from selling fuels.
max: \sum_{f \in F} Revenue[f] * \sum_{s \in S} ProductionAmount[f][s] - \sum_{f \in F} MarketingBudget[f]

Constraint:
1. Inventory constraint.
\sum_{f \in F} ProductionAmount[f][s] \leq Inventory[s] \forall s \in S
2. Quality rating constraint.
\sum_{s \in S} QualityRating[s] * ProductionAmount[f][s] \geq MinQualityRating[f] * \sum_{s \in S} ProductionAmount[f][s] \forall f \in F
3. Demand constraint.
DemandperMarketingDollar[f] * MarketingBudget[f] \geq \sum_{s \in S} ProductionAmount[f][s] \forall f \in F
4. Non-negativity constraint.
ProductionAmount[f][s] \geq 0 \forall f \in F, s \in S
MarketingBudget[f] \geq 0 \forall f \in F

Type:
Continuous, Linear, Linear
LP

Gurobi implementation:
import gurobipy as gp
from gurobipy import GRB


def solve_fuel_production_optimization(
    Inventory=[8000, 12000],
    QualityRating=[12, 6],
    Revenue=[30, 25],
    DemandperMarketingDollar=[8, 15],
    MinQualityRating=[10, 8]
):
    """
    Models and solves the fuel production and marketing optimization problem.
    """
    # Create a new model
    model = gp.Model("Fuel Production and Marketing Optimization")

    # Sets
    Fuels = range(len(Revenue))
    Feedstocks = range(len(Inventory))

    # Decision Variables
    # Amount of fuel f produced from feedstock s
    ProductionAmount = {}
    for f in Fuels:
        for s in Feedstocks:
            ProductionAmount[f, s] = model.addVar(
                vtype=GRB.CONTINUOUS,
                name=f"ProductionAmount_{f+1}_{s+1}"
            )

    # Marketing budget for each fuel
    MarketingBudget = model.addVars(
        Fuels,
        vtype=GRB.CONTINUOUS,
        name="MarketingBudget"
    )

    # Objective: Maximize profit (revenue - marketing costs)
    obj = gp.quicksum(
        Revenue[f] * gp.quicksum(ProductionAmount[f, s] for s in Feedstocks)
        for f in Fuels
    ) - gp.quicksum(MarketingBudget[f] for f in Fuels)

    model.setObjective(obj, GRB.MAXIMIZE)

    # Constraint 1: Inventory constraint
    for s in Feedstocks:
        model.addConstr(
            gp.quicksum(ProductionAmount[f, s] for f in Fuels) <= Inventory[s],
            f"Inventory_{s+1}"
        )

    # Constraint 2: Quality rating constraint
    for f in Fuels:
        model.addConstr(
            gp.quicksum(QualityRating[s] * ProductionAmount[f, s] for s in Feedstocks) >=
            MinQualityRating[f] * gp.quicksum(ProductionAmount[f, s] for s in Feedstocks),
            f"Quality_{f+1}"
        )

    # Constraint 3: Demand constraint
    for f in Fuels:
        model.addConstr(
            DemandperMarketingDollar[f] * MarketingBudget[f] >=
            gp.quicksum(ProductionAmount[f, s] for s in Feedstocks),
            f"Demand_{f+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_fuel_production_optimization()
    print(result)


Solution status: OPTIMAL
Optimal objective value: 518433.33333333