{"action":"created","issue":{"url":"https://api.github.com/repos/QuantEcon/QuantEcon.py/issues/111","labels_url":"https://api.github.com/repos/QuantEcon/QuantEcon.py/issues/111/labels{/name}","comments_url":"https://api.github.com/repos/QuantEcon/QuantEcon.py/issues/111/comments","events_url":"https://api.github.com/repos/QuantEcon/QuantEcon.py/issues/111/events","html_url":"https://github.com/QuantEcon/QuantEcon.py/issues/111","id":55738673,"number":111,"title":"Refactor simulation methods in the IVP module","user":{"login":"davidrpugh","id":2219562,"avatar_url":"https://avatars.githubusercontent.com/u/2219562?v=3","gravatar_id":"","url":"https://api.github.com/users/davidrpugh","html_url":"https://github.com/davidrpugh","followers_url":"https://api.github.com/users/davidrpugh/followers","following_url":"https://api.github.com/users/davidrpugh/following{/other_user}","gists_url":"https://api.github.com/users/davidrpugh/gists{/gist_id}","starred_url":"https://api.github.com/users/davidrpugh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidrpugh/subscriptions","organizations_url":"https://api.github.com/users/davidrpugh/orgs","repos_url":"https://api.github.com/users/davidrpugh/repos","events_url":"https://api.github.com/users/davidrpugh/events{/privacy}","received_events_url":"https://api.github.com/users/davidrpugh/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-01-28T10:29:06Z","updated_at":"2015-01-28T22:16:52Z","closed_at":null,"body":"All,\r\n\r\nI would like to re-factor the simulation loops (i.e, `_integrate_fixed_trajectory` and `integrate_variable_trajectory`) in the `quantecon.ivp` module in order to speed them up. However I am not exactly sure how to go about it. Would this be a good use case for Numba? If so are there examples in the code base already that I could use as a guide?"},"comment":{"url":"https://api.github.com/repos/QuantEcon/QuantEcon.py/issues/comments/71928412","html_url":"https://github.com/QuantEcon/QuantEcon.py/issues/111#issuecomment-71928412","issue_url":"https://api.github.com/repos/QuantEcon/QuantEcon.py/issues/111","id":71928412,"user":{"login":"spencerlyon2","id":1001948,"avatar_url":"https://avatars.githubusercontent.com/u/1001948?v=3","gravatar_id":"","url":"https://api.github.com/users/spencerlyon2","html_url":"https://github.com/spencerlyon2","followers_url":"https://api.github.com/users/spencerlyon2/followers","following_url":"https://api.github.com/users/spencerlyon2/following{/other_user}","gists_url":"https://api.github.com/users/spencerlyon2/gists{/gist_id}","starred_url":"https://api.github.com/users/spencerlyon2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spencerlyon2/subscriptions","organizations_url":"https://api.github.com/users/spencerlyon2/orgs","repos_url":"https://api.github.com/users/spencerlyon2/repos","events_url":"https://api.github.com/users/spencerlyon2/events{/privacy}","received_events_url":"https://api.github.com/users/spencerlyon2/received_events","type":"User","site_admin":false},"created_at":"2015-01-28T22:16:52Z","updated_at":"2015-01-28T22:16:52Z","body":"I think that some benchmarks or line profiling could help so we know exactly where the routines are spending their time. \r\n\r\nAlso I'd say it would be an improvement if we could pre-allocate in `_integrate_fixed_trajectory`.\r\n\r\nIf allocation really is the issue in `_integrate_variable_trajectory` maybe we could allocate in chunks. This is a rough sketch of the idea:\r\n\r\n* start out with an array with space for 50 iterations\r\n* after 50 if we aren't done, reallocate an array with space for 70 (20 more) and fill in the first 50 with data we already computed\r\n* re-evaluate after 70 again and grow the array a bit more.\r\n\r\nThis might be better, or it might well be worse. We would almost certainly allocate \"too much\" space in that we would preallocate at some point and converge before that allocation is all used up.\r\n\r\nAgain, some benchmarks and profiling would probably help answer these questions."}}