Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove AWClauseContainer #587

Merged
merged 1 commit into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 3 additions & 101 deletions Saturation/AWPassiveClauseContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ AWPassiveClauseContainer::AWPassiveClauseContainer(bool isOutermost, const Shell
AWPassiveClauseContainer::~AWPassiveClauseContainer()
{
ClauseQueue::Iterator cit(_ageQueue);
while (cit.hasNext())
while (cit.hasNext())
{
Clause* cl=cit.next();
ASS(!_isOutermost || cl->store()==Clause::PASSIVE);
Expand Down Expand Up @@ -285,9 +285,9 @@ Clause* AWPassiveClauseContainer::popSelected()
_size--;

Clause* cl;
bool selByWeight = _opt.randomAWR() ?
bool selByWeight = _opt.randomAWR() ?
// we respect the ratio, but choose probabilistically
(Random::getInteger(_ageRatio+_weightRatio) < _weightRatio) :
(Random::getInteger(_ageRatio+_weightRatio) < _weightRatio) :
// the deterministic way
byWeight(_balance);

Expand Down Expand Up @@ -686,102 +686,4 @@ bool AWPassiveClauseContainer::fulfilsWeightLimit(unsigned w, unsigned numPositi
return weightForClauseSelection <= _weightSelectionMaxWeight || (weightForClauseSelection == _weightSelectionMaxWeight && age <= _weightSelectionMaxAge);
}

AWClauseContainer::AWClauseContainer(const Options& opt)
: _ageQueue(opt), _weightQueue(opt), _ageRatio(1), _weightRatio(1), _balance(0), _size(0), _randomized(opt.randomAWR())
{
}

bool AWClauseContainer::isEmpty() const
{
ASS(!_ageRatio || !_weightRatio || _ageQueue.isEmpty()==_weightQueue.isEmpty());
return _ageQueue.isEmpty() && _weightQueue.isEmpty();
}

/**
* Add @b c clause in the queue.
* @since 31/12/2007 Manchester
*/
void AWClauseContainer::add(Clause* cl)
{
ASS(_ageRatio > 0 || _weightRatio > 0);

if (_ageRatio) {
_ageQueue.insert(cl);
}
if (_weightRatio) {
_weightQueue.insert(cl);
}
_size++;
addedEvent.fire(cl);
}

/**
* Remove Clause from the container.
*/
bool AWClauseContainer::remove(Clause* cl)
{
bool removed;
if (_ageRatio) {
removed = _ageQueue.remove(cl);
if (_weightRatio) {
ALWAYS(_weightQueue.remove(cl)==removed);
}
}
else {
ASS(_weightRatio);
removed = _weightQueue.remove(cl);
}

if (removed) {
_size--;
removedEvent.fire(cl);
}
return removed;
}

/**
* Return the next selected clause and remove it from the queue.
*/
Clause* AWClauseContainer::popSelected()
{
ASS( ! isEmpty());

_size--;

bool byWeight;
if (! _ageRatio) {
byWeight = true;
}
else if (! _weightRatio) {
byWeight = false;
}
else if (_randomized) {
byWeight = (Random::getInteger(_ageRatio+_weightRatio) < _weightRatio);
} else if (_balance > 0) {
byWeight = true;
}
else if (_balance < 0) {
byWeight = false;
}
else {
byWeight = (_ageRatio <= _weightRatio);
}

Clause* cl;
if (byWeight) {
_balance -= _ageRatio;
cl = _weightQueue.pop();
ALWAYS(_ageQueue.remove(cl));
}
else {
_balance += _weightRatio;
cl = _ageQueue.pop();
ALWAYS(_weightQueue.remove(cl));
}
selectedEvent.fire(cl);
return cl;
}



}
53 changes: 0 additions & 53 deletions Saturation/AWPassiveClauseContainer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,61 +144,8 @@ class AWPassiveClauseContainer
bool fulfilsWeightLimit(unsigned w, unsigned numPositiveLiterals, const Inference& inference) const override;

bool childrenPotentiallyFulfilLimits(Clause* cl, unsigned upperBoundNumSelLits) const override;

}; // class AWPassiveClauseContainer

/**
* Light-weight version of the AWPassiveClauseContainer that
* is not linked to the SaturationAlgorithm
*/
class AWClauseContainer: public ClauseContainer
{
public:
AWClauseContainer(const Shell::Options& opt);

void add(Clause* cl);
bool remove(Clause* cl);

/**
* Set age-weight ratio
* @since 08/01/2008 flight Murcia-Manchester
*/
void setAgeWeightRatio(int age,int weight)
{
ASS(age >= 0);
ASS(weight >= 0);
ASS(age > 0 || weight > 0);

_ageRatio = age;
_weightRatio = weight;
}

Clause* popSelected();
/** True if there are no passive clauses */
bool isEmpty() const;

unsigned size() const { return _size; }

static Comparison compareWeight(Clause* cl1, Clause* cl2);

private:
/** The age queue, empty if _ageRatio=0 */
AgeQueue _ageQueue;
/** The weight queue, empty if _weightRatio=0 */
WeightQueue _weightQueue;
/** the age ratio */
int _ageRatio;
/** the weight ratio */
int _weightRatio;
/** current balance. If &lt;0 then selection by age, if &gt;0
* then by weight */
int _balance;

unsigned _size;

bool _randomized;
};


};

Expand Down