{"action":"created","issue":{"url":"https://api.github.com/repos/snap-stanford/snapvx/issues/19","repository_url":"https://api.github.com/repos/snap-stanford/snapvx","labels_url":"https://api.github.com/repos/snap-stanford/snapvx/issues/19/labels{/name}","comments_url":"https://api.github.com/repos/snap-stanford/snapvx/issues/19/comments","events_url":"https://api.github.com/repos/snap-stanford/snapvx/issues/19/events","html_url":"https://github.com/snap-stanford/snapvx/issues/19","id":171286681,"number":19,"title":"Two sets of edges","user":{"login":"DanqingZ","id":8596775,"avatar_url":"https://avatars.githubusercontent.com/u/8596775?v=3","gravatar_id":"","url":"https://api.github.com/users/DanqingZ","html_url":"https://github.com/DanqingZ","followers_url":"https://api.github.com/users/DanqingZ/followers","following_url":"https://api.github.com/users/DanqingZ/following{/other_user}","gists_url":"https://api.github.com/users/DanqingZ/gists{/gist_id}","starred_url":"https://api.github.com/users/DanqingZ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DanqingZ/subscriptions","organizations_url":"https://api.github.com/users/DanqingZ/orgs","repos_url":"https://api.github.com/users/DanqingZ/repos","events_url":"https://api.github.com/users/DanqingZ/events{/privacy}","received_events_url":"https://api.github.com/users/DanqingZ/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-08-15T23:37:09Z","updated_at":"2016-08-16T01:31:21Z","closed_at":null,"body":"Hi all,\r\n\r\nI have a general question about SnapVX.\r\n\r\nCurrently I have a social network with location information of each individual, which mean apart from the social network, I also have neighborhood based on geographical information. My assumptions of the model is that: the people who are connected have similar coefficients, the people who are in the same neighborhood have similar coefficients.\r\n\r\nThat means I have two sets of edges based on current nodes, then I can add two sets of network lasso terms.I am wondering if current SnapVX package can handle this problem?\r\n\r\nMy current implementation is that I add that I construct graph based on social network and first add edge constraints:\r\n``` Python\r\nL =0.01\r\n# 0.004\r\ndef laplace_reg(src, dst, data):\r\n    return (L*norm(src['x'] - dst['x']), [])\r\n\r\ngvx.AddEdgeObjectives(laplace_reg)\r\n```\r\nAdd then loop within neighborhood to add neighborhood effect:\r\n```Python\r\nfor i in range(len(c2)):\r\n    for j in range(i+1,len(c2)):\r\n        src_id=i\r\n        dst_id=j\r\n        (src_vars, dst_vars) = (gvx.GetNodeVariables(src_id), gvx.GetNodeVariables(dst_id))\r\n        L_2 = 0.02\r\n        edge_obj=  L_2*square(src_vars['x']-dst_vars['x'])\r\n        # gvx.SetEdgeObjective(src_id,dst_id,edge_obj)\r\n#         print 'yes!'\r\n        gvx.AddEdge(src_id, dst_id,Objective=edge_obj)\r\n```\r\n\r\nBut it seems but implementation is not working anyway:\r\n```Python\r\nCombined backtracking failed 90 0 0 0 sigma 1\r\nCombined backtracking failed 90 0 0 0 sigma 1\r\nCombined backtracking failed 90 0 0 0 sigma 1\r\nCombined backtracking failed 90 0 0 0 sigma 1\r\nCombined backtracking failed 90 0 0 0 sigma 1\r\n\r\n---------------------------------------------------------------------------\r\nException                                 Traceback (most recent call last)\r\n<ipython-input-42-cbb022e6b30a> in <module>()\r\n----> 1 gvx.Solve(Verbose=True, Rho=0.1)\r\n\r\n/Users/danqing0703/anaconda/lib/python2.7/site-packages/snapvx.pyc in Solve(self, M, UseADMM, NumProcessors, Rho, MaxIters, EpsAbs, EpsRel, Verbose, UseClustering, ClusterSize)\r\n    146         if UseADMM and self.GetEdges() != 0:\r\n    147             self.__SolveADMM(NumProcessors, Rho, MaxIters, EpsAbs, EpsRel,\r\n--> 148                              Verbose)\r\n    149             return\r\n    150         if Verbose:\r\n\r\n/Users/danqing0703/anaconda/lib/python2.7/site-packages/snapvx.pyc in __SolveADMM(self, numProcessors, rho_param, maxIters, eps_abs, eps_rel, verbose)\r\n    440             if os.name != 'nt':\r\n    441                 pool.map(ADMM_x, node_list)\r\n--> 442                 pool.map(ADMM_z, edge_list)\r\n    443                 pool.map(ADMM_u, edge_list)\r\n    444             else:\r\n\r\n/Users/danqing0703/anaconda/lib/python2.7/multiprocessing/pool.pyc in map(self, func, iterable, chunksize)\r\n    249         '''\r\n    250         assert self._state == RUN\r\n--> 251         return self.map_async(func, iterable, chunksize).get()\r\n    252 \r\n    253     def imap(self, func, iterable, chunksize=1):\r\n\r\n/Users/danqing0703/anaconda/lib/python2.7/multiprocessing/pool.pyc in get(self, timeout)\r\n    565             return self._value\r\n    566         else:\r\n--> 567             raise self._value\r\n    568 \r\n    569     def _set(self, i, obj):\r\n\r\nException: The 'minimize' objective must resolve to a scalar.\r\n\r\n```"},"comment":{"url":"https://api.github.com/repos/snap-stanford/snapvx/issues/comments/239978020","html_url":"https://github.com/snap-stanford/snapvx/issues/19#issuecomment-239978020","issue_url":"https://api.github.com/repos/snap-stanford/snapvx/issues/19","id":239978020,"user":{"login":"davidhallac","id":1550581,"avatar_url":"https://avatars.githubusercontent.com/u/1550581?v=3","gravatar_id":"","url":"https://api.github.com/users/davidhallac","html_url":"https://github.com/davidhallac","followers_url":"https://api.github.com/users/davidhallac/followers","following_url":"https://api.github.com/users/davidhallac/following{/other_user}","gists_url":"https://api.github.com/users/davidhallac/gists{/gist_id}","starred_url":"https://api.github.com/users/davidhallac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidhallac/subscriptions","organizations_url":"https://api.github.com/users/davidhallac/orgs","repos_url":"https://api.github.com/users/davidhallac/repos","events_url":"https://api.github.com/users/davidhallac/events{/privacy}","received_events_url":"https://api.github.com/users/davidhallac/received_events","type":"User","site_admin":false},"created_at":"2016-08-16T01:31:21Z","updated_at":"2016-08-16T01:31:21Z","body":"We unfortunately don’t have an elegant way to incorporate two sets of edges to the same set of nodes, but I do think there are workarounds you can use.\r\n\r\nYour code will overwrite any previous edges between those two nodes, so that won't work. Instead, if edge_ij has both types (social and spatial), you'll have to add them simultaneously - i.e. something like gvx.AddEdge(i,j,Objective=L1*norm(src['x']-dst['x']) + L2*square(src['x'] - dst['x']).\r\n\r\nIt might take a bit longer to set up the problem, but scalability-wise it shouldn't affect the runtime. \r\n\r\nAs for the combined backtracking error, it might go away once you change the code. If not, it depends on your optimization problem, but it looks like it might be due to this: https://github.com/embotech/ecos/issues/134 (ECOS is the underlying solver we call for the ADMM subproblems). If that continues being an issue, let us know and I can help you call another solver."}}
{"actor":{"display_login":"davidhallac"}}