Set linear objective of problem

def set_objective(self, expression):
        """Set linear objective of problem"""

        if isinstance(expression, numbers.Number):
            # Allow expressions with no variables as objective,
            # represented as a number
            expression = Expression()

        self._p.set_linear_objective(
            (lp_name, expression.value(var))
            for var, lp_name in iteritems(self._variables))