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
7a19593d
Commit
7a19593d
authored
Dec 04, 2011
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Proof-logging in the updated solver.
parent
f0d44a4a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
22 deletions
+31
-22
src/sat/bsat/satSolver2.c
+30
-22
src/sat/bsat/satSolver2.h
+1
-0
No files found.
src/sat/bsat/satSolver2.c
View file @
7a19593d
...
...
@@ -30,6 +30,7 @@ ABC_NAMESPACE_IMPL_START
#define SAT_USE_ANALYZE_FINAL
#define SAT_USE_PROOF_LOGGING
//=================================================================================================
// Debug:
...
...
@@ -162,7 +163,7 @@ static inline cla clause_id (sat_solver2* s, satset* c) { return (cla)(
//static inline satset* var_unit_clause(sat_solver2* s, int v) { return (s->reasons[v]&1) ? get_clause(s, s->reasons[v] >> 1) : NULL; }
//static inline void var_set_unit_clause(sat_solver2* s, int v, cla i){ assert(i && !s->reasons[v]); s->reasons[v] = (i << 1) | 1; }
static
inline
satset
*
var_unit_clause
(
sat_solver2
*
s
,
int
v
)
{
return
get_clause
(
s
,
s
->
units
[
v
]);
}
static
inline
void
var_set_unit_clause
(
sat_solver2
*
s
,
int
v
,
cla
i
){
assert
(
v
>=
0
&&
v
<
s
->
size
&&
!
s
->
units
[
v
]);
s
->
units
[
v
]
=
i
;
}
static
inline
void
var_set_unit_clause
(
sat_solver2
*
s
,
int
v
,
cla
i
){
assert
(
v
>=
0
&&
v
<
s
->
size
&&
!
s
->
units
[
v
]);
s
->
units
[
v
]
=
i
;
s
->
nUnits
++
;
}
#define sat_solver_foreach_clause( s, c, i ) \
for ( i = 16; (i < s->nMemSize) && (((c) = get_clause(s, i)), 1); i += clause_size(c->nLits) )
...
...
@@ -404,46 +405,39 @@ static int clause_new(sat_solver2* s, lit* begin, lit* end, int learnt, int proo
// assign clause ID
if
(
learnt
)
{
c
->
Id
=
s
->
stats
.
learnts
+
1
;
s
->
stats
.
learnts
++
;
s
->
stats
.
learnts_literals
+=
nLits
;
c
->
Id
=
s
->
stats
.
learnts
;
assert
(
c
->
Id
==
veci_size
(
&
s
->
claActs
)
);
veci_push
(
&
s
->
claActs
,
0
);
if
(
proof_id
)
veci_push
(
&
s
->
claProofs
,
proof_id
);
if
(
nLits
>
2
)
act_clause_bump
(
s
,
c
);
s
->
stats
.
learnts
++
;
s
->
stats
.
learnts_literals
+=
nLits
;
}
else
{
c
->
Id
=
s
->
stats
.
clauses
+
1
;
// count literals
s
->
stats
.
clauses
++
;
s
->
stats
.
clauses_literals
+=
nLits
;
c
->
Id
=
s
->
stats
.
clauses
;
}
// extend storage
Cid
=
veci_size
(
&
s
->
clauses
);
s
->
clauses
.
size
+=
clause_size
(
nLits
);
if
(
veci_size
(
&
s
->
clauses
)
>
s
->
clauses
.
cap
)
printf
(
"Out of memory!!!
\n
"
);
assert
(
veci_size
(
&
s
->
clauses
)
<=
s
->
clauses
.
cap
);
assert
(((
ABC_PTRUINT_T
)
c
&
3
)
==
0
);
// watch the clause
if
(
nLits
>
1
)
{
veci_push
(
solver2_wlist
(
s
,
lit_neg
(
begin
[
0
])),
clause_id
(
s
,
c
));
veci_push
(
solver2_wlist
(
s
,
lit_neg
(
begin
[
1
])),
clause_id
(
s
,
c
));
}
// remember the last one and first learnt
s
->
fLastConfId
=
Cid
;
if
(
learnt
&&
s
->
iFirstLearnt
==
-
1
)
s
->
iFirstLearnt
=
Cid
;
// watch the clause
if
(
nLits
>
1
){
veci_push
(
solver2_wlist
(
s
,
lit_neg
(
begin
[
0
])),
Cid
);
veci_push
(
solver2_wlist
(
s
,
lit_neg
(
begin
[
1
])),
Cid
);
}
return
Cid
;
}
...
...
@@ -465,6 +459,15 @@ static inline int solver2_enqueue(sat_solver2* s, lit l, int from)
#endif
var_set_value
(
s
,
v
,
lit_sign
(
l
)
);
var_set_level
(
s
,
v
,
solver2_dlevel
(
s
)
);
/*
if ( s->units && s->units[v] != 0 )
{
assert( solver2_dlevel(s) == 0 );
// assert( from == 0 );
if ( from )
printf( "." );
}
*/
s
->
reasons
[
v
]
=
from
;
// = from << 1;
s
->
trail
[
s
->
qtail
++
]
=
l
;
order_assigned
(
s
,
v
);
...
...
@@ -521,6 +524,7 @@ static void solver2_record(sat_solver2* s, veci* cls, int proof_id)
assert
(
veci_size
(
cls
)
>
0
);
if
(
veci_size
(
cls
)
==
1
)
{
if
(
s
->
fProofLogging
)
var_set_unit_clause
(
s
,
lit_var
(
begin
[
0
]),
Cid
);
Cid
=
0
;
}
...
...
@@ -932,7 +936,6 @@ satset* solver2_propagate(sat_solver2* s)
proof_chain_resolve
(
s
,
NULL
,
x
);
}
proof_id
=
proof_chain_stop
(
s
);
//printf( "Deriving clause %d\n", lits[0] );
// get a new clause
Cid
=
clause_new
(
s
,
lits
,
lits
+
1
,
1
,
proof_id
);
assert
(
(
var_unit_clause
(
s
,
Var
)
==
NULL
)
!=
fLitIsFalse
);
...
...
@@ -1221,8 +1224,13 @@ sat_solver2* sat_solver2_new(void)
s
->
cla_inc
=
(
1
<<
11
);
#endif
s
->
random_seed
=
91648253
;
#ifdef SAT_USE_PROOF_LOGGING
s
->
fProofLogging
=
1
;
/*
#else
s
->
fProofLogging
=
0
;
#endif
// prealloc some arrays
if
(
s
->
fProofLogging
)
{
...
...
@@ -1231,7 +1239,6 @@ sat_solver2* sat_solver2_new(void)
s
->
proof_vars
.
cap
=
(
1
<<
20
);
s
->
proof_vars
.
ptr
=
ABC_ALLOC
(
int
,
s
->
proof_clas
.
cap
);
}
*/
return
s
;
}
...
...
@@ -1264,6 +1271,7 @@ void sat_solver2_setnvars(sat_solver2* s,int n)
*
((
int
*
)
s
->
vi
+
var
)
=
0
;
s
->
vi
[
var
].
val
=
varX
;
s
->
orderpos
[
var
]
=
veci_size
(
&
s
->
order
);
s
->
reasons
[
var
]
=
0
;
if
(
s
->
fProofLogging
)
s
->
units
[
var
]
=
0
;
s
->
activity
[
var
]
=
(
1
<<
10
);
// does not hold because variables enqueued at top level will not be reinserted in the heap
...
...
@@ -1278,7 +1286,7 @@ void sat_solver2_delete(sat_solver2* s)
{
// report statistics
assert
(
veci_size
(
&
s
->
proof_clas
)
==
veci_size
(
&
s
->
proof_vars
)
);
printf
(
"Used %6.2f Mb for proof-logging.
\n
"
,
8
.
0
*
veci_size
(
&
s
->
proof_clas
)
/
(
1
<<
20
)
);
printf
(
"Used %6.2f Mb for proof-logging.
Unit clauses = %d.
\n
"
,
8
.
0
*
veci_size
(
&
s
->
proof_clas
)
/
(
1
<<
20
),
s
->
nUnits
);
// delete vectors
veci_delete
(
&
s
->
order
);
...
...
src/sat/bsat/satSolver2.h
View file @
7a19593d
...
...
@@ -134,6 +134,7 @@ struct sat_solver2_t
veci
proof_vars
;
// sequence of proof variables
int
iStartChain
;
// temporary variable to remember beginning of the current chain in proof logging
int
fLastConfId
;
// in proof-logging mode, the ID of the final conflict clause (conf_final)
int
nUnits
;
// the total number of unit clauses
// statistics
stats_t
stats
;
...
...
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