3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-11-13 01:21:14 +00:00
z3/src/math/polysat/restart.cpp
2023-03-18 08:04:03 +01:00

47 lines
1.2 KiB
C++

/*++
Copyright (c) 2021 Microsoft Corporation
Module Name:
Restart
Author:
Jakob Rath, Nikolaj Bjorner (nbjorner) 2021-12-12
--*/
#include "math/polysat/solver.h"
#include "math/polysat/restart.h"
#include "util/luby.h"
namespace polysat {
restart::restart(solver& s):
s(s)
{}
/*
* Basic restart functionality.
* restarts make more sense when the order of variable
* assignments and the values assigned to variables can be diversified.
*/
bool restart::should_apply() const {
if (s.m_stats.m_num_conflicts - m_conflicts_at_restart < m_restart_threshold)
return false;
if (s.base_level() + 2 > s.m_level)
return false;
return true;
}
void restart::operator()() {
LOG_H2("Restarting");
++s.m_stats.m_num_restarts;
s.pop_levels(s.m_level - s.base_level());
m_conflicts_at_restart = s.m_stats.m_num_conflicts;
m_restart_threshold = m_restart_init * get_luby(++m_luby_idx);
IF_VERBOSE(10, verbose_stream() << "Restart with Conflict #" << s.m_stats.m_num_conflicts << "\n";);
s.randomize_activity();
}
}