library(matlib)
Let us solve the working problem we showed in the beginning of this section. Recall that this data set is collected from Guinness Ghana Ltd. and it contains information on the supply of Malta Guinness from two production sites, Kaasi and Achimota, to nine key distributors geographically scattered in the regions of Ghana. They collected data sets twice and the data sets shown in Tables 1.3 and 1.4 were collected between July 7th 2010 and June 8th 2011. Table 1.3 shows the demands from the distributors and supplies from the production sites. Now we want to know if it is possible to satisfy the demand with the given supplies. The coefficient matrix for this system is
A <- matrix(c(1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 1), nrow = 11, ncol = 18, byrow = TRUE)
In the argument of the matrix() function “byrow” defined the order of the entries row by row. This means the elements of the matrix are filled from the first row and to the second row and so on. Now we write the right-hand side in R:
b <- c(1298, 1948, 465, 605, 451, 338, 260, 183, 282, 127, 535)
When you type Solve(A, b) in R, you will see:
Solve(A,b)
## x1 - 1*x11 - 1*x12 - 1*x13 - 1*x14 - 1*x15 - 1*x16 - 1*x17 - 1*x18 = -1483
## x2 + x11 = 605
## x3 + x12 = 451
## x4 + x13 = 338
## x5 + x14 = 260
## x6 + x15 = 183
## x7 + x16 = 282
## x8 + x17 = 127
## x9 + x18 = 535
## x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 = 1948
## 0 = 0
This means that there are infinitely many solutions to the system of linear equations.