MCPcopy Create free account
hub / github.com/ERGO-Code/HiGHS / doAddClique

Method doAddClique

highs/mip/HighsCliqueTable.cpp:334–474  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

332#endif
333
334void HighsCliqueTable::doAddClique(const CliqueVar* cliquevars,
335 HighsInt numcliquevars, bool equality,
336 HighsInt origin) {
337 HighsInt cliqueid;
338
339 if (freeslots.empty()) {
340 cliqueid = cliques.size();
341 cliques.emplace_back();
342 } else {
343 cliqueid = freeslots.back();
344 freeslots.pop_back();
345 }
346
347 cliques[cliqueid].equality = equality;
348 cliques[cliqueid].origin = origin;
349
350 decltype(freespaces)::iterator it;
351 HighsInt maxEnd;
352 if (freespaces.empty() ||
353 (it = freespaces.lower_bound(
354 std::make_pair(numcliquevars, HighsInt{-1}))) == freespaces.end()) {
355 cliques[cliqueid].start = cliqueentries.size();
356 cliques[cliqueid].end = cliques[cliqueid].start + numcliquevars;
357 maxEnd = cliques[cliqueid].end;
358 cliqueentries.resize(cliques[cliqueid].end);
359 } else {
360 auto freespace = *it;
361 freespaces.erase(it);
362
363 cliques[cliqueid].start = freespace.second;
364 cliques[cliqueid].end = cliques[cliqueid].start + numcliquevars;
365 maxEnd = cliques[cliqueid].start + freespace.first;
366 }
367
368 cliques[cliqueid].numZeroFixed = 0;
369
370 bool fixtozero = false;
371 HighsInt k = cliques[cliqueid].start;
372 for (HighsInt i = 0; i != numcliquevars; ++i) {
373 CliqueVar v = cliquevars[i];
374
375 resolveSubstitution(v);
376
377 if (fixtozero) {
378 infeasvertexstack.push_back(v);
379 continue;
380 }
381
382 // due to substitutions the variable may occur together with its complement
383 // in this clique and we can fix all other variables in the clique to zero:
384 // x + ~x + ... <= 1
385 // <=> x + 1 - x + ... <= 1
386 // <=> ... <= 0
387 bool clqHasVCompl =
388 numcliquevars == 2
389 ? invertedHashListSizeTwo[v.complement().index()].contains(cliqueid)
390 : invertedHashList[v.complement().index()].contains(cliqueid);
391

Callers 2

rebuildMethod · 0.80
buildFromMethod · 0.80

Calls 11

sortedEdgeFunction · 0.85
push_backMethod · 0.80
complementMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45
endMethod · 0.45
resizeMethod · 0.45
eraseMethod · 0.45
containsMethod · 0.45
indexMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected