{"action":"created","comment":{"url":"https://api.github.com/repos/hoburg/gpkit/pulls/comments/57462352","id":57462352,"diff_hunk":"@@ -112,3 +115,53 @@ def mdmake(filename, make_tex=True):\n         with open(filename+\".tex.md\", \"w\") as f:\n             f.write(texmd)\n     return open(filename+\".py\")\n+\n+\n+def bound_all_variables(model, eps=1e-30, lower=None, upper=None):\n+    \"Returns model with additional constraints bounding all free variables\"\n+    lb = lower if lower else eps\n+    ub = upper if upper else 1/eps\n+    constraints = []\n+    for varkey in model.varkeys:\n+        units = varkey.descr.get(\"units\", 1)\n+        constraints.append([ub*units >= Variable(**varkey.descr),\n+                            Variable(**varkey.descr) >= lb*units])\n+    m = Model(model.cost, [constraints, model], model.substitutions)\n+    m.bound_all = {\"lb\": lb, \"ub\": ub, \"varkeys\": model.varkeys}\n+    return m\n+\n+\n+# pylint: disable=too-many-locals\n+def determine_unbounded_variables(model, solver=None, verbosity=0,\n+                                  eps=1e-30, lower=None, upper=None, **kwargs):\n+    \"Returns labeled dictionary of unbounded variables.\"\n+    m = bound_all_variables(model, eps, lower, upper)\n+    sol = m.solve(solver, verbosity, **kwargs)\n+    lam = sol[\"sensitivities\"][\"la\"][1:]\n+    out = defaultdict(list)\n+    for i, varkey in enumerate(m.bound_all[\"varkeys\"]):\n+        lam_gt, lam_lt = lam[2*i], lam[2*i+1]","path":"gpkit/tools.py","position":40,"original_position":40,"commit_id":"df5a416930d67c14369ba442ac71ae614255fc53","original_commit_id":"df5a416930d67c14369ba442ac71ae614255fc53","user":{"login":"bqpd","id":1482776,"avatar_url":"https://avatars.githubusercontent.com/u/1482776?v=3","gravatar_id":"","url":"https://api.github.com/users/bqpd","html_url":"https://github.com/bqpd","followers_url":"https://api.github.com/users/bqpd/followers","following_url":"https://api.github.com/users/bqpd/following{/other_user}","gists_url":"https://api.github.com/users/bqpd/gists{/gist_id}","starred_url":"https://api.github.com/users/bqpd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bqpd/subscriptions","organizations_url":"https://api.github.com/users/bqpd/orgs","repos_url":"https://api.github.com/users/bqpd/repos","events_url":"https://api.github.com/users/bqpd/events{/privacy}","received_events_url":"https://api.github.com/users/bqpd/received_events","type":"User","site_admin":false},"body":"Oh whoops you're right, this is what I get for just emailing.\nOn Mar 25, 2016 12:45, \"Edward Burnell\" <eburn@mit.edu> wrote:\n\n> bound_all[\"varkeys\"] is declared above, I think?\n> On Mar 25, 2016 12:42, \"Warren Hoburg\" <notifications@github.com> wrote:\n>\n>> In gpkit/tools.py\n>> <https://github.com/hoburg/gpkit/pull/571#discussion_r57461872>:\n>>\n>> > +                            Variable(**varkey.descr) >= lb*units])\n>> > +    m = Model(model.cost, [constraints, model], model.substitutions)\n>> > +    m.bound_all = {\"lb\": lb, \"ub\": ub, \"varkeys\": model.varkeys}\n>> > +    return m\n>> > +\n>> > +\n>> > +# pylint: disable=too-many-locals\n>> > +def determine_unbounded_variables(model, solver=None, verbosity=0,\n>> > +                                  eps=1e-30, lower=None, upper=None, **kwargs):\n>> > +    \"Returns labeled dictionary of unbounded variables.\"\n>> > +    m = bound_all_variables(model, eps, lower, upper)\n>> > +    sol = m.solve(solver, verbosity, **kwargs)\n>> > +    lam = sol[\"sensitivities\"][\"la\"][1:]\n>> > +    out = defaultdict(list)\n>> > +    for i, varkey in enumerate(m.bound_all[\"varkeys\"]):\n>> > +        lam_gt, lam_lt = lam[2*i], lam[2*i+1]\n>>\n>> really?\n>>\n>> In [16]: from gpkit import Variable, Model\n>>\n>> In [17]: x = Variable('x')\n>>\n>> In [18]: m = Model(x, [x >= 1])\n>>\n>> In [19]: m.varkeys\n>> Out[19]: {x: {x}}\n>>\n>> —\n>> You are receiving this because you authored the thread.\n>> Reply to this email directly or view it on GitHub\n>> <https://github.com/hoburg/gpkit/pull/571/files/df5a416930d67c14369ba442ac71ae614255fc53#r57461872>\n>>\n>\n","created_at":"2016-03-25T16:47:21Z","updated_at":"2016-03-25T16:47:21Z","html_url":"https://github.com/hoburg/gpkit/pull/571#discussion_r57462352","pull_request_url":"https://api.github.com/repos/hoburg/gpkit/pulls/571","_links":{"self":{"href":"https://api.github.com/repos/hoburg/gpkit/pulls/comments/57462352"},"html":{"href":"https://github.com/hoburg/gpkit/pull/571#discussion_r57462352"},"pull_request":{"href":"https://api.github.com/repos/hoburg/gpkit/pulls/571"}}},"pull_request":{"url":"https://api.github.com/repos/hoburg/gpkit/pulls/571","id":62443539,"html_url":"https://github.com/hoburg/gpkit/pull/571","diff_url":"https://github.com/hoburg/gpkit/pull/571.diff","patch_url":"https://github.com/hoburg/gpkit/pull/571.patch","issue_url":"https://api.github.com/repos/hoburg/gpkit/issues/571","number":571,"state":"open","locked":false,"title":"add boundedness debugging tool","user":{"login":"bqpd","id":1482776,"avatar_url":"https://avatars.githubusercontent.com/u/1482776?v=3","gravatar_id":"","url":"https://api.github.com/users/bqpd","html_url":"https://github.com/bqpd","followers_url":"https://api.github.com/users/bqpd/followers","following_url":"https://api.github.com/users/bqpd/following{/other_user}","gists_url":"https://api.github.com/users/bqpd/gists{/gist_id}","starred_url":"https://api.github.com/users/bqpd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bqpd/subscriptions","organizations_url":"https://api.github.com/users/bqpd/orgs","repos_url":"https://api.github.com/users/bqpd/repos","events_url":"https://api.github.com/users/bqpd/events{/privacy}","received_events_url":"https://api.github.com/users/bqpd/received_events","type":"User","site_admin":false},"body":"  - [ ] Turn into `BoundedConstraintSet` and move functions into `__init__` and `sens_from_dual/sens_from_gpconstr`, with a verbosity flag to print during solve.","created_at":"2016-03-10T19:36:41Z","updated_at":"2016-03-25T16:47:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ead1c5a0d0e4ef55f43f81246e22cd59b4250b1a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/hoburg/gpkit/pulls/571/commits","review_comments_url":"https://api.github.com/repos/hoburg/gpkit/pulls/571/comments","review_comment_url":"https://api.github.com/repos/hoburg/gpkit/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hoburg/gpkit/issues/571/comments","statuses_url":"https://api.github.com/repos/hoburg/gpkit/statuses/df5a416930d67c14369ba442ac71ae614255fc53","head":{"label":"hoburg:known_UNKNOWNS","ref":"known_UNKNOWNS","sha":"df5a416930d67c14369ba442ac71ae614255fc53","user":{"login":"hoburg","id":16762937,"avatar_url":"https://avatars.githubusercontent.com/u/16762937?v=3","gravatar_id":"","url":"https://api.github.com/users/hoburg","html_url":"https://github.com/hoburg","followers_url":"https://api.github.com/users/hoburg/followers","following_url":"https://api.github.com/users/hoburg/following{/other_user}","gists_url":"https://api.github.com/users/hoburg/gists{/gist_id}","starred_url":"https://api.github.com/users/hoburg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hoburg/subscriptions","organizations_url":"https://api.github.com/users/hoburg/orgs","repos_url":"https://api.github.com/users/hoburg/repos","events_url":"https://api.github.com/users/hoburg/events{/privacy}","received_events_url":"https://api.github.com/users/hoburg/received_events","type":"Organization","site_admin":false},"repo":{"id":20954246,"name":"gpkit","full_name":"hoburg/gpkit","owner":{"login":"hoburg","id":16762937,"avatar_url":"https://avatars.githubusercontent.com/u/16762937?v=3","gravatar_id":"","url":"https://api.github.com/users/hoburg","html_url":"https://github.com/hoburg","followers_url":"https://api.github.com/users/hoburg/followers","following_url":"https://api.github.com/users/hoburg/following{/other_user}","gists_url":"https://api.github.com/users/hoburg/gists{/gist_id}","starred_url":"https://api.github.com/users/hoburg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hoburg/subscriptions","organizations_url":"https://api.github.com/users/hoburg/orgs","repos_url":"https://api.github.com/users/hoburg/repos","events_url":"https://api.github.com/users/hoburg/events{/privacy}","received_events_url":"https://api.github.com/users/hoburg/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hoburg/gpkit","description":"Python package for defining and manipulating geometric programming models.","fork":false,"url":"https://api.github.com/repos/hoburg/gpkit","forks_url":"https://api.github.com/repos/hoburg/gpkit/forks","keys_url":"https://api.github.com/repos/hoburg/gpkit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hoburg/gpkit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hoburg/gpkit/teams","hooks_url":"https://api.github.com/repos/hoburg/gpkit/hooks","issue_events_url":"https://api.github.com/repos/hoburg/gpkit/issues/events{/number}","events_url":"https://api.github.com/repos/hoburg/gpkit/events","assignees_url":"https://api.github.com/repos/hoburg/gpkit/assignees{/user}","branches_url":"https://api.github.com/repos/hoburg/gpkit/branches{/branch}","tags_url":"https://api.github.com/repos/hoburg/gpkit/tags","blobs_url":"https://api.github.com/repos/hoburg/gpkit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hoburg/gpkit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hoburg/gpkit/git/refs{/sha}","trees_url":"https://api.github.com/repos/hoburg/gpkit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hoburg/gpkit/statuses/{sha}","languages_url":"https://api.github.com/repos/hoburg/gpkit/languages","stargazers_url":"https://api.github.com/repos/hoburg/gpkit/stargazers","contributors_url":"https://api.github.com/repos/hoburg/gpkit/contributors","subscribers_url":"https://api.github.com/repos/hoburg/gpkit/subscribers","subscription_url":"https://api.github.com/repos/hoburg/gpkit/subscription","commits_url":"https://api.github.com/repos/hoburg/gpkit/commits{/sha}","git_commits_url":"https://api.github.com/repos/hoburg/gpkit/git/commits{/sha}","comments_url":"https://api.github.com/repos/hoburg/gpkit/comments{/number}","issue_comment_url":"https://api.github.com/repos/hoburg/gpkit/issues/comments{/number}","contents_url":"https://api.github.com/repos/hoburg/gpkit/contents/{+path}","compare_url":"https://api.github.com/repos/hoburg/gpkit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hoburg/gpkit/merges","archive_url":"https://api.github.com/repos/hoburg/gpkit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hoburg/gpkit/downloads","issues_url":"https://api.github.com/repos/hoburg/gpkit/issues{/number}","pulls_url":"https://api.github.com/repos/hoburg/gpkit/pulls{/number}","milestones_url":"https://api.github.com/repos/hoburg/gpkit/milestones{/number}","notifications_url":"https://api.github.com/repos/hoburg/gpkit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hoburg/gpkit/labels{/name}","releases_url":"https://api.github.com/repos/hoburg/gpkit/releases{/id}","deployments_url":"https://api.github.com/repos/hoburg/gpkit/deployments","created_at":"2014-06-18T08:04:06Z","updated_at":"2016-01-25T01:21:54Z","pushed_at":"2016-03-25T05:04:38Z","git_url":"git://github.com/hoburg/gpkit.git","ssh_url":"git@github.com:hoburg/gpkit.git","clone_url":"https://github.com/hoburg/gpkit.git","svn_url":"https://github.com/hoburg/gpkit","homepage":"http://gpkit.readthedocs.org","size":29774,"stargazers_count":7,"watchers_count":7,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":114,"forks":4,"open_issues":114,"watchers":7,"default_branch":"master"}},"base":{"label":"hoburg:master","ref":"master","sha":"846d454157495fd509131c72feffefec55a861a9","user":{"login":"hoburg","id":16762937,"avatar_url":"https://avatars.githubusercontent.com/u/16762937?v=3","gravatar_id":"","url":"https://api.github.com/users/hoburg","html_url":"https://github.com/hoburg","followers_url":"https://api.github.com/users/hoburg/followers","following_url":"https://api.github.com/users/hoburg/following{/other_user}","gists_url":"https://api.github.com/users/hoburg/gists{/gist_id}","starred_url":"https://api.github.com/users/hoburg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hoburg/subscriptions","organizations_url":"https://api.github.com/users/hoburg/orgs","repos_url":"https://api.github.com/users/hoburg/repos","events_url":"https://api.github.com/users/hoburg/events{/privacy}","received_events_url":"https://api.github.com/users/hoburg/received_events","type":"Organization","site_admin":false},"repo":{"id":20954246,"name":"gpkit","full_name":"hoburg/gpkit","owner":{"login":"hoburg","id":16762937,"avatar_url":"https://avatars.githubusercontent.com/u/16762937?v=3","gravatar_id":"","url":"https://api.github.com/users/hoburg","html_url":"https://github.com/hoburg","followers_url":"https://api.github.com/users/hoburg/followers","following_url":"https://api.github.com/users/hoburg/following{/other_user}","gists_url":"https://api.github.com/users/hoburg/gists{/gist_id}","starred_url":"https://api.github.com/users/hoburg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hoburg/subscriptions","organizations_url":"https://api.github.com/users/hoburg/orgs","repos_url":"https://api.github.com/users/hoburg/repos","events_url":"https://api.github.com/users/hoburg/events{/privacy}","received_events_url":"https://api.github.com/users/hoburg/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hoburg/gpkit","description":"Python package for defining and manipulating geometric programming models.","fork":false,"url":"https://api.github.com/repos/hoburg/gpkit","forks_url":"https://api.github.com/repos/hoburg/gpkit/forks","keys_url":"https://api.github.com/repos/hoburg/gpkit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hoburg/gpkit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hoburg/gpkit/teams","hooks_url":"https://api.github.com/repos/hoburg/gpkit/hooks","issue_events_url":"https://api.github.com/repos/hoburg/gpkit/issues/events{/number}","events_url":"https://api.github.com/repos/hoburg/gpkit/events","assignees_url":"https://api.github.com/repos/hoburg/gpkit/assignees{/user}","branches_url":"https://api.github.com/repos/hoburg/gpkit/branches{/branch}","tags_url":"https://api.github.com/repos/hoburg/gpkit/tags","blobs_url":"https://api.github.com/repos/hoburg/gpkit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hoburg/gpkit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hoburg/gpkit/git/refs{/sha}","trees_url":"https://api.github.com/repos/hoburg/gpkit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hoburg/gpkit/statuses/{sha}","languages_url":"https://api.github.com/repos/hoburg/gpkit/languages","stargazers_url":"https://api.github.com/repos/hoburg/gpkit/stargazers","contributors_url":"https://api.github.com/repos/hoburg/gpkit/contributors","subscribers_url":"https://api.github.com/repos/hoburg/gpkit/subscribers","subscription_url":"https://api.github.com/repos/hoburg/gpkit/subscription","commits_url":"https://api.github.com/repos/hoburg/gpkit/commits{/sha}","git_commits_url":"https://api.github.com/repos/hoburg/gpkit/git/commits{/sha}","comments_url":"https://api.github.com/repos/hoburg/gpkit/comments{/number}","issue_comment_url":"https://api.github.com/repos/hoburg/gpkit/issues/comments{/number}","contents_url":"https://api.github.com/repos/hoburg/gpkit/contents/{+path}","compare_url":"https://api.github.com/repos/hoburg/gpkit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hoburg/gpkit/merges","archive_url":"https://api.github.com/repos/hoburg/gpkit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hoburg/gpkit/downloads","issues_url":"https://api.github.com/repos/hoburg/gpkit/issues{/number}","pulls_url":"https://api.github.com/repos/hoburg/gpkit/pulls{/number}","milestones_url":"https://api.github.com/repos/hoburg/gpkit/milestones{/number}","notifications_url":"https://api.github.com/repos/hoburg/gpkit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hoburg/gpkit/labels{/name}","releases_url":"https://api.github.com/repos/hoburg/gpkit/releases{/id}","deployments_url":"https://api.github.com/repos/hoburg/gpkit/deployments","created_at":"2014-06-18T08:04:06Z","updated_at":"2016-01-25T01:21:54Z","pushed_at":"2016-03-25T05:04:38Z","git_url":"git://github.com/hoburg/gpkit.git","ssh_url":"git@github.com:hoburg/gpkit.git","clone_url":"https://github.com/hoburg/gpkit.git","svn_url":"https://github.com/hoburg/gpkit","homepage":"http://gpkit.readthedocs.org","size":29774,"stargazers_count":7,"watchers_count":7,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":114,"forks":4,"open_issues":114,"watchers":7,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hoburg/gpkit/pulls/571"},"html":{"href":"https://github.com/hoburg/gpkit/pull/571"},"issue":{"href":"https://api.github.com/repos/hoburg/gpkit/issues/571"},"comments":{"href":"https://api.github.com/repos/hoburg/gpkit/issues/571/comments"},"review_comments":{"href":"https://api.github.com/repos/hoburg/gpkit/pulls/571/comments"},"review_comment":{"href":"https://api.github.com/repos/hoburg/gpkit/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hoburg/gpkit/pulls/571/commits"},"statuses":{"href":"https://api.github.com/repos/hoburg/gpkit/statuses/df5a416930d67c14369ba442ac71ae614255fc53"}}}}