def set_objective(self, expression):
if isinstance(expression, numbers.Number):<EOL><INDENT>expression = Expression(offset=expression)<EOL><DEDENT>for i in range(swiglpk.glp_get_num_cols(self._p)):<EOL><INDENT>swiglpk.glp_set_obj_coef(self._p, <NUM_LIT:1> + i, <NUM_LIT:0>)<EOL><DEDENT>for variable, value in expression.values():<EOL><INDENT>var_index = self._variables[variable]<EOL>swiglpk.glp_set_obj_coef(self._p, var_index, float(value))<EOL><DEDENT>swiglpk.glp_set_obj_coef(self._p, <NUM_LIT:0>, float(expression.offset))<EOL>
Set objective of problem.