Description
using JuMP, HiGHS println(“HOMEWORK 4: “)
###Question 1### println(“Question 1 “) println(“b. “)
# Model
model = Model(HiGHS.Optimizer)
# Decision Variables
@variable(model, x_LA_D >= 0) # LA to Dallas
@variable(model, x_LA_H >= 0) # LA to Houston
@variable(model, x_SD_D >= 0) # SD to Dallas
@variable(model, x_SD_H >= 0) # SD to Houston
@variable(model, x_D_NY >= 0) # Dallas to New York
@variable(model, x_D_CH >= 0) # Dallas to Chicago
@variable(model, x_H_NY >= 0) # Houston to New York
@variable(model, x_H_CH >= 0) # Houston to Chicago
# Objective
@objective(model, Min,
300 * x_LA_D + 110 * x_LA_H +
420 * x_SD_D + 100 * x_SD_H +
(450 + 700) * x_D_NY + (550 + 700) * x_D_CH +
(470 + 900) * x_H_NY + (530 + 900) * x_H_CH)
# Constraints
# Supply constraints
@constraint(model, x_LA_D + x_LA_H <= 4) # Los Angeles can supply up to 400,000 barrels
@constraint(model, x_SD_D + x_SD_H <= 5) # San Diego can supply up to 500,000 barrels
# Demand constraints
@constraint(model, x_D_NY + x_H_NY >= 3) # New York requires at least
300,000 barrels
@constraint(model, x_D_CH + x_H_CH >= 4) # Chicago requires at least 400,000 barrels
# Refinery output constraints
@constraint(model, x_D_NY + x_D_CH <= x_LA_D + x_SD_D) # Dallas output
@constraint(model, x_H_NY + x_H_CH <= x_LA_H + x_SD_H) # Houston output
# Solve optimize!(model)
# Results
println(“Objective value: “, objective_value(model)) println(“x_LA_D = “, value(x_LA_D)) println(“x_LA_H = “, value(x_LA_H)) println(“x_SD_D = “, value(x_SD_D)) println(“x_SD_H = “, value(x_SD_H)) println(“x_D_NY = “, value(x_D_NY)) println(“x_D_CH = “, value(x_D_CH)) println(“x_H_NY = “, value(x_H_NY)) println(“x_H_CH = “, value(x_H_CH))
###Question 2### println(“Question 2 “)
# Model
model = Model(HiGHS.Optimizer)
# Decision Variables
@variable(model, x_1 >= 0)
@variable(model, x_2 >= 0)
# Objective
@objective(model, Max, x_1 + x_2)
# Constraints
@constraint(model, x_1 + 2x_2 <= 6)
@constraint(model, -x_1 + x_2 >= 6)
# Solve the model #optimize!(model)
# Output the maximization results
#println(“Objective value for the maximization is: “, objective_value(model))
#println(” x_1 is “, value(x_1))
#println(” x_2 is “, value(x_2))
# Objective
@objective(model, Min, x_1 + x_2)
# Constraints
#optimize!(model)
# Output the minimization results
#println(“Objective value for the minimization is: “, objective_value(model))
#println(” x_1 is “, value(x_1)) #println(” x_2 is “, value(x_2))
println(“There is no feasible region so the problem is infeasible.”)
###Question 3### println(“Question 3 “)
# Model
model = Model(HiGHS.Optimizer)
# Decision Variables
@variable(model, x_1 >= 0)
@variable(model, x_2 >= 0)
# Objective
@objective(model, Max, 4x_1 + x_2)
# Constraints
@constraint(model, 8x_1 + 2x_2 <= 16)
@constraint(model, x_1 + 2x_2 <= 10)
# Solve the model optimize!(model)
# Output the maximization results
println(“Objective value for the maximization is: “, objective_value(model)) println(” x_1 is “, value(x_1)) println(” x_2 is “, value(x_2))
# Objective
@objective(model, Min, 4x_1 + x_2)
# Constraints optimize!(model)
# Output the minimization results
println(“Objective value for the minimization is: “, objective_value(model)) println(” x_1 is “, value(x_1)) println(” x_2 is “, value(x_2))
###Question 4### println(“Question 4 “)
# Model
model = Model(HiGHS.Optimizer)
# Decision Variables
@variable(model, x_1 >= 0)
@variable(model, x_2 >= 0)
# Objective
@objective(model, Max, -x_1 + 4x_2)
# Constraints
@constraint(model, x_1 – x_2 <= 6)
@constraint(model, 2x_1 + 3x_2 >= 3)
# Solve the model #optimize!(model)
# Output the maximization results
#println(“Objective value for the maximization is: “, objective_value(model))
#println(” x_1 is “, value(x_1)) #println(” x_2 is “, value(x_2))
println(“The maximization problem is unbounded.”)
# Objective
@objective(model, Min, -x_1 + 4x_2)
# Constraints optimize!(model)
# Output the minimization results
println(“Objective value for the minimization is: “, objective_value(model)) println(” x_1 is “, value(x_1)) println(” x_2 is “, value(x_2))
###Question 5### println(“Question 5 “)
# Model
model = Model(HiGHS.Optimizer)
# Decision Variables
@variable(model, x_1 >= 0)
@variable(model, x_2 >= 0)
# Objective
@objective(model, Max, 3x_1 + x_2)
# Constraints
@constraint(model, 2x_1 + x_2 <= 6)
@constraint(model, x_1 + 3x_2 <= 9)
# Solve the model optimize!(model)
# Output the maximization results
println(“Objective value for the maximization is: “, objective_value(model))
println(” x_1 is “, value(x_1)) println(” x_2 is “, value(x_2))
# Objective
@objective(model, Min, 3x_1 + x_2)
# Constraints optimize!(model) # Output the minimization results
println(“Objective value for the minimization is: “, objective_value(model)) println(” x_1 is “, value(x_1)) println(” x_2 is “, value(x_2)) HOMEWORK 4: Question 1
b.
Presolving model
6 rows, 8 cols, 16 nonzeros
6 rows, 8 cols, 16 nonzeros
Presolve : Reductions: rows 6(-0); columns 8(-0); elements 16(-0) –
Not reduced
Problem not reduced by presolve: solving the LP
Using EKK dual simplex solver – serial
Iteration Objective Infeasibilities num(sum)
0 0.0000000000e+00 Pr: 2(7) 0s
5 1.0470000000e+04 Pr: 0(0) 0s
Model status : Optimal
Simplex iterations: 5
Objective value : 1.0470000000e+04
HiGHS run time : 0.00
Objective value: 10470.0 x_LA_D = 3.0 x_LA_H = 0.0 x_SD_D = 0.0 x_SD_H = 4.0 x_D_NY = 3.0 x_D_CH = 0.0 x_H_NY = 0.0 x_H_CH = 4.0
Question 2
There is no feasible region so the problem is infeasible.
Question 3
Presolving model
2 rows, 2 cols, 4 nonzeros
2 rows, 2 cols, 4 nonzeros
Presolve : Reductions: rows 2(-0); columns 2(-0); elements 4(-0) – Not reduced
Problem not reduced by presolve: solving the LP
Using EKK dual simplex solver – serial
Iteration Objective Infeasibilities num(sum) 0 -1.4999972737e+00 Ph1: 2(4); Du: 2(1.5) 0s
2 8.0000000000e+00 Pr: 0(0) 0s
Model status : Optimal
Simplex iterations: 2
Objective value : 8.0000000000e+00
HiGHS run time : 0.00 Objective value for the maximization is: 8.0 x_1 is 2.0 x_2 is 0.0
Solving LP without presolve or with basis
Using EKK dual simplex solver – serial
Iteration Objective Infeasibilities num(sum)
0 -1.0000013946e+00 Ph1: 1(1); Du: 1(1) 0s
1 0.0000000000e+00 Pr: 0(0) 0s
Model status : Optimal
Simplex iterations: 1
Objective value : 0.0000000000e+00
HiGHS run time : 0.00 Objective value for the minimization is: 0.0 x_1 is 0.0 x_2 is 0.0 Question 4
The maximization problem is unbounded.
Presolving model
2 rows, 2 cols, 4 nonzeros
0 rows, 0 cols, 0 nonzeros
Presolve : Reductions: rows 0(-2); columns 0(-2); elements 0(-4) –
Reduced to empty
Solving the original LP from the solution after postsolve
Model status : Optimal
Objective value : -6.0000000000e+00
HiGHS run time : 0.00
Objective value for the minimization is: -6.0 x_1 is 6.0 x_2 is 0.0 Question 5
2 rows, 2 cols, 4 nonzeros
2 rows, 2 cols, 4 nonzeros
Presolve : Reductions: rows 2(-0); columns 2(-0); elements 4(-0) – Not reduced
Problem not reduced by presolve: solving the LP
Using EKK dual simplex solver – serial
Iteration Objective Infeasibilities num(sum)
0 -3.9999952417e+00 Ph1: 2(7); Du: 2(4) 0s
2 9.0000000000e+00 Pr: 0(0) 0s
Model status : Optimal
Simplex iterations: 2
Objective value : 9.0000000000e+00
HiGHS run time : 0.00 Objective value for the maximization is: 9.0 x_1 is 3.0 x_2 is 0.0
Solving LP without presolve or with basis
Using EKK dual simplex solver – serial
Iteration Objective Infeasibilities num(sum)
0 -2.0000014690e+00 Ph1: 2(3); Du: 2(2) 0s
1 0.0000000000e+00 Pr: 0(0) 0s
Model status : Optimal
Simplex iterations: 1
Objective value : 0.0000000000e+00
HiGHS run time : 0.00 Objective value for the minimization is: 0.0 x_1 is 0.0 x_2 is 0.0




Reviews
There are no reviews yet.