Austin Schuh | 7fa6521 | 2024-08-18 17:20:58 -0700 | [diff] [blame] | 1 | import casadi |
| 2 | import pylab |
| 3 | |
| 4 | # From https://gist.github.com/jgillis/dec56fa16c90a8e4a69465e8422c5459 |
| 5 | |
| 6 | # Point this to where the files generated by running casadi with solver options of |
| 7 | # {"debug": True} |
| 8 | root = "./" |
| 9 | |
| 10 | actual = casadi.Sparsity.from_file(root + "debug_fatrop_actual.mtx") |
| 11 | |
| 12 | A = casadi.Sparsity.from_file(root + "debug_fatrop_A.mtx") |
| 13 | B = casadi.Sparsity.from_file(root + "debug_fatrop_B.mtx") |
| 14 | C = casadi.Sparsity.from_file(root + "debug_fatrop_C.mtx") |
| 15 | D = casadi.Sparsity.from_file(root + "debug_fatrop_D.mtx") |
| 16 | I = casadi.Sparsity.from_file(root + "debug_fatrop_I.mtx") |
| 17 | errors = casadi.Sparsity.from_file(root + "debug_fatrop_errors.mtx").row() |
| 18 | |
| 19 | pylab.figure() |
| 20 | pylab.spy(A, |
| 21 | marker='o', |
| 22 | color='r', |
| 23 | markersize=5, |
| 24 | label="expected A", |
| 25 | markerfacecolor="white") |
| 26 | pylab.spy(B, |
| 27 | marker='o', |
| 28 | color='b', |
| 29 | markersize=5, |
| 30 | label="expected B", |
| 31 | markerfacecolor="white") |
| 32 | pylab.spy(C, |
| 33 | marker='o', |
| 34 | color='g', |
| 35 | markersize=5, |
| 36 | label="expected C", |
| 37 | markerfacecolor="white") |
| 38 | pylab.spy(D, |
| 39 | marker='o', |
| 40 | color='y', |
| 41 | markersize=5, |
| 42 | label="expected D", |
| 43 | markerfacecolor="white") |
| 44 | pylab.spy(I, |
| 45 | marker='o', |
| 46 | color='k', |
| 47 | markersize=5, |
| 48 | label="expected I", |
| 49 | markerfacecolor="white") |
| 50 | pylab.spy(actual, marker='o', color='k', markersize=2, label="actual") |
| 51 | |
| 52 | pylab.hlines(errors, |
| 53 | 0, |
| 54 | A.shape[1], |
| 55 | color='gray', |
| 56 | linestyle='-', |
| 57 | label="offending rows") |
| 58 | |
| 59 | pylab.title("Debug view of fatrop interface structure detection") |
| 60 | pylab.legend() |
| 61 | pylab.show() |