Title: ecos crash on a very sparse problem · Issue #48 · embotech/ecos-python · GitHub
Open Graph Title: ecos crash on a very sparse problem · Issue #48 · embotech/ecos-python
X Title: ecos crash on a very sparse problem · Issue #48 · embotech/ecos-python
Description: The code below reproduces a non-deterministic bug which causes ecos to crash with the following message, on both Windows (python 3.10) and Gentoo Linux (python 3.8). Despite using the same inputs (by setting numpy's seed), the crash occu...
Open Graph Description: The code below reproduces a non-deterministic bug which causes ecos to crash with the following message, on both Windows (python 3.10) and Gentoo Linux (python 3.8). Despite using the same inputs (...
X Description: The code below reproduces a non-deterministic bug which causes ecos to crash with the following message, on both Windows (python 3.10) and Gentoo Linux (python 3.8). Despite using the same inputs (...
Opengraph URL: https://github.com/embotech/ecos-python/issues/48
X: @github
Domain: github.com
IPv4 address: 140.82.112.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ecos crash on a very sparse problem","articleBody":"The code below reproduces a non-deterministic bug which causes `ecos` to crash with the following message, on both Windows (python 3.10) and Gentoo Linux (python 3.8). Despite using the same inputs (by setting numpy's seed), the crash occurs after a varying number of trials. The code uses the correct parameters to trigger a crash 100% of the time (on my machine).\r\n\r\n```\r\nRuntimeError: Internal problem occurred in ECOS while setting up the problem.\r\nPlease send a bug report with data to Alexander Domahidi.\r\nEmail: domahidi@control.ee.ethz.ch\r\n```\r\n\r\nThe code:\r\n```\r\nimport numpy as np\r\nimport time\r\nimport math\r\nimport scipy\r\nimport qpsolvers\r\n\r\nnp.random.seed(1)\r\n\r\ndef relu_inv(x): d=np.empty_like(x); d[:]=x[:]; d[x[:]\u003c=0]=np.nan; return d\r\ndef relu(x): return (x>0)*x\r\ndef invH(x): return math.sqrt(2)*scipy.special.erfcinv(2*x)\r\n\r\nsolver = \"ecos\"\r\ndef optimize_fixed_points(X, H, threshold=0):\r\n (N, P) = X.shape\r\n assert np.all(H.shape == (N, P))\r\n \r\n # Solve quadratic problem for each row\r\n W = np.empty((N, N)); W[:] = np.nan\r\n Q = np.eye(N-1)\r\n found = 0\r\n for ii in range(N):\r\n I = np.concatenate((np.array(range(ii),dtype=int),np.array(range(ii+1,N),dtype=int)))\r\n I = I.reshape(I.shape[0],1)\r\n J = np.nonzero(np.isfinite(H[ii,:])*1)[0]\r\n coJ = np.nonzero(np.isnan(H[ii,:])*1)[0]\r\n assert len(J)+len(coJ) == P\r\n c = np.zeros(I.shape[0])\r\n lb = None\r\n A = X[I,J].T\r\n b = H[ii,J]\r\n G = X[I,coJ].T\r\n z = np.ones(G.shape[0])*threshold\r\n w = qpsolvers.solve_qp(Q, c, G, z, A, b, lb, solver=solver, abstol=1e-8, reltol=1e-6)\r\n if w is not None:\r\n assert np.all(np.isfinite(w))\r\n assert np.linalg.norm(A@w-b)\u003c1e-6\r\n assert np.all(G@w\u003cz+1e-6)\r\n W[ii,ii] = 0\r\n W[ii,I.T] = w\r\n found += 1\r\n return (W, found)\r\n\r\n# Problem parameters\r\nN = 128; f = 1/64; K = np.round(f*N); P = 1\r\nprint(\"N=%d K=%d P=%d\" % (N,K,P))\r\n\r\nfor i in range(100):\r\n tictocT = time.time()\r\n # Create patterns\r\n X = relu(np.random.randn(N, P) - invH(f))\r\n H = relu_inv(X)\r\n (W, nfound) = optimize_fixed_points(X, H)\r\n d = X - relu(W@X)\r\n assert np.linalg.norm(d[np.isfinite(d[:])]) \u003c 1e-8, \"Fixed-points violation: %1.1e\"%np.linalg.norm(d[np.isfinite(d[:])])\r\n assert nfound\u003cN or np.all(np.isfinite(W))\r\n print(\"Done #%d (found %d/%d, took %1.1fsec).\"%(i, nfound, N, time.time()-tictocT))\r\n```","author":{"url":"https://github.com/uricohen","@type":"Person","name":"uricohen"},"datePublished":"2023-01-31T09:03:55Z","url":"https://github.com/embotech/ecos-python/issues/48"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:e92a9fb4-c3b1-7dee-1b6f-4ff6f0fb2607 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E408:2A0A85:2C72C:3CB89:6B05CE01 |
| html-safe-nonce | 6a13ab7c2719ce40bfd50f3e7f6d4d7b2b5580d0fd9d36d389a92b8d2ba92488 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNDA4OjJBMEE4NToyQzcyQzozQ0I4OTo2QjA1Q0UwMSIsInZpc2l0b3JfaWQiOiI1MzQxMjg2OTE1MjUxNzUyNDQ5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 37257dc726978453d08b3104e6bf42066384a2f689a8347fb5ac2ca2fcb9bcaf |
| hovercard-subject-tag | issue:1563916324 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/embotech/ecos-python/48/issue_layout |
| twitter:image | https://opengraph.githubassets.com/43ceaa5d04fee106e110f83910844e85a896b1bb279fc3c53d8ee07578a68c43/embotech/ecos-python/issues/48 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/43ceaa5d04fee106e110f83910844e85a896b1bb279fc3c53d8ee07578a68c43/embotech/ecos-python/issues/48 |
| og:image:alt | The code below reproduces a non-deterministic bug which causes ecos to crash with the following message, on both Windows (python 3.10) and Gentoo Linux (python 3.8). Despite using the same inputs (... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | uricohen |
| hostname | github.com |
| expected-hostname | github.com |
| None | 08d6d51500e13cdaf71a9aad37c03e883f1143f9325056e77a14fa0d06d5bf64 |
| turbo-cache-control | no-preview |
| go-import | github.com/embotech/ecos-python git https://github.com/embotech/ecos-python.git |
| octolytics-dimension-user_id | 9467034 |
| octolytics-dimension-user_login | embotech |
| octolytics-dimension-repository_id | 26031421 |
| octolytics-dimension-repository_nwo | embotech/ecos-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 26031421 |
| octolytics-dimension-repository_network_root_nwo | embotech/ecos-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 839b69d5acfb3181bc844f20b9848f74b957add3 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width