Skip to content

MIP Worker Refactor#2886

Open
Opt-Mucca wants to merge 211 commits intolatestfrom
hmw-mt
Open

MIP Worker Refactor#2886
Opt-Mucca wants to merge 211 commits intolatestfrom
hmw-mt

Conversation

@Opt-Mucca
Copy link
Copy Markdown
Collaborator

No description provided.

galabovaa and others added 30 commits February 13, 2025 06:11
Copy link
Copy Markdown
Collaborator

@fwesselm fwesselm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some more comments from me.

return std::make_pair(feasible, transformed_solobj);
}

bool HighsMipWorker::trySolution(const std::vector<double>& solution,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a copy of HighsMipSolverData::trySolution?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes...... It is just calling a different addIncumbent at the end of feasibility check (which requires the HighsMipWorker object). I could pass HighsMipWorker* worker = nullptr as a default argument, and call the global HighsMipSolverData::addIncumbent vs HighsMipWorker::addIncumbent depending on whether or not it's a nullptr. Any strong opinion for or against (or a different approach)?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe another thing to look at after the initial submission.

return true;
}

std::pair<bool, double> HighsMipWorker::transformNewIntegerFeasibleSolution(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a modified version of HighsMipSolverData::transformNewIntegerFeasibleSolution. I guess it is not possible to re-use the existing code? Should this live in HighsMipSolverData?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After looking into this again, I guess it is now possible to reuse some of the existing code (I think I may have gotten lazy at this point). It would need:

  • Some nullptr default argument like in the above point
  • Some new statistics added to HighsMipWorker (repair LP iterations)
  • Some timer magic (delaying fixing all of this for now)

Would you want this to be unified into one function?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can make a note and look at it later.

HighsDomain& localdom = heur.getLocalDomain();
heur.setHeuristic(true);

std::vector<HighsInt> intcols_;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this code segment (intcols_, intcols, this->intcols). What is it doing?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have now done this a few times: I don't want to add boolean switches at all points in the code, i.e., wherever intcols is accessed, so I simply define it once as a reference, which involves creating the thing it potentially is referencing, e.g., intcols_.
There might be some obvious C++ mechanic I could be using here.

if (heur.getCurrentDepth() > targetdepth) {
if (!heur.backtrackUntilDepth(targetdepth)) {
lp_iterations += heur.getLocalLpIterations();
worker.heur_stats.lp_iterations += heur.getLocalLpIterations();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not for now, but maybe worth having a getHeurLpIterations method at some point.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would return a reference to heur_stats.lp_iterations?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I just saw similar updates in different places and wanted to ask.

void undo(const HighsOptions& options, HighsSolution& solution,
HighsBasis& basis, const HighsInt report_col = -1) {
reductionValues.resetPosition();
HighsBasis& basis, const HighsInt report_col = -1,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed? Don't the workers have separate postsolve stacks?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workers don't have separate postsolve stacks. The current undo function is changing some global data structures, so you can't call undo on two different threads simultaneously.
This change is adding an argument so it does everything on copied data.

mipsolver->mipdata_->implications.rebuild(model->num_col_, newColIndex,
newRowIndex);
mipsolver->mipdata_->cutpool =
// TODO: Find a sensible way to do this
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you deleting the cut pool?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup! This was done before and I didn't see a need to change the workflow.

I had to get creative here because the std::atomic in HighsCutPool. I didn't want to change cutpool to a ptr in HighsMipData either (wanted to keep it as a reference). I'm happy with any ideas here as I think the current thing looks ugly (even if it works).

@jajhall
Copy link
Copy Markdown
Member

jajhall commented Mar 15, 2026

@Opt-Mucca I've merged latest into this branch to see whether all the CI tests pass

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants