Index: src/work/akos/simann.h
===================================================================
--- src/work/akos/simann.h	(revision 1023)
+++ src/work/akos/simann.h	(revision 1096)
@@ -99,5 +99,6 @@
     }
     void saveAsBest() {
-      *best_ent = *curr_ent;
+      delete(best_ent);
+      best_ent = new E(*curr_ent);
       best_cost = curr_cost;
     }
@@ -130,5 +131,5 @@
      */
     SimpleController(long _max_iter = 500000, long _max_no_impr = 20000,
-    double _temp = 1000, double _ann_fact = 0.9999) : iter(0), last_impr(0),
+    double _temp = 1000.0, double _ann_fact = 0.9999) : iter(0), last_impr(0),
     max_iter(_max_iter), max_no_impr(_max_no_impr), temp(_temp),
     ann_fact(_ann_fact) {}
@@ -150,5 +151,6 @@
       double cost_diff = base->getPrevCost() - base->getCurrCost();
       if (cost_diff < 0.0) {
-        return (drand48() <= exp(cost_diff / temp));
+        bool ret = drand48() <= exp(cost_diff / temp);
+        return ret;
       }
       else {
@@ -167,8 +169,11 @@
     /*! \param time the elapsed time in seconds */
     virtual double threshold(double time) {
-      // this is the function 1 / log(x) scaled and offset
+      // 1 / log(x)
+      /*
       static double xm = 5.0 / end_time;
       static double ym = start_threshold / (1 / log(1.2) - 1 / log(5.0 + 1.2));
       return ym * (1 / log(xm * time + 1.2) - 1 / log(5.0 + 1.2));
+      */
+      return (-1.0) * start_threshold / end_time * time + start_threshold;
     }
   public:
@@ -185,6 +190,6 @@
      */
     AdvancedController(double _end_time, double _alpha = 0.2,
-    double _beta = 0.9, double _gamma = 1.2) : alpha(_alpha), beta(_beta),
-    gamma(_gamma), end_time(_end_time), ann_fact(0.9999), warmup(true) {}
+    double _beta = 0.9, double _gamma = 1.6) : alpha(_alpha), beta(_beta),
+    gamma(_gamma), end_time(_end_time), ann_fact(0.99999999), warmup(true) {}
     void init() {
       avg_cost = base->getCurrCost();
@@ -193,17 +198,11 @@
       avg_cost = alpha * base->getCurrCost() + (1.0 - alpha) * avg_cost;
       if (warmup) {
-        static double max_cost_diff = 0.0;
-        static int incr_cnt = 0;
-        double cost_diff = base->getCurrCost() - base->getPrevCost();
-        if (cost_diff > 0.0) {
-          incr_cnt++;
-          if (cost_diff > max_cost_diff) {
-            max_cost_diff = cost_diff;
-          }
-        }
-        if (incr_cnt >= 100) {
+        static int cnt = 0;
+        cnt++;
+        if (cnt >= 100) {
           // calculate starting threshold and starting temperature
-          start_threshold = fabs(base->getBestCost() - avg_cost);
-          temp = max_cost_diff / log(0.5);
+          start_threshold = 5.0 * fabs(base->getBestCost() - avg_cost);
+          //temp = max_cost_diff / log(0.5);
+          temp = 10000.0;
           warmup = false;
           timer.reset();
@@ -228,4 +227,5 @@
           // increase the temperature
           temp *= gamma;
+          ann_fact = 0.99999999;
         }
         temp *= ann_fact;
Index: src/work/akos/simann_demo.cc
===================================================================
--- src/work/akos/simann_demo.cc	(revision 1023)
+++ src/work/akos/simann_demo.cc	(revision 1096)
@@ -11,4 +11,5 @@
 
 int main() {
+  /*
   SimAnn<MyEntity> simann;
   SimpleController ctrl;
@@ -17,7 +18,8 @@
   simann.setEntity(ent);
   simann.run();
+  */
 
   SimAnn<MyEntity> simann2;
-  AdvancedController ctrl2(20.0);
+  AdvancedController ctrl2(10.0);
   simann2.setController(ctrl2);
   MyEntity ent2;
