{"action":"created","comment":{"url":"https://api.github.com/repos/scipy/scipy/pulls/comments/36940933","id":36940933,"diff_hunk":"@@ -480,41 +558,82 @@ def solve(self):\n \n         # do the optimisation.\n         for nit in range(1, self.maxiter + 1):\n+        \n             if self.dither is not None:\n                 self.scale = self.random_number_generator.rand(\n                 ) * (self.dither[1] - self.dither[0]) + self.dither[0]\n-            for candidate in range(np.size(self.population, 0)):\n+                \n+            # brake the population to subpopulation depending on the size of the pool\n+            # determine number of sub-populations 'nsp', or number of \n+            # parallel evaluations, which is 'nsp + 1'\n+            # and the length of the reminder 'lenrem'\n+            nsp, lenrem = divmod(np.size(self.population, 0), self.pool.poolsize())\n+            \n+            itsp = 0\n+            # iterate among sub-populations\n+            # when self.pool.poolsize() == 1 the mutation is aggressive\n+            # when self.pool.poolsize() > 1 the mutation is quasi-aggressive\n+            while itsp <= nsp:\n+                # determine the length of the subpopulation\n+                lensp = self.pool.poolsize() if (itsp < nsp) else lenrem\n+\n+                # initialize list for all members (parameters) of the current subpopulation\n+                spparams = []\n+                # mutate parameters for the sub-population\n+                for candidate in xrange(lensp):\n+                    trial = self._mutate(candidate + self.pool.poolsize()*itsp)","path":"scipy/optimize/_differentialevolution.py","position":214,"original_position":214,"commit_id":"406fad0ee9b20a2d959e17382a89795ff4f60ddf","original_commit_id":"406fad0ee9b20a2d959e17382a89795ff4f60ddf","user":{"login":"andyfaff","id":702934,"avatar_url":"https://avatars.githubusercontent.com/u/702934?v=3","gravatar_id":"","url":"https://api.github.com/users/andyfaff","html_url":"https://github.com/andyfaff","followers_url":"https://api.github.com/users/andyfaff/followers","following_url":"https://api.github.com/users/andyfaff/following{/other_user}","gists_url":"https://api.github.com/users/andyfaff/gists{/gist_id}","starred_url":"https://api.github.com/users/andyfaff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andyfaff/subscriptions","organizations_url":"https://api.github.com/users/andyfaff/orgs","repos_url":"https://api.github.com/users/andyfaff/repos","events_url":"https://api.github.com/users/andyfaff/events{/privacy}","received_events_url":"https://api.github.com/users/andyfaff/received_events","type":"User","site_admin":false},"body":"This loop can probably be removed in its entirety (the following code may not be entirely correct):\r\n\r\n    # one could vectorize self._mutate, but I'm not sure if it's worth it.\r\n    trials = np.array(map(self._mutate, range(candidate, candidate + self.poolsize))\r\n\r\n    # ensure constraints\r\n    trials[trials < 0.] = np.random.random(np.count_nonzero(trials < 0))\r\n    trials[trials > 1.] = np.random.random(np.count_nonzero(trials > 1.))\r\n\r\n    # scale trials\r\n    params = self._scale_parameters(trials)\r\n    nfev += lensp\r\n\r\n    def unpacker(func):\r\n        def inner(x, args):\r\n            if not len(args):\r\n                return func(x)\r\n            else:\r\n                return func(x, *args)\r\n        return inner\r\n    \r\n    # params.shape = (lensp, self.num_params) and is iterable over the rows\r\n    spenergies = self.pool_map(unpacker(self.func), params, itertools.repeat(args, lensp))","created_at":"2015-08-13T04:54:24Z","updated_at":"2015-08-13T04:54:24Z","html_url":"https://github.com/scipy/scipy/pull/5141#discussion_r36940933","pull_request_url":"https://api.github.com/repos/scipy/scipy/pulls/5141","_links":{"self":{"href":"https://api.github.com/repos/scipy/scipy/pulls/comments/36940933"},"html":{"href":"https://github.com/scipy/scipy/pull/5141#discussion_r36940933"},"pull_request":{"href":"https://api.github.com/repos/scipy/scipy/pulls/5141"}}},"pull_request":{"url":"https://api.github.com/repos/scipy/scipy/pulls/5141","id":42167870,"html_url":"https://github.com/scipy/scipy/pull/5141","diff_url":"https://github.com/scipy/scipy/pull/5141.diff","patch_url":"https://github.com/scipy/scipy/pull/5141.patch","issue_url":"https://api.github.com/repos/scipy/scipy/issues/5141","number":5141,"state":"open","locked":false,"title":"ENH: Parallel differential evolution","user":{"login":"pavelponomarev","id":10148418,"avatar_url":"https://avatars.githubusercontent.com/u/10148418?v=3","gravatar_id":"","url":"https://api.github.com/users/pavelponomarev","html_url":"https://github.com/pavelponomarev","followers_url":"https://api.github.com/users/pavelponomarev/followers","following_url":"https://api.github.com/users/pavelponomarev/following{/other_user}","gists_url":"https://api.github.com/users/pavelponomarev/gists{/gist_id}","starred_url":"https://api.github.com/users/pavelponomarev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pavelponomarev/subscriptions","organizations_url":"https://api.github.com/users/pavelponomarev/orgs","repos_url":"https://api.github.com/users/pavelponomarev/repos","events_url":"https://api.github.com/users/pavelponomarev/events{/privacy}","received_events_url":"https://api.github.com/users/pavelponomarev/received_events","type":"User","site_admin":false},"body":"Adds pool objects and enables parallel execution of the objective functions within a subpopulation. Can significantly speedup DE algorithm especially when objective function is computationally-expensive. Related to #4864 and #5054.","created_at":"2015-08-11T19:30:53Z","updated_at":"2015-08-13T04:54:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f20ba1508a5a68876df22faad9deba415834a1f6","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/scipy/scipy/pulls/5141/commits","review_comments_url":"https://api.github.com/repos/scipy/scipy/pulls/5141/comments","review_comment_url":"https://api.github.com/repos/scipy/scipy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/scipy/scipy/issues/5141/comments","statuses_url":"https://api.github.com/repos/scipy/scipy/statuses/406fad0ee9b20a2d959e17382a89795ff4f60ddf","head":{"label":"pavelponomarev:parDE","ref":"parDE","sha":"406fad0ee9b20a2d959e17382a89795ff4f60ddf","user":{"login":"pavelponomarev","id":10148418,"avatar_url":"https://avatars.githubusercontent.com/u/10148418?v=3","gravatar_id":"","url":"https://api.github.com/users/pavelponomarev","html_url":"https://github.com/pavelponomarev","followers_url":"https://api.github.com/users/pavelponomarev/followers","following_url":"https://api.github.com/users/pavelponomarev/following{/other_user}","gists_url":"https://api.github.com/users/pavelponomarev/gists{/gist_id}","starred_url":"https://api.github.com/users/pavelponomarev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pavelponomarev/subscriptions","organizations_url":"https://api.github.com/users/pavelponomarev/orgs","repos_url":"https://api.github.com/users/pavelponomarev/repos","events_url":"https://api.github.com/users/pavelponomarev/events{/privacy}","received_events_url":"https://api.github.com/users/pavelponomarev/received_events","type":"User","site_admin":false},"repo":{"id":38114780,"name":"scipy","full_name":"pavelponomarev/scipy","owner":{"login":"pavelponomarev","id":10148418,"avatar_url":"https://avatars.githubusercontent.com/u/10148418?v=3","gravatar_id":"","url":"https://api.github.com/users/pavelponomarev","html_url":"https://github.com/pavelponomarev","followers_url":"https://api.github.com/users/pavelponomarev/followers","following_url":"https://api.github.com/users/pavelponomarev/following{/other_user}","gists_url":"https://api.github.com/users/pavelponomarev/gists{/gist_id}","starred_url":"https://api.github.com/users/pavelponomarev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pavelponomarev/subscriptions","organizations_url":"https://api.github.com/users/pavelponomarev/orgs","repos_url":"https://api.github.com/users/pavelponomarev/repos","events_url":"https://api.github.com/users/pavelponomarev/events{/privacy}","received_events_url":"https://api.github.com/users/pavelponomarev/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/pavelponomarev/scipy","description":"Scipy library main repository","fork":true,"url":"https://api.github.com/repos/pavelponomarev/scipy","forks_url":"https://api.github.com/repos/pavelponomarev/scipy/forks","keys_url":"https://api.github.com/repos/pavelponomarev/scipy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pavelponomarev/scipy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pavelponomarev/scipy/teams","hooks_url":"https://api.github.com/repos/pavelponomarev/scipy/hooks","issue_events_url":"https://api.github.com/repos/pavelponomarev/scipy/issues/events{/number}","events_url":"https://api.github.com/repos/pavelponomarev/scipy/events","assignees_url":"https://api.github.com/repos/pavelponomarev/scipy/assignees{/user}","branches_url":"https://api.github.com/repos/pavelponomarev/scipy/branches{/branch}","tags_url":"https://api.github.com/repos/pavelponomarev/scipy/tags","blobs_url":"https://api.github.com/repos/pavelponomarev/scipy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pavelponomarev/scipy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pavelponomarev/scipy/git/refs{/sha}","trees_url":"https://api.github.com/repos/pavelponomarev/scipy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pavelponomarev/scipy/statuses/{sha}","languages_url":"https://api.github.com/repos/pavelponomarev/scipy/languages","stargazers_url":"https://api.github.com/repos/pavelponomarev/scipy/stargazers","contributors_url":"https://api.github.com/repos/pavelponomarev/scipy/contributors","subscribers_url":"https://api.github.com/repos/pavelponomarev/scipy/subscribers","subscription_url":"https://api.github.com/repos/pavelponomarev/scipy/subscription","commits_url":"https://api.github.com/repos/pavelponomarev/scipy/commits{/sha}","git_commits_url":"https://api.github.com/repos/pavelponomarev/scipy/git/commits{/sha}","comments_url":"https://api.github.com/repos/pavelponomarev/scipy/comments{/number}","issue_comment_url":"https://api.github.com/repos/pavelponomarev/scipy/issues/comments{/number}","contents_url":"https://api.github.com/repos/pavelponomarev/scipy/contents/{+path}","compare_url":"https://api.github.com/repos/pavelponomarev/scipy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pavelponomarev/scipy/merges","archive_url":"https://api.github.com/repos/pavelponomarev/scipy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pavelponomarev/scipy/downloads","issues_url":"https://api.github.com/repos/pavelponomarev/scipy/issues{/number}","pulls_url":"https://api.github.com/repos/pavelponomarev/scipy/pulls{/number}","milestones_url":"https://api.github.com/repos/pavelponomarev/scipy/milestones{/number}","notifications_url":"https://api.github.com/repos/pavelponomarev/scipy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pavelponomarev/scipy/labels{/name}","releases_url":"https://api.github.com/repos/pavelponomarev/scipy/releases{/id}","created_at":"2015-06-26T14:13:29Z","updated_at":"2015-06-29T16:17:59Z","pushed_at":"2015-08-11T19:26:07Z","git_url":"git://github.com/pavelponomarev/scipy.git","ssh_url":"git@github.com:pavelponomarev/scipy.git","clone_url":"https://github.com/pavelponomarev/scipy.git","svn_url":"https://github.com/pavelponomarev/scipy","homepage":"http://scipy.org/scipylib/","size":57272,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"scipy:master","ref":"master","sha":"845e46535a5aa3714d80afcfacd161f75f4e118a","user":{"login":"scipy","id":288277,"avatar_url":"https://avatars.githubusercontent.com/u/288277?v=3","gravatar_id":"","url":"https://api.github.com/users/scipy","html_url":"https://github.com/scipy","followers_url":"https://api.github.com/users/scipy/followers","following_url":"https://api.github.com/users/scipy/following{/other_user}","gists_url":"https://api.github.com/users/scipy/gists{/gist_id}","starred_url":"https://api.github.com/users/scipy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scipy/subscriptions","organizations_url":"https://api.github.com/users/scipy/orgs","repos_url":"https://api.github.com/users/scipy/repos","events_url":"https://api.github.com/users/scipy/events{/privacy}","received_events_url":"https://api.github.com/users/scipy/received_events","type":"Organization","site_admin":false},"repo":{"id":1460385,"name":"scipy","full_name":"scipy/scipy","owner":{"login":"scipy","id":288277,"avatar_url":"https://avatars.githubusercontent.com/u/288277?v=3","gravatar_id":"","url":"https://api.github.com/users/scipy","html_url":"https://github.com/scipy","followers_url":"https://api.github.com/users/scipy/followers","following_url":"https://api.github.com/users/scipy/following{/other_user}","gists_url":"https://api.github.com/users/scipy/gists{/gist_id}","starred_url":"https://api.github.com/users/scipy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scipy/subscriptions","organizations_url":"https://api.github.com/users/scipy/orgs","repos_url":"https://api.github.com/users/scipy/repos","events_url":"https://api.github.com/users/scipy/events{/privacy}","received_events_url":"https://api.github.com/users/scipy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/scipy/scipy","description":"Scipy library main repository","fork":false,"url":"https://api.github.com/repos/scipy/scipy","forks_url":"https://api.github.com/repos/scipy/scipy/forks","keys_url":"https://api.github.com/repos/scipy/scipy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/scipy/scipy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/scipy/scipy/teams","hooks_url":"https://api.github.com/repos/scipy/scipy/hooks","issue_events_url":"https://api.github.com/repos/scipy/scipy/issues/events{/number}","events_url":"https://api.github.com/repos/scipy/scipy/events","assignees_url":"https://api.github.com/repos/scipy/scipy/assignees{/user}","branches_url":"https://api.github.com/repos/scipy/scipy/branches{/branch}","tags_url":"https://api.github.com/repos/scipy/scipy/tags","blobs_url":"https://api.github.com/repos/scipy/scipy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/scipy/scipy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/scipy/scipy/git/refs{/sha}","trees_url":"https://api.github.com/repos/scipy/scipy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/scipy/scipy/statuses/{sha}","languages_url":"https://api.github.com/repos/scipy/scipy/languages","stargazers_url":"https://api.github.com/repos/scipy/scipy/stargazers","contributors_url":"https://api.github.com/repos/scipy/scipy/contributors","subscribers_url":"https://api.github.com/repos/scipy/scipy/subscribers","subscription_url":"https://api.github.com/repos/scipy/scipy/subscription","commits_url":"https://api.github.com/repos/scipy/scipy/commits{/sha}","git_commits_url":"https://api.github.com/repos/scipy/scipy/git/commits{/sha}","comments_url":"https://api.github.com/repos/scipy/scipy/comments{/number}","issue_comment_url":"https://api.github.com/repos/scipy/scipy/issues/comments{/number}","contents_url":"https://api.github.com/repos/scipy/scipy/contents/{+path}","compare_url":"https://api.github.com/repos/scipy/scipy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/scipy/scipy/merges","archive_url":"https://api.github.com/repos/scipy/scipy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/scipy/scipy/downloads","issues_url":"https://api.github.com/repos/scipy/scipy/issues{/number}","pulls_url":"https://api.github.com/repos/scipy/scipy/pulls{/number}","milestones_url":"https://api.github.com/repos/scipy/scipy/milestones{/number}","notifications_url":"https://api.github.com/repos/scipy/scipy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/scipy/scipy/labels{/name}","releases_url":"https://api.github.com/repos/scipy/scipy/releases{/id}","created_at":"2011-03-09T18:52:03Z","updated_at":"2015-08-12T18:30:49Z","pushed_at":"2015-08-13T04:52:33Z","git_url":"git://github.com/scipy/scipy.git","ssh_url":"git@github.com:scipy/scipy.git","clone_url":"https://github.com/scipy/scipy.git","svn_url":"https://github.com/scipy/scipy","homepage":"http://scipy.org/scipylib/","size":91171,"stargazers_count":1777,"watchers_count":1777,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":984,"mirror_url":null,"open_issues_count":879,"forks":984,"open_issues":879,"watchers":1777,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/scipy/scipy/pulls/5141"},"html":{"href":"https://github.com/scipy/scipy/pull/5141"},"issue":{"href":"https://api.github.com/repos/scipy/scipy/issues/5141"},"comments":{"href":"https://api.github.com/repos/scipy/scipy/issues/5141/comments"},"review_comments":{"href":"https://api.github.com/repos/scipy/scipy/pulls/5141/comments"},"review_comment":{"href":"https://api.github.com/repos/scipy/scipy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/scipy/scipy/pulls/5141/commits"},"statuses":{"href":"https://api.github.com/repos/scipy/scipy/statuses/406fad0ee9b20a2d959e17382a89795ff4f60ddf"}}}}