Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
sat4j
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
53
Issues
53
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SAT4J
sat4j
Commits
05702b6c
Commit
05702b6c
authored
Nov 11, 2018
by
Daniel Le Berre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Closing properly fwriter without using java7+ try on resources.
parent
15bd4355
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
12 deletions
+17
-12
org.sat4j.pb/src/main/java/org/sat4j/pb/tools/OpbToDimacsWriter.java
...b/src/main/java/org/sat4j/pb/tools/OpbToDimacsWriter.java
+17
-12
No files found.
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
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