In the last post, we have seen how R performs linear programming and estimates the limits of the coefficients of the objective function over which the optimal solution remains the same. That was one kind of sensitivity check. The second way is to vary the constraints and observe how the objective function varies. It is the shadow price (of a constraint) and is defined as the change in the objective function value for a unit increase on the right-hand side of the constraint.
To recap, the following is the summary of the objective function and the constraints.
Maximise 45 X1 + 50 X2 (Objective function)
500 X1 + 500 X2 </= 20000 (constraint 1)
750 X1 + 625 X2 </= 42000 (constraint 2)
150 X1 + 100 X2 </= 10400 (constraint 3)
200 X1 + 300 X2 </= 9600 (constraint 4)
X1 </= 50 (constraint 5)
X2 </= 20 (constraint 6)
X1 >/= 0 (constraint 7)
X2 >/= 0 (constraint 8)
Also, recall that the above set of equations gave the maximum profit (the objective function value) of 1880, and the optimal production quantities are alpha = 24 and beta = 16.
The shadow price of constraint 1 is the change in maximum profit from 1880 when the right-hand side of constraint 1 is increased from 20000 to 20001. We can run the code and find out what it is.
f.obj <- c(45, 50)
f.con <- matrix (c(500, 500, 750, 625, 150, 100, 200, 300, 1, 0, 0, 1), nrow = 6, byrow = TRUE)
f.dir <- c("<=", "<=")
f.rhs <- c(20001, 42000, 10400, 9600, 50, 30)
results <- lp ("max", f.obj, f.con, f.dir, f.rhs, compute.sens=TRUE)
results
Success: the objective function is 1880.07
The value increased by 0.07 (1880.07 – 1880.0). The R can give all the shadow values using the following command. Note that you have added the attribute, ‘compute.sens=TRUE’, in the earlier code.
results$duals
0.07 0.00 0.00 0.05 0.00 0.00 0.00 0.00
The numbers are the shadow values from constraint 1 to constraint 8. The results show that only a change of one unit of constraint 1 and constraint 4 makes changes in the objective function value. They are, respectively, supply of ingredient A and supply of ingredient D. The former has a shadow value of 0.07, and the latter has 0.05.