Problem 1

2)

C = t(c(-1,4))
A = matrix(c(-10,20,5,10,1,0),nrow = 3, byrow = T)
dir = rep("<=",3)
b = c(22,49,5)

sol = lp(direction = 'max',
   objective.in = C,
   const.mat = A,
   const.dir = dir,
   const.rhs = b,
   int.vec = c(1,2))

print (sol$solution)
## [1] 2 2
print (sol$objval)
## [1] 6

3)

As shown in the graph, there are five branches of which only three are feasible.

Problem 2

Let \(F_A,F_D,W_A,W_D\) represent number of factories/warehouses to be built in Austin/Dallas.

\(max\ 9F_A + 5F_D + 6W_A + 4W_D\)

\(s.t.\)

\(6F_A + 3F_D + 5W_A + 2W_D <= 11\)

\(W_A + W_D <=1\)

\(F_A,F_D,W_A,W_D\ are\ binary\)

C2 = t(c(9,5,6,4))
A2 = matrix(c(6,3,5,2,
              0,0,1,1,
              1,1,0,0), nrow = 3, byrow = T)
dir2 = c("<=","<=",">=")
b2 = c(11,1,1)

sol2 = lp(direction = 'max',
          objective.in = C2,
          const.mat = A2,
          const.dir = dir2,
          const.rhs = b2,
          binary.vec = c(1,2,3,4))

print (sol2$solution)
## [1] 1 1 0 1
print (sol2$objval)
## [1] 18

Problem 3

1) Formulation

##    city num
## 1   ATL   1
## 2   BOS   2
## 3   CHI   3
## 4   DEN   4
## 5   HOU   5
## 6   LAX   6
## 7    NO   7
## 8    NY   8
## 9   PIT   9
## 10  SLC  10
## 11   SF  11
## 12  SEA  12

Let \(x_1,\ x_2,\ x_3,\ x_4,\ x_5,\ x_6,\ x_7,\ x_8,\ x_9,\ x_10,\ x_11,\ x_12\) be binary variables, so \(x_i\ =\ 1\) means a hub will be built in place \(i\). The problem can be formulated as:

\(min\ x_1+x_2+x_3+x_4+x_5+x_6+x_7+x_8+x_9+x_10+x_11+x_12\)

\(s.t.\)

\(x_1+x_3+x_5+x_7+x_8+x_9\ >=\ 1\ (Force\ ATL\ to\ be\ covered,\ same\ for\ follows)\)

\(x_2+x_8+x_9\ >=\ 1\)

\(x_1+x_3+x_7+x_8+x_9\ >=\ 1\)

\(x_4+x_10\ >=\ 1\)

\(x_1+x_5+x_7\ >=\ 1\)

\(x_6+x_10+x_11\ >=\ 1\)

\(x_1+x_3+x_5+x_7\ >=\ 1\)

\(x_1+x_3+x_5+x_8+x_9\ >=\ 1\ (Same\ for\ NY\ and\ PIT)\)

\(x_4+x_6+x_10+x_11+x_12\ >=\ 1\)

\(x_6+x_10+x_11+x_12\ >=\ 1\)

\(x_10+x_11+x_12\ >=\ 1\)

2) Solution

C3 = t(rep(1,12))
A3 = matrix(c(1,0,1,0,1,0,1,1,1,0,0,0,
              0,1,0,0,0,0,0,1,1,0,0,0,
              1,0,1,0,0,0,1,1,1,0,0,0,
              0,0,0,1,0,0,0,0,0,1,0,0,
              1,0,0,0,1,0,1,0,0,0,0,0,
              0,0,0,0,0,1,0,0,0,1,1,0,
              1,0,1,0,1,0,1,0,0,0,0,0,
              1,1,1,0,0,0,0,1,1,0,0,0,
              1,1,1,0,0,0,0,1,1,0,0,0,
              0,0,0,1,0,1,0,0,0,1,1,1,
              0,0,0,0,0,1,0,0,0,1,1,1,
              0,0,0,0,0,0,0,0,0,1,1,1),
            nrow = 12, byrow = T)
dir3 = rep(">=",12)
b3 = rep(1,12)

sol3 = lp("min",
          objective.in = C3,
          const.mat = A3,
          const.dir = dir3,
          const.rhs = b3,
          binary.vec = 1:12)

print (sol3$objval)
## [1] 3
print (sol3$solution)
##  [1] 1 0 0 0 0 0 0 1 0 1 0 0

Therefore, a minimal of 3 hubs should be built at ATL, NY, SLC so as to cover all 12 hubs.

Problem 4

There are six combiniations with least possible waste:

##   Unit                      Combos Waste
## 1   x1                     4 * W25    20
## 2   x2           3 * W25 + 1 * W37     8
## 3   x3           2 * W25 + 1 * W54    16
## 4   x4 1 * W25 + 1 * W37 + 1 * W54     4
## 5   x5                     3 * W37     9
## 6   x6                     2 * W54    12
## 7   x7           2 * W37 + 1 * W25    21

Let \(x_1,\ x_2,\ x_3,\ x_4,\ x_5,\ x_6\) represent number of each combos. The objective is to minimize waste while satisfying quantity demands.The problem, therefore, can be formulated as follows:

\(min\ 20x_1 + 8x_2 + 16x_3 + 4x_4 + 9x_5 + 12x_6 + 21x_7\)

\(s.t.\)

\(4x_1 + 3x_2 + 2x_3 + x_4 + x_7\ >=\ 233\)

\(x_2 + x_4 + 3x_5 + 2x_7\ >=\ 148\)

\(x_3 + x_4 + 2x_6\ >=\ 106\)

\(x_1,\ x_2,\ x_3,\ x_4,\ x_5,\ x_6\ are\ integers\)

C4 = t(c(20,8,16,4,9,12,21))
A4 = matrix(c(4,3,2,1,0,0,1,
              0,1,0,1,3,0,2,
              0,0,1,1,0,2,0), nrow = 3, byrow = T)
dir4 = rep(">=",3)
b4 = c(233,148,106)

sol4 = lp("min",
          objective.in = C4,
          const.mat = A4,
          const.dir = dir4,
          const.rhs = b4,
          int.vec = c(1:7))

print (sol4$objval)
## [1] 764
print (sol4$solution)
## [1]   0  42   0 107   0   0   0

The solution says we should produce 42 sets of Combo 2 and 107 sets of Combo 4.

Problem 5

1) Formulation

##   Type Mon Tue Wed Thu Fri Sat Sun Cost
## 1   x1   1   1   1   1   1   0   0  300
## 2   x2   0   1   1   1   1   1   0  330
## 3   x3   0   0   1   1   1   1   1  360
## 4   x4   1   0   0   1   1   1   1  360
## 5   x5   1   1   0   0   1   1   1  360
## 6   x6   1   1   1   0   0   1   1  360
## 7   x7   1   1   1   1   0   0   1  330

Let \(x_1,\ x_2,\ x_3,\ x_4,\ x_5,\ x_6\) represent number of 6 types of workers, so the question can be formulated as follows:

\(min\ 300x_1 + 330x_2 + 360x_3 + 360x_4 + 360x_5 + 360x_6\)

\(s.t.\)

\(x_1 + x_4 + x_5 + x_6 + x_7\ >=\ 13\)

\(x_1 + x_2 + x_5 + x_6 + x_7\ >=\ 12\)

\(x_1 + x_2 + x_3 + x_6 + x_7\ >=\ 10\)

\(x_1 + x_2 + x_3 + x_4 + x_7\ >=\ 14\)

\(x_1 + x_2 + x_3 + x_4 + x_5\ >= 8\)

\(x_2 + x_3 + x_4 + x_5 + x_6\ >= 6\)

\(x_3 + x_4 + x_5 + x_6 + x_7\ >= 5\)

\(x_i\ are\ integers\)

2) Solution

C5 = t(Cost)
A5 = matrix(c(Mon,Tue,Wed,Thu,Fri,Sat,Sun),
            nrow = 7, byrow = T)
dir5 = rep(">=",7)
b5 = c(13,12,10,14,8,6,5)

sol5 = lp("min",
          objective.in = C5,
          const.mat = A5,
          const.dir = dir5,
          const.rhs = b5,
          int.vec = 1:7)

print (sol5$objval)
## [1] 4830
print (sol5$solution)
## [1] 8 2 0 3 1 0 1

Therefore, we need 8 workers of Type 1, 2 of Type 2, 3 of Type 4, 1 of Type 5, and 1 of Type 7.

3)

Type 1 workers who work from Mon to Fri are most popular. This makes sense because Mon - Fri are higher in workder demand and lower in cost comparing to Sat and Sun.