Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instance attributes #9

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions benchmarks/run_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
LOAD_BLASFEO_RES = True
numpy_res_file = 'riccati_benchmark_numpy.json'
LOAD_NUMPY_RES = True
numpy_blasfeo_res_file = 'riccati_benchmark_numpy_blasfeo.json'
LOAD_NUMPY_BLASFEO_RES = True
julia_res_file = 'riccati_benchmark_julia.json'
LOAD_JULIA_RES = True

Expand Down Expand Up @@ -89,6 +91,13 @@
plt.semilogy(2*AVG_CPU_TIME_BLASFEO[:,1], AVG_CPU_TIME_BLASFEO[:,0])
legend.append('NumPy')

if LOAD_NUMPY_BLASFEO_RES:
with open(numpy_blasfeo_res_file) as res:
AVG_CPU_TIME_BLASFEO = json.load(res)
AVG_CPU_TIME_BLASFEO = np.array(AVG_CPU_TIME_BLASFEO)
plt.semilogy(2*AVG_CPU_TIME_BLASFEO[:,1], AVG_CPU_TIME_BLASFEO[:,0])
legend.append('NumPy + BLASFEO')

if LOAD_JULIA_RES:
with open(julia_res_file) as res:
AVG_CPU_TIME_BLASFEO = json.load(res)
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/run_benchmark_numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
NREP_medium = 100
NREP_large = 10
AVG_CPU_TIME = []
res_file = 'riccati_benchmark_numpy.json'
res_file = 'riccati_benchmark_numpy_blasfeo.json'
RUN = True
UPDATE_res = True

Expand Down
1 change: 1 addition & 0 deletions examples/laparser/laparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def main() -> int:
B[1,1] = 1.0

C: pmat = pmat(nx, nx)
D: pmat = pmat(nx, nx)

pparse('C = A - A.T \ (B * D).T')

Expand Down
16 changes: 8 additions & 8 deletions examples/riccati_example/riccati.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@
N: dims = 5

class qp_data:
A: List = plist(pmat, sizes)
B: List = plist(pmat, sizes)
Q: List = plist(pmat, sizes)
R: List = plist(pmat, sizes)
P: List = plist(pmat, sizes)

fact: List = plist(pmat, sizes)
def __init__(self) -> None:
self.A: List = plist(pmat, sizes)
self.B: List = plist(pmat, sizes)
self.Q: List = plist(pmat, sizes)
self.R: List = plist(pmat, sizes)
self.P: List = plist(pmat, sizes)

def factorize(self) -> None:
M: pmat = pmat(nxu, nxu)
Expand All @@ -39,12 +38,13 @@ def factorize(self) -> None:
pmt_gemm_nn(BAtP, BA, M, M)
pmat_fill(L, 0.0)
pmt_potrf(M, L)
pmat_print(L)

Mxx[0:nx, 0:nx] = L[nu:nu+nx, nu:nu+nx]

pmat_fill(self.P[N-i-1], 0.0)
pmt_gemm_nt(Mxx, Mxx, self.P[N-i-1], self.P[N-i-1])
pmat_print(self.P[N-i-1])
# pmat_print(self.P[N-i-1])

return

Expand Down
15 changes: 8 additions & 7 deletions examples/riccati_example/riccati_compact.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
N: dims = 5

class qp_data:
A: List = plist(pmat, sizes)
B: List = plist(pmat, sizes)
Q: List = plist(pmat, sizes)
R: List = plist(pmat, sizes)
P: List = plist(pmat, sizes)

fact: List = plist(pmat, sizes)
def __init__(self) -> None:
self.A: List = plist(pmat, sizes)
self.B: List = plist(pmat, sizes)
self.Q: List = plist(pmat, sizes)
self.R: List = plist(pmat, sizes)
self.P: List = plist(pmat, sizes)

self.fact: pmat = pmat(nx,nx)

def factorize(self) -> None:
Qk: pmat = pmat(nx, nx)
Expand Down
1 change: 0 additions & 1 deletion examples/riccati_example/riccati_mass_spring.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,5 @@ def main() -> int:
pmt_syrk_ln(w_nxu_nx, w_nxu_nx, RSQ, M)
pmt_potrf(M, M)
Lxx[0:nx,0:nx] = M[nu:nu+nx,nu:nu+nx]
# pmat_print(M)

return 0
17 changes: 8 additions & 9 deletions examples/riccati_example/riccati_mass_spring_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,20 @@

nm: dims = 4
nx: dims = 2*nm
# nx: dims = 2
# sizes: dimv = [[2,2], [2,2], [2,2], [2,2], [2,2]]
sizes: dimv = [[8,8], [8,8], [8,8], [8,8], [8,8]]
nu: dims = nm
nxu: dims = nx + nu
N: dims = 5

class qp_data:
A: List = plist(pmat, sizes)
B: List = plist(pmat, sizes)
Q: List = plist(pmat, sizes)
R: List = plist(pmat, sizes)
P: List = plist(pmat, sizes)

fact: List = plist(pmat, sizes)
def __init__(self) -> None:
self.A: List = plist(pmat, sizes)
self.B: List = plist(pmat, sizes)
self.Q: List = plist(pmat, sizes)
self.R: List = plist(pmat, sizes)
self.P: List = plist(pmat, sizes)

self.fact: List = plist(pmat, sizes)

def factorize(self) -> None:
M: pmat = pmat(nxu, nxu)
Expand Down
1 change: 1 addition & 0 deletions examples/riccati_example/riccati_numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
M[nu:nu+nx, nu:nu+nx] = Q
M = M + dot(BAtP, BA)
L = linalg.cholesky(M)
print('L:\n', L)
Mxx = L[nu:nu+nx, nu:nu+nx]
P = dot(transpose(Mxx), Mxx)
print('P:\n', P)
Expand Down
Loading