Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Romain WALLON
sat4j
Commits
ac1ce775
Commit
ac1ce775
authored
May 17, 2021
by
Daniel Le Berre
Browse files
fixes id for = constraints
parent
c4ebee28
Changes
1
Hide whitespace changes
Inline
Side-by-side
org.sat4j.pb/src/main/java/org/sat4j/pb/reader/OPBReader2005.java
View file @
ac1ce775
...
...
@@ -63,6 +63,7 @@ import java.text.ParseException;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.sat4j.core.ConstrGroup
;
import
org.sat4j.core.Vec
;
import
org.sat4j.core.VecInt
;
import
org.sat4j.pb.IPBSolver
;
...
...
@@ -120,6 +121,7 @@ public class OPBReader2005 extends Reader implements Serializable {
// file.
protected
int
nbConstraintsRead
;
protected
int
currentConstraintId
;
/**
* callback called when we get the number of variables and the expected
...
...
@@ -128,7 +130,7 @@ public class OPBReader2005 extends Reader implements Serializable {
* @param nbvar
* the number of variables
* @param nbconstr
* the number of contraints
* the number of con
s
traints
*/
protected
void
metaData
(
int
nbvar
,
int
nbconstr
)
{
this
.
solver
.
newVar
(
nbvar
);
...
...
@@ -178,14 +180,20 @@ public class OPBReader2005 extends Reader implements Serializable {
IConstr
constr
;
if
(
"="
.
equals
(
this
.
operator
))
{
constr
=
this
.
solver
.
addExactly
(
this
.
lits
,
this
.
coeffs
,
this
.
d
);
ConstrGroup
cg
=
((
ConstrGroup
)
constr
);
for
(
int
i
=
0
;
i
<
cg
.
size
();
i
++)
{
constr
.
setId
(++
this
.
currentConstraintId
);
}
}
else
if
(
"<="
.
equals
(
this
.
operator
))
{
constr
=
this
.
solver
.
addAtMost
(
this
.
lits
,
this
.
coeffs
,
this
.
d
);
constr
.
setId
(++
this
.
currentConstraintId
);
}
else
{
assert
">="
.
equals
(
this
.
operator
);
constr
=
this
.
solver
.
addAtLeast
(
this
.
lits
,
this
.
coeffs
,
this
.
d
);
constr
.
setId
(++
this
.
currentConstraintId
);
}
this
.
nbConstraintsRead
++;
constr
.
setId
(
this
.
nbConstraintsRead
);
}
/**
...
...
@@ -717,6 +725,7 @@ public class OPBReader2005 extends Reader implements Serializable {
// read constraints
this
.
nbConstraintsRead
=
0
;
this
.
currentConstraintId
=
0
;
char
c
;
while
(!
eof
())
{
skipSpaces
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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