## Problem Description and Formulation

The Boarstone factory needs to determine the optimal number of regular and advanced machines to minimize costs while meeting the requirements of completing at least 120 tasks per hour with a maximum of 20 workers.

### Decision Variables

- \(R\): The number of regular machines to be used.
- \(A\): The number of advanced machines to be used.

### Objective Function

The objective is to minimize the total cost. The cost of a regular machine is $1000, and the cost of an advanced machine is $10,000. Therefore, the objective function can be formulated as:

\[ \text{Minimize:} \quad 1000R + 10000A \]

### Constraints

1. **Tasks per Hour Constraint**: A regular machine can perform 5 tasks per hour, and an advanced machine can perform 25 tasks per hour. The factory wants to complete at least 120 tasks per hour.

\[ 5R + 25A \geq 120 \]

2. **Worker Constraint**: A regular machine requires 2 workers, and an advanced machine requires 5 workers. The factory has a maximum of 20 workers.

\[ 2R + 5A \leq 20 \]

3. **Non-Negativity Constraint**: The number of machines cannot be negative.

\[ R \geq 0, A \geq 0 \]

4. **Integer Constraint**: Since we cannot have a fraction of a machine, both \(R\) and \(A\) must be integers.

## Gurobi Code

```python
import gurobi

def solve_boarstone_factory_problem():
    # Create a new model
    model = gurobi.Model()

    # Define the decision variables
    R = model.addVar(lb=0, vtype=gurobi.GRB.INTEGER, name="Regular_Machines")
    A = model.addVar(lb=0, vtype=gurobi.GRB.INTEGER, name="Advanced_Machines")

    # Objective function: Minimize cost
    model.setObjective(1000*R + 10000*A, gurobi.GRB.MINIMIZE)

    # Tasks per hour constraint
    model.addConstr(5*R + 25*A >= 120, name="Tasks_Constraint")

    # Worker constraint
    model.addConstr(2*R + 5*A <= 20, name="Workers_Constraint")

    # Optimize the model
    model.optimize()

    # Print the results
    if model.status == gurobi.GRB.OPTIMAL:
        print(f"Optimal Solution:")
        print(f"Regular Machines: {R.varValue}")
        print(f"Advanced Machines: {A.varValue}")
        print(f"Total Cost: ${model.objVal}")
    else:
        print("The model is infeasible.")

solve_boarstone_factory_problem()
```