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
f6815808
Commit
f6815808
authored
Mar 13, 2022
by
Daniel Le Berre
Browse files
removed deprecated methods Reader.parseInstance() and Reader.decode()
parent
33b77655
Pipeline
#20208
failed with stages
in 32 minutes and 3 seconds
Changes
12
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
org.sat4j.core/src/main/java/org/sat4j/reader/AAGReader.java
View file @
f6815808
...
...
@@ -49,6 +49,11 @@ import org.sat4j.tools.GateTranslator;
@Feature
(
value
=
"reader"
,
parent
=
"expert"
)
public
class
AAGReader
extends
Reader
{
/**
*
*/
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
int
FALSE
=
0
;
private
static
final
int
TRUE
=
1
;
...
...
@@ -63,15 +68,6 @@ public class AAGReader extends Reader {
this
.
solver
=
new
GateTranslator
(
s
);
}
@Override
public
String
decode
(
int
[]
model
)
{
var
stb
=
new
StringBuilder
();
for
(
var
i
=
0
;
i
<
this
.
nbinputs
;
i
++)
{
stb
.
append
(
model
[
i
]
>
0
?
1
:
0
);
}
return
stb
.
toString
();
}
@Override
public
void
decode
(
int
[]
model
,
PrintWriter
out
)
{
for
(
var
i
=
0
;
i
<
this
.
nbinputs
;
i
++)
{
...
...
org.sat4j.core/src/main/java/org/sat4j/reader/AIGReader.java
View file @
f6815808
...
...
@@ -67,15 +67,6 @@ public class AIGReader extends Reader {
this
.
solver
=
new
GateTranslator
(
s
);
}
@Override
public
String
decode
(
int
[]
model
)
{
var
stb
=
new
StringBuilder
();
for
(
var
i
=
0
;
i
<
this
.
nbinputs
;
i
++)
{
stb
.
append
(
model
[
i
]
>
0
?
1
:
0
);
}
return
stb
.
toString
();
}
@Override
public
void
decode
(
int
[]
model
,
PrintWriter
out
)
{
for
(
var
i
=
0
;
i
<
this
.
nbinputs
;
i
++)
{
...
...
org.sat4j.core/src/main/java/org/sat4j/reader/DimacsReader.java
View file @
f6815808
...
...
@@ -263,17 +263,6 @@ public class DimacsReader extends Reader implements Serializable {
}
}
@Override
public
String
decode
(
int
[]
model
)
{
var
stb
=
new
StringBuilder
();
for
(
int
element
:
model
)
{
stb
.
append
(
element
);
stb
.
append
(
" "
);
}
stb
.
append
(
"0"
);
return
stb
.
toString
();
}
@Override
public
void
decode
(
int
[]
model
,
PrintWriter
out
)
{
for
(
int
element
:
model
)
{
...
...
org.sat4j.core/src/main/java/org/sat4j/reader/InstanceReader.java
View file @
f6815808
...
...
@@ -49,6 +49,11 @@ import org.sat4j.specs.ISolver;
@Feature
(
value
=
"reader"
,
parent
=
"expert"
)
public
class
InstanceReader
extends
Reader
{
/**
*
*/
private
static
final
long
serialVersionUID
=
1L
;
private
AAGReader
aag
;
private
AIGReader
aig
;
...
...
@@ -145,12 +150,6 @@ public class InstanceReader extends Reader {
return
getDefaultSATReader
();
}
@Override
@Deprecated
public
String
decode
(
int
[]
model
)
{
return
this
.
reader
.
decode
(
model
);
}
@Override
public
void
decode
(
int
[]
model
,
PrintWriter
out
)
{
this
.
reader
.
decode
(
model
,
out
);
...
...
org.sat4j.core/src/main/java/org/sat4j/reader/JSONReader.java
View file @
f6815808
...
...
@@ -177,15 +177,6 @@ public class JSONReader<S extends ISolver> extends Reader {
return
solver
;
}
/**
* @deprecated use {@link #decode(int[], PrintWriter)} instead
*/
@Override
@Deprecated
public
String
decode
(
int
[]
model
)
{
return
"["
+
new
VecInt
(
model
)
+
"]"
;
}
@Override
public
void
decode
(
int
[]
model
,
PrintWriter
out
)
{
out
.
print
(
"["
);
...
...
org.sat4j.core/src/main/java/org/sat4j/reader/LecteurDimacs.java
View file @
f6815808
...
...
@@ -287,17 +287,6 @@ public class LecteurDimacs extends Reader implements Serializable {
return
car
;
}
@Override
public
String
decode
(
int
[]
model
)
{
var
stb
=
new
StringBuilder
();
for
(
int
element
:
model
)
{
stb
.
append
(
element
);
stb
.
append
(
" "
);
}
stb
.
append
(
"0"
);
return
stb
.
toString
();
}
@Override
public
void
decode
(
int
[]
model
,
PrintWriter
out
)
{
if
(
isUsingMapping
()
&&
hasAMapping
())
{
...
...
org.sat4j.core/src/main/java/org/sat4j/reader/Reader.java
View file @
f6815808
...
...
@@ -148,48 +148,6 @@ public abstract class Reader implements Serializable {
public
abstract
IProblem
parseInstance
(
final
InputStream
in
)
throws
ParseFormatException
,
ContradictionException
,
IOException
;
/**
* Read a file from a reader.
*
* Do not use that method, it is no longer supported.
*
* @param in
* a stream containing the benchmark.
* @return the problem to solve (an ISolver in fact).
* @throws ParseFormatException
* if an error occurs during parsing.
* @throws IOException
* if an I/O error occurs.
* @throws ContradictionException
* if the problem is found trivially inconsistent.
* @see #parseInstance(InputStream)
* @deprecated use {@link #parseInstance(InputStream)} instead
*/
@Deprecated
public
IProblem
parseInstance
(
java
.
io
.
Reader
in
)
throws
ParseFormatException
,
ContradictionException
,
IOException
{
throw
new
UnsupportedOperationException
(
"Use #parseInstance(InputStream) instead"
);
}
/**
* Produce a model using the reader format.
*
* Note that the approach of building a string representation of the model
* may be quite inefficient when the model is rather large. For that reason,
* the preferred way to proceed is to directly output the textual
* representation in a specific PrintWriter using
* {@link #decode(int[], PrintWriter)}
*
* @param model
* a model using the Dimacs format.
* @return a human readable view of the model.
* @see #decode(int[], PrintWriter)
* @deprecated use {@link #decode(int[], PrintWriter)} instead
*/
@Deprecated
public
abstract
String
decode
(
int
[]
model
);
/**
* Produce a model using the reader format on a provided printwriter.
*
...
...
org.sat4j.pb/src/main/java/org/sat4j/pb/reader/OPBReader2005.java
View file @
f6815808
...
...
@@ -754,7 +754,6 @@ public class OPBReader2005 extends Reader implements Serializable {
}
}
@Override
public
IProblem
parseInstance
(
final
java
.
io
.
Reader
input
)
throws
ParseFormatException
,
ContradictionException
{
IProblem
problem
=
parseInstance
(
new
LineNumberReader
(
input
));
...
...
@@ -783,23 +782,6 @@ public class OPBReader2005 extends Reader implements Serializable {
}
}
@Override
public
String
decode
(
int
[]
model
)
{
StringBuilder
stb
=
new
StringBuilder
();
for
(
int
i
=
0
;
i
<
model
.
length
;
i
++)
{
if
(
model
[
i
]
<
0
)
{
stb
.
append
(
"-x"
);
stb
.
append
(-
model
[
i
]);
}
else
{
stb
.
append
(
"x"
);
stb
.
append
(
model
[
i
]);
}
stb
.
append
(
" "
);
}
return
stb
.
toString
();
}
@Override
public
void
decode
(
int
[]
model
,
PrintWriter
out
)
{
for
(
int
i
=
0
;
i
<
model
.
length
;
i
++)
{
...
...
org.sat4j.pb/src/main/java/org/sat4j/pb/reader/OPBReader2007.java
View file @
f6815808
...
...
@@ -317,26 +317,6 @@ public class OPBReader2007 extends OPBReader2006 {
return
null
;
}
@Override
public
String
decode
(
int
[]
model
)
{
StringBuilder
stb
=
new
StringBuilder
();
int
p
;
for
(
int
element
:
model
)
{
p
=
element
;
if
(
Math
.
abs
(
p
)
<=
this
.
nbVars
)
{
if
(
p
<
0
)
{
stb
.
append
(
"-x"
);
stb
.
append
(-
p
);
}
else
{
stb
.
append
(
"x"
);
stb
.
append
(
p
);
}
stb
.
append
(
" "
);
}
}
return
stb
.
toString
();
}
@Override
public
void
decode
(
int
[]
model
,
PrintWriter
out
)
{
int
p
;
...
...
org.sat4j.pb/src/test/java/org/sat4j/pb/BugJo.java
View file @
f6815808
...
...
@@ -8,7 +8,6 @@ import java.io.StringReader;
import
org.junit.Test
;
import
org.sat4j.pb.reader.OPBReader2012
;
import
org.sat4j.reader.ParseFormatException
;
import
org.sat4j.reader.Reader
;
import
org.sat4j.specs.ContradictionException
;
public
class
BugJo
{
...
...
@@ -17,7 +16,7 @@ public class BugJo {
public
void
testJoUnit
()
throws
ParseFormatException
,
ContradictionException
,
IOException
{
IPBSolver
solver
=
SolverFactory
.
newDefault
();
Reader
reader
=
new
OPBReader2012
(
OPB
Reader
2012
reader
=
new
OPBReader2012
(
new
PBSolverHandle
(
new
PseudoOptDecorator
(
solver
)));
reader
.
parseInstance
(
new
StringReader
(
"* #variable= 1 #constraint= 1\n*\n+1 x1 >= 1 ;\n"
));
...
...
@@ -30,7 +29,7 @@ public class BugJo {
public
void
testJoBinary
()
throws
ParseFormatException
,
ContradictionException
,
IOException
{
IPBSolver
solver
=
SolverFactory
.
newDefault
();
Reader
reader
=
new
OPBReader2012
(
OPB
Reader
2012
reader
=
new
OPBReader2012
(
new
PBSolverHandle
(
new
PseudoOptDecorator
(
solver
)));
reader
.
parseInstance
(
new
StringReader
(
"* #variable= 2 #constraint= 1\n*\n+1 x1 +1 x2 >= 1 ;\n"
));
...
...
org.sat4j.pb/src/test/java/org/sat4j/pb/GoodOPBReader.java
View file @
f6815808
...
...
@@ -79,7 +79,6 @@ public class GoodOPBReader extends Reader implements Serializable {
this
.
solver
=
solver
;
}
@Override
public
final
IProblem
parseInstance
(
final
java
.
io
.
Reader
in
)
throws
ParseFormatException
,
ContradictionException
,
IOException
{
return
parseInstance
(
new
LineNumberReader
(
in
));
...
...
@@ -199,21 +198,6 @@ public class GoodOPBReader extends Reader implements Serializable {
}
}
@Override
public
String
decode
(
int
[]
model
)
{
StringBuilder
stb
=
new
StringBuilder
();
for
(
int
i
=
0
;
i
<
model
.
length
;
i
++)
{
if
(
model
[
i
]
<
0
)
{
stb
.
append
(
"-"
);
stb
.
append
(
this
.
decode
.
get
(-
model
[
i
]
-
1
));
}
else
{
stb
.
append
(
this
.
decode
.
get
(
model
[
i
]
-
1
));
}
stb
.
append
(
" "
);
}
return
stb
.
toString
();
}
@Override
public
void
decode
(
int
[]
model
,
PrintWriter
out
)
{
for
(
int
i
=
0
;
i
<
model
.
length
;
i
++)
{
...
...
org.sat4j.sat/src/main/java/org/sat4j/sat/KTHLauncher.java
View file @
f6815808
...
...
@@ -67,6 +67,8 @@ import org.sat4j.tools.DotSearchTracing;
*/
public
class
KTHLauncher
{
private
static
final
PrintWriter
out
=
new
PrintWriter
(
System
.
out
);
public
static
Options
createCLIOptions
()
{
Options
options
=
new
Options
();
options
.
addOption
(
"cl"
,
"coeflim"
,
true
,
...
...
@@ -520,7 +522,7 @@ public class KTHLauncher {
// stop the solver before displaying solutions
optimizer
.
expireTimeout
();
optimizer
.
printStat
(
new
PrintWriter
(
System
.
out
)
)
;
optimizer
.
printStat
(
out
);
}
};
Runtime
.
getRuntime
().
addShutdownHook
(
shutdownHook
);
...
...
@@ -541,7 +543,9 @@ public class KTHLauncher {
}
else
{
log
(
"SATISFIABLE"
,
"s "
);
}
log
(
reader
.
decode
(
optimizer
.
model
())
+
" 0"
,
"v "
);
out
.
print
(
"v "
);
reader
.
decode
(
optimizer
.
model
(),
out
);
out
.
println
(
" 0"
);
}
else
{
log
(
"UNSATISFIABLE"
,
"s "
);
}
...
...
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