Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
ttc18
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
stgroup
ttc18
Commits
fb3eda51
Commit
fb3eda51
authored
6 years ago
by
René Schöne
Browse files
Options
Downloads
Patches
Plain Diff
Change time estimates for ilp-external.
parent
54477d96
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
jastadd-mquat-solver-ilp/src/main/java/de/tudresden/inf/st/mquat/solving/ilp/ILPExternalSolver.java
+11
-6
11 additions, 6 deletions
...tudresden/inf/st/mquat/solving/ilp/ILPExternalSolver.java
with
11 additions
and
6 deletions
jastadd-mquat-solver-ilp/src/main/java/de/tudresden/inf/st/mquat/solving/ilp/ILPExternalSolver.java
+
11
−
6
View file @
fb3eda51
...
...
@@ -73,6 +73,7 @@ public class ILPExternalSolver extends AbstractILPSolver {
protected
double
solve0
(
Root
model
,
StopWatch
watch
,
List
<
IlpVariable
>
variablesSetToOne
)
throws
SolvingException
{
// Create temporary files
StopWatch
writeOut
=
StopWatch
.
start
();
try
{
lp
=
Files
.
createTempFile
(
"ilp"
,
null
);
// solution = Files.createTempFile("solution", null);
...
...
@@ -88,12 +89,15 @@ public class ILPExternalSolver extends AbstractILPSolver {
lp
,
StandardOpenOption
.
CREATE
,
StandardOpenOption
.
TRUNCATE_EXISTING
))
{
writer
.
write
(
output
.
toString
());
}
catch
(
IOException
e
)
{
cleanup
(
watch
);
throw
new
SolvingException
(
"Could not write to lp file"
,
e
);
}
long
secondsNeededToWriteOut
=
writeOut
.
time
(
TimeUnit
.
SECONDS
);
// take twice the time to have buffer to write out solution afterwards
long
newTimeout
=
Math
.
min
(
1
,
timeoutInSeconds
-
2
*
secondsNeededToWriteOut
);
// start GLPK to solve the lp file just written, writing out the solution
Process
process
;
String
command
=
"glpsol --lp "
+
lp
.
toAbsolutePath
()
+
// " -w " + solution.toAbsolutePath() +
" --tmlim "
+
t
imeout
InSeconds
+
" --tmlim "
+
newT
imeout
+
" -o "
+
solutionReadable
.
toAbsolutePath
();
logger
.
debug
(
"Call: '{}'"
,
command
);
try
{
...
...
@@ -101,22 +105,23 @@ public class ILPExternalSolver extends AbstractILPSolver {
}
catch
(
IOException
e
)
{
cleanup
(
watch
);
throw
new
SolvingException
(
"Problem calling glpsol. Is it installed?"
,
e
);
}
boolean
finishedInTime
;
try
{
finishedInTime
=
process
.
waitFor
(
t
imeout
InSeconds
,
TimeUnit
.
SECONDS
);
finishedInTime
=
process
.
waitFor
(
newT
imeout
,
TimeUnit
.
SECONDS
);
}
catch
(
InterruptedException
e
)
{
cleanup
(
watch
);
throw
new
SolvingException
(
"Interrupted while waiting for result"
,
e
);
}
if
(!
finishedInTime
)
{
// solver already had a timeout, so wait
at least 2
seconds longer to let it write a solution file
// solver already had a timeout, so wait
some
seconds longer to let it write a solution file
this
.
timedOut
=
true
;
try
{
process
.
waitFor
(
2
,
TimeUnit
.
SECONDS
);
process
.
waitFor
(
10
,
TimeUnit
.
SECONDS
);
}
catch
(
InterruptedException
ignored
)
{
}
// then destroy the process
process
.
destroyForcibly
();
if
(!
solutionReadable
.
toFile
().
exists
())
{
if
(!
solutionReadable
.
toAbsolutePath
().
toFile
().
exists
())
{
cleanup
(
watch
);
throw
new
SolvingException
(
"Solving did not finish within "
+
timeoutValue
+
" "
+
timeoutUnit
.
toString
());
throw
new
SolvingException
(
"Solving did not finish within "
+
timeoutValue
+
" "
+
timeoutUnit
.
toString
()
+
", file at "
+
solutionReadable
.
toAbsolutePath
()
+
" was not written."
);
}
// if there is a solution file, move on and check its content
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment