{"action":"opened","issue":{"url":"https://api.github.com/repos/coin-or/pulp/issues/104","repository_url":"https://api.github.com/repos/coin-or/pulp","labels_url":"https://api.github.com/repos/coin-or/pulp/issues/104/labels{/name}","comments_url":"https://api.github.com/repos/coin-or/pulp/issues/104/comments","events_url":"https://api.github.com/repos/coin-or/pulp/issues/104/events","html_url":"https://github.com/coin-or/pulp/issues/104","id":146755715,"number":104,"title":"LpProblem.valid() doesn't work properly when objective is zero","user":{"login":"kotaishr","id":16282891,"avatar_url":"https://avatars.githubusercontent.com/u/16282891?v=3","gravatar_id":"","url":"https://api.github.com/users/kotaishr","html_url":"https://github.com/kotaishr","followers_url":"https://api.github.com/users/kotaishr/followers","following_url":"https://api.github.com/users/kotaishr/following{/other_user}","gists_url":"https://api.github.com/users/kotaishr/gists{/gist_id}","starred_url":"https://api.github.com/users/kotaishr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kotaishr/subscriptions","organizations_url":"https://api.github.com/users/kotaishr/orgs","repos_url":"https://api.github.com/users/kotaishr/repos","events_url":"https://api.github.com/users/kotaishr/events{/privacy}","received_events_url":"https://api.github.com/users/kotaishr/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-04-07T22:05:47Z","updated_at":"2016-04-07T22:05:47Z","closed_at":null,"body":"```python\r\nimport pulp\r\n\r\nmip1 = pulp.LpProblem('****** MIP1 ******')\r\nx = pulp.LpVariable('x')\r\nmip1 += (0 * x)\r\nmip1 += (x >= 1)\r\n\r\nmip1.solve() # This problem is obviously feasible\r\nprint mip1\r\nprint 'x', x.value()  # x = 1.0 is a feasible solution of the LP problem,\r\nprint mip1.valid()  # but valid() returns false.\r\nprint\r\n\r\nmip2 = pulp.LpProblem('****** MIP2 ******')\r\ny = pulp.LpVariable('y')\r\nmip2 += (1 * y)   # If the objective is not zero, the problem above doesn't occur.\r\nmip2 += (y >= 1)\r\n\r\nmip2.solve() \r\nprint mip2\r\nprint 'y', y.value()\r\nprint mip2.valid()\r\n```\r\n\r\nThis problem is caused by the dummy variable introduced to `mip1`  when it is solved.\r\nThe default value of it is `None`, not `0`.  This causes the method valid() to return false:\r\n```python\r\n#line 1205, pulp.py\r\n    def valid(self, eps = 0):  \r\n        for v in self.variables():  \r\n            if not v.valid(eps): return False  # if dummy==None, this line returns false\r\n```\r\n\r\nI think there're two ways to fix this problem:\r\n1. Making the default value of dummy variables to zero.\r\n2. Skipping dummy variables in checking validity.\r\n\r\nHowever, I'm not sure either of the suggestions is consistent with other methods."}}