Best writers. Best papers. Let professionals take care of your academic papers

Order a similar paper and get 15% discount on your first order with us
Use the following coupon "FIRST15"
ORDER NOW

MATLAB linear assignment problems.

Today we’ll take a look how to solve some linear problems for the matrix with rows and columns. For example for M = matchpairs(Cost,costUnmatched) will be the solution for the matrix Cost . Here each row will be linked to a column in a way that resulting cost will be minimized. Second variable costUnmatched specifies the cost per row of not linking each row and also cost per column for each of them which is not having a row linked to each column.

[M,uR,uC] = matchpairs(Cost,costUnmatched) also gives indexes for unmatched rows to uR and gives indexes for unmatched columns to uC.

[___] = matchpairs(Cost,costUnmatched,goal) defines the goal of the optimization using any of the output argument variations in previous syntaxes. Variable goal here can be 'min' or 'max' to make matches that will minimize or maximize the total cost.

Examples of usage

Let’s see at few examples here, first one will be something like to find flights with minimal cost. Let’s assume that we have like four people and we want them to visit four main cities in our country. This flights must be booked in advanced but also there is a need to spend as little as only possible. Company is big and that sales people located in different parts of the country so it’s different for them to visit each city in money for the flight. Here is the table below which will show how much it will cost for each person to fly to certain city.

Dallas Chicago New York City St. Louis
Greg $600 $670 $960 $560
Sue $900 $280 $970 $540
Beth $310 $350 $950 $820
Fred $325 $290 $600 $540

And each visit to the city is sort of big sale opportunity. If the city is missed then company will loose something like $2000 revenue in average.

So we create matrix C with to represent all this costs of flying to each city for each person here.

C = [600 670 960 560
     900 280 970 540
     310 350 950 820
     325 290 600 540];

And then we will use our function matchpair to link all that sales people to each city with minimal cost. Unassignment case there will be 1000 instead of 2000 cause it will be unmatching for both row and column, see my point ? It’s important thing to notice here.

M = matchpairs(C,1000)
 M = 4×2      
3     1      
2     2
4     3      
1     4 

So that function matchpairs have calculated the least expensive way to deliver sales person to each city there.

Dallas Chicago New York City St. Louis
Greg $600 $670 $960 $560
Sue $900 $280 $970 $540
Beth $310 $350 $950 $820
Fred $325 $290 $600 $540

Another example would be link taxi drivers to routes in order to maximize profits this time. Some taxi company have been given several requests to ride across the city. It have only 3 cabs and can’t fulfill all requests but want to make most of money from what is given obviously. Let’s build a table for each cab and each request, we got 5 requests, but only 3 can be filled.

Ride 1 Ride 2 Ride 3 Ride 4 Ride 5
Cab 1 $5.7 $6.3 $3.1 $4.8 $3.5
Cab 2 $5.8 $6.4 $3.3 $4.7 $3.2
Cab3 $5.7 $6.3 $3.2 $4.9 $3.4

Then let’s create profit matrix P to put all that numbers in it

P = [5.7 6.3 3.1 4.8 3.5
     5.8 6.4 3.3 4.7 3.2
     5.7 6.3 3.2 4.9 3.4];

Now let’s use matchpairs to get taxis to most profitable destinations. We need to select 3 outputs to get in return all nonmatched columns and rows and ‘max’ option to get max of the profits. Define unlinked rides as 0 since there is no profit of unfulfilled request or empty taxi

costUnmatched = 0;
[M,uR,uC] = matchpairs(P,costUnmatched,'max')
M = 3×2

     1     1
     2     2
     3     4

uR =

  0x1 empty double column vector
uC = 2×1

     3
     5

So it have calculated it all in the end really. Let’s make our table with answers once again.

Ride 1 Ride 2 Ride 3 Ride 4 Ride 5
Cab 1 $5.7 $6.3 $3.1 $4.8 $3.5
Cab 2 $5.8 $6.4 $3.3 $4.7 $3.2
Cab 3 $5.7 $6.3 $3.2 $4.9 $3.4

There are probably left example with unmatched rows and columns and their indexes, but that is way too much for now;)

Upload your project here

The post MATLAB linear assignment problems. appeared first on High Quality Academic Writing Help and Programming Help.

 
Looking for a Similar Assignment? Order now and Get 10% Discount! Use Coupon Code "Newclient"