forked from alexander-nadel/intel_sat_solver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTopiBacktrack.cc
63 lines (50 loc) · 1.96 KB
/
TopiBacktrack.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Copyright(C) 2021-2022 Intel Corporation
// SPDX - License - Identifier: MIT
#include "Topi.hpp"
using namespace Topor;
using namespace std;
template <typename TLit, typename TUInd, bool Compress>
void CTopi<TLit,TUInd,Compress>::BacktrackingInit()
{
m_CurrChronoBtIfHigher = m_QueryCurr == TQueryType::QUERY_INC_SHORT ? m_ParamChronoBtIfHigherS : m_QueryCurr == TQueryType::QUERY_INC_NORMAL ? m_ParamChronoBtIfHigherN : m_ParamChronoBtIfHigherInit;
m_CurrCustomBtStrat = m_QueryCurr == TQueryType::QUERY_INC_SHORT ? m_ParamCustomBtStratS : m_QueryCurr == TQueryType::QUERY_INC_NORMAL ? m_ParamCustomBtStratN : m_ParamCustomBtStratInit;
m_ConfsSinceNewInv = m_Stat.m_Conflicts;
}
template <typename TLit, typename TUInd, bool Compress>
void CTopi<TLit,TUInd,Compress>::Backtrack(TLit decLevelL, bool isBCPBacktrack, bool reuseTrail, bool isAPICall)
{
TUV decLevel = (TUV)decLevelL;
// cout << "\tc b <BacktrackLevel>" << endl;
if (m_DumpFile && isAPICall) (*m_DumpFile) << "b " << decLevel << endl;
if (decLevel >= m_DecLevel)
{
return;
}
if (m_ParamReuseTrail)
{
m_ReuseTrail.clear();
}
assert(NV(2) || P("***** Backtracking to " + to_string(decLevel) + "\n"));
++m_Stat.m_Backtracks;
if (isBCPBacktrack) ++m_Stat.m_BCPBacktracks;
m_Stat.m_ChronoBacktracks += (decLevel == m_DecLevel - 1);
// Cleaning up collapsed decision levels
while (decLevel != 0 && m_TrailLastVarPerDecLevel[decLevel] == BadClsInd)
{
if (decLevel == m_DecLevelOfLastAssignedAssumption)
{
--m_DecLevelOfLastAssignedAssumption;
}
--decLevel;
}
while (m_TrailEnd != m_TrailLastVarPerDecLevel[decLevel])
{
UnassignVar(m_TrailEnd, reuseTrail);
}
m_DecLevel = decLevel;
assert(NV(2) || P("***** Backtracked to " + to_string(m_DecLevel) + "\n"));
assert(NV(2) || !m_ParamReuseTrail || P(SReuseTrail()) + "\n");
}
template class Topor::CTopi<int32_t, uint32_t, false>;
template class Topor::CTopi<int32_t, uint64_t, false>;
template class Topor::CTopi<int32_t, uint64_t, true>;