blob: 13fa18ca019d0c69071708860dc69c22f75fa914 [file] [edit]
#include "internal.hpp"
namespace CaDiCaL {
void Internal::copy_phases (vector<signed char> &dst) {
PROFILE_SCOPE (copy);
for (auto i : vars) {
const signed char tmp = phases.saved[i];
if (tmp)
dst[i] = tmp;
}
}
void Internal::save_assigned_phases (vector<signed char> &dst) {
PROFILE_SCOPE (copy);
for (auto l : trail) {
// discussion with Armin and Florian to only save value excluding
// the ones that lead to the conflict to avoid the order of
// propagation to lead to different conflicts.
if (var (l).level < level)
dst[vidx (l)] = vals[vidx (l)];
}
}
void Internal::clear_phases (vector<signed char> &dst) {
PROFILE_SCOPE (copy);
for (auto i : vars)
dst[i] = 0;
}
void Internal::phase (int lit) {
const int idx = vidx (lit);
signed char old_forced_phase = phases.forced[idx];
signed char new_forced_phase = sign (lit);
if (old_forced_phase == new_forced_phase) {
LOG ("forced phase remains at %d", old_forced_phase * idx);
return;
}
if (old_forced_phase)
LOG ("overwriting old forced phase %d", old_forced_phase * idx);
LOG ("new forced phase %d", new_forced_phase * idx);
phases.forced[idx] = new_forced_phase;
}
void Internal::unphase (int lit) {
const int idx = vidx (lit);
signed char old_forced_phase = phases.forced[idx];
if (!old_forced_phase) {
LOG ("forced phase of %d already reset", lit);
return;
}
LOG ("clearing old forced phase %d", old_forced_phase * idx);
phases.forced[idx] = 0;
}
} // namespace CaDiCaL