Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
Conversion
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Vladislav Kiselev
Conversion
Commits
648a3509
Commit
648a3509
authored
Aug 05, 2019
by
Vladislav Kiselev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Добавлена возможность паралельного исполнения.
parent
99ae99fe
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
10 deletions
+28
-10
src/inport/ConversionUtils/Solver.java
src/inport/ConversionUtils/Solver.java
+28
-10
No files found.
src/inport/ConversionUtils/Solver.java
View file @
648a3509
...
...
@@ -56,12 +56,31 @@ public class Solver {
directory
.
mkdir
();
}
tempDir
=
tempDir
+
"/"
;
File
candidate
=
new
File
(
tempDir
+
"/1/"
);
final
int
limitOfDirectories
=
1000000
;
int
i
=
1
;
while
(
i
<
limitOfDirectories
)
{
candidate
=
new
File
(
tempDir
+
"/"
+
i
+
"/"
);
if
(
candidate
.
mkdir
())
{
break
;
}
i
++;
}
if
(
i
==
limitOfDirectories
)
{
return
"Impossible to create files from "
+
tempDir
+
"/1/ to "
+
tempDir
+
"/"
+
(
limitOfDirectories
-
1
)
+
"/ ."
;
}
tempDir
=
tempDir
+
"/"
+
i
+
"/"
;
String
minizincData
=
tempDir
+
"minizinc_data.dzn"
;
String
solverResults
=
tempDir
+
"solver_results.txt"
;
String
constraints
=
tempDir
+
"constraints.mzn"
;
String
flatZincConstraints
=
tempDir
+
"model.fzn"
;
new
File
(
solverResults
).
delete
();
try
{
try
(
FileWriter
res
=
new
FileWriter
(
constraints
))
{
BufferedReader
reader
=
new
BufferedReader
(
new
InputStreamReader
(
Main
.
class
.
getResourceAsStream
(
"/constraints/"
+
constraintName
)));
...
...
@@ -133,6 +152,9 @@ public class Solver {
}
});
BufferedReader
br
=
new
BufferedReader
(
new
InputStreamReader
(
process
.
getInputStream
()));
// BufferedReader br2 = new BufferedReader(new InputStreamReader(process.getErrorStream()));
killer
.
start
();
int
exitCode
=
process
.
waitFor
();
...
...
@@ -156,20 +178,16 @@ public class Solver {
if
(
isResultsInOutput
)
{
try
(
FileWriter
res
=
new
FileWriter
(
solverResults
))
{
BufferedReader
br
=
new
BufferedReader
(
new
InputStreamReader
(
process
.
getInputStream
()));
res
.
write
(
br
.
lines
().
collect
(
Collectors
.
joining
(
"\n"
)));
}
interpreter
.
accept
(
task
,
solverResults
);
}
else
{
BufferedReader
br
=
new
BufferedReader
(
new
InputStreamReader
(
process
.
getInputStream
()));
String
output
=
br
.
lines
().
collect
(
Collectors
.
joining
(
"\n"
));
// BufferedReader br2 = new BufferedReader(new InputStreamReader(process.getErrorStream()));
// String errors = br.lines().collect(Collectors.joining("\n"));
// System.out.println("output : " + output);
// System.out.println("errors : " + errors);
// String errors = br.lines().collect(Collectors.joining("\n"));
//
// System.out.println("output : " + output);
// System.out.println("errors : " + errors);
if
(
output
.
trim
().
equals
(
"=====UNSATISFIABLE====="
))
{
task
.
setSolution
(
new
ArrayList
<>());
...
...
@@ -181,7 +199,7 @@ public class Solver {
}
catch
(
UncheckedIOException
|
IOException
|
InterruptedException
|
ParserException
ex
)
{
return
ex
.
getMessage
();
}
finally
{
// removeDirectory(directory
);
removeDirectory
(
candidate
);
}
return
""
;
}
...
...
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