Skip to content

Commit 411be6e

Browse files
committed
example progress
1 parent fd6210e commit 411be6e

File tree

1 file changed

+42
-16
lines changed

1 file changed

+42
-16
lines changed

examples/swifty.py

Lines changed: 42 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -200,37 +200,63 @@ def rand_q():
200200

201201

202202
def rand_v():
203-
# return randn(0, 1, (6,))
204-
return np.array([0.1, 0.1, 0.1, 0.0, 0.0, 0.0])
203+
v = randn(0, 1, (3,))
204+
v = v / np.linalg.norm(v)
205205

206+
return np.r_[v, 0, 0, 0]
207+
# return np.array([0.1, 0.1, 0.1, 0.0, 0.0, 0.0])
206208

207-
for i in range(100000):
209+
210+
x = []
211+
y = []
212+
213+
for i in range(10000000):
208214

209215
q = rand_q()
210216
v = rand_v()
211217

212218
J = r.jacob0(q)
213-
cond = np.linalg.cond(J[:3, :])
219+
Jt = J[:3, :]
220+
# H = r.hessian0(q)
221+
# Ht = H[:3, :, :]
222+
223+
q_n = [10000, 0]
224+
q_m = [10000, 0]
225+
226+
# cond = np.linalg.cond(J[:3, :])
214227
m = r.manipulability(J=J, axes='trans')
228+
# infn = np.linalg.norm(Jt, 2)
229+
psi = (np.cbrt(np.linalg.det(Jt @ np.transpose(Jt)))) / \
230+
(np.trace(Jt @ np.transpose(Jt)) / 3)
231+
232+
for j in range(1000):
233+
qd = np.linalg.pinv(J) @ v
215234

216-
qd = np.linalg.pinv(J) @ v
235+
if np.max(qd) > q_m[1]:
236+
q_m[1] = np.max(qd)
217237

218-
print(np.linalg.norm(np.abs(qd)))
238+
if np.min(qd) < q_m[0]:
239+
q_m[0] = np.min(qd)
219240

220-
qd_norm = np.linalg.norm(np.abs(qd))
241+
if np.linalg.norm(qd) > q_n[1]:
242+
q_n[1] = np.linalg.norm(qd)
243+
elif np.linalg.norm(qd) < q_n[0]:
244+
q_n[0] = np.linalg.norm(qd)
221245

246+
# # ax.plot(m, np.log10(cond), 'o', color='black')
247+
# ax.plot(m, infn, 'o', color='black')
248+
# # ax.plot(1, 0.002, 'o', color='black')
222249

223-
# if cond > 1000:
224-
# print(np.round(q, 2), np.round(cond), np.round(r.manipulability(q), 3))
250+
x.append(psi)
251+
y.append(np.log10(q_m[1]))
252+
# y.append(psi)
225253

226-
# ax.plot(m, np.log10(cond), 'o', color='black')
227-
ax.plot(m, np.log10(qd_norm), 'o', color='black')
228-
# ax.plot(1, 0.002, 'o', color='black')
229-
plt.pause(0.001)
254+
# ax.plot(m, np.log10(q_m[1]), 'o', color='black')
230255

231-
# if m > 3 and cond > 30:
232-
# print(np.round(q, 2), np.round(cond), np.round(m, 3))
256+
if len(x) % 100 == 0:
257+
ax.hist2d(x, y, bins=100)
258+
plt.pause(0.001)
233259

234260

235261
plt.ioff()
236-
plt.show()
262+
plt.show()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy