Commit c91cc414 authored by Robert Ricci's avatar Robert Ricci

Change the termination conditions in subtle, but important, way. When using

epsilon termination (and ALLOW_NEGATIVE_EPSILON), it used to be the case that
we wrapped the termination condition in a fabs(), and compared that to epsilon.
The termination condition is basically a measure of how 'stable' of a score
we're at. What this meant was that we used to keep going until we reached a
space where the solution was going neither up nor down too much. All this is
relative to the difference between initial socre and the best score - so, if
those are close (ie. it's an easy problem), we could end up thrashing a whole
lot. With the new behavior, if we ever hit a spot in which solutions start
getting worse, we'll stop.

Also, fix the GNUPLOT_OUTPUT code, which I used to debut this.
parent 6cdef019
...@@ -34,6 +34,11 @@ name_name_map fixed_nodes; ...@@ -34,6 +34,11 @@ name_name_map fixed_nodes;
// allowed to move these. // allowed to move these.
name_name_map node_hints; name_name_map node_hints;
// From assign.cc
#ifdef GNUPLOT_OUTPUT
extern FILE *scoresout, *tempout, *deltaout;
#endif
// Determines whether to accept a change of score difference 'change' at // Determines whether to accept a change of score difference 'change' at
// temperature 'temperature'. // temperature 'temperature'.
inline int accept(double change, double temperature) inline int accept(double change, double temperature)
...@@ -889,11 +894,13 @@ void anneal(bool scoring_selftest, double scale_neighborhood, ...@@ -889,11 +894,13 @@ void anneal(bool scoring_selftest, double scale_neighborhood,
if (accepttrans) { if (accepttrans) {
bestscore = newscore; bestscore = newscore;
bestviolated = violated; bestviolated = violated;
#ifdef GNUPLOT_OUTPUT #ifdef GNUPLOT_OUTPUT
fprintf(tempout,"%f\n",temp); fprintf(tempout,"%f\n",temp);
fprintf(scoresout,"%f\n",newscore); fprintf(scoresout,"%f\n",newscore);
fprintf(deltaout,"%f\n",-scorediff); fprintf(deltaout,"%f\n",-scorediff);
#endif #endif
avgscore += newscore; avgscore += newscore;
accepts++; accepts++;
...@@ -1073,8 +1080,9 @@ NOTQUITEDONE: ...@@ -1073,8 +1080,9 @@ NOTQUITEDONE:
); );
if ((tsteps >= mintsteps) && if ((tsteps >= mintsteps) &&
#ifdef ALLOW_NEGATIVE_DELTA #ifdef ALLOW_NEGATIVE_DELTA
((fabs(deltaavg) < 0.0000001) // ((fabs(deltaavg) < 0.0000001)
|| (fabs((temp / initialavg) * (deltaavg/ deltatemp)) < epsilon))) { // || (fabs((temp / initialavg) * (deltaavg/ deltatemp)) < epsilon))) {
((temp / initialavg) * (deltaavg/ deltatemp)) < epsilon) {
#else #else
(deltaavg > 0) && ((temp / initialavg) * (deltaavg/ deltatemp) < epsilon)) { (deltaavg > 0) && ((temp / initialavg) * (deltaavg/ deltatemp) < epsilon)) {
#endif #endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment