{"action":"closed","number":12,"pull_request":{"url":"https://api.github.com/repos/kul-forbes/StructuredOptimization.jl/pulls/12","id":195161122,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk1MTYxMTIy","html_url":"https://github.com/kul-forbes/StructuredOptimization.jl/pull/12","diff_url":"https://github.com/kul-forbes/StructuredOptimization.jl/pull/12.diff","patch_url":"https://github.com/kul-forbes/StructuredOptimization.jl/pull/12.patch","issue_url":"https://api.github.com/repos/kul-forbes/StructuredOptimization.jl/issues/12","number":12,"state":"closed","locked":false,"title":"Fix to nonlinear displaced operators","user":{"login":"nantonel","id":9741655,"node_id":"MDQ6VXNlcjk3NDE2NTU=","avatar_url":"https://avatars0.githubusercontent.com/u/9741655?v=4","gravatar_id":"","url":"https://api.github.com/users/nantonel","html_url":"https://github.com/nantonel","followers_url":"https://api.github.com/users/nantonel/followers","following_url":"https://api.github.com/users/nantonel/following{/other_user}","gists_url":"https://api.github.com/users/nantonel/gists{/gist_id}","starred_url":"https://api.github.com/users/nantonel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nantonel/subscriptions","organizations_url":"https://api.github.com/users/nantonel/orgs","repos_url":"https://api.github.com/users/nantonel/repos","events_url":"https://api.github.com/users/nantonel/events{/privacy}","received_events_url":"https://api.github.com/users/nantonel/received_events","type":"User","site_admin":false},"body":"There was a bug involving displacements in expressions. \r\n\r\nFor example using the current master and AbstractOperators `v0.0.5`:\r\n```julia\r\njulia> using StructuredOptimization\r\n\r\njulia> x = Variable(1);\r\n\r\njulia> b = 10*ones(1);\r\n\r\njulia> @minimize ls(sigmoid(x-b))+1e-5*norm(x,1);\r\n    it |      gamma |        fpr |        tau |        FBE |\r\n ------|------------|------------|------------|------------|\r\n     1 | 7.6000e+00 | 5.6084e-02 | 1.0000e+00 | 2.6957e-02 | \r\n    10 | 7.6000e+00 | 9.2645e-05 | 1.0000e+00 | 9.7839e-05 | \r\n\r\njulia> ~x\r\n1-element Array{Float64,1}:\r\n -4.57973\r\n\r\n```\r\n\r\nThis is wrong since `b` should set the first sigmoid to be completely 0 and hence `x`, being zero, is already a local minimum.\r\n\r\nThe cause of this bug is due to the internal displacement `b` not being detected in the nonlinear operator\r\n(when using liner operators things worked fine).\r\n \r\nIn fact, the displacement is merged in the function `ls` by creating a `ProximableFunction` (using `Precompose(Diagonal)`), but apparently this was done only if the displacement was present at the end of the expression e.g. the cost function:\r\n```julia\r\nls( sigmoid(x) + b )\r\n```\r\nwouldn't be affected by this bug.  \r\n\r\nIn `v0.0.6` of `AbstractOperators` some new features were introduced:\r\n* `AffineAdd` which is a new calculus rule that creates an affine addition to the operator (it is not named `Affine` since it should not to be confused with _affine space_ which involves linear mappings only)\r\n* `displacement` is the function that returns the displacement of the `AffineAdd` regardless of the position where it appears in a composition of `AbstractOperators`. This should be applied only to _linear_ operators, as the displacement of the combination of nonlinear operators, contrary to linear operators, is not constant when variable changes.\r\n\r\nI'm not going to describe the details here, but in short this is the solution that I've adopted: \r\n* displacements are removed from expressions and handled by AbstractOperators instead \r\n* when the operator is linear the displacement is still merged with the 'ProximableFunction' \r\n* when the operator is nonlinear the the displacement is _kept_ inside the operator \r\nsee the [build function](https://github.com/nantonel/StructuredOptimization.jl/blob/master/src/solvers/build_solve.jl#L25). \r\n \r\nNew features are included in this PR, with some new trigonometry functions and possibility of doing Hadamard products.\r\n\r\nFinally, the problem is fixed with this PR and AbstractOperators `v0.0.6`:\r\n```julia\r\njulia> using StructuredOptimization\r\n\r\njulia> x = Variable(1);\r\n\r\njulia> b = 10*ones(1);\r\n\r\njulia> @minimize ls(sigmoid(x-b))+1e-5*norm(x,1);\r\n    it |      gamma |        fpr |        tau |        FBE |\r\n ------|------------|------------|------------|------------|\r\n     1 | 2.3050e+08 | 0.0000e+00 | 1.0000e+00 | 1.0305e-09 | \r\n     1 | 2.3050e+08 | 0.0000e+00 | 1.0000e+00 | 1.0305e-09 | \r\n\r\njulia> ~x\r\n1-element Array{Float64,1}:\r\n 0.0\r\n\r\n```","created_at":"2018-06-15T12:34:45Z","updated_at":"2018-08-02T12:12:19Z","closed_at":"2018-08-02T12:12:18Z","merged_at":"2018-08-02T12:12:18Z","merge_commit_sha":"2771bb11cb1c7efc484984372b2ef4953729a708","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/kul-forbes/StructuredOptimization.jl/pulls/12/commits","review_comments_url":"https://api.github.com/repos/kul-forbes/StructuredOptimization.jl/pulls/12/comments","review_comment_url":"https://api.github.com/repos/kul-forbes/StructuredOptimization.jl/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kul-forbes/StructuredOptimization.jl/issues/12/comments","statuses_url":"https://api.github.com/repos/kul-forbes/StructuredOptimization.jl/statuses/5bfe34e5c84e385d834757aa7619d661d13a171a","head":{"label":"nantonel:master","ref":"master","sha":"5bfe34e5c84e385d834757aa7619d661d13a171a","user":{"login":"nantonel","id":9741655,"node_id":"MDQ6VXNlcjk3NDE2NTU=","avatar_url":"https://avatars0.githubusercontent.com/u/9741655?v=4","gravatar_id":"","url":"https://api.github.com/users/nantonel","html_url":"https://github.com/nantonel","followers_url":"https://api.github.com/users/nantonel/followers","following_url":"https://api.github.com/users/nantonel/following{/other_user}","gists_url":"https://api.github.com/users/nantonel/gists{/gist_id}","starred_url":"https://api.github.com/users/nantonel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nantonel/subscriptions","organizations_url":"https://api.github.com/users/nantonel/orgs","repos_url":"https://api.github.com/users/nantonel/repos","events_url":"https://api.github.com/users/nantonel/events{/privacy}","received_events_url":"https://api.github.com/users/nantonel/received_events","type":"User","site_admin":false},"repo":{"id":129104105,"node_id":"MDEwOlJlcG9zaXRvcnkxMjkxMDQxMDU=","name":"StructuredOptimization.jl","full_name":"nantonel/StructuredOptimization.jl","owner":{"login":"nantonel","id":9741655,"node_id":"MDQ6VXNlcjk3NDE2NTU=","avatar_url":"https://avatars0.githubusercontent.com/u/9741655?v=4","gravatar_id":"","url":"https://api.github.com/users/nantonel","html_url":"https://github.com/nantonel","followers_url":"https://api.github.com/users/nantonel/followers","following_url":"https://api.github.com/users/nantonel/following{/other_user}","gists_url":"https://api.github.com/users/nantonel/gists{/gist_id}","starred_url":"https://api.github.com/users/nantonel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nantonel/subscriptions","organizations_url":"https://api.github.com/users/nantonel/orgs","repos_url":"https://api.github.com/users/nantonel/repos","events_url":"https://api.github.com/users/nantonel/events{/privacy}","received_events_url":"https://api.github.com/users/nantonel/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nantonel/StructuredOptimization.jl","description":"Structured optimization in Julia","fork":true,"url":"https://api.github.com/repos/nantonel/StructuredOptimization.jl","forks_url":"https://api.github.com/repos/nantonel/StructuredOptimization.jl/forks","keys_url":"https://api.github.com/repos/nantonel/StructuredOptimization.jl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nantonel/StructuredOptimization.jl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nantonel/StructuredOptimization.jl/teams","hooks_url":"https://api.github.com/repos/nantonel/StructuredOptimization.jl/hooks","issue_events_url":"https://api.github.com/repos/nantonel/StructuredOptimization.jl/issues/events{/number}","events_url":"https://api.github.com/repos/nantonel/StructuredOptimization.jl/events","assignees_url":"https://api.github.com/repos/nantonel/StructuredOptimization.jl/assignees{/user}","branches_url":"https://api.github.com/repos/nantonel/StructuredOptimization.jl/branches{/branch}","tags_url":"https://api.github.com/repos/nantonel/StructuredOptimization.jl/tags","blobs_url":"https://api.github.com/repos/nantonel/StructuredOptimization.jl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nantonel/StructuredOptimization.jl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nantonel/StructuredOptimization.jl/git/refs{/sha}","trees_url":"https://api.github.com/repos/nantonel/StructuredOptimization.jl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nantonel/StructuredOptimization.jl/statuses/{sha}","languages_url":"https://api.github.com/repos/nantonel/StructuredOptimization.jl/languages","stargazers_url":"https://api.github.com/repos/nantonel/StructuredOptimization.jl/stargazers","contributors_url":"https://api.github.com/repos/nantonel/StructuredOptimization.jl/contributors","subscribers_url":"https://api.github.com/repos/nantonel/StructuredOptimization.jl/subscribers","subscription_url":"https://api.github.com/repos/nantonel/StructuredOptimization.jl/subscription","commits_url":"https://api.github.com/repos/nantonel/StructuredOptimization.jl/commits{/sha}","git_commits_url":"https://api.github.com/repos/nantonel/StructuredOptimization.jl/git/commits{/sha}","comments_url":"https://api.github.com/repos/nantonel/StructuredOptimization.jl/comments{/number}","issue_comment_url":"https://api.github.com/repos/nantonel/StructuredOptimization.jl/issues/comments{/number}","contents_url":"https://api.github.com/repos/nantonel/StructuredOptimization.jl/contents/{+path}","compare_url":"https://api.github.com/repos/nantonel/StructuredOptimization.jl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nantonel/StructuredOptimization.jl/merges","archive_url":"https://api.github.com/repos/nantonel/StructuredOptimization.jl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nantonel/StructuredOptimization.jl/downloads","issues_url":"https://api.github.com/repos/nantonel/StructuredOptimization.jl/issues{/number}","pulls_url":"https://api.github.com/repos/nantonel/StructuredOptimization.jl/pulls{/number}","milestones_url":"https://api.github.com/repos/nantonel/StructuredOptimization.jl/milestones{/number}","notifications_url":"https://api.github.com/repos/nantonel/StructuredOptimization.jl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nantonel/StructuredOptimization.jl/labels{/name}","releases_url":"https://api.github.com/repos/nantonel/StructuredOptimization.jl/releases{/id}","deployments_url":"https://api.github.com/repos/nantonel/StructuredOptimization.jl/deployments","created_at":"2018-04-11T14:10:43Z","updated_at":"2018-06-15T13:14:37Z","pushed_at":"2018-06-15T13:14:35Z","git_url":"git://github.com/nantonel/StructuredOptimization.jl.git","ssh_url":"git@github.com:nantonel/StructuredOptimization.jl.git","clone_url":"https://github.com/nantonel/StructuredOptimization.jl.git","svn_url":"https://github.com/nantonel/StructuredOptimization.jl","homepage":"","size":3463,"stargazers_count":0,"watchers_count":0,"language":"Julia","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"kul-forbes:master","ref":"master","sha":"d34a2f49fa26998faad3b26f3dd8b3fad960a08b","user":{"login":"kul-forbes","id":17712628,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE3NzEyNjI4","avatar_url":"https://avatars3.githubusercontent.com/u/17712628?v=4","gravatar_id":"","url":"https://api.github.com/users/kul-forbes","html_url":"https://github.com/kul-forbes","followers_url":"https://api.github.com/users/kul-forbes/followers","following_url":"https://api.github.com/users/kul-forbes/following{/other_user}","gists_url":"https://api.github.com/users/kul-forbes/gists{/gist_id}","starred_url":"https://api.github.com/users/kul-forbes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kul-forbes/subscriptions","organizations_url":"https://api.github.com/users/kul-forbes/orgs","repos_url":"https://api.github.com/users/kul-forbes/repos","events_url":"https://api.github.com/users/kul-forbes/events{/privacy}","received_events_url":"https://api.github.com/users/kul-forbes/received_events","type":"Organization","site_admin":false},"repo":{"id":62650702,"node_id":"MDEwOlJlcG9zaXRvcnk2MjY1MDcwMg==","name":"StructuredOptimization.jl","full_name":"kul-forbes/StructuredOptimization.jl","owner":{"login":"kul-forbes","id":17712628,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE3NzEyNjI4","avatar_url":"https://avatars3.githubusercontent.com/u/17712628?v=4","gravatar_id":"","url":"https://api.github.com/users/kul-forbes","html_url":"https://github.com/kul-forbes","followers_url":"https://api.github.com/users/kul-forbes/followers","following_url":"https://api.github.com/users/kul-forbes/following{/other_user}","gists_url":"https://api.github.com/users/kul-forbes/gists{/gist_id}","starred_url":"https://api.github.com/users/kul-forbes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kul-forbes/subscriptions","organizations_url":"https://api.github.com/users/kul-forbes/orgs","repos_url":"https://api.github.com/users/kul-forbes/repos","events_url":"https://api.github.com/users/kul-forbes/events{/privacy}","received_events_url":"https://api.github.com/users/kul-forbes/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/kul-forbes/StructuredOptimization.jl","description":"Structured optimization in Julia","fork":false,"url":"https://api.github.com/repos/kul-forbes/StructuredOptimization.jl","forks_url":"https://api.github.com/repos/kul-forbes/StructuredOptimization.jl/forks","keys_url":"https://api.github.com/repos/kul-forbes/StructuredOptimization.jl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kul-forbes/StructuredOptimization.jl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kul-forbes/StructuredOptimization.jl/teams","hooks_url":"https://api.github.com/repos/kul-forbes/StructuredOptimization.jl/hooks","issue_events_url":"https://api.github.com/repos/kul-forbes/StructuredOptimization.jl/issues/events{/number}","events_url":"https://api.github.com/repos/kul-forbes/StructuredOptimization.jl/events","assignees_url":"https://api.github.com/repos/kul-forbes/StructuredOptimization.jl/assignees{/user}","branches_url":"https://api.github.com/repos/kul-forbes/StructuredOptimization.jl/branches{/branch}","tags_url":"https://api.github.com/repos/kul-forbes/StructuredOptimization.jl/tags","blobs_url":"https://api.github.com/repos/kul-forbes/StructuredOptimization.jl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kul-forbes/StructuredOptimization.jl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kul-forbes/StructuredOptimization.jl/git/refs{/sha}","trees_url":"https://api.github.com/repos/kul-forbes/StructuredOptimization.jl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kul-forbes/StructuredOptimization.jl/statuses/{sha}","languages_url":"https://api.github.com/repos/kul-forbes/StructuredOptimization.jl/languages","stargazers_url":"https://api.github.com/repos/kul-forbes/StructuredOptimization.jl/stargazers","contributors_url":"https://api.github.com/repos/kul-forbes/StructuredOptimization.jl/contributors","subscribers_url":"https://api.github.com/repos/kul-forbes/StructuredOptimization.jl/subscribers","subscription_url":"https://api.github.com/repos/kul-forbes/StructuredOptimization.jl/subscription","commits_url":"https://api.github.com/repos/kul-forbes/StructuredOptimization.jl/commits{/sha}","git_commits_url":"https://api.github.com/repos/kul-forbes/StructuredOptimization.jl/git/commits{/sha}","comments_url":"https://api.github.com/repos/kul-forbes/StructuredOptimization.jl/comments{/number}","issue_comment_url":"https://api.github.com/repos/kul-forbes/StructuredOptimization.jl/issues/comments{/number}","contents_url":"https://api.github.com/repos/kul-forbes/StructuredOptimization.jl/contents/{+path}","compare_url":"https://api.github.com/repos/kul-forbes/StructuredOptimization.jl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kul-forbes/StructuredOptimization.jl/merges","archive_url":"https://api.github.com/repos/kul-forbes/StructuredOptimization.jl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kul-forbes/StructuredOptimization.jl/downloads","issues_url":"https://api.github.com/repos/kul-forbes/StructuredOptimization.jl/issues{/number}","pulls_url":"https://api.github.com/repos/kul-forbes/StructuredOptimization.jl/pulls{/number}","milestones_url":"https://api.github.com/repos/kul-forbes/StructuredOptimization.jl/milestones{/number}","notifications_url":"https://api.github.com/repos/kul-forbes/StructuredOptimization.jl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kul-forbes/StructuredOptimization.jl/labels{/name}","releases_url":"https://api.github.com/repos/kul-forbes/StructuredOptimization.jl/releases{/id}","deployments_url":"https://api.github.com/repos/kul-forbes/StructuredOptimization.jl/deployments","created_at":"2016-07-05T16:03:11Z","updated_at":"2018-05-24T17:03:45Z","pushed_at":"2018-08-02T12:12:18Z","git_url":"git://github.com/kul-forbes/StructuredOptimization.jl.git","ssh_url":"git@github.com:kul-forbes/StructuredOptimization.jl.git","clone_url":"https://github.com/kul-forbes/StructuredOptimization.jl.git","svn_url":"https://github.com/kul-forbes/StructuredOptimization.jl","homepage":"","size":3453,"stargazers_count":14,"watchers_count":14,"language":"Julia","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":1,"open_issues":1,"watchers":14,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/kul-forbes/StructuredOptimization.jl/pulls/12"},"html":{"href":"https://github.com/kul-forbes/StructuredOptimization.jl/pull/12"},"issue":{"href":"https://api.github.com/repos/kul-forbes/StructuredOptimization.jl/issues/12"},"comments":{"href":"https://api.github.com/repos/kul-forbes/StructuredOptimization.jl/issues/12/comments"},"review_comments":{"href":"https://api.github.com/repos/kul-forbes/StructuredOptimization.jl/pulls/12/comments"},"review_comment":{"href":"https://api.github.com/repos/kul-forbes/StructuredOptimization.jl/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kul-forbes/StructuredOptimization.jl/pulls/12/commits"},"statuses":{"href":"https://api.github.com/repos/kul-forbes/StructuredOptimization.jl/statuses/5bfe34e5c84e385d834757aa7619d661d13a171a"}},"author_association":"MEMBER","merged":true,"mergeable":null,"rebaseable":null,"mergeable_state":"unknown","merged_by":{"login":"nantonel","id":9741655,"node_id":"MDQ6VXNlcjk3NDE2NTU=","avatar_url":"https://avatars0.githubusercontent.com/u/9741655?v=4","gravatar_id":"","url":"https://api.github.com/users/nantonel","html_url":"https://github.com/nantonel","followers_url":"https://api.github.com/users/nantonel/followers","following_url":"https://api.github.com/users/nantonel/following{/other_user}","gists_url":"https://api.github.com/users/nantonel/gists{/gist_id}","starred_url":"https://api.github.com/users/nantonel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nantonel/subscriptions","organizations_url":"https://api.github.com/users/nantonel/orgs","repos_url":"https://api.github.com/users/nantonel/repos","events_url":"https://api.github.com/users/nantonel/events{/privacy}","received_events_url":"https://api.github.com/users/nantonel/received_events","type":"User","site_admin":false},"comments":4,"review_comments":5,"maintainer_can_modify":false,"commits":10,"additions":399,"deletions":401,"changed_files":23}}
{"actor":{"display_login":"nantonel"}}