Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SAT4J
sat4j
Commits
b119c31e
Commit
b119c31e
authored
Jul 01, 2018
by
Daniel Le Berre
Browse files
Testcase for #143.
parent
37faa28d
Changes
1
Hide whitespace changes
Inline
Side-by-side
org.sat4j.pb/src/test/java/org/sat4j/pb/BugSAT143.java
0 → 100644
View file @
b119c31e
package
org.sat4j.pb
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
java.math.BigInteger
;
import
org.junit.Test
;
import
org.sat4j.core.Vec
;
import
org.sat4j.core.VecInt
;
import
org.sat4j.specs.ContradictionException
;
import
org.sat4j.specs.IConstr
;
import
org.sat4j.specs.IVec
;
import
org.sat4j.specs.IVecInt
;
import
org.sat4j.specs.TimeoutException
;
public
class
BugSAT143
{
@Test
public
void
testWithCard
()
throws
ContradictionException
,
TimeoutException
{
IVecInt
lits
=
new
VecInt
(
new
int
[]
{
1
,
2
,
3
});
IVec
<
BigInteger
>
coeffs_good
=
new
Vec
<
BigInteger
>(
new
BigInteger
[]
{
BigInteger
.
ONE
,
BigInteger
.
ONE
,
BigInteger
.
ONE
});
IPBSolver
solver
=
SolverFactory
.
newDefault
();
solver
.
newVar
(
3
);
IConstr
constr
=
null
;
solver
.
addAtMost
(
lits
,
2
);
boolean
is_sat
=
solver
.
isSatisfiable
();
assertTrue
(
is_sat
);
constr
=
solver
.
addPseudoBoolean
(
lits
,
coeffs_good
,
true
,
new
BigInteger
(
"3"
));
is_sat
=
solver
.
isSatisfiable
();
assertFalse
(
is_sat
);
solver
.
removeConstr
(
constr
);
is_sat
=
solver
.
isSatisfiable
();
assertTrue
(
is_sat
);
}
@Test
public
void
testWithPB
()
throws
ContradictionException
,
TimeoutException
{
IVecInt
lits
=
new
VecInt
(
new
int
[]
{
1
,
2
,
3
});
IVec
<
BigInteger
>
coeffs_bug
=
new
Vec
<
BigInteger
>(
new
BigInteger
[]
{
BigInteger
.
ONE
,
BigInteger
.
ONE
,
new
BigInteger
(
"2"
)
});
IPBSolver
solver
=
SolverFactory
.
newDefault
();
solver
.
newVar
(
3
);
IConstr
constr
=
null
;
solver
.
addAtMost
(
lits
,
2
);
boolean
is_sat
=
solver
.
isSatisfiable
();
assertTrue
(
is_sat
);
constr
=
solver
.
addPseudoBoolean
(
lits
,
coeffs_bug
,
true
,
new
BigInteger
(
"4"
));
is_sat
=
solver
.
isSatisfiable
();
assertFalse
(
is_sat
);
solver
.
removeConstr
(
constr
);
is_sat
=
solver
.
isSatisfiable
();
assertTrue
(
is_sat
);
}
}
Write
Preview
Supports
Markdown
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