Operations Research
Operations Research
library(lpSolve)
# Set up cost matrix
a <- matrix(c(35, 41, 27, 40, 47, 45, 32, 51, 39, 56, 36, 43, 32, 51, 25, 46),
nrow = 4, byrow = TRUE)
b <- c(14, 12, 13, 15)
cost.mat <- a*b
How should the jobs be assigned to the various machines so that the total
cost is minimized?
Code & Output:
Problem 4: There are four jobs to be assigned to the machines. Only one job
could be assigned to one machine. The amount of time in hours required for the
jobs in a machine are given in the following matrix.
> library(lpSolve)
> cost.mat <-
matrix(c(4,3,6,2,7,10,12,11,14,16,4,3,2,1,5,8,7,6,9,6),nrow=4,byrow=TRUE)
> lpassign <- lp.assign(cost.mat, direction = "min")
> lpassign$solution
[,1] [,2] [,3] [,4] [,5]
[1,] 0 0 0 0 0
[2,] 0 0 0 0 0
[3,] 0 0 0 0 0
[4,] 0 0 0 0 0
> lpassign$objval
[1] 0
1. The owner of a small machine shop has four mechanics available to assign
jobs for the day. Five jobs are offered with expected profit for each mechanic
on each job which are as follows:
Find the assignment of salesmen to the districts that will result in the
maximum sales.