Skip to content

[Callback] A possible improvement to setCallback() #2717

@JunchengLiamLi

Description

@JunchengLiamLi

I am wondering if it would be better to replace the line if (cb_in) *cb_in = cc_in; in the method setCallback(), file Highs.cpp, with the following line
if (cb_in) cb_in->user_interrupt = (cc_in.user_interrupt != 0);

because if I understand it correctly, the C callback modifies cb_in directly via cbdata. Functions like Highs_setCallbackSolution modify the C++ object (cb_in) directly through the cbdata pointer, so cb_in already has the updated state. It suffices to only copy back the interrupt flag which might have been modified directly in cc_in.

In my experiment, the original code does not work if I inject a feasible solution to the MIP solver at the root node, right after the LP relaxation has been solved for the first time. With this modification, it works. My implementation is based on the C API.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions