/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* */ /* This file is part of the HiGHS linear optimization suite */ /* */ /* Written and engineered 2008-2022 at the University of Edinburgh */ /* */ /* Available as open-source under the MIT License */ /* */ /* Authors: Julian Hall, Ivet Galabova, Leona Gottwald and Michael */ /* Feldmeier */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #ifndef HIGHS_CONFLICTPOOL_H_ #define HIGHS_CONFLICTPOOL_H_ #include #include #include "mip/HighsDomain.h" #include "util/HighsInt.h" class HighsConflictPool { private: HighsInt agelim_; HighsInt softlimit_; std::vector ageDistribution_; std::vector ages_; std::vector modification_; std::vector conflictEntries_; std::vector> conflictRanges_; /// keep an ordered set of free spaces in the row arrays so that they can be /// reused efficiently std::set> freeSpaces_; /// vector of deleted conflicts so that their indices can be reused std::vector deletedConflicts_; std::vector propagationDomains; public: HighsConflictPool(HighsInt agelim, HighsInt softlimit) : agelim_(agelim), softlimit_(softlimit), ageDistribution_(), ages_(), modification_(), conflictEntries_(), conflictRanges_(), freeSpaces_(), deletedConflicts_(), propagationDomains() { ageDistribution_.resize(agelim_ + 1); } void addConflictCut(const HighsDomain& domain, const std::set& reasonSideFrontier); void addReconvergenceCut( const HighsDomain& domain, const std::set& reconvergenceFrontier, const HighsDomainChange& reconvergenceDomchg); void removeConflict(HighsInt conflict); void performAging(); void resetAge(HighsInt conflict) { if (ages_[conflict] > 0) { ageDistribution_[ages_[conflict]] -= 1; ageDistribution_[0] += 1; ages_[conflict] = 0; } } void setAgeLimit(HighsInt agelim) { agelim_ = agelim; ageDistribution_.resize(agelim_ + 1); } unsigned getModificationCount(HighsInt cut) const { return modification_[cut]; } void addPropagationDomain(HighsDomain::ConflictPoolPropagation* domain) { propagationDomains.push_back(domain); } void removePropagationDomain(HighsDomain::ConflictPoolPropagation* domain) { for (HighsInt k = propagationDomains.size() - 1; k >= 0; --k) { if (propagationDomains[k] == domain) { propagationDomains.erase(propagationDomains.begin() + k); return; } } } const std::vector& getConflictEntryVector() const { return conflictEntries_; } const std::vector>& getConflictRanges() const { return conflictRanges_; } HighsInt getNumConflicts() const { return conflictRanges_.size() - deletedConflicts_.size(); } }; #endif