Experiment
- Generate random data \(\color{darkblue}A\) and \(\color{darkblue}b\).
- Solve \(\color{darkblue}A\color{darkred}x=\color{darkblue}b\).
- Introduce an error in \(\color{darkblue}A\).
- Resolve and observe the effects on the solution.
- Tremble in fear.
---- 61 PARAMETER result collected results original perturbed diff %diff different signflip i1 -1.049 -1.234 0.185 17.624 different i2 -0.413 -0.294 0.119 28.851 different i3 0.034 -0.163 0.197 572.422 different signflip i4 -0.761 -0.653 0.108 14.165 different i5 -0.569 -0.546 0.023 4.002 i6 -0.333 -0.283 0.050 15.110 different i7 0.330 0.371 0.041 12.302 different i8 -0.128 -0.081 0.047 36.661 different i9 0.358 0.259 0.099 27.651 different i10 -0.279 -0.413 0.134 48.130 different i11 -0.305 -0.418 0.113 37.000 different i12 0.665 0.568 0.097 14.627 different i13 -0.413 -0.549 0.136 32.948 different i14 -0.885 -0.989 0.105 11.833 different i15 -0.552 -0.542 0.010 1.793 i16 -0.652 -0.691 0.039 5.982 i17 -0.244 -0.162 0.082 33.752 different i18 0.596 0.452 0.144 24.186 different i19 -0.143 -0.018 0.124 87.086 different i20 -0.465 -0.466 0.002 0.378 i21 -0.080 0.185 0.265 331.702 different signflip i22 0.767 0.789 0.022 2.890 i23 0.337 0.287 0.049 14.672 different i24 -0.199 -0.120 0.079 39.891 different i25 -0.800 -0.810 0.010 1.225 i26 -0.567 -0.557 0.009 1.672 i27 -0.341 -0.367 0.026 7.583 i28 -0.780 -0.921 0.141 18.025 different i29 0.259 0.299 0.040 15.386 different i30 0.219 0.077 0.143 65.061 different i31 -0.570 -0.847 0.276 48.410 different i32 0.235 0.244 0.009 3.896 i33 0.081 -0.042 0.123 151.192 different signflip i34 0.099 0.039 0.060 60.201 different i35 -0.106 -0.052 0.053 50.595 different i36 0.213 0.246 0.032 15.176 different i37 0.310 0.304 0.005 1.771 i38 -0.012 0.225 0.238 1927.458 different signflip i39 -0.752 -0.677 0.075 9.989 i40 0.135 0.019 0.117 86.159 different i41 0.270 0.179 0.090 33.449 different i42 0.308 0.491 0.183 59.361 different i43 -0.416 -0.428 0.012 2.953 i44 0.093 0.419 0.326 349.219 different i45 -0.033 -0.163 0.130 399.702 different i46 0.324 0.151 0.173 53.330 different i47 -0.041 -0.134 0.094 229.921 different i48 0.140 0.190 0.050 35.987 different i49 0.851 1.024 0.173 20.391 different i50 -0.210 -0.109 0.101 47.879 different
Conclusion
Appendix: GAMS model
$onText
Experiment: show the difference in results for Ax=b when we change one element in A a little bit.
$offText
*-------------------------------------------------------- * data *--------------------------------------------------------
set i /i1*i50/; alias(i,j);
parameter A(i,j),b(i); A(i,j) = uniform(-10,10); b(i) = uniform(-10,10);
*-------------------------------------------------------- * solve Ax=b *--------------------------------------------------------
variable x(i);
Equation lineq(i) 'linear equations' ;
lineq(i).. sum(j, A(i,j)*x(j)) =e= b(i);
model m /all/; solve m using cns display x.l;
parameter result(i,*) 'collected results'; result(j,'original') = x.l(j);
*-------------------------------------------------------- * introduce an error in A *--------------------------------------------------------
* shift decimal point by one in one single number a('i3','i5') = a('i3','i5')/10;
solve m using cns; display x.l; result(j,'perturbed') = x.l(j); display result;
*-------------------------------------------------------- * report differences in solution x *--------------------------------------------------------
acronym different,signflip; result(j,'diff') = abs(result(j,'original')-result(j,'perturbed')); result(j,'%diff') = 100*result(j,'diff')/max(0.0001,abs(result(j,'original'))); result(j,'different')$(result(j,'%diff')>10) = different; result(j,'signflip')$(result(j,'original')*result(j,'perturbed') < 0) = signflip; display result;
|
It would be interesting to compare the condition number of original and modified matrix A, even the condition number relates errors in b to solution x.
ReplyDeleteIn commercial LP systems for crude oil refining there is always a place for simultaneous equations, for example with blends produced to specification limit. Common approach is to use SLP solvers hinged on "best guess" and evaluation of tolerances applied to recursive properties.
This is an interesting topic. A long time ago I purchased this book to look into it more https://shop.elsevier.com/books/data-processing-and-reconciliation-for-chemical-process-operations/romagnoli/978-0-12-594460-1. Sadly, I didn't get much headway through it, but this post reminded me of it :)
ReplyDelete