## Problem Description and Formulation

The film company wants to maximize the total audience for their new movie by advertising on three platforms: Banana Livestream, Durian TV, and Orange Premium Video. Each platform has a different cost per ad and attracts a different number of viewers. The company has a weekly advertising budget of $20,000 and must adhere to several constraints:
1. The cost for each ad on Banana Livestream is $1,500, attracting 300,000 viewers.
2. The cost for each ad on Durian TV is $300, attracting 10,000 viewers, with a limit of 15 ads from a single company.
3. The cost for each ad on Orange Premium Video is $500, attracting 12,000 viewers.
4. At most a third of the total number of ads should be on Orange Premium Video.
5. At least 5% of the ads should be on Banana Livestream.

## Decision Variables

Let \(B\), \(D\), and \(O\) be the number of advertisements on Banana Livestream, Durian TV, and Orange Premium Video, respectively.

## Objective Function

Maximize the total audience:
\[ \text{Maximize:} \quad 300,000B + 10,000D + 12,000O \]

## Constraints

1. **Budget Constraint:**
\[ 1,500B + 300D + 500O \leq 20,000 \]
2. **Durian TV Ad Limit:**
\[ D \leq 15 \]
3. **Orange Premium Video Limit (at most a third of total ads):**
\[ O \leq \frac{1}{3}(B + D + O) \]
4. **Banana Livestream Minimum (at least 5% of total ads):**
\[ B \geq 0.05(B + D + O) \]
5. **Non-Negativity Constraints:**
\[ B, D, O \geq 0 \]
6. **Integer Constraints (since ads must be whole numbers):**
\[ B, D, O \in \mathbb{Z} \]

## Gurobi Code

```python
import gurobipy as gp

# Create a new model
m = gp.Model("Advertising_Optimization")

# Decision variables
B = m.addVar(lb=0, vtype=gp.GRB.INTEGER, name="Banana_Livestream")
D = m.addVar(lb=0, vtype=gp.GRB.INTEGER, name="Durian_TV")
O = m.addVar(lb=0, vtype=gp.GRB.INTEGER, name="Orange_Premium_Video")

# Objective function: Maximize total audience
m.setObjective(300000*B + 10000*D + 12000*O, gp.GRB.MAXIMIZE)

# Budget constraint
m.addConstr(1500*B + 300*D + 500*O <= 20000, name="Budget_Constraint")

# Durian TV ad limit
m.addConstr(D <= 15, name="Durian_TV_Limit")

# Orange Premium Video limit (at most a third of total ads)
m.addConstr(O <= (B + D + O)/3, name="Orange_Premium_Video_Limit")

# Banana Livestream minimum (at least 5% of total ads)
m.addConstr(B >= 0.05*(B + D + O), name="Banana_Livestream_Minimum")

# Solve the model
m.optimize()

# Print the results
if m.status == gp.GRB.OPTIMAL:
    print("Optimal Solution:")
    print(f"Banana Livestream: {B.varValue}")
    print(f"Durian TV: {D.varValue}")
    print(f"Orange Premium Video: {O.varValue}")
    print(f"Total Audience: {300000*B.varValue + 10000*D.varValue + 12000*O.varValue}")
else:
    print("The model is infeasible.")
```