{"action":"created","comment":{"url":"https://api.github.com/repos/gonum/optimize/pulls/comments/40982587","id":40982587,"diff_hunk":"@@ -74,63 +67,55 @@ func (b *Bisection) Iterate(f, g float64) (Operation, float64, error) {\n \tif b.minF < minF {\n \t\tminF = b.minF\n \t}\n-\tif StrongWolfeConditionsMet(f, g, minF, b.initGrad, b.currStep, 0, b.GradConst) {\n-\t\tb.lastOp = MajorIteration\n-\t\treturn b.lastOp, b.currStep, nil\n-\t}\n-\n-\t// Deciding on the next step size\n-\tif math.IsInf(b.maxStep, 1) {\n-\t\t// Have not yet bounded the minimum\n-\t\tswitch {\n-\t\tcase g > 0:\n-\t\t\t// Found a change in derivative sign, so this is the new maximum\n-\t\t\tb.maxStep = b.currStep\n-\t\t\tb.maxF = f\n-\t\t\tb.maxGrad = g\n-\t\t\treturn b.nextStep((b.minStep + b.maxStep) / 2)\n-\t\tcase f <= b.minF:\n-\t\t\t// Still haven't found an upper bound, but there is not an increase in\n-\t\t\t// function value and the gradient is still negative, so go more in\n-\t\t\t// that direction.\n-\t\t\tb.minStep = b.currStep\n-\t\t\tb.minF = f\n-\t\t\tb.minGrad = g\n-\t\t\treturn b.nextStep(b.currStep * 2)\n-\t\tdefault:\n-\t\t\t// Increase in function value, but the gradient is still negative.\n-\t\t\t// Means we must have skipped over a local minimum, so set this point\n-\t\t\t// as the new maximum\n-\t\t\tb.maxStep = b.currStep\n-\t\t\tb.maxF = f\n-\t\t\tb.maxGrad = g\n-\t\t\treturn b.nextStep((b.minStep + b.maxStep) / 2)\n+\tif b.lastOp == FuncEvaluation {\n+\t\t// See if the function value is good enough to make progress. If it is,\n+\t\t// evaluate the gradient. If not, set it to the upper bound if the bound\n+\t\t// has not yet been found, otherwise iterate toward the minimum location.\n+\t\tif f <= b.minF {\n+\t\t\tb.lastOp = GradEvaluation\n+\t\t\treturn b.lastOp, b.currStep, nil\n \t\t}\n-\t}\n-\n-\t// Already bounded the minimum, but wolfe conditions not met. Need to step to\n-\t// find minimum.\n-\tif f <= b.minF && f <= b.maxF {\n-\t\tif g < 0 {\n-\t\t\tb.minStep = b.currStep\n-\t\t\tb.minF = f\n-\t\t\tb.minGrad = g\n-\t\t} else {\n+\t\tif math.IsInf(b.maxStep, 1) {\n \t\t\tb.maxStep = b.currStep\n \t\t\tb.maxF = f\n-\t\t\tb.maxGrad = g\n+\t\t\treturn b.nextStep((b.minStep + b.maxStep) / 2)\n \t\t}\n-\t} else {\n-\t\t// We found a higher point. Want to push toward the minimal bound\n \t\tif b.minF <= b.maxF {\n \t\t\tb.maxStep = b.currStep\n \t\t\tb.maxF = f\n-\t\t\tb.maxGrad = g\n \t\t} else {\n \t\t\tb.minStep = b.currStep\n \t\t\tb.minF = f\n-\t\t\tb.minGrad = g\n \t\t}\n+\t\treturn b.nextStep((b.minStep + b.maxStep) / 2)\n+\t}\n+\t// The function value was lower. Check if this location is sufficient to\n+\t// converge the linesearch, otherwise iterate.\n+\tif StrongWolfeConditionsMet(f, g, minF, b.initGrad, b.currStep, 0, b.GradConst) {\n+\t\tb.lastOp = MajorIteration\n+\t\treturn b.lastOp, b.currStep, nil\n+\t}\n+\tif math.IsInf(b.maxStep, 1) {\n+\t\t// The function value is lower. If the gradient is positive, an upper bound\n+\t\t// of the minimum been found. If the gradient is negative, search farther\n+\t\t// in that direction.\n+\t\tif g > 0 {\n+\t\t\tb.maxStep = b.currStep\n+\t\t\tb.maxF = f","path":"bisection.go","position":118,"original_position":118,"commit_id":"46ad71c6a030d0540c580db527034c58ce7d0c18","original_commit_id":"46ad71c6a030d0540c580db527034c58ce7d0c18","user":{"login":"vladimir-ch","id":1837502,"avatar_url":"https://avatars.githubusercontent.com/u/1837502?v=3","gravatar_id":"","url":"https://api.github.com/users/vladimir-ch","html_url":"https://github.com/vladimir-ch","followers_url":"https://api.github.com/users/vladimir-ch/followers","following_url":"https://api.github.com/users/vladimir-ch/following{/other_user}","gists_url":"https://api.github.com/users/vladimir-ch/gists{/gist_id}","starred_url":"https://api.github.com/users/vladimir-ch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vladimir-ch/subscriptions","organizations_url":"https://api.github.com/users/vladimir-ch/orgs","repos_url":"https://api.github.com/users/vladimir-ch/repos","events_url":"https://api.github.com/users/vladimir-ch/events{/privacy}","received_events_url":"https://api.github.com/users/vladimir-ch/received_events","type":"User","site_admin":false},"body":"We use f even though the last operation was GradEvaluation. We should either document that Linesearchers must receive the previous function value after requesting GradEvaluation or (probably better) we should store f after FuncEvaluation and then we don't have to assume anything.","created_at":"2015-10-02T00:27:22Z","updated_at":"2015-10-02T00:27:22Z","html_url":"https://github.com/gonum/optimize/pull/143#discussion_r40982587","pull_request_url":"https://api.github.com/repos/gonum/optimize/pulls/143","_links":{"self":{"href":"https://api.github.com/repos/gonum/optimize/pulls/comments/40982587"},"html":{"href":"https://github.com/gonum/optimize/pull/143#discussion_r40982587"},"pull_request":{"href":"https://api.github.com/repos/gonum/optimize/pulls/143"}}},"pull_request":{"url":"https://api.github.com/repos/gonum/optimize/pulls/143","id":46541638,"html_url":"https://github.com/gonum/optimize/pull/143","diff_url":"https://github.com/gonum/optimize/pull/143.diff","patch_url":"https://github.com/gonum/optimize/pull/143.patch","issue_url":"https://api.github.com/repos/gonum/optimize/issues/143","number":143,"state":"open","locked":false,"title":"Modify bisection so it only requests the gradient when appropriate","user":{"login":"btracey","id":3680859,"avatar_url":"https://avatars.githubusercontent.com/u/3680859?v=3","gravatar_id":"","url":"https://api.github.com/users/btracey","html_url":"https://github.com/btracey","followers_url":"https://api.github.com/users/btracey/followers","following_url":"https://api.github.com/users/btracey/following{/other_user}","gists_url":"https://api.github.com/users/btracey/gists{/gist_id}","starred_url":"https://api.github.com/users/btracey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/btracey/subscriptions","organizations_url":"https://api.github.com/users/btracey/orgs","repos_url":"https://api.github.com/users/btracey/repos","events_url":"https://api.github.com/users/btracey/events{/privacy}","received_events_url":"https://api.github.com/users/btracey/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-10-01T15:52:12Z","updated_at":"2015-10-02T00:27:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7a0dcde43c3f5d374072f78e4208ad106a2e886f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/gonum/optimize/pulls/143/commits","review_comments_url":"https://api.github.com/repos/gonum/optimize/pulls/143/comments","review_comment_url":"https://api.github.com/repos/gonum/optimize/pulls/comments{/number}","comments_url":"https://api.github.com/repos/gonum/optimize/issues/143/comments","statuses_url":"https://api.github.com/repos/gonum/optimize/statuses/46ad71c6a030d0540c580db527034c58ce7d0c18","head":{"label":"gonum:bisectiongrad","ref":"bisectiongrad","sha":"46ad71c6a030d0540c580db527034c58ce7d0c18","user":{"login":"gonum","id":3771091,"avatar_url":"https://avatars.githubusercontent.com/u/3771091?v=3","gravatar_id":"","url":"https://api.github.com/users/gonum","html_url":"https://github.com/gonum","followers_url":"https://api.github.com/users/gonum/followers","following_url":"https://api.github.com/users/gonum/following{/other_user}","gists_url":"https://api.github.com/users/gonum/gists{/gist_id}","starred_url":"https://api.github.com/users/gonum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gonum/subscriptions","organizations_url":"https://api.github.com/users/gonum/orgs","repos_url":"https://api.github.com/users/gonum/repos","events_url":"https://api.github.com/users/gonum/events{/privacy}","received_events_url":"https://api.github.com/users/gonum/received_events","type":"Organization","site_admin":false},"repo":{"id":24917465,"name":"optimize","full_name":"gonum/optimize","owner":{"login":"gonum","id":3771091,"avatar_url":"https://avatars.githubusercontent.com/u/3771091?v=3","gravatar_id":"","url":"https://api.github.com/users/gonum","html_url":"https://github.com/gonum","followers_url":"https://api.github.com/users/gonum/followers","following_url":"https://api.github.com/users/gonum/following{/other_user}","gists_url":"https://api.github.com/users/gonum/gists{/gist_id}","starred_url":"https://api.github.com/users/gonum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gonum/subscriptions","organizations_url":"https://api.github.com/users/gonum/orgs","repos_url":"https://api.github.com/users/gonum/repos","events_url":"https://api.github.com/users/gonum/events{/privacy}","received_events_url":"https://api.github.com/users/gonum/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/gonum/optimize","description":"Package for finding the optimum value of functions.","fork":false,"url":"https://api.github.com/repos/gonum/optimize","forks_url":"https://api.github.com/repos/gonum/optimize/forks","keys_url":"https://api.github.com/repos/gonum/optimize/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gonum/optimize/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gonum/optimize/teams","hooks_url":"https://api.github.com/repos/gonum/optimize/hooks","issue_events_url":"https://api.github.com/repos/gonum/optimize/issues/events{/number}","events_url":"https://api.github.com/repos/gonum/optimize/events","assignees_url":"https://api.github.com/repos/gonum/optimize/assignees{/user}","branches_url":"https://api.github.com/repos/gonum/optimize/branches{/branch}","tags_url":"https://api.github.com/repos/gonum/optimize/tags","blobs_url":"https://api.github.com/repos/gonum/optimize/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gonum/optimize/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gonum/optimize/git/refs{/sha}","trees_url":"https://api.github.com/repos/gonum/optimize/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gonum/optimize/statuses/{sha}","languages_url":"https://api.github.com/repos/gonum/optimize/languages","stargazers_url":"https://api.github.com/repos/gonum/optimize/stargazers","contributors_url":"https://api.github.com/repos/gonum/optimize/contributors","subscribers_url":"https://api.github.com/repos/gonum/optimize/subscribers","subscription_url":"https://api.github.com/repos/gonum/optimize/subscription","commits_url":"https://api.github.com/repos/gonum/optimize/commits{/sha}","git_commits_url":"https://api.github.com/repos/gonum/optimize/git/commits{/sha}","comments_url":"https://api.github.com/repos/gonum/optimize/comments{/number}","issue_comment_url":"https://api.github.com/repos/gonum/optimize/issues/comments{/number}","contents_url":"https://api.github.com/repos/gonum/optimize/contents/{+path}","compare_url":"https://api.github.com/repos/gonum/optimize/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gonum/optimize/merges","archive_url":"https://api.github.com/repos/gonum/optimize/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gonum/optimize/downloads","issues_url":"https://api.github.com/repos/gonum/optimize/issues{/number}","pulls_url":"https://api.github.com/repos/gonum/optimize/pulls{/number}","milestones_url":"https://api.github.com/repos/gonum/optimize/milestones{/number}","notifications_url":"https://api.github.com/repos/gonum/optimize/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gonum/optimize/labels{/name}","releases_url":"https://api.github.com/repos/gonum/optimize/releases{/id}","created_at":"2014-10-08T00:14:50Z","updated_at":"2015-09-30T20:54:19Z","pushed_at":"2015-10-02T00:18:25Z","git_url":"git://github.com/gonum/optimize.git","ssh_url":"git@github.com:gonum/optimize.git","clone_url":"https://github.com/gonum/optimize.git","svn_url":"https://github.com/gonum/optimize","homepage":null,"size":1851,"stargazers_count":26,"watchers_count":26,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":12,"forks":5,"open_issues":12,"watchers":26,"default_branch":"master"}},"base":{"label":"gonum:master","ref":"master","sha":"b9186969c5b82f381b19acabbdfa84338212814b","user":{"login":"gonum","id":3771091,"avatar_url":"https://avatars.githubusercontent.com/u/3771091?v=3","gravatar_id":"","url":"https://api.github.com/users/gonum","html_url":"https://github.com/gonum","followers_url":"https://api.github.com/users/gonum/followers","following_url":"https://api.github.com/users/gonum/following{/other_user}","gists_url":"https://api.github.com/users/gonum/gists{/gist_id}","starred_url":"https://api.github.com/users/gonum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gonum/subscriptions","organizations_url":"https://api.github.com/users/gonum/orgs","repos_url":"https://api.github.com/users/gonum/repos","events_url":"https://api.github.com/users/gonum/events{/privacy}","received_events_url":"https://api.github.com/users/gonum/received_events","type":"Organization","site_admin":false},"repo":{"id":24917465,"name":"optimize","full_name":"gonum/optimize","owner":{"login":"gonum","id":3771091,"avatar_url":"https://avatars.githubusercontent.com/u/3771091?v=3","gravatar_id":"","url":"https://api.github.com/users/gonum","html_url":"https://github.com/gonum","followers_url":"https://api.github.com/users/gonum/followers","following_url":"https://api.github.com/users/gonum/following{/other_user}","gists_url":"https://api.github.com/users/gonum/gists{/gist_id}","starred_url":"https://api.github.com/users/gonum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gonum/subscriptions","organizations_url":"https://api.github.com/users/gonum/orgs","repos_url":"https://api.github.com/users/gonum/repos","events_url":"https://api.github.com/users/gonum/events{/privacy}","received_events_url":"https://api.github.com/users/gonum/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/gonum/optimize","description":"Package for finding the optimum value of functions.","fork":false,"url":"https://api.github.com/repos/gonum/optimize","forks_url":"https://api.github.com/repos/gonum/optimize/forks","keys_url":"https://api.github.com/repos/gonum/optimize/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gonum/optimize/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gonum/optimize/teams","hooks_url":"https://api.github.com/repos/gonum/optimize/hooks","issue_events_url":"https://api.github.com/repos/gonum/optimize/issues/events{/number}","events_url":"https://api.github.com/repos/gonum/optimize/events","assignees_url":"https://api.github.com/repos/gonum/optimize/assignees{/user}","branches_url":"https://api.github.com/repos/gonum/optimize/branches{/branch}","tags_url":"https://api.github.com/repos/gonum/optimize/tags","blobs_url":"https://api.github.com/repos/gonum/optimize/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gonum/optimize/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gonum/optimize/git/refs{/sha}","trees_url":"https://api.github.com/repos/gonum/optimize/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gonum/optimize/statuses/{sha}","languages_url":"https://api.github.com/repos/gonum/optimize/languages","stargazers_url":"https://api.github.com/repos/gonum/optimize/stargazers","contributors_url":"https://api.github.com/repos/gonum/optimize/contributors","subscribers_url":"https://api.github.com/repos/gonum/optimize/subscribers","subscription_url":"https://api.github.com/repos/gonum/optimize/subscription","commits_url":"https://api.github.com/repos/gonum/optimize/commits{/sha}","git_commits_url":"https://api.github.com/repos/gonum/optimize/git/commits{/sha}","comments_url":"https://api.github.com/repos/gonum/optimize/comments{/number}","issue_comment_url":"https://api.github.com/repos/gonum/optimize/issues/comments{/number}","contents_url":"https://api.github.com/repos/gonum/optimize/contents/{+path}","compare_url":"https://api.github.com/repos/gonum/optimize/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gonum/optimize/merges","archive_url":"https://api.github.com/repos/gonum/optimize/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gonum/optimize/downloads","issues_url":"https://api.github.com/repos/gonum/optimize/issues{/number}","pulls_url":"https://api.github.com/repos/gonum/optimize/pulls{/number}","milestones_url":"https://api.github.com/repos/gonum/optimize/milestones{/number}","notifications_url":"https://api.github.com/repos/gonum/optimize/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gonum/optimize/labels{/name}","releases_url":"https://api.github.com/repos/gonum/optimize/releases{/id}","created_at":"2014-10-08T00:14:50Z","updated_at":"2015-09-30T20:54:19Z","pushed_at":"2015-10-02T00:18:25Z","git_url":"git://github.com/gonum/optimize.git","ssh_url":"git@github.com:gonum/optimize.git","clone_url":"https://github.com/gonum/optimize.git","svn_url":"https://github.com/gonum/optimize","homepage":null,"size":1851,"stargazers_count":26,"watchers_count":26,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":12,"forks":5,"open_issues":12,"watchers":26,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/gonum/optimize/pulls/143"},"html":{"href":"https://github.com/gonum/optimize/pull/143"},"issue":{"href":"https://api.github.com/repos/gonum/optimize/issues/143"},"comments":{"href":"https://api.github.com/repos/gonum/optimize/issues/143/comments"},"review_comments":{"href":"https://api.github.com/repos/gonum/optimize/pulls/143/comments"},"review_comment":{"href":"https://api.github.com/repos/gonum/optimize/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/gonum/optimize/pulls/143/commits"},"statuses":{"href":"https://api.github.com/repos/gonum/optimize/statuses/46ad71c6a030d0540c580db527034c58ce7d0c18"}}}}