Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
abc
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
abc
Commits
ba8112ff
Commit
ba8112ff
authored
Aug 29, 2017
by
Bruno Schmitt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing bronken C++ build; Satoko internal header, solver.h, should not be used in other packages
parent
d0f81fcf
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
166 additions
and
137 deletions
+166
-137
src/aig/gia/giaSatoko.c
+1
-2
src/aig/gia/giaSupp.c
+3
-4
src/proof/cec/cecSat.c
+10
-8
src/proof/pdr/pdrInt.h
+3
-4
src/sat/bmc/bmcBmc.c
+3
-4
src/sat/bmc/bmcBmc2.c
+5
-6
src/sat/bmc/bmcBmc3.c
+14
-15
src/sat/bmc/bmcBmcS.c
+7
-8
src/sat/bmc/bmcMesh.c
+4
-5
src/sat/bmc/bmcMesh2.c
+3
-4
src/sat/satoko/satoko.h
+20
-1
src/sat/satoko/solver.c
+17
-17
src/sat/satoko/solver.h
+4
-43
src/sat/satoko/solver_api.c
+72
-16
No files found.
src/aig/gia/giaSatoko.c
View file @
ba8112ff
...
@@ -21,7 +21,6 @@
...
@@ -21,7 +21,6 @@
#include "gia.h"
#include "gia.h"
#include "sat/cnf/cnf.h"
#include "sat/cnf/cnf.h"
#include "sat/satoko/satoko.h"
#include "sat/satoko/satoko.h"
#include "sat/satoko/solver.h"
ABC_NAMESPACE_IMPL_START
ABC_NAMESPACE_IMPL_START
...
@@ -133,7 +132,7 @@ int Gia_ManSatokoCallOne( Gia_Man_t * p, satoko_opts_t * opts, int iOutput )
...
@@ -133,7 +132,7 @@ int Gia_ManSatokoCallOne( Gia_Man_t * p, satoko_opts_t * opts, int iOutput )
if
(
pSat
)
if
(
pSat
)
{
{
status
=
satoko_solve
(
pSat
);
status
=
satoko_solve
(
pSat
);
Cost
=
(
unsigned
)
pSat
->
stats
.
n_conflicts
;
Cost
=
satoko_stats
(
pSat
)
->
n_conflicts
;
satoko_destroy
(
pSat
);
satoko_destroy
(
pSat
);
}
}
else
else
...
...
src/aig/gia/giaSupp.c
View file @
ba8112ff
...
@@ -20,7 +20,6 @@
...
@@ -20,7 +20,6 @@
#include "gia.h"
#include "gia.h"
#include "sat/satoko/satoko.h"
#include "sat/satoko/satoko.h"
#include "sat/satoko/solver.h"
#ifdef ABC_USE_CUDD
#ifdef ABC_USE_CUDD
#include "bdd/extrab/extraBdd.h"
#include "bdd/extrab/extraBdd.h"
...
@@ -389,7 +388,7 @@ Gia_Man2Min_t * Gia_Man2SuppStart( Gia_Man_t * pGia )
...
@@ -389,7 +388,7 @@ Gia_Man2Min_t * Gia_Man2SuppStart( Gia_Man_t * pGia )
p
->
vFanins
=
Vec_PtrAlloc
(
100
);
p
->
vFanins
=
Vec_PtrAlloc
(
100
);
p
->
vSatVars
=
Vec_IntAlloc
(
100
);
p
->
vSatVars
=
Vec_IntAlloc
(
100
);
p
->
iPattern
=
1
;
p
->
iPattern
=
1
;
p
->
pSat
->
opts
.
learnt_ratio
=
0
;
// prevent garbage collection
satoko_options
(
p
->
pSat
)
->
learnt_ratio
=
0
;
// prevent garbage collection
return
p
;
return
p
;
}
}
void
Gia_Man2SuppStop
(
Gia_Man2Min_t
*
p
)
void
Gia_Man2SuppStop
(
Gia_Man2Min_t
*
p
)
...
@@ -725,7 +724,7 @@ int Gia_Min2ManSolve( Gia_Man2Min_t * p )
...
@@ -725,7 +724,7 @@ int Gia_Min2ManSolve( Gia_Man2Min_t * p )
// assert( iTemp == -1 );
// assert( iTemp == -1 );
Vec_IntFillExtra
(
&
p
->
pGia
->
vCopies
,
Gia_ManObjNum
(
p
->
pGia
),
-
1
);
Vec_IntFillExtra
(
&
p
->
pGia
->
vCopies
,
Gia_ManObjNum
(
p
->
pGia
),
-
1
);
Vec_IntClear
(
p
->
vSatVars
);
Vec_IntClear
(
p
->
vSatVars
);
assert
(
s
olver
_varnum
(
p
->
pSat
)
==
0
);
assert
(
s
atoko
_varnum
(
p
->
pSat
)
==
0
);
iVar0
=
Gia_Min2ObjGetCnfVar
(
p
,
iObj0
);
iVar0
=
Gia_Min2ObjGetCnfVar
(
p
,
iObj0
);
iVar1
=
Gia_Min2ObjGetCnfVar
(
p
,
iObj1
);
iVar1
=
Gia_Min2ObjGetCnfVar
(
p
,
iObj1
);
satoko_assump_push
(
p
->
pSat
,
Abc_Var2Lit
(
iVar0
,
Abc_LitIsCompl
(
p
->
iLits
[
0
]))
);
satoko_assump_push
(
p
->
pSat
,
Abc_Var2Lit
(
iVar0
,
Abc_LitIsCompl
(
p
->
iLits
[
0
]))
);
...
@@ -739,7 +738,7 @@ int Gia_Min2ManSolve( Gia_Man2Min_t * p )
...
@@ -739,7 +738,7 @@ int Gia_Min2ManSolve( Gia_Man2Min_t * p )
assert
(
Gia_Min2ManSimulate
(
p
)
==
1
);
assert
(
Gia_Min2ManSimulate
(
p
)
==
1
);
for
(
n
=
0
;
n
<
2
;
n
++
)
for
(
n
=
0
;
n
<
2
;
n
++
)
Vec_IntForEachEntry
(
p
->
vCis
[
n
],
iTemp
,
i
)
Vec_IntForEachEntry
(
p
->
vCis
[
n
],
iTemp
,
i
)
Gia_Min2SimSetInputBit
(
p
,
iTemp
,
var_polarity
(
p
->
pSat
,
Gia_Min2ObjSatId
(
p
->
pGia
,
Gia_ManObj
(
p
->
pGia
,
iTemp
)))
==
LIT_TRUE
,
p
->
iPattern
);
Gia_Min2SimSetInputBit
(
p
,
iTemp
,
satoko_var_polarity
(
p
->
pSat
,
Gia_Min2ObjSatId
(
p
->
pGia
,
Gia_ManObj
(
p
->
pGia
,
iTemp
)))
==
SATOKO_
LIT_TRUE
,
p
->
iPattern
);
//assert( Gia_Min2ManSimulate(p) == 0 );
//assert( Gia_Min2ManSimulate(p) == 0 );
p
->
iPattern
=
p
->
iPattern
==
63
?
1
:
p
->
iPattern
+
1
;
p
->
iPattern
=
p
->
iPattern
==
63
?
1
:
p
->
iPattern
+
1
;
p
->
nSatSat
++
;
p
->
nSatSat
++
;
...
...
src/proof/cec/cecSat.c
View file @
ba8112ff
...
@@ -21,7 +21,6 @@
...
@@ -21,7 +21,6 @@
#include "aig/gia/gia.h"
#include "aig/gia/gia.h"
#include "misc/util/utilTruth.h"
#include "misc/util/utilTruth.h"
#include "sat/satoko/satoko.h"
#include "sat/satoko/satoko.h"
#include "sat/satoko/solver.h"
#include "cec.h"
#include "cec.h"
ABC_NAMESPACE_IMPL_START
ABC_NAMESPACE_IMPL_START
...
@@ -660,6 +659,7 @@ Cec2_Man_t * Cec2_ManCreate( Gia_Man_t * pAig, Cec2_Par_t * pPars )
...
@@ -660,6 +659,7 @@ Cec2_Man_t * Cec2_ManCreate( Gia_Man_t * pAig, Cec2_Par_t * pPars )
{
{
Cec2_Man_t
*
p
;
Cec2_Man_t
*
p
;
Gia_Obj_t
*
pObj
;
int
i
;
Gia_Obj_t
*
pObj
;
int
i
;
satoko_opts_t
Pars
;
//assert( Gia_ManRegNum(pAig) == 0 );
//assert( Gia_ManRegNum(pAig) == 0 );
p
=
ABC_CALLOC
(
Cec2_Man_t
,
1
);
p
=
ABC_CALLOC
(
Cec2_Man_t
,
1
);
memset
(
p
,
0
,
sizeof
(
Cec2_Man_t
)
);
memset
(
p
,
0
,
sizeof
(
Cec2_Man_t
)
);
...
@@ -675,6 +675,7 @@ Cec2_Man_t * Cec2_ManCreate( Gia_Man_t * pAig, Cec2_Par_t * pPars )
...
@@ -675,6 +675,7 @@ Cec2_Man_t * Cec2_ManCreate( Gia_Man_t * pAig, Cec2_Par_t * pPars )
Gia_ManHashAlloc
(
p
->
pNew
);
Gia_ManHashAlloc
(
p
->
pNew
);
Vec_IntFill
(
&
p
->
pNew
->
vCopies
,
Gia_ManObjNum
(
p
->
pNew
),
-
1
);
Vec_IntFill
(
&
p
->
pNew
->
vCopies
,
Gia_ManObjNum
(
p
->
pNew
),
-
1
);
// SAT solving
// SAT solving
memset
(
&
Pars
,
0
,
sizeof
(
satoko_opts_t
)
);
p
->
pSat
=
satoko_create
();
p
->
pSat
=
satoko_create
();
p
->
vFrontier
=
Vec_PtrAlloc
(
1000
);
p
->
vFrontier
=
Vec_PtrAlloc
(
1000
);
p
->
vFanins
=
Vec_PtrAlloc
(
100
);
p
->
vFanins
=
Vec_PtrAlloc
(
100
);
...
@@ -682,7 +683,8 @@ Cec2_Man_t * Cec2_ManCreate( Gia_Man_t * pAig, Cec2_Par_t * pPars )
...
@@ -682,7 +683,8 @@ Cec2_Man_t * Cec2_ManCreate( Gia_Man_t * pAig, Cec2_Par_t * pPars )
p
->
vSatVars
=
Vec_IntAlloc
(
100
);
p
->
vSatVars
=
Vec_IntAlloc
(
100
);
p
->
vObjSatPairs
=
Vec_IntAlloc
(
100
);
p
->
vObjSatPairs
=
Vec_IntAlloc
(
100
);
p
->
vCexTriples
=
Vec_IntAlloc
(
100
);
p
->
vCexTriples
=
Vec_IntAlloc
(
100
);
p
->
pSat
->
opts
.
conf_limit
=
pPars
->
nConfLimit
;
Pars
.
conf_limit
=
pPars
->
nConfLimit
;
satoko_configure
(
p
->
pSat
,
&
Pars
);
// remember pointer to the solver in the AIG manager
// remember pointer to the solver in the AIG manager
pAig
->
pData
=
p
->
pSat
;
pAig
->
pData
=
p
->
pSat
;
return
p
;
return
p
;
...
@@ -742,7 +744,7 @@ int Cec2_ManVerify_rec( Gia_Man_t * p, int iObj, satoko_t * pSat )
...
@@ -742,7 +744,7 @@ int Cec2_ManVerify_rec( Gia_Man_t * p, int iObj, satoko_t * pSat )
return
pObj
->
fMark1
;
return
pObj
->
fMark1
;
Gia_ObjSetTravIdCurrentId
(
p
,
iObj
);
Gia_ObjSetTravIdCurrentId
(
p
,
iObj
);
if
(
Gia_ObjIsCi
(
pObj
)
)
if
(
Gia_ObjIsCi
(
pObj
)
)
return
pObj
->
fMark1
=
var_polarity
(
pSat
,
Cec2_ObjSatId
(
p
,
pObj
))
==
LIT_TRUE
;
return
pObj
->
fMark1
=
satoko_var_polarity
(
pSat
,
Cec2_ObjSatId
(
p
,
pObj
))
==
SATOKO_
LIT_TRUE
;
assert
(
Gia_ObjIsAnd
(
pObj
)
);
assert
(
Gia_ObjIsAnd
(
pObj
)
);
Value0
=
Cec2_ManVerify_rec
(
p
,
Gia_ObjFaninId0
(
pObj
,
iObj
),
pSat
)
^
Gia_ObjFaninC0
(
pObj
);
Value0
=
Cec2_ManVerify_rec
(
p
,
Gia_ObjFaninId0
(
pObj
,
iObj
),
pSat
)
^
Gia_ObjFaninC0
(
pObj
);
Value1
=
Cec2_ManVerify_rec
(
p
,
Gia_ObjFaninId1
(
pObj
,
iObj
),
pSat
)
^
Gia_ObjFaninC1
(
pObj
);
Value1
=
Cec2_ManVerify_rec
(
p
,
Gia_ObjFaninId1
(
pObj
,
iObj
),
pSat
)
^
Gia_ObjFaninC1
(
pObj
);
...
@@ -750,8 +752,8 @@ int Cec2_ManVerify_rec( Gia_Man_t * p, int iObj, satoko_t * pSat )
...
@@ -750,8 +752,8 @@ int Cec2_ManVerify_rec( Gia_Man_t * p, int iObj, satoko_t * pSat )
}
}
void
Cec2_ManVerify
(
Gia_Man_t
*
p
,
int
iObj0
,
int
iObj1
,
int
fPhase
,
satoko_t
*
pSat
)
void
Cec2_ManVerify
(
Gia_Man_t
*
p
,
int
iObj0
,
int
iObj1
,
int
fPhase
,
satoko_t
*
pSat
)
{
{
// int val0 =
var_polarity(pSat, Cec2_ObjSatId(p, Gia_ManObj(p, iObj0))) ==
LIT_TRUE;
// int val0 =
satoko_var_polarity(pSat, Cec2_ObjSatId(p, Gia_ManObj(p, iObj0))) == SATOKO_
LIT_TRUE;
// int val1 =
var_polarity(pSat, Cec2_ObjSatId(p, Gia_ManObj(p, iObj1))) ==
LIT_TRUE;
// int val1 =
satoko_var_polarity(pSat, Cec2_ObjSatId(p, Gia_ManObj(p, iObj1))) == SATOKO_
LIT_TRUE;
int
Value0
,
Value1
;
int
Value0
,
Value1
;
Gia_ManIncrementTravId
(
p
);
Gia_ManIncrementTravId
(
p
);
Value0
=
Cec2_ManVerify_rec
(
p
,
iObj0
,
pSat
);
Value0
=
Cec2_ManVerify_rec
(
p
,
iObj0
,
pSat
);
...
@@ -805,7 +807,7 @@ int Cec2_ManSolveTwo( Cec2_Man_t * p, int iObj0, int iObj1, int fPhase )
...
@@ -805,7 +807,7 @@ int Cec2_ManSolveTwo( Cec2_Man_t * p, int iObj0, int iObj1, int fPhase )
if
(
iObj1
<
iObj0
)
if
(
iObj1
<
iObj0
)
iObj1
^=
iObj0
,
iObj0
^=
iObj1
,
iObj1
^=
iObj0
;
iObj1
^=
iObj0
,
iObj0
^=
iObj1
,
iObj1
^=
iObj0
;
assert
(
iObj0
<
iObj1
);
assert
(
iObj0
<
iObj1
);
assert
(
p
->
pPars
->
fUseCones
||
s
olver
_varnum
(
p
->
pSat
)
==
0
);
assert
(
p
->
pPars
->
fUseCones
||
s
atoko
_varnum
(
p
->
pSat
)
==
0
);
if
(
!
iObj0
&&
Cec2_ObjSatId
(
p
->
pNew
,
Gia_ManConst0
(
p
->
pNew
))
==
-
1
)
if
(
!
iObj0
&&
Cec2_ObjSatId
(
p
->
pNew
,
Gia_ManConst0
(
p
->
pNew
))
==
-
1
)
Cec2_ObjSetSatId
(
p
->
pNew
,
Gia_ManConst0
(
p
->
pNew
),
satoko_add_variable
(
p
->
pSat
,
0
)
);
Cec2_ObjSetSatId
(
p
->
pNew
,
Gia_ManConst0
(
p
->
pNew
),
satoko_add_variable
(
p
->
pSat
,
0
)
);
iVar0
=
Cec2_ObjGetCnfVar
(
p
,
iObj0
);
iVar0
=
Cec2_ObjGetCnfVar
(
p
,
iObj0
);
...
@@ -859,7 +861,7 @@ int Cec2_ManSweepNode( Cec2_Man_t * p, int iObj )
...
@@ -859,7 +861,7 @@ int Cec2_ManSweepNode( Cec2_Man_t * p, int iObj )
p
->
pAig
->
iPatsPi
=
(
p
->
pAig
->
iPatsPi
==
64
*
p
->
pAig
->
nSimWords
-
1
)
?
1
:
p
->
pAig
->
iPatsPi
+
1
;
p
->
pAig
->
iPatsPi
=
(
p
->
pAig
->
iPatsPi
==
64
*
p
->
pAig
->
nSimWords
-
1
)
?
1
:
p
->
pAig
->
iPatsPi
+
1
;
assert
(
p
->
pAig
->
iPatsPi
>
0
&&
p
->
pAig
->
iPatsPi
<
64
*
p
->
pAig
->
nSimWords
);
assert
(
p
->
pAig
->
iPatsPi
>
0
&&
p
->
pAig
->
iPatsPi
<
64
*
p
->
pAig
->
nSimWords
);
Vec_IntForEachEntryDouble
(
p
->
vObjSatPairs
,
IdAig
,
IdSat
,
i
)
Vec_IntForEachEntryDouble
(
p
->
vObjSatPairs
,
IdAig
,
IdSat
,
i
)
Cec2_ObjSimSetInputBit
(
p
->
pAig
,
IdAig
,
var_polarity
(
p
->
pSat
,
IdSat
)
==
LIT_TRUE
);
Cec2_ObjSimSetInputBit
(
p
->
pAig
,
IdAig
,
satoko_var_polarity
(
p
->
pSat
,
IdSat
)
==
SATOKO_
LIT_TRUE
);
p
->
timeSatSat
+=
Abc_Clock
()
-
clk
;
p
->
timeSatSat
+=
Abc_Clock
()
-
clk
;
RetValue
=
0
;
RetValue
=
0
;
}
}
...
@@ -884,7 +886,7 @@ int Cec2_ManSweepNode( Cec2_Man_t * p, int iObj )
...
@@ -884,7 +886,7 @@ int Cec2_ManSweepNode( Cec2_Man_t * p, int iObj )
clk
=
Abc_Clock
();
clk
=
Abc_Clock
();
satoko_rollback
(
p
->
pSat
);
satoko_rollback
(
p
->
pSat
);
p
->
timeExtra
+=
Abc_Clock
()
-
clk
;
p
->
timeExtra
+=
Abc_Clock
()
-
clk
;
p
->
pSat
->
stats
.
n_conflicts
=
0
;
satoko_stats
(
p
->
pSat
)
->
n_conflicts
=
0
;
return
RetValue
;
return
RetValue
;
}
}
void
Cec2_ManPrintStats
(
Gia_Man_t
*
p
,
Cec2_Par_t
*
pPars
,
Cec2_Man_t
*
pMan
)
void
Cec2_ManPrintStats
(
Gia_Man_t
*
p
,
Cec2_Par_t
*
pPars
,
Cec2_Man_t
*
pMan
)
...
...
src/proof/pdr/pdrInt.h
View file @
ba8112ff
...
@@ -38,7 +38,6 @@
...
@@ -38,7 +38,6 @@
#include "sat/bsat/satSolver.h"
#include "sat/bsat/satSolver.h"
#else
#else
#include "sat/satoko/satoko.h"
#include "sat/satoko/satoko.h"
#include "sat/satoko/solver.h"
#define l_Undef 0
#define l_Undef 0
#define l_True 1
#define l_True 1
#define l_False -1
#define l_False -1
...
@@ -47,13 +46,13 @@
...
@@ -47,13 +46,13 @@
#define sat_solver_delete satoko_destroy
#define sat_solver_delete satoko_destroy
#define zsat_solver_new_seed(s) satoko_create()
#define zsat_solver_new_seed(s) satoko_create()
#define zsat_solver_restart_seed(s,a) satoko_reset(s)
#define zsat_solver_restart_seed(s,a) satoko_reset(s)
#define sat_solver_nvars s
olver
_varnum
#define sat_solver_nvars s
atoko
_varnum
#define sat_solver_setnvars satoko_setnvars
#define sat_solver_setnvars satoko_setnvars
#define sat_solver_addclause(s,b,e) satoko_add_clause(s,b,e-b)
#define sat_solver_addclause(s,b,e) satoko_add_clause(s,b,e-b)
#define sat_solver_final satoko_final_conflict
#define sat_solver_final satoko_final_conflict
#define sat_solver_solve(s,b,e,c,x,y,z) satoko_solve_assumptions_limit(s,b,e-b,(int)c)
#define sat_solver_solve(s,b,e,c,x,y,z) satoko_solve_assumptions_limit(s,b,e-b,(int)c)
#define sat_solver_var_value s
olver
_read_cex_varvalue
#define sat_solver_var_value s
atoko
_read_cex_varvalue
#define sat_solver_set_runtime_limit s
olver
_set_runtime_limit
#define sat_solver_set_runtime_limit s
atoko
_set_runtime_limit
#define sat_solver_compress(s)
#define sat_solver_compress(s)
#endif
#endif
...
...
src/sat/bmc/bmcBmc.c
View file @
ba8112ff
...
@@ -22,7 +22,6 @@
...
@@ -22,7 +22,6 @@
#include "sat/cnf/cnf.h"
#include "sat/cnf/cnf.h"
#include "sat/bsat/satStore.h"
#include "sat/bsat/satStore.h"
#include "sat/satoko/satoko.h"
#include "sat/satoko/satoko.h"
#include "sat/satoko/solver.h"
#include "bmc.h"
#include "bmc.h"
ABC_NAMESPACE_IMPL_START
ABC_NAMESPACE_IMPL_START
...
@@ -190,7 +189,7 @@ int * Sat2_SolverGetModel( satoko_t * p, int * pVars, int nVars )
...
@@ -190,7 +189,7 @@ int * Sat2_SolverGetModel( satoko_t * p, int * pVars, int nVars )
int
i
;
int
i
;
pModel
=
ABC_CALLOC
(
int
,
nVars
+
1
);
pModel
=
ABC_CALLOC
(
int
,
nVars
+
1
);
for
(
i
=
0
;
i
<
nVars
;
i
++
)
for
(
i
=
0
;
i
<
nVars
;
i
++
)
pModel
[
i
]
=
s
olver
_read_cex_varvalue
(
p
,
pVars
[
i
]);
pModel
[
i
]
=
s
atoko
_read_cex_varvalue
(
p
,
pVars
[
i
]);
return
pModel
;
return
pModel
;
}
}
...
@@ -320,8 +319,8 @@ int Saig_ManBmcSimple( Aig_Man_t * pAig, int nFrames, int nSizeMax, int nConfLim
...
@@ -320,8 +319,8 @@ int Saig_ManBmcSimple( Aig_Man_t * pAig, int nFrames, int nSizeMax, int nConfLim
printf
(
"Solved %2d outputs of frame %3d. "
,
printf
(
"Solved %2d outputs of frame %3d. "
,
Saig_ManPoNum
(
pAig
),
i
/
Saig_ManPoNum
(
pAig
)
);
Saig_ManPoNum
(
pAig
),
i
/
Saig_ManPoNum
(
pAig
)
);
printf
(
"Conf =%8.0f. Imp =%11.0f. "
,
printf
(
"Conf =%8.0f. Imp =%11.0f. "
,
(
double
)(
pSat
?
pSat
->
stats
.
conflicts
:
s
olver
_conflictnum
(
pSat2
)),
(
double
)(
pSat
?
pSat
->
stats
.
conflicts
:
s
atoko
_conflictnum
(
pSat2
)),
(
double
)(
pSat
?
pSat
->
stats
.
propagations
:
satoko_stats
(
pSat2
)
.
n_propagations
)
);
(
double
)(
pSat
?
pSat
->
stats
.
propagations
:
satoko_stats
(
pSat2
)
->
n_propagations
)
);
ABC_PRT
(
"T"
,
Abc_Clock
()
-
clkPart
);
ABC_PRT
(
"T"
,
Abc_Clock
()
-
clkPart
);
clkPart
=
Abc_Clock
();
clkPart
=
Abc_Clock
();
fflush
(
stdout
);
fflush
(
stdout
);
...
...
src/sat/bmc/bmcBmc2.c
View file @
ba8112ff
...
@@ -21,7 +21,6 @@
...
@@ -21,7 +21,6 @@
#include "sat/cnf/cnf.h"
#include "sat/cnf/cnf.h"
#include "sat/bsat/satStore.h"
#include "sat/bsat/satStore.h"
#include "sat/satoko/satoko.h"
#include "sat/satoko/satoko.h"
#include "sat/satoko/solver.h"
#include "proof/ssw/ssw.h"
#include "proof/ssw/ssw.h"
#include "bmc.h"
#include "bmc.h"
...
@@ -690,7 +689,7 @@ Abc_Cex_t * Saig_BmcGenerateCounterExample( Saig_Bmc_t * p )
...
@@ -690,7 +689,7 @@ Abc_Cex_t * Saig_BmcGenerateCounterExample( Saig_Bmc_t * p )
iVarNum
=
Saig_BmcSatNum
(
p
,
pObjFrm
);
iVarNum
=
Saig_BmcSatNum
(
p
,
pObjFrm
);
if
(
iVarNum
==
0
)
if
(
iVarNum
==
0
)
continue
;
continue
;
if
(
p
->
pSat2
?
s
olver
_read_cex_varvalue
(
p
->
pSat2
,
iVarNum
)
:
sat_solver_var_value
(
p
->
pSat
,
iVarNum
)
)
if
(
p
->
pSat2
?
s
atoko
_read_cex_varvalue
(
p
->
pSat2
,
iVarNum
)
:
sat_solver_var_value
(
p
->
pSat
,
iVarNum
)
)
Abc_InfoSetBit
(
pCex
->
pData
,
pCex
->
nRegs
+
Saig_ManPiNum
(
p
->
pAig
)
*
f
+
i
);
Abc_InfoSetBit
(
pCex
->
pData
,
pCex
->
nRegs
+
Saig_ManPiNum
(
p
->
pAig
)
*
f
+
i
);
}
}
}
}
...
@@ -729,7 +728,7 @@ int Saig_BmcSolveTargets( Saig_Bmc_t * p, int nStart, int * pnOutsSolved )
...
@@ -729,7 +728,7 @@ int Saig_BmcSolveTargets( Saig_Bmc_t * p, int nStart, int * pnOutsSolved )
{
{
if
(
((
*
pnOutsSolved
)
++
/
Saig_ManPoNum
(
p
->
pAig
))
<
nStart
)
if
(
((
*
pnOutsSolved
)
++
/
Saig_ManPoNum
(
p
->
pAig
))
<
nStart
)
continue
;
continue
;
if
(
p
->
nConfMaxAll
&&
(
p
->
pSat
?
p
->
pSat
->
stats
.
conflicts
:
s
olver
_conflictnum
(
p
->
pSat2
))
>
p
->
nConfMaxAll
)
if
(
p
->
nConfMaxAll
&&
(
p
->
pSat
?
p
->
pSat
->
stats
.
conflicts
:
s
atoko
_conflictnum
(
p
->
pSat2
))
>
p
->
nConfMaxAll
)
return
l_Undef
;
return
l_Undef
;
VarNum
=
Saig_BmcSatNum
(
p
,
Aig_Regular
(
pObj
)
);
VarNum
=
Saig_BmcSatNum
(
p
,
Aig_Regular
(
pObj
)
);
Lit
=
toLitCond
(
VarNum
,
Aig_IsComplement
(
pObj
)
);
Lit
=
toLitCond
(
VarNum
,
Aig_IsComplement
(
pObj
)
);
...
@@ -838,7 +837,7 @@ int Saig_BmcPerform( Aig_Man_t * pAig, int nStart, int nFramesMax, int nNodesMax
...
@@ -838,7 +837,7 @@ int Saig_BmcPerform( Aig_Man_t * pAig, int nStart, int nFramesMax, int nNodesMax
if
(
nTimeOut
)
if
(
nTimeOut
)
{
{
if
(
p
->
pSat2
)
if
(
p
->
pSat2
)
s
olver
_set_runtime_limit
(
p
->
pSat2
,
nTimeToStop
);
s
atoko
_set_runtime_limit
(
p
->
pSat2
,
nTimeToStop
);
else
else
sat_solver_set_runtime_limit
(
p
->
pSat
,
nTimeToStop
);
sat_solver_set_runtime_limit
(
p
->
pSat
,
nTimeToStop
);
}
}
...
@@ -867,7 +866,7 @@ int Saig_BmcPerform( Aig_Man_t * pAig, int nStart, int nFramesMax, int nNodesMax
...
@@ -867,7 +866,7 @@ int Saig_BmcPerform( Aig_Man_t * pAig, int nStart, int nFramesMax, int nNodesMax
{
{
printf
(
"%4d : F =%5d. O =%4d. And =%8d. Var =%8d. Conf =%7d. "
,
printf
(
"%4d : F =%5d. O =%4d. And =%8d. Var =%8d. Conf =%7d. "
,
Iter
,
p
->
iFrameLast
,
p
->
iOutputLast
,
Aig_ManNodeNum
(
p
->
pFrm
),
p
->
nSatVars
,
Iter
,
p
->
iFrameLast
,
p
->
iOutputLast
,
Aig_ManNodeNum
(
p
->
pFrm
),
p
->
nSatVars
,
p
->
pSat
?
(
int
)
p
->
pSat
->
stats
.
conflicts
:
s
olver
_conflictnum
(
p
->
pSat2
)
);
p
->
pSat
?
(
int
)
p
->
pSat
->
stats
.
conflicts
:
s
atoko
_conflictnum
(
p
->
pSat2
)
);
printf
(
"%4.0f MB"
,
4
.
0
*
(
p
->
iFrameLast
+
1
)
*
p
->
nObjs
/
(
1
<<
20
)
);
printf
(
"%4.0f MB"
,
4
.
0
*
(
p
->
iFrameLast
+
1
)
*
p
->
nObjs
/
(
1
<<
20
)
);
printf
(
"%9.2f sec"
,
(
float
)(
Abc_Clock
()
-
clkTotal
)
/
(
float
)(
CLOCKS_PER_SEC
)
);
printf
(
"%9.2f sec"
,
(
float
)(
Abc_Clock
()
-
clkTotal
)
/
(
float
)(
CLOCKS_PER_SEC
)
);
printf
(
"
\n
"
);
printf
(
"
\n
"
);
...
@@ -922,7 +921,7 @@ int Saig_BmcPerform( Aig_Man_t * pAig, int nStart, int nFramesMax, int nNodesMax
...
@@ -922,7 +921,7 @@ int Saig_BmcPerform( Aig_Man_t * pAig, int nStart, int nFramesMax, int nNodesMax
{
{
if
(
p
->
iFrameLast
>=
p
->
nFramesMax
)
if
(
p
->
iFrameLast
>=
p
->
nFramesMax
)
printf
(
"Reached limit on the number of timeframes (%d).
\n
"
,
p
->
nFramesMax
);
printf
(
"Reached limit on the number of timeframes (%d).
\n
"
,
p
->
nFramesMax
);
else
if
(
p
->
nConfMaxAll
&&
(
p
->
pSat
?
(
int
)
p
->
pSat
->
stats
.
conflicts
:
s
olver
_conflictnum
(
p
->
pSat2
))
>
p
->
nConfMaxAll
)
else
if
(
p
->
nConfMaxAll
&&
(
p
->
pSat
?
(
int
)
p
->
pSat
->
stats
.
conflicts
:
s
atoko
_conflictnum
(
p
->
pSat2
))
>
p
->
nConfMaxAll
)
printf
(
"Reached global conflict limit (%d).
\n
"
,
p
->
nConfMaxAll
);
printf
(
"Reached global conflict limit (%d).
\n
"
,
p
->
nConfMaxAll
);
else
if
(
nTimeOut
&&
Abc_Clock
()
>
nTimeToStop
)
else
if
(
nTimeOut
&&
Abc_Clock
()
>
nTimeToStop
)
printf
(
"Reached timeout (%d seconds).
\n
"
,
nTimeOut
);
printf
(
"Reached timeout (%d seconds).
\n
"
,
nTimeOut
);
...
...
src/sat/bmc/bmcBmc3.c
View file @
ba8112ff
...
@@ -22,7 +22,6 @@
...
@@ -22,7 +22,6 @@
#include "sat/cnf/cnf.h"
#include "sat/cnf/cnf.h"
#include "sat/bsat/satStore.h"
#include "sat/bsat/satStore.h"
#include "sat/satoko/satoko.h"
#include "sat/satoko/satoko.h"
#include "sat/satoko/solver.h"
#include "misc/vec/vecHsh.h"
#include "misc/vec/vecHsh.h"
#include "misc/vec/vecWec.h"
#include "misc/vec/vecWec.h"
#include "bmc.h"
#include "bmc.h"
...
@@ -798,9 +797,9 @@ void Saig_Bmc3ManStop( Gia_ManBmc_t * p )
...
@@ -798,9 +797,9 @@ void Saig_Bmc3ManStop( Gia_ManBmc_t * p )
p
->
pSat
?
p
->
pSat
->
nLearntDelta
:
0
,
p
->
pSat
?
p
->
pSat
->
nLearntDelta
:
0
,
p
->
pSat
?
p
->
pSat
->
nLearntRatio
:
0
,
p
->
pSat
?
p
->
pSat
->
nLearntRatio
:
0
,
p
->
pSat
?
p
->
pSat
->
nDBreduces
:
0
,
p
->
pSat
?
p
->
pSat
->
nDBreduces
:
0
,
p
->
pSat
?
sat_solver_nvars
(
p
->
pSat
)
:
s
olver
_varnum
(
p
->
pSat2
),
p
->
pSat
?
sat_solver_nvars
(
p
->
pSat
)
:
s
atoko
_varnum
(
p
->
pSat2
),
nUsedVars
,
nUsedVars
,
100
.
0
*
nUsedVars
/
(
p
->
pSat
?
sat_solver_nvars
(
p
->
pSat
)
:
s
olver
_varnum
(
p
->
pSat2
))
);
100
.
0
*
nUsedVars
/
(
p
->
pSat
?
sat_solver_nvars
(
p
->
pSat
)
:
s
atoko
_varnum
(
p
->
pSat2
))
);
Abc_Print
(
1
,
"Buffs = %d. Dups = %d. Hash hits = %d. Hash misses = %d. UniProps = %d.
\n
"
,
Abc_Print
(
1
,
"Buffs = %d. Dups = %d. Hash hits = %d. Hash misses = %d. UniProps = %d.
\n
"
,
p
->
nBufNum
,
p
->
nDupNum
,
p
->
nHashHit
,
p
->
nHashMiss
,
p
->
nUniProps
);
p
->
nBufNum
,
p
->
nDupNum
,
p
->
nHashHit
,
p
->
nHashMiss
,
p
->
nUniProps
);
}
}
...
@@ -1382,7 +1381,7 @@ Abc_Cex_t * Saig_ManGenerateCex( Gia_ManBmc_t * p, int f, int i )
...
@@ -1382,7 +1381,7 @@ Abc_Cex_t * Saig_ManGenerateCex( Gia_ManBmc_t * p, int f, int i )
int
iLit
=
Saig_ManBmcLiteral
(
p
,
pObjPi
,
j
);
int
iLit
=
Saig_ManBmcLiteral
(
p
,
pObjPi
,
j
);
if
(
p
->
pSat2
)
if
(
p
->
pSat2
)
{
{
if
(
iLit
!=
~
0
&&
s
olver
_read_cex_varvalue
(
p
->
pSat2
,
lit_var
(
iLit
))
)
if
(
iLit
!=
~
0
&&
s
atoko
_read_cex_varvalue
(
p
->
pSat2
,
lit_var
(
iLit
))
)
Abc_InfoSetBit
(
pCex
->
pData
,
iBit
+
k
);
Abc_InfoSetBit
(
pCex
->
pData
,
iBit
+
k
);
}
}
else
else
...
@@ -1465,8 +1464,8 @@ int Saig_ManBmcScalable( Aig_Man_t * pAig, Saig_ParBmc_t * pPars )
...
@@ -1465,8 +1464,8 @@ int Saig_ManBmcScalable( Aig_Man_t * pAig, Saig_ParBmc_t * pPars )
}
}
else
else
{
{
p
->
pSat2
->
RunId
=
p
->
pPars
->
RunId
;
satoko_set_runid
(
p
->
pSat2
,
p
->
pPars
->
RunId
)
;
p
->
pSat2
->
pFuncStop
=
p
->
pPars
->
pFuncStop
;
satoko_set_stop_func
(
p
->
pSat2
,
p
->
pPars
->
pFuncStop
)
;
}
}
if
(
pPars
->
fSolveAll
&&
p
->
vCexes
==
NULL
)
if
(
pPars
->
fSolveAll
&&
p
->
vCexes
==
NULL
)
p
->
vCexes
=
Vec_PtrStart
(
Saig_ManPoNum
(
pAig
)
);
p
->
vCexes
=
Vec_PtrStart
(
Saig_ManPoNum
(
pAig
)
);
...
@@ -1483,7 +1482,7 @@ int Saig_ManBmcScalable( Aig_Man_t * pAig, Saig_ParBmc_t * pPars )
...
@@ -1483,7 +1482,7 @@ int Saig_ManBmcScalable( Aig_Man_t * pAig, Saig_ParBmc_t * pPars )
if
(
nTimeToStop
)
if
(
nTimeToStop
)
{
{
if
(
p
->
pSat2
)
if
(
p
->
pSat2
)
s
olver
_set_runtime_limit
(
p
->
pSat2
,
nTimeToStop
);
s
atoko
_set_runtime_limit
(
p
->
pSat2
,
nTimeToStop
);
else
else
sat_solver_set_runtime_limit
(
p
->
pSat
,
nTimeToStop
);
sat_solver_set_runtime_limit
(
p
->
pSat
,
nTimeToStop
);
}
}
...
@@ -1614,7 +1613,7 @@ clkOther += Abc_Clock() - clk2;
...
@@ -1614,7 +1613,7 @@ clkOther += Abc_Clock() - clk2;
assert
(
p
->
pTime4Outs
[
i
]
>
0
);
assert
(
p
->
pTime4Outs
[
i
]
>
0
);
clkOne
=
Abc_Clock
();
clkOne
=
Abc_Clock
();
if
(
p
->
pSat2
)
if
(
p
->
pSat2
)
s
olver
_set_runtime_limit
(
p
->
pSat2
,
p
->
pTime4Outs
[
i
]
+
Abc_Clock
()
);
s
atoko
_set_runtime_limit
(
p
->
pSat2
,
p
->
pTime4Outs
[
i
]
+
Abc_Clock
()
);
else
else
sat_solver_set_runtime_limit
(
p
->
pSat
,
p
->
pTime4Outs
[
i
]
+
Abc_Clock
()
);
sat_solver_set_runtime_limit
(
p
->
pSat
,
p
->
pTime4Outs
[
i
]
+
Abc_Clock
()
);
}
}
...
@@ -1673,8 +1672,8 @@ nTimeSat += clkSatRun;
...
@@ -1673,8 +1672,8 @@ nTimeSat += clkSatRun;
{
{
Abc_Print
(
1
,
"%4d %s : "
,
f
,
fUnfinished
?
"-"
:
"+"
);
Abc_Print
(
1
,
"%4d %s : "
,
f
,
fUnfinished
?
"-"
:
"+"
);
Abc_Print
(
1
,
"Var =%8.0f. "
,
(
double
)
p
->
nSatVars
);
Abc_Print
(
1
,
"Var =%8.0f. "
,
(
double
)
p
->
nSatVars
);
Abc_Print
(
1
,
"Cla =%9.0f. "
,
(
double
)(
p
->
pSat
?
p
->
pSat
->
stats
.
clauses
:
s
olver
_clausenum
(
p
->
pSat2
))
);
Abc_Print
(
1
,
"Cla =%9.0f. "
,
(
double
)(
p
->
pSat
?
p
->
pSat
->
stats
.
clauses
:
s
atoko
_clausenum
(
p
->
pSat2
))
);
Abc_Print
(
1
,
"Conf =%7.0f. "
,
(
double
)(
p
->
pSat
?
p
->
pSat
->
stats
.
conflicts
:
s
olver
_conflictnum
(
p
->
pSat2
))
);
Abc_Print
(
1
,
"Conf =%7.0f. "
,
(
double
)(
p
->
pSat
?
p
->
pSat
->
stats
.
conflicts
:
s
atoko
_conflictnum
(
p
->
pSat2
))
);
// Abc_Print( 1, "Imp =%10.0f. ", (double)p->pSat->stats.propagations );
// Abc_Print( 1, "Imp =%10.0f. ", (double)p->pSat->stats.propagations );
Abc_Print
(
1
,
"Uni =%7.0f. "
,(
double
)(
p
->
pSat
?
sat_solver_count_assigned
(
p
->
pSat
)
:
0
)
);
Abc_Print
(
1
,
"Uni =%7.0f. "
,(
double
)(
p
->
pSat
?
sat_solver_count_assigned
(
p
->
pSat
)
:
0
)
);
// ABC_PRT( "Time", Abc_Clock() - clk );
// ABC_PRT( "Time", Abc_Clock() - clk );
...
@@ -1721,7 +1720,7 @@ nTimeSat += clkSatRun;
...
@@ -1721,7 +1720,7 @@ nTimeSat += clkSatRun;
if
(
nTimeToStop
)
if
(
nTimeToStop
)
{
{
if
(
p
->
pSat2
)
if
(
p
->
pSat2
)
s
olver
_set_runtime_limit
(
p
->
pSat2
,
nTimeToStop
);
s
atoko
_set_runtime_limit
(
p
->
pSat2
,
nTimeToStop
);
else
else
sat_solver_set_runtime_limit
(
p
->
pSat
,
nTimeToStop
);
sat_solver_set_runtime_limit
(
p
->
pSat
,
nTimeToStop
);
}
}
...
@@ -1738,7 +1737,7 @@ nTimeSat += clkSatRun;
...
@@ -1738,7 +1737,7 @@ nTimeSat += clkSatRun;
Lit
=
Saig_ManBmcCreateCnf
(
p
,
pObj
,
f
);
Lit
=
Saig_ManBmcCreateCnf
(
p
,
pObj
,
f
);
if
(
p
->
pSat2
)
if
(
p
->
pSat2
)
{
{
if
(
s
olver
_read_cex_varvalue
(
p
->
pSat2
,
lit_var
(
Lit
))
==
Abc_LitIsCompl
(
Lit
)
)
if
(
s
atoko
_read_cex_varvalue
(
p
->
pSat2
,
lit_var
(
Lit
))
==
Abc_LitIsCompl
(
Lit
)
)
continue
;
continue
;
}
}
else
else
...
@@ -1781,7 +1780,7 @@ nTimeUndec += clkSatRun;
...
@@ -1781,7 +1780,7 @@ nTimeUndec += clkSatRun;
}
}
if
(
pPars
->
fVerbose
)
if
(
pPars
->
fVerbose
)
{
{
if
(
fFirst
==
1
&&
f
>
0
&&
(
p
->
pSat
?
p
->
pSat
->
stats
.
conflicts
:
s
olver
_conflictnum
(
p
->
pSat2
))
>
1
)
if
(
fFirst
==
1
&&
f
>
0
&&
(
p
->
pSat
?
p
->
pSat
->
stats
.
conflicts
:
s
atoko
_conflictnum
(
p
->
pSat2
))
>
1
)
{
{
fFirst
=
0
;
fFirst
=
0
;
// Abc_Print( 1, "Outputs of frames up to %d are trivially UNSAT.\n", f );
// Abc_Print( 1, "Outputs of frames up to %d are trivially UNSAT.\n", f );
...
@@ -1789,8 +1788,8 @@ nTimeUndec += clkSatRun;
...
@@ -1789,8 +1788,8 @@ nTimeUndec += clkSatRun;
Abc_Print
(
1
,
"%4d %s : "
,
f
,
fUnfinished
?
"-"
:
"+"
);
Abc_Print
(
1
,
"%4d %s : "
,
f
,
fUnfinished
?
"-"
:
"+"
);
Abc_Print
(
1
,
"Var =%8.0f. "
,
(
double
)
p
->
nSatVars
);
Abc_Print
(
1
,
"Var =%8.0f. "
,
(
double
)
p
->
nSatVars
);
// Abc_Print( 1, "Used =%8.0f. ", (double)sat_solver_count_usedvars(p->pSat) );
// Abc_Print( 1, "Used =%8.0f. ", (double)sat_solver_count_usedvars(p->pSat) );
Abc_Print
(
1
,
"Cla =%9.0f. "
,
(
double
)(
p
->
pSat
?
p
->
pSat
->
stats
.
clauses
:
s
olver
_clausenum
(
p
->
pSat2
))
);
Abc_Print
(
1
,
"Cla =%9.0f. "
,
(
double
)(
p
->
pSat
?
p
->
pSat
->
stats
.
clauses
:
s
atoko
_clausenum
(
p
->
pSat2
))
);
Abc_Print
(
1
,
"Conf =%7.0f. "
,(
double
)(
p
->
pSat
?
p
->
pSat
->
stats
.
conflicts
:
s
olver
_conflictnum
(
p
->
pSat2
))
);
Abc_Print
(
1
,
"Conf =%7.0f. "
,(
double
)(
p
->
pSat
?
p
->
pSat
->
stats
.
conflicts
:
s
atoko
_conflictnum
(
p
->
pSat2
))
);
// Abc_Print( 1, "Imp =%10.0f. ", (double)p->pSat->stats.propagations );
// Abc_Print( 1, "Imp =%10.0f. ", (double)p->pSat->stats.propagations );
Abc_Print
(
1
,
"Uni =%7.0f. "
,
(
double
)(
p
->
pSat
?
sat_solver_count_assigned
(
p
->
pSat
)
:
0
)
);
Abc_Print
(
1
,
"Uni =%7.0f. "
,
(
double
)(
p
->
pSat
?
sat_solver_count_assigned
(
p
->
pSat
)
:
0
)
);
if
(
pPars
->
fSolveAll
)
if
(
pPars
->
fSolveAll
)
...
...
src/sat/bmc/bmcBmcS.c
View file @
ba8112ff
...
@@ -21,7 +21,6 @@
...
@@ -21,7 +21,6 @@
#include "bmc.h"
#include "bmc.h"
#include "sat/cnf/cnf.h"
#include "sat/cnf/cnf.h"
#include "sat/satoko/satoko.h"
#include "sat/satoko/satoko.h"
#include "sat/satoko/solver.h"
//#define ABC_USE_EXT_SOLVERS 1
//#define ABC_USE_EXT_SOLVERS 1
...
@@ -41,8 +40,8 @@
...
@@ -41,8 +40,8 @@
#define bmc_sat_solver_addclause satoko_add_clause
#define bmc_sat_solver_addclause satoko_add_clause
#define bmc_sat_solver_addvar(s) satoko_add_variable(s, 0)
#define bmc_sat_solver_addvar(s) satoko_add_variable(s, 0)
#define bmc_sat_solver_solve satoko_solve_assumptions
#define bmc_sat_solver_solve satoko_solve_assumptions
#define bmc_sat_solver_read_cex_varvalue s
olver
_read_cex_varvalue
#define bmc_sat_solver_read_cex_varvalue s
atoko
_read_cex_varvalue
#define bmc_sat_solver_setstop s
olver
_set_stop
#define bmc_sat_solver_setstop s
atoko
_set_stop
#endif
#endif
...
@@ -546,7 +545,7 @@ Cnf_Dat_t * Bmcs_ManAddNewCnf( Bmcs_Man_t * p, int f, int nFramesAdd )
...
@@ -546,7 +545,7 @@ Cnf_Dat_t * Bmcs_ManAddNewCnf( Bmcs_Man_t * p, int f, int nFramesAdd )
if
(
pNew
==
NULL
)
if
(
pNew
==
NULL
)
return
NULL
;
return
NULL
;
clk
=
Abc_Clock
();
clk
=
Abc_Clock
();
pCnf
=
Mf_ManGenerateCnf
(
pNew
,
8
,
1
,
0
,
0
,
0
);
pCnf
=
(
Cnf_Dat_t
*
)
Mf_ManGenerateCnf
(
pNew
,
8
,
1
,
0
,
0
,
0
);
pMap
=
ABC_FALLOC
(
int
,
Gia_ManObjNum
(
pNew
)
);
pMap
=
ABC_FALLOC
(
int
,
Gia_ManObjNum
(
pNew
)
);
pMap
[
0
]
=
0
;
pMap
[
0
]
=
0
;
Gia_ManForEachObj1
(
pNew
,
pObj
,
i
)
Gia_ManForEachObj1
(
pNew
,
pObj
,
i
)
...
@@ -584,10 +583,10 @@ void Bmcs_ManPrintFrame( Bmcs_Man_t * p, int f, int nClauses, int Solver, abctim
...
@@ -584,10 +583,10 @@ void Bmcs_ManPrintFrame( Bmcs_Man_t * p, int f, int nClauses, int Solver, abctim
return
;
return
;
Abc_Print
(
1
,
"%4d %s : "
,
f
,
fUnfinished
?
"-"
:
"+"
);
Abc_Print
(
1
,
"%4d %s : "
,
f
,
fUnfinished
?
"-"
:
"+"
);
#ifndef ABC_USE_EXT_SOLVERS
#ifndef ABC_USE_EXT_SOLVERS
Abc_Print
(
1
,
"Var =%8.0f. "
,
(
double
)
s
olver
_varnum
(
p
->
pSats
[
0
])
);
Abc_Print
(
1
,
"Var =%8.0f. "
,
(
double
)
s
atoko
_varnum
(
p
->
pSats
[
0
])
);
Abc_Print
(
1
,
"Cla =%9.0f. "
,
(
double
)
s
olver
_clausenum
(
p
->
pSats
[
0
])
);
Abc_Print
(
1
,
"Cla =%9.0f. "
,
(
double
)
s
atoko
_clausenum
(
p
->
pSats
[
0
])
);
Abc_Print
(
1
,
"Learn =%9.0f. "
,(
double
)
s
olver
_learntnum
(
p
->
pSats
[
0
])
);
Abc_Print
(
1
,
"Learn =%9.0f. "
,(
double
)
s
atoko
_learntnum
(
p
->
pSats
[
0
])
);
Abc_Print
(
1
,
"Conf =%9.0f. "
,
(
double
)
s
olver
_conflictnum
(
p
->
pSats
[
0
])
);
Abc_Print
(
1
,
"Conf =%9.0f. "
,
(
double
)
s
atoko
_conflictnum
(
p
->
pSats
[
0
])
);
#else
#else
Abc_Print
(
1
,
"Var =%8.0f. "
,
(
double
)
p
->
nSatVars
);
Abc_Print
(
1
,
"Var =%8.0f. "
,
(
double
)
p
->
nSatVars
);
Abc_Print
(
1
,
"Cla =%9.0f. "
,
(
double
)
nClauses
);
Abc_Print
(
1
,
"Cla =%9.0f. "
,
(
double
)
nClauses
);
...
...
src/sat/bmc/bmcMesh.c
View file @
ba8112ff
...
@@ -20,7 +20,6 @@
...
@@ -20,7 +20,6 @@
#include "bmc.h"
#include "bmc.h"
#include "sat/satoko/satoko.h"
#include "sat/satoko/satoko.h"
#include "sat/satoko/solver.h"
ABC_NAMESPACE_IMPL_START
ABC_NAMESPACE_IMPL_START
...
@@ -53,9 +52,9 @@ static inline int Bmc_MeshUVar( int Me[102][102], int x, int y ) { return Me[x][
...
@@ -53,9 +52,9 @@ static inline int Bmc_MeshUVar( int Me[102][102], int x, int y ) { return Me[x][
***********************************************************************/
***********************************************************************/
static
inline
int
Bmc_MeshVarValue
(
satoko_t
*
p
,
int
v
)
static
inline
int
Bmc_MeshVarValue
(
satoko_t
*
p
,
int
v
)
{
{
// int value = var_value(p, v) !=
VAR_UNASSING ? var_value(p, v) :
var_polarity(p, v);
// int value = var_value(p, v) !=
SATOKO_VAR_UNASSING ? var_value(p, v) : satoko_
var_polarity(p, v);
// return value == LIT_TRUE;
// return value ==
SATOKO_
LIT_TRUE;
return
var_polarity
(
p
,
v
)
==
LIT_TRUE
;
return
satoko_var_polarity
(
p
,
v
)
==
SATOKO_
LIT_TRUE
;
}
}
/**Function*************************************************************
/**Function*************************************************************
...
@@ -360,7 +359,7 @@ void Bmc_MeshTest( Gia_Man_t * p, int X, int Y, int T, int fVerbose )
...
@@ -360,7 +359,7 @@ void Bmc_MeshTest( Gia_Man_t * p, int X, int Y, int T, int fVerbose )
}
}
printf
(
"Satisfying solution found. "
);
printf
(
"Satisfying solution found. "
);
/*
/*
iVar = s
olver
_varnum(pSat);
iVar = s
atoko
_varnum(pSat);
for ( i = 0; i < iVar; i++ )
for ( i = 0; i < iVar; i++ )
if ( Bmc_MeshVarValue(pSat, i) )
if ( Bmc_MeshVarValue(pSat, i) )
printf( "%d ", i );
printf( "%d ", i );
...
...
src/sat/bmc/bmcMesh2.c
View file @
ba8112ff
...
@@ -20,7 +20,6 @@
...
@@ -20,7 +20,6 @@
#include "bmc.h"
#include "bmc.h"
//#include "sat/satoko/satoko.h"
//#include "sat/satoko/satoko.h"
//#include "sat/satoko/solver.h"
#include "sat/bsat/satSolver.h"
#include "sat/bsat/satSolver.h"
ABC_NAMESPACE_IMPL_START
ABC_NAMESPACE_IMPL_START
...
@@ -56,8 +55,8 @@ static inline int Bmc_MeshUVar( int Me[102][102], int x, int y ) { return Me[x][
...
@@ -56,8 +55,8 @@ static inline int Bmc_MeshUVar( int Me[102][102], int x, int y ) { return Me[x][
***********************************************************************/
***********************************************************************/
static
inline
int
Bmc_MeshVarValue2
(
sat_solver
*
p
,
int
v
)
static
inline
int
Bmc_MeshVarValue2
(
sat_solver
*
p
,
int
v
)
{
{
// int value = var_value(p, v) !=
VAR_UNASSING ? var_value(p, v) :
var_polarity(p, v);
// int value = var_value(p, v) !=
SATOKO_VAR_UNASSING ? var_value(p, v) : satoko_
var_polarity(p, v);
// return value == LIT_TRUE;
// return value ==
SATOKO_
LIT_TRUE;
return
sat_solver_var_value
(
p
,
v
);
return
sat_solver_var_value
(
p
,
v
);
}
}
...
@@ -370,7 +369,7 @@ void Bmc_MeshTest2( Gia_Man_t * p, int X, int Y, int T, int fVerbose )
...
@@ -370,7 +369,7 @@ void Bmc_MeshTest2( Gia_Man_t * p, int X, int Y, int T, int fVerbose )
}
}
printf
(
"Satisfying solution found. "
);
printf
(
"Satisfying solution found. "
);
/*
/*
// iVar = s
olver
_varnum(pSat);
// iVar = s
atoko
_varnum(pSat);
iVar = sat_solver_nvars(pSat);
iVar = sat_solver_nvars(pSat);
for ( i = 0; i < iVar; i++ )
for ( i = 0; i < iVar; i++ )
if ( Bmc_MeshVarValue2(pSat, i) )
if ( Bmc_MeshVarValue2(pSat, i) )
...
...
src/sat/satoko/satoko.h
View file @
ba8112ff
...
@@ -25,6 +25,12 @@ enum {
...
@@ -25,6 +25,12 @@ enum {
SATOKO_UNSAT
=
-
1
SATOKO_UNSAT
=
-
1
};
};
enum
{
SATOKO_LIT_FALSE
=
1
,
SATOKO_LIT_TRUE
=
0
,
SATOKO_VAR_UNASSING
=
3
};
struct
solver_t_
;
struct
solver_t_
;
typedef
struct
solver_t_
satoko_t
;
typedef
struct
solver_t_
satoko_t
;
...
@@ -120,7 +126,20 @@ extern int satoko_final_conflict(satoko_t *, int **);
...
@@ -120,7 +126,20 @@ extern int satoko_final_conflict(satoko_t *, int **);
* file will not be a DIMACS. (value 1 will use 0 as ID).
* file will not be a DIMACS. (value 1 will use 0 as ID).
*/
*/
extern
void
satoko_write_dimacs
(
satoko_t
*
,
char
*
,
int
,
int
);
extern
void
satoko_write_dimacs
(
satoko_t
*
,
char
*
,
int
,
int
);
extern
satoko_stats_t
satoko_stats
(
satoko_t
*
);
extern
satoko_stats_t
*
satoko_stats
(
satoko_t
*
);
extern
satoko_opts_t
*
satoko_options
(
satoko_t
*
);
extern
int
satoko_varnum
(
satoko_t
*
);
extern
int
satoko_clausenum
(
satoko_t
*
);
extern
int
satoko_learntnum
(
satoko_t
*
);
extern
int
satoko_conflictnum
(
satoko_t
*
);
extern
void
satoko_set_stop
(
satoko_t
*
,
int
*
);
extern
void
satoko_set_stop_func
(
satoko_t
*
s
,
int
(
*
fnct
)(
int
));
extern
void
satoko_set_runid
(
satoko_t
*
,
int
);
extern
int
satoko_read_cex_varvalue
(
satoko_t
*
,
int
);
extern
abctime
satoko_set_runtime_limit
(
satoko_t
*
,
abctime
);
extern
char
satoko_var_polarity
(
satoko_t
*
,
unsigned
);
ABC_NAMESPACE_HEADER_END
ABC_NAMESPACE_HEADER_END
#endif
/* satoko__satoko_h */
#endif
/* satoko__satoko_h */
src/sat/satoko/solver.c
View file @
ba8112ff
...
@@ -43,8 +43,8 @@ static inline int lit_is_removable(solver_t* s, unsigned lit, unsigned min_level
...
@@ -43,8 +43,8 @@ static inline int lit_is_removable(solver_t* s, unsigned lit, unsigned min_level
unsigned
*
lits
=
&
(
c
->
data
[
0
].
lit
);
unsigned
*
lits
=
&
(
c
->
data
[
0
].
lit
);
assert
(
var_reason
(
s
,
var
)
!=
UNDEF
);
assert
(
var_reason
(
s
,
var
)
!=
UNDEF
);
if
(
c
->
size
==
2
&&
lit_value
(
s
,
lits
[
0
])
==
LIT_FALSE
)
{
if
(
c
->
size
==
2
&&
lit_value
(
s
,
lits
[
0
])
==
SATOKO_
LIT_FALSE
)
{
assert
(
lit_value
(
s
,
lits
[
1
])
==
LIT_TRUE
);
assert
(
lit_value
(
s
,
lits
[
1
])
==
SATOKO_
LIT_TRUE
);
stk_swap
(
unsigned
,
lits
[
0
],
lits
[
1
]);
stk_swap
(
unsigned
,
lits
[
0
],
lits
[
1
]);
}
}
...
@@ -117,7 +117,7 @@ static inline void clause_bin_resolution(solver_t *s, vec_uint_t *clause_lits)
...
@@ -117,7 +117,7 @@ static inline void clause_bin_resolution(solver_t *s, vec_uint_t *clause_lits)
watch_list_foreach_bin
(
s
->
watches
,
w
,
neg_lit
)
{
watch_list_foreach_bin
(
s
->
watches
,
w
,
neg_lit
)
{
unsigned
imp_lit
=
w
->
blocker
;
unsigned
imp_lit
=
w
->
blocker
;
if
(
vec_uint_at
(
s
->
stamps
,
lit2var
(
imp_lit
))
==
s
->
cur_stamp
&&
if
(
vec_uint_at
(
s
->
stamps
,
lit2var
(
imp_lit
))
==
s
->
cur_stamp
&&
lit_value
(
s
,
imp_lit
)
==
LIT_TRUE
)
{
lit_value
(
s
,
imp_lit
)
==
SATOKO_
LIT_TRUE
)
{
counter
++
;
counter
++
;
vec_uint_assign
(
s
->
stamps
,
lit2var
(
imp_lit
),
(
s
->
cur_stamp
-
1
));
vec_uint_assign
(
s
->
stamps
,
lit2var
(
imp_lit
),
(
s
->
cur_stamp
-
1
));
}
}
...
@@ -186,7 +186,7 @@ static inline unsigned solver_decide(solver_t *s)
...
@@ -186,7 +186,7 @@ static inline unsigned solver_decide(solver_t *s)
{
{
unsigned
next_var
=
UNDEF
;
unsigned
next_var
=
UNDEF
;
while
(
next_var
==
UNDEF
||
var_value
(
s
,
next_var
)
!=
VAR_UNASSING
)
{
while
(
next_var
==
UNDEF
||
var_value
(
s
,
next_var
)
!=
SATOKO_
VAR_UNASSING
)
{
if
(
heap_size
(
s
->
var_order
)
==
0
)
{
if
(
heap_size
(
s
->
var_order
)
==
0
)
{
next_var
=
UNDEF
;
next_var
=
UNDEF
;
return
UNDEF
;
return
UNDEF
;
...
@@ -195,14 +195,14 @@ static inline unsigned solver_decide(solver_t *s)
...
@@ -195,14 +195,14 @@ static inline unsigned solver_decide(solver_t *s)
if
(
solver_has_marks
(
s
)
&&
!
var_mark
(
s
,
next_var
))
if
(
solver_has_marks
(
s
)
&&
!
var_mark
(
s
,
next_var
))
next_var
=
UNDEF
;
next_var
=
UNDEF
;
}
}
return
var2lit
(
next_var
,
var_polarity
(
s
,
next_var
));
return
var2lit
(
next_var
,
satoko_
var_polarity
(
s
,
next_var
));
}
}
static
inline
void
solver_new_decision
(
solver_t
*
s
,
unsigned
lit
)
static
inline
void
solver_new_decision
(
solver_t
*
s
,
unsigned
lit
)
{
{
if
(
solver_has_marks
(
s
)
&&
!
var_mark
(
s
,
lit2var
(
lit
)))
if
(
solver_has_marks
(
s
)
&&
!
var_mark
(
s
,
lit2var
(
lit
)))
return
;
return
;
assert
(
var_value
(
s
,
lit2var
(
lit
))
==
VAR_UNASSING
);
assert
(
var_value
(
s
,
lit2var
(
lit
))
==
SATOKO_
VAR_UNASSING
);
vec_uint_push_back
(
s
->
trail_lim
,
vec_uint_size
(
s
->
trail
));
vec_uint_push_back
(
s
->
trail_lim
,
vec_uint_size
(
s
->
trail
));
solver_enqueue
(
s
,
lit
,
UNDEF
);
solver_enqueue
(
s
,
lit
,
UNDEF
);
}
}
...
@@ -270,8 +270,8 @@ static inline void solver_analyze(solver_t *s, unsigned cref, vec_uint_t *learnt
...
@@ -270,8 +270,8 @@ static inline void solver_analyze(solver_t *s, unsigned cref, vec_uint_t *learnt
clause
=
clause_fetch
(
s
,
cref
);
clause
=
clause_fetch
(
s
,
cref
);
lits
=
&
(
clause
->
data
[
0
].
lit
);
lits
=
&
(
clause
->
data
[
0
].
lit
);
if
(
p
!=
UNDEF
&&
clause
->
size
==
2
&&
lit_value
(
s
,
lits
[
0
])
==
LIT_FALSE
)
{
if
(
p
!=
UNDEF
&&
clause
->
size
==
2
&&
lit_value
(
s
,
lits
[
0
])
==
SATOKO_
LIT_FALSE
)
{
assert
(
lit_value
(
s
,
lits
[
1
])
==
LIT_TRUE
);
assert
(
lit_value
(
s
,
lits
[
1
])
==
SATOKO_
LIT_TRUE
);
stk_swap
(
unsigned
,
lits
[
0
],
lits
[
1
]
);
stk_swap
(
unsigned
,
lits
[
0
],
lits
[
1
]
);
}
}
...
@@ -522,7 +522,7 @@ void solver_cancel_until(solver_t *s, unsigned level)
...
@@ -522,7 +522,7 @@ void solver_cancel_until(solver_t *s, unsigned level)
unsigned
var
=
lit2var
(
vec_uint_at
(
s
->
trail
,
i
));
unsigned
var
=
lit2var
(
vec_uint_at
(
s
->
trail
,
i
));
vec_char_assign
(
s
->
polarity
,
var
,
vec_char_at
(
s
->
assigns
,
var
));
vec_char_assign
(
s
->
polarity
,
var
,
vec_char_at
(
s
->
assigns
,
var
));
vec_char_assign
(
s
->
assigns
,
var
,
VAR_UNASSING
);
vec_char_assign
(
s
->
assigns
,
var
,
SATOKO_
VAR_UNASSING
);
vec_uint_assign
(
s
->
reasons
,
var
,
UNDEF
);
vec_uint_assign
(
s
->
reasons
,
var
,
UNDEF
);
if
(
!
heap_in_heap
(
s
->
var_order
,
var
))
if
(
!
heap_in_heap
(
s
->
var_order
,
var
))
heap_insert
(
s
->
var_order
,
var
);
heap_insert
(
s
->
var_order
,
var
);
...
@@ -550,9 +550,9 @@ unsigned solver_propagate(solver_t *s)
...
@@ -550,9 +550,9 @@ unsigned solver_propagate(solver_t *s)
watch_list_foreach_bin
(
s
->
watches
,
i
,
p
)
{
watch_list_foreach_bin
(
s
->
watches
,
i
,
p
)
{
if
(
solver_has_marks
(
s
)
&&
!
var_mark
(
s
,
lit2var
(
i
->
blocker
)))
if
(
solver_has_marks
(
s
)
&&
!
var_mark
(
s
,
lit2var
(
i
->
blocker
)))
continue
;
continue
;
if
(
var_value
(
s
,
lit2var
(
i
->
blocker
))
==
VAR_UNASSING
)
if
(
var_value
(
s
,
lit2var
(
i
->
blocker
))
==
SATOKO_
VAR_UNASSING
)
solver_enqueue
(
s
,
i
->
blocker
,
i
->
cref
);
solver_enqueue
(
s
,
i
->
blocker
,
i
->
cref
);
else
if
(
lit_value
(
s
,
i
->
blocker
)
==
LIT_FALSE
)
else
if
(
lit_value
(
s
,
i
->
blocker
)
==
SATOKO_
LIT_FALSE
)
return
i
->
cref
;
return
i
->
cref
;
}
}
...
@@ -567,7 +567,7 @@ unsigned solver_propagate(solver_t *s)
...
@@ -567,7 +567,7 @@ unsigned solver_propagate(solver_t *s)
*
j
++
=
*
i
++
;
*
j
++
=
*
i
++
;
continue
;
continue
;
}
}
if
(
lit_value
(
s
,
i
->
blocker
)
==
LIT_TRUE
)
{
if
(
lit_value
(
s
,
i
->
blocker
)
==
SATOKO_
LIT_TRUE
)
{
*
j
++
=
*
i
++
;
*
j
++
=
*
i
++
;
continue
;
continue
;
}
}
...
@@ -585,13 +585,13 @@ unsigned solver_propagate(solver_t *s)
...
@@ -585,13 +585,13 @@ unsigned solver_propagate(solver_t *s)
w
.
blocker
=
lits
[
0
];
w
.
blocker
=
lits
[
0
];
/* If 0th watch is true, then clause is already satisfied. */
/* If 0th watch is true, then clause is already satisfied. */
if
(
lits
[
0
]
!=
i
->
blocker
&&
lit_value
(
s
,
lits
[
0
])
==
LIT_TRUE
)
if
(
lits
[
0
]
!=
i
->
blocker
&&
lit_value
(
s
,
lits
[
0
])
==
SATOKO_
LIT_TRUE
)
*
j
++
=
w
;
*
j
++
=
w
;
else
{
else
{
/* Look for new watch */
/* Look for new watch */
unsigned
k
;
unsigned
k
;
for
(
k
=
2
;
k
<
clause
->
size
;
k
++
)
{
for
(
k
=
2
;
k
<
clause
->
size
;
k
++
)
{
if
(
lit_value
(
s
,
lits
[
k
])
!=
LIT_FALSE
)
{
if
(
lit_value
(
s
,
lits
[
k
])
!=
SATOKO_
LIT_FALSE
)
{
lits
[
1
]
=
lits
[
k
];
lits
[
1
]
=
lits
[
k
];
lits
[
k
]
=
neg_lit
;
lits
[
k
]
=
neg_lit
;
watch_list_push
(
vec_wl_at
(
s
->
watches
,
lit_compl
(
lits
[
1
])),
w
,
0
);
watch_list_push
(
vec_wl_at
(
s
->
watches
,
lit_compl
(
lits
[
1
])),
w
,
0
);
...
@@ -602,7 +602,7 @@ unsigned solver_propagate(solver_t *s)
...
@@ -602,7 +602,7 @@ unsigned solver_propagate(solver_t *s)
*
j
++
=
w
;
*
j
++
=
w
;
/* Clause becomes unit under this assignment */
/* Clause becomes unit under this assignment */
if
(
lit_value
(
s
,
lits
[
0
])
==
LIT_FALSE
)
{
if
(
lit_value
(
s
,
lits
[
0
])
==
SATOKO_
LIT_FALSE
)
{
conf_cref
=
i
->
cref
;
conf_cref
=
i
->
cref
;
s
->
i_qhead
=
vec_uint_size
(
s
->
trail
);
s
->
i_qhead
=
vec_uint_size
(
s
->
trail
);
i
++
;
i
++
;
...
@@ -665,9 +665,9 @@ char solver_search(solver_t *s)
...
@@ -665,9 +665,9 @@ char solver_search(solver_t *s)
next_lit
=
UNDEF
;
next_lit
=
UNDEF
;
while
(
solver_dlevel
(
s
)
<
vec_uint_size
(
s
->
assumptions
))
{
while
(
solver_dlevel
(
s
)
<
vec_uint_size
(
s
->
assumptions
))
{
unsigned
lit
=
vec_uint_at
(
s
->
assumptions
,
solver_dlevel
(
s
));
unsigned
lit
=
vec_uint_at
(
s
->
assumptions
,
solver_dlevel
(
s
));
if
(
lit_value
(
s
,
lit
)
==
LIT_TRUE
)
{
if
(
lit_value
(
s
,
lit
)
==
SATOKO_
LIT_TRUE
)
{
vec_uint_push_back
(
s
->
trail_lim
,
vec_uint_size
(
s
->
trail
));
vec_uint_push_back
(
s
->
trail_lim
,
vec_uint_size
(
s
->
trail
));
}
else
if
(
lit_value
(
s
,
lit
)
==
LIT_FALSE
)
{
}
else
if
(
lit_value
(
s
,
lit
)
==
SATOKO_
LIT_FALSE
)
{
solver_analyze_final
(
s
,
lit_compl
(
lit
));
solver_analyze_final
(
s
,
lit_compl
(
lit
));
return
SATOKO_UNSAT
;
return
SATOKO_UNSAT
;
}
else
{
}
else
{
...
...
src/sat/satoko/solver.h
View file @
ba8112ff
...
@@ -30,11 +30,7 @@
...
@@ -30,11 +30,7 @@
#include "misc/util/abc_global.h"
#include "misc/util/abc_global.h"
ABC_NAMESPACE_HEADER_START
ABC_NAMESPACE_HEADER_START
enum
{
LIT_FALSE
=
1
,
LIT_TRUE
=
0
,
VAR_UNASSING
=
3
};
#define UNDEF 0xFFFFFFFF
#define UNDEF 0xFFFFFFFF
...
@@ -145,11 +141,6 @@ static inline char var_value(solver_t *s, unsigned var)
...
@@ -145,11 +141,6 @@ static inline char var_value(solver_t *s, unsigned var)
return
vec_char_at
(
s
->
assigns
,
var
);
return
vec_char_at
(
s
->
assigns
,
var
);
}
}
static
inline
char
var_polarity
(
solver_t
*
s
,
unsigned
var
)
{
return
vec_char_at
(
s
->
polarity
,
var
);
}
static
inline
unsigned
var_dlevel
(
solver_t
*
s
,
unsigned
var
)
static
inline
unsigned
var_dlevel
(
solver_t
*
s
,
unsigned
var
)
{
{
return
vec_uint_at
(
s
->
levels
,
var
);
return
vec_uint_at
(
s
->
levels
,
var
);
...
@@ -226,45 +217,15 @@ static inline int solver_enqueue(solver_t *s, unsigned lit, unsigned reason)
...
@@ -226,45 +217,15 @@ static inline int solver_enqueue(solver_t *s, unsigned lit, unsigned reason)
return
SATOKO_OK
;
return
SATOKO_OK
;
}
}
static
inline
int
solver_varnum
(
solver_t
*
s
)
static
inline
int
solver_has_marks
(
satoko_t
*
s
)
{
return
vec_char_size
(
s
->
assigns
);
}
static
inline
int
solver_clausenum
(
solver_t
*
s
)
{
return
vec_uint_size
(
s
->
originals
);
}
static
inline
int
solver_learntnum
(
solver_t
*
s
)
{
return
vec_uint_size
(
s
->
learnts
);
}
static
inline
int
solver_conflictnum
(
solver_t
*
s
)
{
return
satoko_stats
(
s
).
n_conflicts
;
}
static
inline
int
solver_has_marks
(
solver_t
*
s
)
{
{
return
(
int
)(
s
->
marks
!=
NULL
);
return
(
int
)(
s
->
marks
!=
NULL
);
}
}
static
inline
int
solver_stop
(
solver_t
*
s
)
static
inline
int
solver_stop
(
satoko_t
*
s
)
{
{
return
s
->
pstop
&&
*
s
->
pstop
;
return
s
->
pstop
&&
*
s
->
pstop
;
}
}
static
inline
void
solver_set_stop
(
solver_t
*
s
,
int
*
pstop
)
{
s
->
pstop
=
pstop
;
}
static
inline
int
solver_read_cex_varvalue
(
solver_t
*
s
,
int
ivar
)
{
return
var_polarity
(
s
,
ivar
)
==
LIT_TRUE
;
}
static
abctime
solver_set_runtime_limit
(
solver_t
*
s
,
abctime
Limit
)
{
abctime
nRuntimeLimit
=
s
->
nRuntimeLimit
;
s
->
nRuntimeLimit
=
Limit
;
return
nRuntimeLimit
;
}
//===------------------------------------------------------------------------===
//===------------------------------------------------------------------------===
// Inline clause functions
// Inline clause functions
...
...
src/sat/satoko/solver_api.c
View file @
ba8112ff
...
@@ -27,7 +27,7 @@ static inline void solver_rebuild_order(solver_t *s)
...
@@ -27,7 +27,7 @@ static inline void solver_rebuild_order(solver_t *s)
vec_uint_t
*
vars
=
vec_uint_alloc
(
vec_char_size
(
s
->
assigns
));
vec_uint_t
*
vars
=
vec_uint_alloc
(
vec_char_size
(
s
->
assigns
));
for
(
var
=
0
;
var
<
vec_char_size
(
s
->
assigns
);
var
++
)
for
(
var
=
0
;
var
<
vec_char_size
(
s
->
assigns
);
var
++
)
if
(
var_value
(
s
,
var
)
==
VAR_UNASSING
)
if
(
var_value
(
s
,
var
)
==
SATOKO_
VAR_UNASSING
)
vec_uint_push_back
(
vars
,
var
);
vec_uint_push_back
(
vars
,
var
);
heap_build
(
s
->
var_order
,
vars
);
heap_build
(
s
->
var_order
,
vars
);
vec_uint_free
(
vars
);
vec_uint_free
(
vars
);
...
@@ -38,7 +38,7 @@ static inline int clause_is_satisfied(solver_t *s, struct clause *clause)
...
@@ -38,7 +38,7 @@ static inline int clause_is_satisfied(solver_t *s, struct clause *clause)
unsigned
i
;
unsigned
i
;
unsigned
*
lits
=
&
(
clause
->
data
[
0
].
lit
);
unsigned
*
lits
=
&
(
clause
->
data
[
0
].
lit
);
for
(
i
=
0
;
i
<
clause
->
size
;
i
++
)
for
(
i
=
0
;
i
<
clause
->
size
;
i
++
)
if
(
lit_value
(
s
,
lits
[
i
])
==
LIT_TRUE
)
if
(
lit_value
(
s
,
lits
[
i
])
==
SATOKO_
LIT_TRUE
)
return
SATOKO_OK
;
return
SATOKO_OK
;
return
SATOKO_ERR
;
return
SATOKO_ERR
;
}
}
...
@@ -226,7 +226,7 @@ int satoko_simplify(solver_t * s)
...
@@ -226,7 +226,7 @@ int satoko_simplify(solver_t * s)
void
satoko_setnvars
(
solver_t
*
s
,
int
nvars
)
void
satoko_setnvars
(
solver_t
*
s
,
int
nvars
)
{
{
int
i
;
int
i
;
for
(
i
=
s
olver
_varnum
(
s
);
i
<
nvars
;
i
++
)
for
(
i
=
s
atoko
_varnum
(
s
);
i
<
nvars
;
i
++
)
satoko_add_variable
(
s
,
0
);
satoko_add_variable
(
s
,
0
);
}
}
...
@@ -237,7 +237,7 @@ int satoko_add_variable(solver_t *s, char sign)
...
@@ -237,7 +237,7 @@ int satoko_add_variable(solver_t *s, char sign)
vec_wl_push
(
s
->
watches
);
vec_wl_push
(
s
->
watches
);
vec_act_push_back
(
s
->
activity
,
0
);
vec_act_push_back
(
s
->
activity
,
0
);
vec_uint_push_back
(
s
->
levels
,
0
);
vec_uint_push_back
(
s
->
levels
,
0
);
vec_char_push_back
(
s
->
assigns
,
VAR_UNASSING
);
vec_char_push_back
(
s
->
assigns
,
SATOKO_
VAR_UNASSING
);
vec_char_push_back
(
s
->
polarity
,
sign
);
vec_char_push_back
(
s
->
polarity
,
sign
);
vec_uint_push_back
(
s
->
reasons
,
UNDEF
);
vec_uint_push_back
(
s
->
reasons
,
UNDEF
);
vec_uint_push_back
(
s
->
stamps
,
0
);
vec_uint_push_back
(
s
->
stamps
,
0
);
...
@@ -258,15 +258,15 @@ int satoko_add_clause(solver_t *s, int *lits, int size)
...
@@ -258,15 +258,15 @@ int satoko_add_clause(solver_t *s, int *lits, int size)
qsort
((
void
*
)
lits
,
size
,
sizeof
(
unsigned
),
stk_uint_compare
);
qsort
((
void
*
)
lits
,
size
,
sizeof
(
unsigned
),
stk_uint_compare
);
max_var
=
lit2var
(
lits
[
size
-
1
]);
max_var
=
lit2var
(
lits
[
size
-
1
]);
while
(
max_var
>=
vec_act_size
(
s
->
activity
))
while
(
max_var
>=
vec_act_size
(
s
->
activity
))
satoko_add_variable
(
s
,
LIT_FALSE
);
satoko_add_variable
(
s
,
SATOKO_
LIT_FALSE
);
vec_uint_clear
(
s
->
temp_lits
);
vec_uint_clear
(
s
->
temp_lits
);
j
=
0
;
j
=
0
;
prev_lit
=
UNDEF
;
prev_lit
=
UNDEF
;
for
(
i
=
0
;
i
<
(
unsigned
)
size
;
i
++
)
{
for
(
i
=
0
;
i
<
(
unsigned
)
size
;
i
++
)
{
if
((
unsigned
)
lits
[
i
]
==
lit_compl
(
prev_lit
)
||
lit_value
(
s
,
lits
[
i
])
==
LIT_TRUE
)
if
((
unsigned
)
lits
[
i
]
==
lit_compl
(
prev_lit
)
||
lit_value
(
s
,
lits
[
i
])
==
SATOKO_
LIT_TRUE
)
return
SATOKO_OK
;
return
SATOKO_OK
;
else
if
((
unsigned
)
lits
[
i
]
!=
prev_lit
&&
var_value
(
s
,
lit2var
(
lits
[
i
]))
==
VAR_UNASSING
)
{
else
if
((
unsigned
)
lits
[
i
]
!=
prev_lit
&&
var_value
(
s
,
lit2var
(
lits
[
i
]))
==
SATOKO_
VAR_UNASSING
)
{
prev_lit
=
lits
[
i
];
prev_lit
=
lits
[
i
];
vec_uint_push_back
(
s
->
temp_lits
,
lits
[
i
]);
vec_uint_push_back
(
s
->
temp_lits
,
lits
[
i
]);
}
}
...
@@ -287,7 +287,7 @@ int satoko_add_clause(solver_t *s, int *lits, int size)
...
@@ -287,7 +287,7 @@ int satoko_add_clause(solver_t *s, int *lits, int size)
void
satoko_assump_push
(
solver_t
*
s
,
int
lit
)
void
satoko_assump_push
(
solver_t
*
s
,
int
lit
)
{
{
assert
(
lit2var
(
lit
)
<
s
olver
_varnum
(
s
));
assert
(
lit2var
(
lit
)
<
s
atoko
_varnum
(
s
));
// printf("[Satoko] Push assumption: %d\n", lit);
// printf("[Satoko] Push assumption: %d\n", lit);
vec_uint_push_back
(
s
->
assumptions
,
lit
);
vec_uint_push_back
(
s
->
assumptions
,
lit
);
}
}
...
@@ -337,8 +337,8 @@ int satoko_solve_assumptions(solver_t *s, int * plits, int nlits)
...
@@ -337,8 +337,8 @@ int satoko_solve_assumptions(solver_t *s, int * plits, int nlits)
{
{
int
i
,
status
;
int
i
,
status
;
// printf("\n[Satoko] Solve with assumptions.. (%d)\n", vec_uint_size(s->assumptions));
// printf("\n[Satoko] Solve with assumptions.. (%d)\n", vec_uint_size(s->assumptions));
// printf("[Satoko] + Variables: %d\n", s
olver
_varnum(s));
// printf("[Satoko] + Variables: %d\n", s
atoko
_varnum(s));
// printf("[Satoko] + Clauses: %d\n", s
olver
_clausenum(s));
// printf("[Satoko] + Clauses: %d\n", s
atoko
_clausenum(s));
// printf("[Satoko] + Trail size: %d\n", vec_uint_size(s->trail));
// printf("[Satoko] + Trail size: %d\n", vec_uint_size(s->trail));
// printf("[Satoko] + Queue head: %d\n", s->i_qhead);
// printf("[Satoko] + Queue head: %d\n", s->i_qhead);
// solver_debug_check_trail(s);
// solver_debug_check_trail(s);
...
@@ -365,9 +365,14 @@ int satoko_final_conflict(solver_t *s, int **out)
...
@@ -365,9 +365,14 @@ int satoko_final_conflict(solver_t *s, int **out)
return
vec_uint_size
(
s
->
final_conflict
);
return
vec_uint_size
(
s
->
final_conflict
);
}
}
satoko_stats_t
satoko_stats
(
satoko_t
*
s
)
satoko_stats_t
*
satoko_stats
(
satoko_t
*
s
)
{
{
return
s
->
stats
;
return
&
s
->
stats
;
}
satoko_opts_t
*
satoko_options
(
satoko_t
*
s
)
{
return
&
s
->
opts
;
}
}
void
satoko_bookmark
(
satoko_t
*
s
)
void
satoko_bookmark
(
satoko_t
*
s
)
...
@@ -493,7 +498,7 @@ void satoko_mark_cone(satoko_t *s, int * pvars, int n_vars)
...
@@ -493,7 +498,7 @@ void satoko_mark_cone(satoko_t *s, int * pvars, int n_vars)
{
{
int
i
;
int
i
;
if
(
!
solver_has_marks
(
s
))
if
(
!
solver_has_marks
(
s
))
s
->
marks
=
vec_char_init
(
s
olver
_varnum
(
s
),
0
);
s
->
marks
=
vec_char_init
(
s
atoko
_varnum
(
s
),
0
);
for
(
i
=
0
;
i
<
n_vars
;
i
++
)
{
for
(
i
=
0
;
i
<
n_vars
;
i
++
)
{
var_set_mark
(
s
,
pvars
[
i
]);
var_set_mark
(
s
,
pvars
[
i
]);
vec_sdbl_assign
(
s
->
activity
,
pvars
[
i
],
0
);
vec_sdbl_assign
(
s
->
activity
,
pvars
[
i
],
0
);
...
@@ -532,11 +537,11 @@ void satoko_write_dimacs(satoko_t *s, char *fname, int wrt_lrnt, int zero_var)
...
@@ -532,11 +537,11 @@ void satoko_write_dimacs(satoko_t *s, char *fname, int wrt_lrnt, int zero_var)
}
}
fprintf
(
file
,
"p cnf %d %d
\n
"
,
n_vars
,
wrt_lrnt
?
n_orig
+
n_lrnts
:
n_orig
);
fprintf
(
file
,
"p cnf %d %d
\n
"
,
n_vars
,
wrt_lrnt
?
n_orig
+
n_lrnts
:
n_orig
);
for
(
i
=
0
;
i
<
vec_char_size
(
s
->
assigns
);
i
++
)
{
for
(
i
=
0
;
i
<
vec_char_size
(
s
->
assigns
);
i
++
)
{
if
(
var_value
(
s
,
i
)
!=
VAR_UNASSING
)
{
if
(
var_value
(
s
,
i
)
!=
SATOKO_
VAR_UNASSING
)
{
if
(
zero_var
)
if
(
zero_var
)
fprintf
(
file
,
"%d
\n
"
,
var_value
(
s
,
i
)
==
LIT_FALSE
?
-
(
int
)(
i
)
:
i
);
fprintf
(
file
,
"%d
\n
"
,
var_value
(
s
,
i
)
==
SATOKO_
LIT_FALSE
?
-
(
int
)(
i
)
:
i
);
else
else
fprintf
(
file
,
"%d 0
\n
"
,
var_value
(
s
,
i
)
==
LIT_FALSE
?
-
(
int
)(
i
+
1
)
:
i
+
1
);
fprintf
(
file
,
"%d 0
\n
"
,
var_value
(
s
,
i
)
==
SATOKO_
LIT_FALSE
?
-
(
int
)(
i
+
1
)
:
i
+
1
);
}
}
}
}
array
=
vec_uint_data
(
s
->
originals
);
array
=
vec_uint_data
(
s
->
originals
);
...
@@ -552,5 +557,56 @@ void satoko_write_dimacs(satoko_t *s, char *fname, int wrt_lrnt, int zero_var)
...
@@ -552,5 +557,56 @@ void satoko_write_dimacs(satoko_t *s, char *fname, int wrt_lrnt, int zero_var)
}
}
int
satoko_varnum
(
satoko_t
*
s
)
{
return
vec_char_size
(
s
->
assigns
);
}
int
satoko_clausenum
(
satoko_t
*
s
)
{
return
vec_uint_size
(
s
->
originals
);
}
int
satoko_learntnum
(
satoko_t
*
s
)
{
return
vec_uint_size
(
s
->
learnts
);
}
int
satoko_conflictnum
(
satoko_t
*
s
)
{
return
satoko_stats
(
s
)
->
n_conflicts
;
}
void
satoko_set_stop
(
satoko_t
*
s
,
int
*
pstop
)
{
s
->
pstop
=
pstop
;
}
void
satoko_set_stop_func
(
satoko_t
*
s
,
int
(
*
fnct
)(
int
))
{
s
->
pFuncStop
=
fnct
;
}
void
satoko_set_runid
(
satoko_t
*
s
,
int
id
)
{
s
->
RunId
=
id
;
}
int
satoko_read_cex_varvalue
(
satoko_t
*
s
,
int
ivar
)
{
return
satoko_var_polarity
(
s
,
ivar
)
==
SATOKO_LIT_TRUE
;
}
abctime
satoko_set_runtime_limit
(
satoko_t
*
s
,
abctime
Limit
)
{
abctime
nRuntimeLimit
=
s
->
nRuntimeLimit
;
s
->
nRuntimeLimit
=
Limit
;
return
nRuntimeLimit
;
}
char
satoko_var_polarity
(
satoko_t
*
s
,
unsigned
var
)
{
return
vec_char_at
(
s
->
polarity
,
var
);
}
ABC_NAMESPACE_IMPL_END
ABC_NAMESPACE_IMPL_END
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment