{"action":"opened","issue":{"url":"https://api.github.com/repos/coin-or/pulp/issues/95","labels_url":"https://api.github.com/repos/coin-or/pulp/issues/95/labels{/name}","comments_url":"https://api.github.com/repos/coin-or/pulp/issues/95/comments","events_url":"https://api.github.com/repos/coin-or/pulp/issues/95/events","html_url":"https://github.com/coin-or/pulp/issues/95","id":123853928,"number":95,"title":"Small bug in writeLP, easy to fix -- Andres Sommerhoff","user":{"login":"stumitchell","id":738393,"avatar_url":"https://avatars.githubusercontent.com/u/738393?v=3","gravatar_id":"","url":"https://api.github.com/users/stumitchell","html_url":"https://github.com/stumitchell","followers_url":"https://api.github.com/users/stumitchell/followers","following_url":"https://api.github.com/users/stumitchell/following{/other_user}","gists_url":"https://api.github.com/users/stumitchell/gists{/gist_id}","starred_url":"https://api.github.com/users/stumitchell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stumitchell/subscriptions","organizations_url":"https://api.github.com/users/stumitchell/orgs","repos_url":"https://api.github.com/users/stumitchell/repos","events_url":"https://api.github.com/users/stumitchell/events{/privacy}","received_events_url":"https://api.github.com/users/stumitchell/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-12-25T05:23:42Z","updated_at":"2015-12-25T05:23:42Z","closed_at":null,"body":"Hi Stu, just found a small bug in writeLP() of file pulp.py.\r\n\r\nIn line 1501 dummyVar is used to remember that a dummy variable was necessary to fix the objective affine expression. If there was no need to fix the objective then dummyVar is set to None. Later on, in line 1570 the use of the dummyVar is reverted (by subtracting dummyVar from objective if dummyVar was not None).  The problem is that the line 1512 uses the same \"dummyVar\" name but for solving a constrain issue. This means that Objective's dummyVar will be overwritten when constrains need to be fixed, making impossible to recover previous objective in line 1570 (actually the objective will end with a new dummy LPvariable included on it). \r\n\r\nThe fix is easy. For example, just to rename \"dummyVar\" to \"ObjectiveDummyVar\" in line 1501 and line 1570. I will appreciate you can fix this, to avoid some workaround I have done today.\r\n\r\nBest regards, Andres\r\n\r\n1501         wasNone, dummyVar = self.fixObjective()   \r\n1502         objName = self.objective.name \r\n1503         if not objName: objName = \"OBJ\" \r\n1504         f.write(self.objective.asCplexLpAffineExpression(objName, constant = 0)) \r\n1505         f.write(\"Subject To\\n\") \r\n1506         ks = list(self.constraints.keys()) \r\n1507         ks.sort() \r\n1508         for k in ks: \r\n1509             constraint = self.constraints[k] \r\n1510             if not list(constraint.keys()): \r\n1511                 #empty constraint add the dummyVar \r\n1512                 dummyVar = self.get_dummyVar() \r\n1513                 constraint += dummyVar \r\n1514                 #set this dummyvar to zero so infeasible problems are not made feasible \r\n1515                 f.write((dummyVar == 0.0).asCplexLpConstraint(\"_dummy\"))\r\n.....\r\n1568         f.write(\"End\\n\") \r\n1569         f.close() \r\n1570         self.restoreObjective(wasNone, dummyVar)\r\n"}}