0% found this document useful (0 votes)
8 views13 pages

Operations Research

assignment problems
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views13 pages

Operations Research

assignment problems
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 13

Assignment Problems in R

Dr. Amrit Das, SAS,VIT. 1


Problem 1: Solve the following Assignment problem.

Code & Output:

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

Dr. Amrit Das, SAS,VIT. 2


# Run
lpassign <- lp.assign(cost.mat, direction = "min")
lpassign$solution
[,1] [,2] [,3] [,4]
[1,] 0 0 1 0
[2,] 0 1 0 0
[3,] 0 0 0 1
[4,] 1 0 0 0
lpassign$objval
[1] 1957

Dr. Amrit Das, SAS,VIT. 3


Problem 2: Solve the Assignment problem (problem 1) with out hourly wages.

Code & Output:


> library(lpSolve)
> cost.mat <- matrix(c(35, 41, 27, 40, 47, 45, 32, 51, 39, 56, 36, 43, 32, 51, 25,
46), nrow = 4, byrow = TRUE)
> lpassign <- lp.assign(cost.mat, direction = "min")
> lpassign$solution
[,1] [,2] [,3] [,4]
[1,] 0 0 1 0
[2,] 0 1 0 0
[3,] 0 0 0 1
[4,] 1 0 0 0
> lpassign$objval
[1] 147
Dr. Amrit Das, SAS,VIT. 4
Problem 3: Four different jobs can be done on four different machines and take
down time are prohibitively higher for change overs. The following matrix gives
the cost is rupees of producing job i on machine j.

How should the jobs be assigned to the various machines so that the total
cost is minimized?
Code & Output:

> cost.mat <- matrix(c(5,7,11,6,8,5,9,6,4,7,10,7,10,4,8,3),nrow=4,byrow=TRUE)


> lpassign <- lp.assign(cost.mat, direction = "min")

Dr. Amrit Das, SAS,VIT. 5


> lpassign$solution
[,1] [,2] [,3] [,4]
[1,] 0 0 0 1
[2,] 0 0 1 0
[3,] 1 0 0 0
[4,] 0 1 0 0
> lpassign <- lp.assign(cost.mat, direction = "max")
> lpassign$objval
> lpassign$solution
[1] 23
[,1] [,2] [,3] [,4]
[1,] 0 0 1 0
[2,] 0 0 0 1
[3,] 0 1 0 0
[4,] 1 0 0 0
> lpassign$objval
[1] 34
Dr. Amrit Das, SAS,VIT. 6
Unbalanced Assignment problem

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.

Find an optimum assignment of jobs to the machines to minimize the total


processing time and also, find for which machine no job is assigned. What is
the total processing time to complete all the jobs?

Dr. Amrit Das, SAS,VIT. 7


Code & Output:

> 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

Dr. Amrit Das, SAS,VIT. 8


Code & Output:

> cost.mat <- matrix(c(4,3,6,2,7,10,12,11,14,16,4,3,2,1,5,8,7,6,9,6,0,0,0,0,0),


nrow=5, byrow=TRUE)
> lpassign <- lp.assign(cost.mat, direction = "min")
> lpassign$solution
[,1] [,2] [,3] [,4] [,5]
[1,] 0 0 0 1 0
[2,] 1 0 0 0 0
[3,] 0 0 1 0 0
[4,] 0 0 0 0 1
[5,] 0 1 0 0 0
> lpassign$objval
[1] 20

Dr. Amrit Das, SAS,VIT. 9


Practice Problems

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 by using the assignment method, the assignment of mechanics to the


job that will result in a maximum profit. Which job should be declined?

Dr. Amrit Das, SAS,VIT. 10


2. A marketing manager has 5 salesmen and there are 5 sales districts.
Considering the capabilities of the salesmen and the nature of districts, the
estimates made by the marketing manager for the sales per month (in 1000
rupees) for each salesmen in each district would be as follows.

Find the assignment of salesmen to the districts that will result in the
maximum sales.

Dr. Amrit Das, SAS,VIT. 11


3. Using the following cost matrix, determine (a) the optimal job
assignment (b) the cost of assignments.

Dr. Amrit Das, SAS,VIT. 12


4. A company has 5 jobs to be done on five machines. Any job can be done on
any machine. The cost of doing the jobs in different machines are given
below. Assign the jobs for different machines so as to minimize the total cost.

Dr. Amrit Das, SAS,VIT. 13

You might also like