Skip to content

Commit

Permalink
try and fix CoinStaticConflictGraph
Browse files Browse the repository at this point in the history
  • Loading branch information
jjhforrest committed Aug 30, 2024
1 parent 5885a2e commit 917c816
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
13 changes: 8 additions & 5 deletions src/CoinAdjacencyVector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,14 @@ void CoinAdjacencyVector::sort()

bool CoinAdjacencyVector::tryAddElementSortedVector(std::vector<size_t> &el, size_t newEl)
{
std::vector<size_t>::iterator pos = std::lower_bound(el.begin(), el.end(), newEl);
if (*pos == newEl)
return false;

el.insert(pos, newEl);
if (el.size()) {
std::vector<size_t>::iterator pos = std::lower_bound(el.begin(), el.end(), newEl);
if (*pos == newEl)
return false;
el.insert(pos, newEl);
} else {
el.push_back(newEl);
}
return true;
}

Expand Down
4 changes: 2 additions & 2 deletions src/CoinLpIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
/************************************************************************/

CoinLpIO::CoinLpIO()
: problemName_(CoinStrdup(""))
: problemName_(NULL)
, defaultHandler_(true)
, numberRows_(0)
, numberColumns_(0)
Expand Down Expand Up @@ -94,7 +94,7 @@ CoinLpIO::CoinLpIO()
// Copy constructor
//-------------------------------------------------------------------
CoinLpIO::CoinLpIO(const CoinLpIO &rhs)
: problemName_(CoinStrdup(""))
: problemName_(NULL)
, defaultHandler_(true)
, numberRows_(0)
, numberColumns_(0)
Expand Down
6 changes: 2 additions & 4 deletions src/CoinStaticConflictGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,20 +248,18 @@ CoinStaticConflictGraph::CoinStaticConflictGraph( const CoinConflictGraph *cgrap
cliques_[i] = std::vector<size_t>(largeClqs.cliqueElements(i), largeClqs.cliqueElements(i) + largeClqs.cliqueSize(i));
}

// reusing vector
std::vector<size_t> conf = clqEls;

// copying remaining direct conflicts
// adding new conflicts when they exist
for ( size_t i=0 ; (i<n) ; ++i ) {
size_t idxOrig = elements[i];
size_t sizeConf = 0;
std::vector<size_t> conf;

for ( size_t j=0 ; ( j < cgraph->nDirectConflicts(idxOrig) ) ; ++j ) {
size_t ni = newIdx[ cgraph->directConflicts(idxOrig)[j] ] ;
if ( ni == REMOVED )
continue;
conf[sizeConf++] = ni;
conf.push_back(ni);
}

conflicts_[i] = conf;
Expand Down

0 comments on commit 917c816

Please sign in to comment.