# ISYE524 Homework 1

\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

# 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:

min2x1x2+3x32x4s.t. 3x2x3+4x44x17x2+x3x4x13x3+8x4x1,x40x2,x310=53 Unrestricted in Sign (Free)min2𝑥1−𝑥2+3𝑥3−2𝑥4s.t. 3𝑥2−𝑥3+4𝑥4≥104𝑥1−7𝑥2+𝑥3−𝑥4=5𝑥1−3𝑥3+8𝑥4≤3𝑥1,𝑥4≥0𝑥2,𝑥3 Unrestricted in Sign (Free)

(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.