blob: 2f7fa92f47d089cbf92493fa9f96016b22bccaee [file] [log] [blame]
Austin Schuh7fa65212024-08-18 17:20:58 -07001import casadi
2import 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}
8root = "./"
9
10actual = casadi.Sparsity.from_file(root + "debug_fatrop_actual.mtx")
11
12A = casadi.Sparsity.from_file(root + "debug_fatrop_A.mtx")
13B = casadi.Sparsity.from_file(root + "debug_fatrop_B.mtx")
14C = casadi.Sparsity.from_file(root + "debug_fatrop_C.mtx")
15D = casadi.Sparsity.from_file(root + "debug_fatrop_D.mtx")
16I = casadi.Sparsity.from_file(root + "debug_fatrop_I.mtx")
17errors = casadi.Sparsity.from_file(root + "debug_fatrop_errors.mtx").row()
18
19pylab.figure()
20pylab.spy(A,
21 marker='o',
22 color='r',
23 markersize=5,
24 label="expected A",
25 markerfacecolor="white")
26pylab.spy(B,
27 marker='o',
28 color='b',
29 markersize=5,
30 label="expected B",
31 markerfacecolor="white")
32pylab.spy(C,
33 marker='o',
34 color='g',
35 markersize=5,
36 label="expected C",
37 markerfacecolor="white")
38pylab.spy(D,
39 marker='o',
40 color='y',
41 markersize=5,
42 label="expected D",
43 markerfacecolor="white")
44pylab.spy(I,
45 marker='o',
46 color='k',
47 markersize=5,
48 label="expected I",
49 markerfacecolor="white")
50pylab.spy(actual, marker='o', color='k', markersize=2, label="actual")
51
52pylab.hlines(errors,
53 0,
54 A.shape[1],
55 color='gray',
56 linestyle='-',
57 label="offending rows")
58
59pylab.title("Debug view of fatrop interface structure detection")
60pylab.legend()
61pylab.show()