Linear Algebra: Traffic Problem with Systems of Equations

7 Comments

Assuming this is a homework assignment, you have probably already seen that it is one of the "classics". For example Palm's book (Introduction to MATLAB for Engineers by Palm W.J. 3rd edition 2010, p349) discsses this exact problem.
Without looking too carefully at the problem, you'll probably find it is underconstrained, and rank or even better rref will help you obtain a sensible course of action.
This is what i have so far. I'm a little confused on what is actually being asked. Not sure where to go next
%1: 100 + 200 = f1 + f3
%2: 300 + f1 = f2 + f4
%3: f5 + f2 = 100 +500
%4: f3 + f6 = 100 +300
%5: f4 +f7 = f6 +200
%6: 200 + 400 = f5 + f7
A=[1 0 1 0 0 0 0; -1 1 0 1 0 0 0; 0 1 0 0 1 0 0; 0 0 1 0 0 1 0; ...
0 0 0 1 0 -1 1; 0 0 0 0 1 0 1;];
B=[300; 300; 600; 400; 200; 600;];
mldivide(A,B)
rref(A,B)
rank(A,B)
Notice that A\B gives some negative numbers. In a real solution, none of the numbers should be negative.
rref(A,B) uses B as a tolerance in calculating the rref of A, which is not what you want. rank() is the same.
rank(A,B) just gives me 0 as the output
and rref just gives me a large matrix of all 0's
rref(A,B) uses B as the tolerence in the calculation. As in two values are to be considered to be the same if the are within B of each other. A typical value there might be something like 20*eps
Consider for example
[1/49*49 3;
2 6]
Examined algebraically this appears to be [1 3; 2 6] which is immediately recognizable as being rank 1 because the second row is 2 * the first row.
However, in the world of floating point numbers, 1/49*49 is not exactly 1: it is about 1.11e-16 less than 1. If you did bitwise comparisons between (1/49*49)*2 and 2, they would not be bit-for-bit equal, and you would decide that the matrix has rank 2. The tolerance parameter is there to permit you to take that kind of floating point round-off into account, so that you do not accidentally consider two values to be different due to floating point round-off when algebraically they should be the same.
I’m not getting any closer to solving the problem lol the code above is what I have and I dont know what it needs

Sign in to comment.

Answers (0)

Asked:

on 11 May 2019

Commented:

on 11 May 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!