Nutritional Requirements-A rancher has determined that the minimum weekly nutritional requirements for an average-sized horse include 40 lb of protein, 20 lb of carbohydrates, and 45 lb of roughage. These are obtained from the following sources in varying amounts at the prices indicated:
| items | protein | carbs | roughage | cost |
|---|---|---|---|---|
| hay | 0.5 | 2.0 | 5.0 | 1.8 |
| oats | 1.0 | 4.0 | 2.0 | 3.5 |
| feeding blocks | 2.0 | 0.5 | 1.0 | 0.4 |
| hpc | 6.0 | 1.0 | 2.5 | 1.0 |
| horse requirement | 40.0 | 20.0 | 45.0 | 0.0 |
Formulate a mathematical model to determine how to meet the minimum nutritional requirements at minimum cost.
\(x_1=\mathrm{hay~per~bale}\\\)
\(x_2=\mathrm{oats~per~sack}\\\)
\(x_3=\mathrm{feeding~blocks~per~block}\\\)
\(x_4=\mathrm{high~protein~concentrate~per~sack}\)
\(\textrm{Minimize}~1.8 x_1+3.5x_2+0.4x_3+1.0x_4\)
\(0.5x_1+x_2+2x_3+6x_4 \ge40\textrm{(protein)}\\\)
\(2x_1+4x_2+0.5x_3+x_4\ge20\textrm{(carbs)}\\\)
\(5x_1+2x_2+x_3+2.5x_4\ge45\textrm{(roughage)}\)
\({10x+35y}\)
\(8x+6y\le48\textrm{(board-feet of lumber)}\\\)
\(4x+y\le20\textrm{(hours of capacity)}\\\)
\(y\ge5\textrm{(demand)}\\\)
\(x,y \ge0\textrm{(nonnegativity)}\)
| points | x | y | obj_func |
|---|---|---|---|
| 1 | 0.00 | 5 | 175.0 |
| 2 | 0.00 | 8 | 280.0 |
| 3 | 2.25 | 5 | 197.5 |
The objective function is maximized at point (0,8) with a value of 280.
x <- seq(0, 6, by=0.1)
data <- data.frame(x = x, board_feet = (48-8*x)/6, hours = 20-4*x, demand = 5)
tidy <- gather(data, variable, "y", -x)
ggplotly(ggplot(tidy, aes(x=x, y=y, color=variable)) + geom_line())ggplot(data.frame(x=c(-5,10)),aes(x)) +
stat_function(fun=function(x) -4/3*x+8, geom="line", aes(col='y=-4/3x+8')) +
stat_function(fun=function(x) -4*x + 20, geom="line", aes(col='y=-4x+20')) +
stat_function(fun=function(x)5, geom="line", aes(col='y=5')) +
geom_vline(xintercept=0, aes(col= 'x=0')) +
geom_hline(yintercept= 0, aes(col='y=0')) +
geom_point(data=myint, aes(x,y)) +
annotate('text', x = 0, y = 9.2, label="(0, 8)", size=3 ) +
annotate('text', x = 0, y = 3.8, label="(0, 5)", size=3 ) +
annotate('text', x = 2.25, y = 3.8, label="(9/4, 5)", size=3 )Use the curve-fitting criterion to minimize the sum of the absolute deviations for the following models and data set:
\(y=ax\)
while(d > t){
if(crit_val_1<=crit_val_2){
b <- cv2
cv1 <- a+(1-r)*(b-a)
cv2 <- a+r*(b-a)
crit_val_1 <- cost(cv1,df1)
crit_val_2 <- cost(cv2,df1)
d1 <- rbind(d1,c(a,b,cv1,cv2,crit_val_1,crit_val_2))
d <- b-a
} else{
a <- cv1
cv1 <- a+(1-r)*(b-a)
cv2 <- a+r*(b-a)
crit_val_1 <- cost(cv1,df1)
crit_val_2 <- cost(cv2,df1)
d1 <- rbind(d1,c(a,b,cv1,cv2,crit_val_1,crit_val_2))
d <- b-a
}
}## [1] 7.066307
\(y=ax^2\)
while(d > t){
if(crit_val_1<=crit_val_2){
b <- cv2
cv1 <- a+(1-r)*(b-a)
cv2 <- a+r*(b-a)
crit_val_1 <- cost2(cv1,df2)
crit_val_2 <- cost2(cv2,df2)
d2 <- rbind(d2,c(a,b,cv1,cv2,crit_val_1,crit_val_2))
d <- b-a
} else{
a <- cv1
cv1 <- a+(1-r)*(b-a)
cv2 <- a+r*(b-a)
crit_val_1 <- cost2(cv1,df2)
crit_val_2 <- cost2(cv2,df2)
d2 <- rbind(d2,c(a,b,cv1,cv2,crit_val_1,crit_val_2))
d <- b-a
}
}## [1] 0.2232466
\(y=ax^3\)
while(d > t){
if(crit_val_1<=crit_val_2){
b <- cv2
cv1 <- a+(1-r)*(b-a)
cv2 <- a+r*(b-a)
crit_val_1 <- cost3(cv1,df3)
crit_val_2 <- cost3(cv2,df3)
d3 <- rbind(d3,c(a,b,cv1,cv2,crit_val_1,crit_val_2))
d <- b-a
} else{
a <- cv1
cv1 <- a+(1-r)*(b-a)
cv2 <- a+r*(b-a)
crit_val_1 <- cost3(cv1,df3)
crit_val_2 <- cost3(cv2,df3)
d3 <- rbind(d3,c(a,b,cv1,cv2,crit_val_1,crit_val_2))
d <- b-a
}
}## [1] 0
## [1] 0.01400168
## [1] 0.00700084
## [1] 433.7104
## [1] "The Optimal Value for the Model y=ax = 199.53946343722"
## [1] "The optimal value for the model y=ax^2 = 219.567063518652"
## [1] "The optimal value for the model y=ax^3 = 433.710399871649"