Skip to content

Commit

Permalink
next segfault
Browse files Browse the repository at this point in the history
  • Loading branch information
galabovaa committed Feb 11, 2025
1 parent fa6317e commit a3a3174
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 28 deletions.
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ else()
if (UNIX)
target_compile_options(highs PRIVATE "-Wno-unused-variable")
target_compile_options(highs PRIVATE "-Wno-unused-const-variable")
# target_compile_options(highs PRIVATE "-O0")
endif()

# Configure the config file for the build tree:
Expand Down
5 changes: 4 additions & 1 deletion src/mip/HighsCutPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,11 @@ struct HighsCutSet {
};

class HighsCutPool {
private:
public:
HighsDynamicRowMatrix matrix_;

private:
// HighsDynamicRowMatrix matrix_;
std::vector<double> rhs_;
std::vector<int16_t> ages_;
std::vector<double> rownormalization_;
Expand Down
24 changes: 24 additions & 0 deletions src/mip/HighsDomain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ HighsDomain::HighsDomain(HighsMipSolver& mipsolver) : mipsolver(&mipsolver) {
void HighsDomain::addCutpool(HighsCutPool& cutpool) {
HighsInt cutpoolindex = cutpoolpropagation.size();
cutpoolpropagation.emplace_back(cutpoolindex, this, cutpool);

// std::cout << cutpoolpropagation[cutpoolindex].cutpool->matrix_.AheadNeg_.size() << std::endl;
// assign(cutpool->matrix_.numCol)
}

void HighsDomain::addConflictPool(HighsConflictPool& conflictPool) {
Expand Down Expand Up @@ -475,6 +478,9 @@ void HighsDomain::CutpoolPropagation::updateActivityLbChange(HighsInt col,
});
}

// std::cout << "Update activity LB change" << cutpool->getMatrix().AheadNeg_[2] << std::endl;
// std::cout << "Update activity LB change" << cutpool->getMatrix().AheadNeg_[17] << std::endl;

cutpool->getMatrix().forEachPositiveColumnEntry(
col, [&](HighsInt row, double val) {
assert(val > 0);
Expand Down Expand Up @@ -1990,6 +1996,22 @@ void HighsDomain::changeBound(HighsDomainChange boundchg, Reason reason) {

bool binary = isBinary(boundchg.column);

// std::cout << "FROM highs domain" << cutpoolpropagation[0].cutpool->matrix_.AheadNeg_[10] << std::endl;
if (cutpoolpropagation.size() > 1) {
// segfaults
// std::cout << "FROM highs domain" << cutpoolpropagation[1].cutpool->matrix_.AheadNeg_[10] << std::endl;
for (int index = 1; index < cutpoolpropagation.size() ; index++) {
if (cutpoolpropagation[1].cutpool->matrix_.AheadNeg_.size() == 0) {
cutpoolpropagation[1].cutpool->matrix_.AheadNeg_.assign(colLowerPos_.size(), -1);
std::cout << "New Size index " << index << " " << cutpoolpropagation[1].cutpool->matrix_.AheadNeg_.size() << std::endl;
}
if (cutpoolpropagation[1].cutpool->matrix_.AheadPos_.size() == 0) {
cutpoolpropagation[1].cutpool->matrix_.AheadPos_.assign(colLowerPos_.size(), -1);
std::cout << "New Size index " << index << " " << cutpoolpropagation[1].cutpool->matrix_.AheadNeg_.size() << std::endl;
}
}
}

double oldbound = doChangeBound(boundchg);

prevboundval_.emplace_back(oldbound, prevPos);
Expand Down Expand Up @@ -2055,7 +2077,9 @@ void HighsDomain::setDomainChangeStack(
branchPos_.clear();
HighsInt stacksize = domchgstack.size();
HighsInt k = 0;
// std::cout << "size = " << branchingPositions.size() << std::endl;
for (HighsInt branchPos : branchingPositions) {
// std::cout << branchPos << std::endl;
for (; k < branchPos; ++k) {
if (domchgstack[k].boundtype == HighsBoundType::kLower &&
domchgstack[k].boundval <= col_lower_[domchgstack[k].column])
Expand Down
3 changes: 2 additions & 1 deletion src/mip/HighsDomain.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,9 @@ class HighsDomain {

HighsMipSolver* mipsolver;

private:
public:
std::deque<CutpoolPropagation> cutpoolpropagation;
private:
std::deque<ConflictPoolPropagation> conflictPoolPropagation;

bool infeasible_ = 0;
Expand Down
9 changes: 7 additions & 2 deletions src/mip/HighsDynamicRowMatrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
#include "util/HighsInt.h"

class HighsDynamicRowMatrix {
public:

std::vector<HighsInt> AheadPos_;
std::vector<HighsInt> AheadNeg_;

private:
/// vector of index ranges in the index and value arrays of AR for each row
std::vector<std::pair<HighsInt, HighsInt>> ARrange_;
Expand All @@ -32,8 +37,8 @@ class HighsDynamicRowMatrix {

/// vector of pointers to the head/tail of the nonzero block list for each
/// column
std::vector<HighsInt> AheadPos_;
std::vector<HighsInt> AheadNeg_;
// std::vector<HighsInt> AheadPos_;
// std::vector<HighsInt> AheadNeg_;

std::vector<uint8_t> colsLinked;

Expand Down
9 changes: 8 additions & 1 deletion src/mip/HighsMipSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,8 @@ void HighsMipSolver::run() {
} // if (!submip && mipdata_->num_nodes >= nextCheck))

// Now perform the node search
const bool allow_multiple_node_search = false;
// const bool allow_multiple_node_search = false;
const bool allow_multiple_node_search = true;
for (HighsInt iSearch = 0; iSearch < mip_search_concurrency; iSearch++) {
if (iSearch > 0 && !allow_multiple_node_search) continue;
HighsSearch& search = *concurrent_searches[iSearch];
Expand Down Expand Up @@ -620,6 +621,12 @@ void HighsMipSolver::run() {
if (nextNode.lower_bound == bestBoundNodeLb &&
(HighsInt)nextNode.domchgstack.size() == bestBoundNodeStackSize)
lastLbLeave = numQueueLeaves;

// std::cout << mipworkers[0].cutpool_.matrix_.AheadNeg_[2] << std::endl;
// const HighsDomain& localdom = mipworkers[0].getSearch().getLocalDomain();
// int number = localdom.cutpoolpropagation[0].cutpool->matrix_.AheadNeg_[2];
// std::cout << number << std::endl;

search.installNode(std::move(nextNode));
}

Expand Down
12 changes: 12 additions & 0 deletions src/mip/HighsMipWorker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "mip/HighsMipWorker.h"

#include "mip/HighsSearch.h"
#include "mip/HighsMipSolverData.h"

HighsMipWorker::HighsMipWorker(const HighsMipSolver& mipsolver__)
: mipsolver_(mipsolver__),
Expand Down Expand Up @@ -35,6 +36,17 @@ HighsMipWorker::HighsMipWorker(const HighsMipSolver& mipsolver__)
// search_ptr_= std::unique_ptr<HighsSearch>(new HighsSearch(mipsolver_, pseudocost_));
search_ptr_= std::unique_ptr<HighsSearch>(new HighsSearch(*this, pseudocost_));

// add global cutpool
// search_ptr_->getLocalDomain().addCutpool(mipsolver__.mipdata_->cutpool);
// search_ptr_->getLocalDomain().addConflictPool(mipsolver_.mipdata_->conflictPool);

// cutpool_.matrix_.AheadNeg_.assign(mipsolver__.numCol(), -1);
// cutpool_.matrix_.AheadPos_.assign(mipsolver__.numCol(), -1);

// std::vector<HighsInt> AheadPos_;
// std::vector<HighsInt> AheadNeg_;

// add local cutpool
search_ptr_->getLocalDomain().addCutpool(cutpool_);
search_ptr_->getLocalDomain().addConflictPool(conflictpool_);

Expand Down
5 changes: 3 additions & 2 deletions src/mip/HighsMipWorker.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ class HighsMipWorker {
const HighsMipSolver& mipsolver_;

HighsLpRelaxation lprelaxation_;
HighsCutPool cutpool_;
HighsConflictPool conflictpool_;
HighsCliqueTable cliquetable_;

// Not sure if this should be here or elsewhere.
Expand All @@ -48,6 +46,9 @@ class HighsMipWorker {

HighsSearch& getSearch();

HighsCutPool cutpool_;
HighsConflictPool conflictpool_;

// members for worker threads.
HighsPseudocostInitialization pscostinit_;
HighsCliqueTable clqtableinit_;
Expand Down
42 changes: 21 additions & 21 deletions src/mip/HighsSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,9 @@ void HighsSearch::addBoundExceedingConflict() {
rhs)) {
if (mipsolver.mipdata_->domain.infeasible()) return;
localdom.conflictAnalysis(inds.data(), vals.data(), inds.size(), rhs,
mipsolver.mipdata_->conflictPool);
mipworker.conflictpool_);

HighsCutGeneration cutGen(*lp, mipsolver.mipdata_->cutpool);
HighsCutGeneration cutGen(*lp, mipworker.cutpool_);
mipsolver.mipdata_->debugSolution.checkCut(inds.data(), vals.data(),
inds.size(), rhs);
cutGen.generateConflict(localdom, inds, vals, rhs);
Expand Down Expand Up @@ -234,9 +234,9 @@ void HighsSearch::addInfeasibleConflict() {
//}
// HighsInt oldnumcuts = cutpool.getNumCuts();
localdom.conflictAnalysis(inds.data(), vals.data(), inds.size(), rhs,
mipsolver.mipdata_->conflictPool);
mipworker.conflictpool_);

HighsCutGeneration cutGen(*lp, mipsolver.mipdata_->cutpool);
HighsCutGeneration cutGen(*lp, mipworker.cutpool_);
mipsolver.mipdata_->debugSolution.checkCut(inds.data(), vals.data(),
inds.size(), rhs);
cutGen.generateConflict(localdom, inds, vals, rhs);
Expand Down Expand Up @@ -446,14 +446,14 @@ HighsInt HighsSearch::selectBranchingCandidate(int64_t maxSbIters,
localdom.changeBound(HighsBoundType::kUpper, fracints[k].first,
otherdownval);
if (localdom.infeasible()) {
localdom.conflictAnalysis(mipsolver.mipdata_->conflictPool);
localdom.conflictAnalysis(mipworker.conflictpool_);
localdom.backtrack();
localdom.clearChangedCols(numChangedCols);
continue;
}
localdom.propagate();
if (localdom.infeasible()) {
localdom.conflictAnalysis(mipsolver.mipdata_->conflictPool);
localdom.conflictAnalysis(mipworker.conflictpool_);
localdom.backtrack();
localdom.clearChangedCols(numChangedCols);
continue;
Expand Down Expand Up @@ -498,14 +498,14 @@ HighsInt HighsSearch::selectBranchingCandidate(int64_t maxSbIters,
otherupval);

if (localdom.infeasible()) {
localdom.conflictAnalysis(mipsolver.mipdata_->conflictPool);
localdom.conflictAnalysis(mipworker.conflictpool_);
localdom.backtrack();
localdom.clearChangedCols(numChangedCols);
continue;
}
localdom.propagate();
if (localdom.infeasible()) {
localdom.conflictAnalysis(mipsolver.mipdata_->conflictPool);
localdom.conflictAnalysis(mipworker.conflictpool_);
localdom.backtrack();
localdom.clearChangedCols(numChangedCols);
continue;
Expand Down Expand Up @@ -573,7 +573,7 @@ HighsInt HighsSearch::selectBranchingCandidate(int64_t maxSbIters,

inferences += localdom.getDomainChangeStack().size();
if (localdom.infeasible()) {
localdom.conflictAnalysis(mipsolver.mipdata_->conflictPool);
localdom.conflictAnalysis(mipworker.conflictpool_);
pseudocost.addCutoffObservation(col, false);
localdom.backtrack();
localdom.clearChangedCols();
Expand Down Expand Up @@ -705,7 +705,7 @@ HighsInt HighsSearch::selectBranchingCandidate(int64_t maxSbIters,

inferences += localdom.getDomainChangeStack().size();
if (localdom.infeasible()) {
localdom.conflictAnalysis(mipsolver.mipdata_->conflictPool);
localdom.conflictAnalysis(mipworker.conflictpool_);
pseudocost.addCutoffObservation(col, true);
localdom.backtrack();
localdom.clearChangedCols();
Expand Down Expand Up @@ -836,7 +836,7 @@ void HighsSearch::currentNodeToQueue(HighsNodeQueue& nodequeue) {
localdom.propagate();
localdom.clearChangedCols(oldchangedcols);
prune = localdom.infeasible();
if (prune) localdom.conflictAnalysis(mipsolver.mipdata_->conflictPool);
if (prune) localdom.conflictAnalysis(mipworker.conflictpool_);
}
if (!prune) {
std::vector<HighsInt> branchPositions;
Expand Down Expand Up @@ -875,7 +875,7 @@ void HighsSearch::openNodesToQueue(HighsNodeQueue& nodequeue) {
localdom.propagate();
localdom.clearChangedCols(oldchangedcols);
prune = localdom.infeasible();
if (prune) localdom.conflictAnalysis(mipsolver.mipdata_->conflictPool);
if (prune) localdom.conflictAnalysis(mipworker.conflictpool_);
}
if (!prune) {
std::vector<HighsInt> branchPositions;
Expand Down Expand Up @@ -1046,7 +1046,7 @@ HighsSearch::NodeResult HighsSearch::evaluateNode(
upbranch);
}

localdom.conflictAnalysis(mipsolver.mipdata_->conflictPool);
localdom.conflictAnalysis(mipworker.conflictpool_);
} else {
lp->flushDomain(localdom);
lp->setObjectiveLimit(mipsolver.mipdata_->upper_limit);
Expand Down Expand Up @@ -1079,7 +1079,7 @@ HighsSearch::NodeResult HighsSearch::evaluateNode(
upbranch);
}

localdom.conflictAnalysis(mipsolver.mipdata_->conflictPool);
localdom.conflictAnalysis(mipworker.conflictpool_);
} else if (lp->scaledOptimal(status)) {
lp->storeBasis();
lp->performAging();
Expand Down Expand Up @@ -1146,7 +1146,7 @@ HighsSearch::NodeResult HighsSearch::evaluateNode(
parent->branchingdecision.column, upbranch);
}

localdom.conflictAnalysis(mipsolver.mipdata_->conflictPool);
localdom.conflictAnalysis(mipworker.conflictpool_);
} else if (!localdom.getChangedCols().empty()) {
if (analysis_.analyse_mip_time)
assert(analysis_.mipTimerRunning(kMipClockEvaluateNodeInner));
Expand All @@ -1172,7 +1172,7 @@ HighsSearch::NodeResult HighsSearch::evaluateNode(
parent->branchingdecision.column, upbranch);
}

localdom.conflictAnalysis(mipsolver.mipdata_->conflictPool);
localdom.conflictAnalysis(mipworker.conflictpool_);
} else if (!localdom.getChangedCols().empty()) {
const HighsSearch::NodeResult evaluate_node_result =
evaluateNode(recursion_level + 1);
Expand Down Expand Up @@ -1721,7 +1721,7 @@ bool HighsSearch::backtrack(bool recoverBasis) {
if (!prune) {
localdom.propagate();
prune = localdom.infeasible();
if (prune) localdom.conflictAnalysis(mipsolver.mipdata_->conflictPool);
if (prune) localdom.conflictAnalysis(mipworker.conflictpool_);
}
if (!prune) {
mipsolver.mipdata_->symmetries.propagateOrbitopes(localdom);
Expand Down Expand Up @@ -1851,7 +1851,7 @@ bool HighsSearch::backtrackPlunge(HighsNodeQueue& nodequeue) {
if (!prune) {
localdom.propagate();
prune = localdom.infeasible();
if (prune) localdom.conflictAnalysis(mipsolver.mipdata_->conflictPool);
if (prune) localdom.conflictAnalysis(mipworker.conflictpool_);
}
if (!prune) {
mipsolver.mipdata_->symmetries.propagateOrbitopes(localdom);
Expand Down Expand Up @@ -2014,7 +2014,7 @@ void HighsSearch::dive(const HighsInt search_id) {
}
}
analysis_.mipTimerStart(kMipClockPerformAging1);
mipsolver.mipdata_->conflictPool.performAging();
mipworker.conflictpool_.performAging();
analysis_.mipTimerStop(kMipClockPerformAging1);

// set iteration limit for each lp solve during the dive to 10 times the
Expand Down Expand Up @@ -2131,10 +2131,10 @@ void HighsSearch::dive(const HighsInt search_id) {

assert(this->hasNode());

if (mipsolver.mipdata_->conflictPool.getNumConflicts() >
if (mipworker.conflictpool_.getNumConflicts() >
options_mip_->mip_pool_soft_limit) {
analysis_.mipTimerStart(kMipClockPerformAging2);
mipsolver.mipdata_->conflictPool.performAging();
mipworker.conflictpool_.performAging();
analysis_.mipTimerStop(kMipClockPerformAging2);
}

Expand Down

0 comments on commit a3a3174

Please sign in to comment.