Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
SAT4J
sat4j
Commits
ae7c812b
Commit
ae7c812b
authored
Aug 24, 2017
by
Daniel Le Berre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Try to fix the erratic behavior of the solver.
parent
52b54a00
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
10 deletions
+33
-10
org.sat4j.pb/src/main/java/org/sat4j/pb/constraints/pb/ConflictMap.java
...rc/main/java/org/sat4j/pb/constraints/pb/ConflictMap.java
+33
-10
No files found.
org.sat4j.pb/src/main/java/org/sat4j/pb/constraints/pb/ConflictMap.java
View file @
ae7c812b
...
...
@@ -767,6 +767,28 @@ public class ConflictMap extends MapPb implements IConflict {
return
true
;
}
private
static
final
class
Counter
{
private
BigInteger
value
;
public
Counter
()
{
value
=
BigInteger
.
ZERO
;
}
public
Counter
(
BigInteger
initialValue
)
{
value
=
initialValue
;
}
public
void
inc
(
BigInteger
amount
)
{
value
=
value
.
add
(
amount
);
}
public
BigInteger
getValue
()
{
return
value
;
}
}
/**
* computes the level for the backtrack : the highest decision level for
* which the conflict is assertive.
...
...
@@ -786,19 +808,20 @@ public class ConflictMap extends MapPb implements IConflict {
if
(
voc
.
isFalsified
(
l
))
levels
.
add
(
voc
.
getLevel
(
l
));
}
Map
<
Integer
,
BigInteg
er
>
bylvl
=
new
HashMap
<
Integer
,
BigInteg
er
>();
bylvl
.
put
(
0
,
BigInteger
.
ZERO
);
List
<
Integer
>
vv_indices
=
new
ArrayList
<
Integer
>();
Map
<
Integer
,
Count
er
>
bylvl
=
new
HashMap
<
Integer
,
Count
er
>();
bylvl
.
put
(
0
,
new
Counter
()
);
List
<
Integer
>
vv_indices
=
new
ArrayList
<
Integer
>(
weightedLits
.
size
()
);
BigInteger
s
=
degree
.
negate
();
for
(
int
i
=
0
;
i
<
weightedLits
.
size
();
i
++)
{
int
l
=
weightedLits
.
getLit
(
i
);
BigInteger
coef
=
weightedLits
.
getCoef
(
i
);
if
(
voc
.
isFalsified
(
l
))
{
if
(!
bylvl
.
containsKey
(
voc
.
getLevel
(
l
)))
bylvl
.
put
(
voc
.
getLevel
(
l
),
coef
);
else
bylvl
.
put
(
voc
.
getLevel
(
l
),
bylvl
.
get
(
voc
.
getLevel
(
l
)).
add
(
coef
));
Counter
counter
=
bylvl
.
get
(
voc
.
getLevel
(
l
));
if
(
counter
==
null
)
{
bylvl
.
put
(
voc
.
getLevel
(
l
),
new
Counter
(
coef
));
}
else
{
counter
.
inc
(
coef
);
}
}
vv_indices
.
add
(
i
);
s
=
s
.
add
(
coef
);
...
...
@@ -812,8 +835,8 @@ public class ConflictMap extends MapPb implements IConflict {
}
});
int
at
=
0
;
for
(
i
nt
lvl
:
levels
)
{
s
=
s
.
subtract
(
bylvl
.
get
(
lvl
));
for
(
I
nt
eger
lvl
:
levels
)
{
s
=
s
.
subtract
(
bylvl
.
get
(
lvl
)
.
getValue
()
);
for
(;;
at
++)
{
assert
at
<
vv_indices
.
size
();
int
i
=
vv_indices
.
get
(
at
);
...
...
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