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
SAT4J
sat4j
Commits
05702b6c
Commit
05702b6c
authored
Nov 11, 2018
by
Daniel Le Berre
Browse files
Closing properly fwriter without using java7+ try on resources.
parent
15bd4355
Changes
1
Hide whitespace changes
Inline
Side-by-side
org.sat4j.pb/src/main/java/org/sat4j/pb/tools/OpbToDimacsWriter.java
View file @
05702b6c
...
...
@@ -22,28 +22,33 @@ import org.sat4j.tools.encoding.Policy;
*/
public
class
OpbToDimacsWriter
{
public
static
void
main
(
String
args
[])
throws
ParseFormatException
,
IOException
,
ContradictionException
{
public
static
void
main
(
String
args
[])
throws
ParseFormatException
,
IOException
,
ContradictionException
{
new
OpbToDimacsWriter
(
args
);
}
public
OpbToDimacsWriter
(
String
[]
args
)
throws
ParseFormatException
,
IOException
,
ContradictionException
{
Set
<
EncodingStrategy
>
tabooEncodings
=
new
HashSet
<
EncodingStrategy
>();
public
OpbToDimacsWriter
(
String
[]
args
)
throws
ParseFormatException
,
IOException
,
ContradictionException
{
Set
<
EncodingStrategy
>
tabooEncodings
=
new
HashSet
<>();
tabooEncodings
.
add
(
EncodingStrategy
.
NATIVE
);
for
(
EncodingStrategy
strategy
:
EncodingStrategy
.
values
())
{
if
(
tabooEncodings
.
contains
(
strategy
))
continue
;
DimacsStringSolver
dss
=
new
DimacsStringSolver
();
IPBSolver
solver
=
new
ClausalConstraintsDecorator
(
new
PBAdapter
(
dss
),
Policy
.
getAdapterFromEncodingName
(
strategy
));
OPBReader2012
reader
=
new
OPBReader2012
(
new
PBSolverHandle
(
solver
));
IPBSolver
solver
=
new
ClausalConstraintsDecorator
(
new
PBAdapter
(
dss
),
Policy
.
getAdapterFromEncodingName
(
strategy
));
OPBReader2012
reader
=
new
OPBReader2012
(
new
PBSolverHandle
(
solver
));
solver
.
setVerbose
(
false
);
reader
.
parseInstance
(
args
[
0
]);
FileWriter
fwriter
=
new
FileWriter
(
args
[
0
]
+
".cardEncoding."
+
strategy
.
name
()
+
".cnf"
);
fwriter
.
write
(
dss
.
toString
());
fwriter
.
close
();
FileWriter
fwriter
=
new
FileWriter
(
args
[
0
]
+
".cardEncoding."
+
strategy
.
name
()
+
".cnf"
);
try
{
fwriter
.
write
(
dss
.
toString
());
}
finally
{
fwriter
.
close
();
}
}
}
}
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