Step 2: Modelling: Define the objective function and constraints for the linear
programming model.
# Coefficients of the objective function (total labor cost)
f.obj <-c(10, 15, 12) # Assuming $10/hr labor cost
# Constraints matrix (demand must be met and employee availability)
f.con <-matrix(c(1, 0, 0,
0, 1, 0,
0, 0, 1,
-1, 0, 0,
0, -1, 0,
0, 0, -1), nrow=6, byrow=TRUE)
# Right-hand side of the constraints (customer demand and employee availability)
f.rhs <-c(10, 15, 12, 8, 6, 5)
# Directions of the constraints (greater than or equal to for demand and availability)
f.dir <-c(“>=”, “>=”, “>=”, “>=”, “>=”, “>=”)
# Solving the linear programming model
solution <-lp(“min”, f.obj, f.con, f.dir, f.rhs)
# Display the optimal workforce scheduling
solution$solution
names(solution$solution) <-shifts
print(solution$solution)
www.tutorhelpdesk.com