## Description

## Problem 1 – Getting Started with Julia/JuMP

Model the following problem in JuMP:

Solve this problem using Clp, ECOS, and SCS solvers.

\begin{align*}

$

\end{align*}$

- Which solver is most accurate (gets closest to the “right” answer)?
- Which is fastest (use the @time macro)? NOTE: you should notice it takes longer to solve the problem the first time you run your code, and goes much faster if you re-sovle subsequent times. The first time you run the code, the solver takes extra time to compile/”load” the model (it doesn’t repeat the compilation step in future re-solves).
- Can you speculate as to why?

- If there is no clear difference between the solvers, can you think of some factors that might contribute to solver speed differences?

## Problem 2 – Honest Work

Farmer Brandt must determine how many acres of corn and hay to plant this year. An acre of hay yields 25 bushels of hay and requires 10 hours of labor per week. An acre of corn yields 10 bushels of corn and requires 4 hours of labor per week. All hay can be sold at $4 a bushel, and all corn can be sold at $3 a bushel. Seven acres of land and 40 hours per week of labor are available. Government regulations require that at least 30 bushels of corn be produced during the current year.

(a) Formulate a linear program to help Famer Brandt plan his crops for the upcoming season to maximize his revenue. State the math model, then code and solve the model using Julia. (Hint: you should have two decision variables).

(b) Code the same model once again, this time separating the parameters from the solution as we did in class (see Top Brass examples). Confirm that you obtain the same solution as in part (a).

(c) Solve the problem graphically by plotting the feasible set and at least two isocost lines for the objective function. Confirm that you obtain the same solution as in the previous parts.

## Problem 3 – OptiMine

A mining company (“OptiMine”) is planning mine operations for the next week. There are 10 different mine locations available for ore extraction. OptiMine needs to mine 3,000 tons of ore to meet demand. Each mine location has a total number of tons of ore available. Mining at each location has an associated cost per ton. Finally, ore extracted from each mine contains a different percentage of different elements (e.g., carbon, gold). The cost, ore available, and percentage of elements in the ore at each mining location are given in the .csv file “mine.csv.” A sample of the data is given in the table below. There is a minimum percentage of each element required across the total ore extracted, also given in the .csv file.

The data is provided in “mine.csv” on Canvas. You can use the code snippet provided below to read the .csv files and load them into Julia.

Mine | Cu % | Su % | C % | Ar % | Au % | Cost per ton | Max tons avail |
---|---|---|---|---|---|---|---|

Min % | 11 | 12 | 13 | 10 | 9 | ||

1 | 10 | 8 | 8 | 13 | 10 | 20 | 500 |

⋮⋮ | ⋮⋮ | ⋮⋮ | ⋮⋮ | ⋮⋮ | ⋮⋮ | ⋮⋮ | ⋱⋱ |

(a) Formulate a linear program to help OptiMine plan mining operations to meet requriments at a minimal cost. Give a general form (parameters only — no numbers) of the math model.

(b) Implement and solve this instance of the model in Julia/JuMP. Display the optimal objective value and the optimal variable values.

```
#You might need to run "Pkg.add(...)" before using these packages
using DataFrames, CSV, NamedArrays
#Load the data file
df = CSV.read("mine.csv",DataFrame,delim=',');
# create a list of mines
mines = convert(Array,df[2:end,1])
# create a list of elements
elements = 1:5
# create a dictionary of the total cost of mining at each location
cost_to_mine = Dict(zip(mines,df[2:end,7]))
# create a dictionary of the max tons available at each location
max_avail = Dict(zip(mines,df[2:end,8]))
# create a dictionary of the min % of each element
min_req = Dict(zip(elements,df[1,2:6]))
# create a matrix of the % of each element at each loation
mine_element_matrix = Matrix(df[2:end,2:6])
# rows are mines, columns are elements
mine_element_array = NamedArray(mine_element_matrix, (mines, elements),("mines","elements"))
;
```

## Problem 4 – Standard Form

Consider the following LP:

(a) Convert the problem to standard form.

(b) What are A𝐴, b𝑏, c𝑐,and x𝑥 in this problem? Clearly indicate how the decision variables of your transformed LP relate to those of the original LP.

(c) Solve the standard-form LP in Julia and report the objective value and the value of each decision variable in an optimal solution to the original LP.