python-mip
python-mip copied to clipboard
objective_values[k] returns the wrong value
import mip, time;
mip.version
'1.13.0'
model = mip.Model()
x = model.add_var(name='x', var_type=mip.INTEGER);
y = model.add_var(name='y', var_type=mip.INTEGER);
y.ub = 2
model += ( 2*x + 3*y <= 13);
model.objective = ( 2*x + 3*y );
model.sense = mip.MAXIMIZE;
status = model.optimize(max_seconds=300);
for k in range(model.num_solutions):
print('solution {} objective {} x = {} y = {}'.format(k, model.objective_values[k], x.xi(k), y.xi(k)))
solution 0 objective 13.0 x = 5.0 y = 1.0 solution 1 objective -12.0 x = 6.0 y = 0.0
Obviously the objective of solution 1 is +12, not -12 :)
I can confirm this. BTW, after changing the model sense to minimize and negating the objective, the solution objectives are correctly reported as -13 and -12. I suspect the bug is in cbc.
@tkralphs Any idea on that?
@tkralphs Any idea on that?
Not really. I just looked through the whole chain of calls and could see nothing that would cause this. It's very odd. If you can narrow it down to an issue with Cbc (create a stand-alone reproduction using only Cbc itself), then you can report it there and we'll be able to take a look.