{"action":"created","comment":{"url":"https://api.github.com/repos/EconForge/Dolo.jl/pulls/comments/158257968","pull_request_review_id":85038702,"id":158257968,"diff_hunk":"@@ -68,45 +74,49 @@ function time_iteration_direct(model, dprocess::AbstractDiscretizedProcess,\n     ###############################   Iteration loop\n     n_h = length(model.symbols[:expectations])\n \n+    # temporary vars\n+    E_f = DRStore(Point{n_h}, [length(e) for e in ds0.data])\n+    d_E_f = deepcopy(E_f.data[1])\n+    S = deepcopy(s)\n+    X = deepcopy(ds0.data[1])\n+\n \n     while it<maxit && err>tol_η\n \n         it += 1\n \n         tic()\n \n-        E_f = [zeros(Point{n_h},N) for i=1:number_of_smooth_drs(dprocess)]\n+        set_values!(dr, [ds0.data...])","path":"src/algos/time_iteration_direct.jl","position":73,"original_position":73,"commit_id":"c3fa10287957836ff98d937b8a7eef5c1bb04077","original_commit_id":"c3fa10287957836ff98d937b8a7eef5c1bb04077","user":{"login":"albop","id":276777,"avatar_url":"https://avatars2.githubusercontent.com/u/276777?v=4","gravatar_id":"","url":"https://api.github.com/users/albop","html_url":"https://github.com/albop","followers_url":"https://api.github.com/users/albop/followers","following_url":"https://api.github.com/users/albop/following{/other_user}","gists_url":"https://api.github.com/users/albop/gists{/gist_id}","starred_url":"https://api.github.com/users/albop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/albop/subscriptions","organizations_url":"https://api.github.com/users/albop/orgs","repos_url":"https://api.github.com/users/albop/repos","events_url":"https://api.github.com/users/albop/events{/privacy}","received_events_url":"https://api.github.com/users/albop/received_events","type":"User","site_admin":false},"body":"For now I don't think we have any penalty. The elements of `[ds0.data...]` should be correctly inferred. `set_values!` itself  could be improved to take a tuple as argument. I doubt unrolling would provide much benefit, as the amount of code within the loop is quite big.","created_at":"2017-12-21T11:46:57Z","updated_at":"2017-12-21T11:46:57Z","html_url":"https://github.com/EconForge/Dolo.jl/pull/126#discussion_r158257968","pull_request_url":"https://api.github.com/repos/EconForge/Dolo.jl/pulls/126","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/EconForge/Dolo.jl/pulls/comments/158257968"},"html":{"href":"https://github.com/EconForge/Dolo.jl/pull/126#discussion_r158257968"},"pull_request":{"href":"https://api.github.com/repos/EconForge/Dolo.jl/pulls/126"}},"in_reply_to_id":158183631},"pull_request":{"url":"https://api.github.com/repos/EconForge/Dolo.jl/pulls/126","id":159496177,"html_url":"https://github.com/EconForge/Dolo.jl/pull/126","diff_url":"https://github.com/EconForge/Dolo.jl/pull/126.diff","patch_url":"https://github.com/EconForge/Dolo.jl/pull/126.patch","issue_url":"https://api.github.com/repos/EconForge/Dolo.jl/issues/126","number":126,"state":"open","locked":false,"title":"ENH: special object for decision rules.","user":{"login":"albop","id":276777,"avatar_url":"https://avatars2.githubusercontent.com/u/276777?v=4","gravatar_id":"","url":"https://api.github.com/users/albop","html_url":"https://github.com/albop","followers_url":"https://api.github.com/users/albop/followers","following_url":"https://api.github.com/users/albop/following{/other_user}","gists_url":"https://api.github.com/users/albop/gists{/gist_id}","starred_url":"https://api.github.com/users/albop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/albop/subscriptions","organizations_url":"https://api.github.com/users/albop/orgs","repos_url":"https://api.github.com/users/albop/repos","events_url":"https://api.github.com/users/albop/events{/privacy}","received_events_url":"https://api.github.com/users/albop/received_events","type":"User","site_admin":false},"body":"@sglyon : here is an attempt to resolve issue #125 .\r\nOne can do:\r\n```\r\ndrs = DRStore([rand(32) for i=1:3])\r\ndrs.data :: Tuple{Vector{Float64}}\r\ndrs.flat :: Vector{Float64}\r\nmaximum(abs, cat(1, drs.data...)- drs.flat) # -> 0\r\ndrs.flat[10] = 1.2\r\nmaximum(abs, cat(1, drs.data...)- drs.flat) # -> 0\r\n```\r\n\r\nThe fields `drs.data`  can contain the decision rule as we store it right now (almost, it is a tuple instead of a vector so that it is immutable) and `drs.flat`  represents it in all states as one single vector. Trick is both fields refer to the same part of memory and are always synchronized. I believe there is no memory cleaning problem but that would require careful thinking.\r\n\r\nI have hesitated as to how `drs` itself should behave. In the end, I implemented the behaviour from before (so `drs[1]` returns a vector) but didn't use it. The reason is to backward compatibility, but I ended up not using `drs` directly, using instead `drs.data` most of the time.\r\nThe alternative would `drs` to behave as `drs.flat`, at which case it could derive from AbstractVector. I can see how we would get some operations for free, but haven't found one very good reason. An idea would be to do `drs[i]`  for flat indexing and `drs[G(i)]` or smthg like that for group indexing.\r\n\r\nSo far I have only applied it to `time_iteration_direct` (memory 350->20) and would like some early feedback before generalizing it. Any thought ?\r\n\r\n","created_at":"2017-12-20T19:13:40Z","updated_at":"2017-12-21T11:46:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b817cf06b215934902b074a2d5a5924dc4085267","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/EconForge/Dolo.jl/pulls/126/commits","review_comments_url":"https://api.github.com/repos/EconForge/Dolo.jl/pulls/126/comments","review_comment_url":"https://api.github.com/repos/EconForge/Dolo.jl/pulls/comments{/number}","comments_url":"https://api.github.com/repos/EconForge/Dolo.jl/issues/126/comments","statuses_url":"https://api.github.com/repos/EconForge/Dolo.jl/statuses/c3fa10287957836ff98d937b8a7eef5c1bb04077","head":{"label":"EconForge:albop/inplace","ref":"albop/inplace","sha":"c3fa10287957836ff98d937b8a7eef5c1bb04077","user":{"login":"EconForge","id":5486828,"avatar_url":"https://avatars1.githubusercontent.com/u/5486828?v=4","gravatar_id":"","url":"https://api.github.com/users/EconForge","html_url":"https://github.com/EconForge","followers_url":"https://api.github.com/users/EconForge/followers","following_url":"https://api.github.com/users/EconForge/following{/other_user}","gists_url":"https://api.github.com/users/EconForge/gists{/gist_id}","starred_url":"https://api.github.com/users/EconForge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/EconForge/subscriptions","organizations_url":"https://api.github.com/users/EconForge/orgs","repos_url":"https://api.github.com/users/EconForge/repos","events_url":"https://api.github.com/users/EconForge/events{/privacy}","received_events_url":"https://api.github.com/users/EconForge/received_events","type":"Organization","site_admin":false},"repo":{"id":54569812,"name":"Dolo.jl","full_name":"EconForge/Dolo.jl","owner":{"login":"EconForge","id":5486828,"avatar_url":"https://avatars1.githubusercontent.com/u/5486828?v=4","gravatar_id":"","url":"https://api.github.com/users/EconForge","html_url":"https://github.com/EconForge","followers_url":"https://api.github.com/users/EconForge/followers","following_url":"https://api.github.com/users/EconForge/following{/other_user}","gists_url":"https://api.github.com/users/EconForge/gists{/gist_id}","starred_url":"https://api.github.com/users/EconForge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/EconForge/subscriptions","organizations_url":"https://api.github.com/users/EconForge/orgs","repos_url":"https://api.github.com/users/EconForge/repos","events_url":"https://api.github.com/users/EconForge/events{/privacy}","received_events_url":"https://api.github.com/users/EconForge/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/EconForge/Dolo.jl","description":"Economic modeling in Julia","fork":false,"url":"https://api.github.com/repos/EconForge/Dolo.jl","forks_url":"https://api.github.com/repos/EconForge/Dolo.jl/forks","keys_url":"https://api.github.com/repos/EconForge/Dolo.jl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/EconForge/Dolo.jl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/EconForge/Dolo.jl/teams","hooks_url":"https://api.github.com/repos/EconForge/Dolo.jl/hooks","issue_events_url":"https://api.github.com/repos/EconForge/Dolo.jl/issues/events{/number}","events_url":"https://api.github.com/repos/EconForge/Dolo.jl/events","assignees_url":"https://api.github.com/repos/EconForge/Dolo.jl/assignees{/user}","branches_url":"https://api.github.com/repos/EconForge/Dolo.jl/branches{/branch}","tags_url":"https://api.github.com/repos/EconForge/Dolo.jl/tags","blobs_url":"https://api.github.com/repos/EconForge/Dolo.jl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/EconForge/Dolo.jl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/EconForge/Dolo.jl/git/refs{/sha}","trees_url":"https://api.github.com/repos/EconForge/Dolo.jl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/EconForge/Dolo.jl/statuses/{sha}","languages_url":"https://api.github.com/repos/EconForge/Dolo.jl/languages","stargazers_url":"https://api.github.com/repos/EconForge/Dolo.jl/stargazers","contributors_url":"https://api.github.com/repos/EconForge/Dolo.jl/contributors","subscribers_url":"https://api.github.com/repos/EconForge/Dolo.jl/subscribers","subscription_url":"https://api.github.com/repos/EconForge/Dolo.jl/subscription","commits_url":"https://api.github.com/repos/EconForge/Dolo.jl/commits{/sha}","git_commits_url":"https://api.github.com/repos/EconForge/Dolo.jl/git/commits{/sha}","comments_url":"https://api.github.com/repos/EconForge/Dolo.jl/comments{/number}","issue_comment_url":"https://api.github.com/repos/EconForge/Dolo.jl/issues/comments{/number}","contents_url":"https://api.github.com/repos/EconForge/Dolo.jl/contents/{+path}","compare_url":"https://api.github.com/repos/EconForge/Dolo.jl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/EconForge/Dolo.jl/merges","archive_url":"https://api.github.com/repos/EconForge/Dolo.jl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/EconForge/Dolo.jl/downloads","issues_url":"https://api.github.com/repos/EconForge/Dolo.jl/issues{/number}","pulls_url":"https://api.github.com/repos/EconForge/Dolo.jl/pulls{/number}","milestones_url":"https://api.github.com/repos/EconForge/Dolo.jl/milestones{/number}","notifications_url":"https://api.github.com/repos/EconForge/Dolo.jl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/EconForge/Dolo.jl/labels{/name}","releases_url":"https://api.github.com/repos/EconForge/Dolo.jl/releases{/id}","deployments_url":"https://api.github.com/repos/EconForge/Dolo.jl/deployments","created_at":"2016-03-23T15:10:55Z","updated_at":"2017-12-09T09:35:57Z","pushed_at":"2017-12-20T19:13:41Z","git_url":"git://github.com/EconForge/Dolo.jl.git","ssh_url":"git@github.com:EconForge/Dolo.jl.git","clone_url":"https://github.com/EconForge/Dolo.jl.git","svn_url":"https://github.com/EconForge/Dolo.jl","homepage":null,"size":901,"stargazers_count":18,"watchers_count":18,"language":"Julia","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":10,"mirror_url":null,"archived":false,"open_issues_count":17,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":10,"open_issues":17,"watchers":18,"default_branch":"master"}},"base":{"label":"EconForge:master","ref":"master","sha":"7ef705b432ad037fdb9c0db9c8755c0023026443","user":{"login":"EconForge","id":5486828,"avatar_url":"https://avatars1.githubusercontent.com/u/5486828?v=4","gravatar_id":"","url":"https://api.github.com/users/EconForge","html_url":"https://github.com/EconForge","followers_url":"https://api.github.com/users/EconForge/followers","following_url":"https://api.github.com/users/EconForge/following{/other_user}","gists_url":"https://api.github.com/users/EconForge/gists{/gist_id}","starred_url":"https://api.github.com/users/EconForge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/EconForge/subscriptions","organizations_url":"https://api.github.com/users/EconForge/orgs","repos_url":"https://api.github.com/users/EconForge/repos","events_url":"https://api.github.com/users/EconForge/events{/privacy}","received_events_url":"https://api.github.com/users/EconForge/received_events","type":"Organization","site_admin":false},"repo":{"id":54569812,"name":"Dolo.jl","full_name":"EconForge/Dolo.jl","owner":{"login":"EconForge","id":5486828,"avatar_url":"https://avatars1.githubusercontent.com/u/5486828?v=4","gravatar_id":"","url":"https://api.github.com/users/EconForge","html_url":"https://github.com/EconForge","followers_url":"https://api.github.com/users/EconForge/followers","following_url":"https://api.github.com/users/EconForge/following{/other_user}","gists_url":"https://api.github.com/users/EconForge/gists{/gist_id}","starred_url":"https://api.github.com/users/EconForge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/EconForge/subscriptions","organizations_url":"https://api.github.com/users/EconForge/orgs","repos_url":"https://api.github.com/users/EconForge/repos","events_url":"https://api.github.com/users/EconForge/events{/privacy}","received_events_url":"https://api.github.com/users/EconForge/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/EconForge/Dolo.jl","description":"Economic modeling in Julia","fork":false,"url":"https://api.github.com/repos/EconForge/Dolo.jl","forks_url":"https://api.github.com/repos/EconForge/Dolo.jl/forks","keys_url":"https://api.github.com/repos/EconForge/Dolo.jl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/EconForge/Dolo.jl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/EconForge/Dolo.jl/teams","hooks_url":"https://api.github.com/repos/EconForge/Dolo.jl/hooks","issue_events_url":"https://api.github.com/repos/EconForge/Dolo.jl/issues/events{/number}","events_url":"https://api.github.com/repos/EconForge/Dolo.jl/events","assignees_url":"https://api.github.com/repos/EconForge/Dolo.jl/assignees{/user}","branches_url":"https://api.github.com/repos/EconForge/Dolo.jl/branches{/branch}","tags_url":"https://api.github.com/repos/EconForge/Dolo.jl/tags","blobs_url":"https://api.github.com/repos/EconForge/Dolo.jl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/EconForge/Dolo.jl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/EconForge/Dolo.jl/git/refs{/sha}","trees_url":"https://api.github.com/repos/EconForge/Dolo.jl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/EconForge/Dolo.jl/statuses/{sha}","languages_url":"https://api.github.com/repos/EconForge/Dolo.jl/languages","stargazers_url":"https://api.github.com/repos/EconForge/Dolo.jl/stargazers","contributors_url":"https://api.github.com/repos/EconForge/Dolo.jl/contributors","subscribers_url":"https://api.github.com/repos/EconForge/Dolo.jl/subscribers","subscription_url":"https://api.github.com/repos/EconForge/Dolo.jl/subscription","commits_url":"https://api.github.com/repos/EconForge/Dolo.jl/commits{/sha}","git_commits_url":"https://api.github.com/repos/EconForge/Dolo.jl/git/commits{/sha}","comments_url":"https://api.github.com/repos/EconForge/Dolo.jl/comments{/number}","issue_comment_url":"https://api.github.com/repos/EconForge/Dolo.jl/issues/comments{/number}","contents_url":"https://api.github.com/repos/EconForge/Dolo.jl/contents/{+path}","compare_url":"https://api.github.com/repos/EconForge/Dolo.jl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/EconForge/Dolo.jl/merges","archive_url":"https://api.github.com/repos/EconForge/Dolo.jl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/EconForge/Dolo.jl/downloads","issues_url":"https://api.github.com/repos/EconForge/Dolo.jl/issues{/number}","pulls_url":"https://api.github.com/repos/EconForge/Dolo.jl/pulls{/number}","milestones_url":"https://api.github.com/repos/EconForge/Dolo.jl/milestones{/number}","notifications_url":"https://api.github.com/repos/EconForge/Dolo.jl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/EconForge/Dolo.jl/labels{/name}","releases_url":"https://api.github.com/repos/EconForge/Dolo.jl/releases{/id}","deployments_url":"https://api.github.com/repos/EconForge/Dolo.jl/deployments","created_at":"2016-03-23T15:10:55Z","updated_at":"2017-12-09T09:35:57Z","pushed_at":"2017-12-20T19:13:41Z","git_url":"git://github.com/EconForge/Dolo.jl.git","ssh_url":"git@github.com:EconForge/Dolo.jl.git","clone_url":"https://github.com/EconForge/Dolo.jl.git","svn_url":"https://github.com/EconForge/Dolo.jl","homepage":null,"size":901,"stargazers_count":18,"watchers_count":18,"language":"Julia","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":10,"mirror_url":null,"archived":false,"open_issues_count":17,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":10,"open_issues":17,"watchers":18,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/EconForge/Dolo.jl/pulls/126"},"html":{"href":"https://github.com/EconForge/Dolo.jl/pull/126"},"issue":{"href":"https://api.github.com/repos/EconForge/Dolo.jl/issues/126"},"comments":{"href":"https://api.github.com/repos/EconForge/Dolo.jl/issues/126/comments"},"review_comments":{"href":"https://api.github.com/repos/EconForge/Dolo.jl/pulls/126/comments"},"review_comment":{"href":"https://api.github.com/repos/EconForge/Dolo.jl/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/EconForge/Dolo.jl/pulls/126/commits"},"statuses":{"href":"https://api.github.com/repos/EconForge/Dolo.jl/statuses/c3fa10287957836ff98d937b8a7eef5c1bb04077"}},"author_association":"OWNER"}}
{"actor":{"display_login":"albop"}}