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
15bd4355
Commit
15bd4355
authored
Nov 11, 2018
by
Daniel Le Berre
Browse files
Closing properly fwriter without using java7+ try on resources.
parent
febe5b72
Changes
1
Show whitespace changes
Inline
Side-by-side
org.sat4j.sat/src/main/java/org/sat4j/sat/visu/GnuplotBasedSolverVisualisation.java
View file @
15bd4355
...
...
@@ -111,8 +111,9 @@ public class GnuplotBasedSolverVisualisation implements SolverVisualisation {
double
width
=
ONE_THIRD
;
double
height
=
ONE_THIRD
;
PrintStream
out
=
new
PrintStream
(
new
FileOutputStream
(
this
.
dataPath
+
GNUPLOT_GNUPLOT
));
PrintStream
out
=
new
PrintStream
(
new
FileOutputStream
(
this
.
dataPath
+
GNUPLOT_GNUPLOT
));
try
{
out
.
println
(
SET_TERMINAL_X11
);
out
.
println
(
SET_MULTIPLOT
);
out
.
println
(
SET_AUTOSCALE_X
);
...
...
@@ -121,13 +122,15 @@ public class GnuplotBasedSolverVisualisation implements SolverVisualisation {
out
.
println
(
SET_NOLOGSCALE_Y
);
out
.
println
(
SET_YTICS_AUTO
);
GnuplotFunction
f
=
new
GnuplotFunction
(
"2"
,
Color
.
black
,
""
);
GnuplotFunction
f
=
new
GnuplotFunction
(
"2"
,
Color
.
black
,
""
);
// bottom right: Decision Level when conflict
if
(
this
.
visuPreferences
.
isDisplayConflictsDecision
())
{
out
.
println
(
setSize
(
width
,
height
));
out
.
println
(
setOrigin
(
bottom
,
right
));
out
.
println
(
setTitle
(
"Decision level at which the conflict occurs"
));
out
.
println
(
setTitle
(
"Decision level at which the conflict occurs"
));
out
.
println
(
SET_AUTOSCALE_YMAX
);
out
.
println
(
SET_Y2RANGE_0
);
GnuplotDataFile
conflictLevelDF
=
new
GnuplotDataFile
(
...
...
@@ -141,10 +144,12 @@ public class GnuplotBasedSolverVisualisation implements SolverVisualisation {
Color
.
orange
,
CLEAN
,
IMPULSES
);
out
.
println
(
this
.
visuPreferences
.
generatePlotLineOnDifferenteAxes
(
new
GnuplotDataFile
[]
{
conflictLevelDF
},
new
GnuplotDataFile
[]
{
conflictLevelDF
},
new
GnuplotDataFile
[]
{
conflictLevelRestartDF
,
conflictLevelCleanDF
},
true
));
conflictLevelCleanDF
},
true
));
}
// top left: size of learned clause
...
...
@@ -155,22 +160,27 @@ public class GnuplotBasedSolverVisualisation implements SolverVisualisation {
out
.
println
(
SET_Y2RANGE_0
);
out
.
println
(
setSize
(
width
,
height
));
out
.
println
(
setOrigin
(
top
,
left
));
out
.
println
(
setTitle
(
"Size of the clause learned (after minimization if any)"
));
out
.
println
(
setTitle
(
"Size of the clause learned (after minimization if any)"
));
GnuplotDataFile
learnedClausesDF
=
new
GnuplotDataFile
(
this
.
dataPath
+
"-learned-clauses-size.dat"
,
Color
.
blue
,
SIZE
);
GnuplotDataFile
learnedClausesRestartDF
=
new
GnuplotDataFile
(
this
.
dataPath
+
"-learned-clauses-size-restart.dat"
,
this
.
dataPath
+
"-learned-clauses-size-restart.dat"
,
Color
.
gray
,
RESTART
,
IMPULSES
);
GnuplotDataFile
learnedClausesCleanDF
=
new
GnuplotDataFile
(
this
.
dataPath
+
"-learned-clauses-size-clean.dat"
,
this
.
dataPath
+
"-learned-clauses-size-clean.dat"
,
Color
.
orange
,
CLEAN
,
IMPULSES
);
out
.
println
(
this
.
visuPreferences
.
generatePlotLineOnDifferenteAxes
(
new
GnuplotDataFile
[]
{
learnedClausesDF
},
new
GnuplotDataFile
[]
{
learnedClausesDF
},
new
GnuplotDataFile
[]
{
learnedClausesCleanDF
,
learnedClausesRestartDF
},
true
));
learnedClausesRestartDF
},
true
));
}
// top middle: clause activity
...
...
@@ -179,12 +189,13 @@ public class GnuplotBasedSolverVisualisation implements SolverVisualisation {
out
.
println
(
SET_AUTOSCALE_Y
);
out
.
println
(
setSize
(
width
,
height
));
out
.
println
(
setOrigin
(
top
,
middle
));
out
.
println
(
setTitle
(
"Value of learned clauses evaluation"
));
out
.
println
(
setTitle
(
"Value of learned clauses evaluation"
));
GnuplotDataFile
learnedDF
=
new
GnuplotDataFile
(
this
.
dataPath
+
"-learned.dat"
,
Color
.
blue
,
EVALUATION
);
out
.
println
(
this
.
visuPreferences
.
generatePlotLine
(
learnedDF
,
f
,
""
,
false
));
out
.
println
(
this
.
visuPreferences
.
generatePlotLine
(
learnedDF
,
f
,
""
,
false
));
}
// for bottom graphs, y range should be O-maxVar
...
...
@@ -198,16 +209,15 @@ public class GnuplotBasedSolverVisualisation implements SolverVisualisation {
// bottom left: index decision variable
if
(
this
.
visuPreferences
.
isDisplayDecisionIndexes
())
{
out
.
println
(
UNSET_AUTOSCALE
);
out
.
println
(
"if(system(\"head "
+
this
.
dataPath
out
.
println
(
"if(system(\"head "
+
this
.
dataPath
+
"-decision-indexes-pos.dat | wc -l\")!=0){set autoscale x;}"
);
out
.
println
(
"if(system(\"head "
+
this
.
dataPath
out
.
println
(
"if(system(\"head "
+
this
.
dataPath
+
"-decision-indexes-pos.dat | wc -l\")!=0){set yrange [1:"
+
this
.
nVar
+
"]};"
);
out
.
println
(
setSize
(
width
,
height
));
out
.
println
(
setOrigin
(
bottom
,
left
));
out
.
println
(
setTitle
(
"Index of the decision variables"
));
out
.
println
(
setTitle
(
"Index of the decision variables"
));
GnuplotDataFile
negativeDF
=
new
GnuplotDataFile
(
this
.
dataPath
+
"-decision-indexes-neg.dat"
,
Color
.
red
,
"Negative Decision"
);
...
...
@@ -220,28 +230,34 @@ public class GnuplotBasedSolverVisualisation implements SolverVisualisation {
out
.
println
(
this
.
visuPreferences
.
generatePlotLineOnDifferenteAxes
(
new
GnuplotDataFile
[]
{
negativeDF
},
new
GnuplotDataFile
[]
{
decisionRestartDF
,
decisionCleanDF
},
true
,
this
.
visuPreferences
.
getNbLinesRead
()
*
4
));
new
GnuplotDataFile
[]
{
decisionRestartDF
,
decisionCleanDF
},
true
,
this
.
visuPreferences
.
getNbLinesRead
()
*
4
));
// verybottom left: index decision variable
out
.
println
(
UNSET_AUTOSCALE
);
out
.
println
(
"if(system(\"head "
+
this
.
dataPath
out
.
println
(
"if(system(\"head "
+
this
.
dataPath
+
"-decision-indexes-pos.dat | wc -l\")!=0){set autoscale x;set yrange [1:"
+
this
.
nVar
+
"]; set y2range [0:]; }"
);
out
.
println
(
setSize
(
width
,
height
));
out
.
println
(
setOrigin
(
verybottom
,
left
));
out
.
println
(
setTitle
(
"Index of the decision variables"
));
out
.
println
(
setTitle
(
"Index of the decision variables"
));
GnuplotDataFile
positiveDF
=
new
GnuplotDataFile
(
this
.
dataPath
+
"-decision-indexes-pos.dat"
,
Color
.
green
,
"Positive Decision"
);
out
.
println
(
this
.
visuPreferences
.
generatePlotLineOnDifferenteAxes
(
new
GnuplotDataFile
[]
{
positiveDF
},
new
GnuplotDataFile
[]
{
decisionRestartDF
,
decisionCleanDF
},
true
,
this
.
visuPreferences
.
getNbLinesRead
()
*
4
));
new
GnuplotDataFile
[]
{
decisionRestartDF
,
decisionCleanDF
},
true
,
this
.
visuPreferences
.
getNbLinesRead
()
*
4
));
}
// top right: depth search when conflict
...
...
@@ -252,13 +268,14 @@ public class GnuplotBasedSolverVisualisation implements SolverVisualisation {
out
.
println
(
SET_NOLOGSCALE_Y
);
out
.
println
(
setSize
(
width
,
height
));
out
.
println
(
setOrigin
(
top
,
right
));
out
.
println
(
setTitle
(
"Trail level when the conflict occurs"
));
out
.
println
(
setTitle
(
"Trail level when the conflict occurs"
));
out
.
println
(
SET_Y2RANGE_0
);
GnuplotDataFile
trailLevelDF
=
new
GnuplotDataFile
(
this
.
dataPath
+
"-conflict-depth.dat"
,
Color
.
magenta
,
"Trail level"
);
GnuplotFunction
nbVar2
=
new
GnuplotFunction
(
""
+
this
.
nVar
/
2
,
Color
.
green
,
"#Var/2"
);
GnuplotFunction
nbVar2
=
new
GnuplotFunction
(
""
+
this
.
nVar
/
2
,
Color
.
green
,
"#Var/2"
);
GnuplotDataFile
trailLevelRestartDF
=
new
GnuplotDataFile
(
this
.
dataPath
+
"-conflict-depth-restart.dat"
,
Color
.
gray
,
RESTART
,
IMPULSES
);
...
...
@@ -271,10 +288,12 @@ public class GnuplotBasedSolverVisualisation implements SolverVisualisation {
new
GnuplotDataFile
[]
{
trailLevelRestartDF
,
trailLevelCleanDF
},
new
GnuplotFunction
[]
{
nbVar2
},
true
));
new
GnuplotFunction
[]
{
nbVar2
},
true
));
out
.
println
(
this
.
visuPreferences
.
generatePlotLine
(
trailLevelDF
,
nbVar2
,
this
.
dataPath
+
"-conflict-level-restart.dat"
,
true
));
trailLevelDF
,
nbVar2
,
this
.
dataPath
+
"-conflict-level-restart.dat"
,
true
));
}
// bottom middle: variable activity
...
...
@@ -291,8 +310,8 @@ public class GnuplotBasedSolverVisualisation implements SolverVisualisation {
GnuplotDataFile
heuristicsDF
=
new
GnuplotDataFile
(
this
.
dataPath
+
"-heuristics.dat"
,
Color
.
red
,
"Activity"
,
"lines"
);
out
.
println
(
this
.
visuPreferences
.
generatePlotLine
(
heuristicsDF
,
f
,
""
,
false
));
out
.
println
(
this
.
visuPreferences
.
generatePlotLine
(
heuristicsDF
,
f
,
""
,
false
));
}
if
(
this
.
visuPreferences
.
isDisplaySpeed
())
{
...
...
@@ -301,27 +320,33 @@ public class GnuplotBasedSolverVisualisation implements SolverVisualisation {
out
.
println
(
SET_NOLOGSCALE_Y
);
out
.
println
(
setSize
(
width
,
height
));
out
.
println
(
setOrigin
(
verybottom
,
middle
));
out
.
println
(
setTitle
(
"Number of propagations per second"
));
out
.
println
(
setTitle
(
"Number of propagations per second"
));
out
.
println
(
SET_Y2RANGE_0
);
GnuplotDataFile
speedDF
=
new
GnuplotDataFile
(
this
.
dataPath
+
SPEED_DAT
,
Color
.
cyan
,
SPEED
,
"lines"
);
GnuplotDataFile
cleanDF
=
new
GnuplotDataFile
(
this
.
dataPath
+
"-speed-clean.dat"
,
Color
.
orange
,
CLEAN
,
IMPULSES
);
GnuplotDataFile
speedDF
=
new
GnuplotDataFile
(
this
.
dataPath
+
SPEED_DAT
,
Color
.
cyan
,
SPEED
,
"lines"
);
GnuplotDataFile
cleanDF
=
new
GnuplotDataFile
(
this
.
dataPath
+
"-speed-clean.dat"
,
Color
.
orange
,
CLEAN
,
IMPULSES
);
GnuplotDataFile
restartDF
=
new
GnuplotDataFile
(
this
.
dataPath
+
SPEED_RESTART_DAT
,
Color
.
gray
,
RESTART
,
IMPULSES
);
out
.
println
(
this
.
visuPreferences
.
generatePlotLineOnDifferenteAxes
(
new
GnuplotDataFile
[]
{
speedDF
},
new
GnuplotDataFile
[]
{
cleanDF
,
restartDF
},
new
GnuplotDataFile
[]
{
cleanDF
,
restartDF
},
true
,
50
));
}
out
.
println
(
UNSET_MULTIPLOT
);
int
pauseTime
=
this
.
visuPreferences
.
getRefreshTime
()
/
1000
;
int
pauseTime
=
this
.
visuPreferences
.
getRefreshTime
()
/
1000
;
out
.
println
(
"pause "
+
pauseTime
);
out
.
println
(
REREAD
);
}
finally
{
out
.
close
();
}
this
.
logger
.
log
(
GNUPLOT_WILL_START_IN_A_FEW_SECONDS
);
Thread
errorStreamThread
=
new
Thread
()
{
...
...
@@ -330,7 +355,8 @@ public class GnuplotBasedSolverVisualisation implements SolverVisualisation {
try
{
try
{
Thread
.
sleep
(
GnuplotBasedSolverVisualisation
.
this
.
visuPreferences
Thread
.
sleep
(
GnuplotBasedSolverVisualisation
.
this
.
visuPreferences
.
getTimeBeforeLaunching
());
}
catch
(
InterruptedException
e
)
{
GnuplotBasedSolverVisualisation
.
this
.
logger
...
...
@@ -345,7 +371,8 @@ public class GnuplotBasedSolverVisualisation implements SolverVisualisation {
GnuplotBasedSolverVisualisation
.
this
.
gnuplotProcess
=
Runtime
.
getRuntime
()
.
exec
(
GnuplotBasedSolverVisualisation
.
this
.
visuPreferences
.
createCommandLine
(
GnuplotBasedSolverVisualisation
.
this
.
dataPath
.
createCommandLine
(
GnuplotBasedSolverVisualisation
.
this
.
dataPath
+
GNUPLOT_GNUPLOT
));
GnuplotBasedSolverVisualisation
.
this
.
logger
...
...
@@ -367,8 +394,8 @@ public class GnuplotBasedSolverVisualisation implements SolverVisualisation {
}
gnuInt
.
close
();
}
catch
(
IOException
e
)
{
GnuplotBasedSolverVisualisation
.
this
.
logger
.
log
(
e
.
getMessage
());
GnuplotBasedSolverVisualisation
.
this
.
logger
.
log
(
e
.
getMessage
());
}
}
};
...
...
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