Merge branch 'license/spdx'
[oweals/gnunet.git] / src / ats / gnunet-ats-solver-eval.c
index 7eb1638df75a491a452338f25f40e4f8a1b80b36..62e09533f185ed4f18b730612d50b935d440c798 100644 (file)
@@ -1,21 +1,21 @@
 /*
  This file is part of GNUnet.
- (C) 2010-2013 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2010-2013 GNUnet e.V.
 
- GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
+ GNUnet is free software: you can redistribute it and/or modify it
under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License,
+ or (at your option) any later version.
 
  GNUnet is distributed in the hope that it will be useful, but
  WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- General Public License for more details.
Affero General Public License for more details.
 
- You should have received a copy of the GNU General Public License
- along with GNUnet; see the file COPYING.  If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
+ You should have received a copy of the GNU Affero General Public License
+ along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+     SPDX-License-Identifier: AGPL3.0-or-later
  */
 /**
  * @file ats-tests/ats-testing-experiment.c
 #include "platform.h"
 #include "gnunet_util_lib.h"
 #include "gnunet-ats-solver-eval.h"
+#include "gnunet-service-ats_normalization.h"
+#include "gnunet-service-ats_preferences.c"
 
 #define BIG_M_STRING "unlimited"
 
+/**
+ * Handle for statistics.
+ */
+struct GNUNET_STATISTICS_Handle *GSA_stats;
+
+
 static struct Experiment *e;
 
 static struct LoggingHandle *l;
@@ -36,8 +44,12 @@ static struct LoggingHandle *l;
 static struct SolverHandle *sh;
 
 static struct TestPeer *peer_head;
+
 static struct TestPeer *peer_tail;
 
+static double default_properties[GNUNET_ATS_PropertyCount];
+static double default_preferences[GNUNET_ATS_PreferenceCount];
+
 /**
  * cmd option -e: experiment file
  */
@@ -53,7 +65,7 @@ static int opt_log;
 /**
  * cmd option -p: enable plots
  */
-static int opt_plot;
+static int opt_save;
 
 /**
  * cmd option -v: verbose logs
@@ -65,11 +77,17 @@ static int opt_verbose;
  */
 static int opt_print;
 
+/**
+ * cmd option -d: disable normalization
+ */
+static int opt_disable_normalization;
+
 static int res;
 
 static void
 end_now ();
 
+
 static char *
 print_generator_type (enum GeneratorType g)
 {
@@ -88,36 +106,23 @@ print_generator_type (enum GeneratorType g)
   }
 }
 
-struct AddressLookupCtx
-{
-  struct ATS_Address *res;
-  char *plugin;
-  char *addr;
-};
-
 
-int find_address_it (void *cls,
-                     const struct GNUNET_PeerIdentity *key,
-                     void *value)
+static struct TestPeer *
+find_peer_by_id (int id)
 {
-  struct AddressLookupCtx *ctx = cls;
-  struct ATS_Address *addr = value;
-
-  if ( (0 == strcmp (ctx->plugin, addr->plugin)) &&
-       (0 == strcmp (ctx->addr, addr->addr)) )
-  {
-       ctx->res = addr;
-       return GNUNET_NO;
-  }
-  return GNUNET_YES;
+  struct TestPeer *cur;
+  for (cur = peer_head; NULL != cur; cur = cur->next)
+    if (cur->id == id)
+      return cur;
+  return NULL;
 }
 
 static struct TestPeer *
-find_peer_by_id (int id)
+find_peer_by_pid (const struct GNUNET_PeerIdentity *pid)
 {
   struct TestPeer *cur;
   for (cur = peer_head; NULL != cur; cur = cur->next)
-    if (cur->id == id)
+    if (0 == memcmp (&cur->peer_id, pid, sizeof (struct GNUNET_PeerIdentity)))
       return cur;
   return NULL;
 }
@@ -133,36 +138,93 @@ find_address_by_id (struct TestPeer *peer, int aid)
 }
 
 
-
 /**
  * Logging
  */
-
 void
 GNUNET_ATS_solver_logging_now (struct LoggingHandle *l)
 {
   struct LoggingTimeStep *lts;
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Logging\n");
+  struct TestPeer *cur;
+  struct TestAddress *cur_addr;
+  struct LoggingPeer *log_p;
+  struct LoggingAddress *log_a;
+  int c;
 
   lts = GNUNET_new (struct LoggingTimeStep);
+  GNUNET_CONTAINER_DLL_insert_tail(l->head, l->tail, lts);
   lts->timestamp = GNUNET_TIME_absolute_get();
+  if (NULL == lts->prev)
+    lts->delta = GNUNET_TIME_UNIT_ZERO;
+  else
+    lts->delta = GNUNET_TIME_absolute_get_duration(lts->prev->timestamp);
+
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Logging %llu, delta %llu\n",
+      lts->timestamp.abs_value_us, lts->delta.rel_value_us);
+
 
   /* Store logging data here */
+  for (cur = peer_head; NULL != cur; cur = cur->next)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                "Logging peer id %llu\n", cur->id);
 
-  GNUNET_CONTAINER_DLL_insert_tail(l->head, l->tail, lts);
+    log_p = GNUNET_new (struct LoggingPeer);
+    log_p->id = cur->id;
+    log_p->peer_id = cur->peer_id;
+    log_p->is_requested = cur->is_requested;
+    for (c = 0; c < GNUNET_ATS_PreferenceCount; c++)
+    {
+      log_p->pref_abs[c] = cur->pref_abs[c];
+      log_p->pref_norm[c] = cur->pref_norm[c];
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "\t %s = %.2f %.2f [abs/rel]\n",
+                  GNUNET_ATS_print_preference_type(c),
+                  log_p->pref_abs[c], log_p->pref_norm[c]);
+    }
+    GNUNET_CONTAINER_DLL_insert_tail(lts->head, lts->tail, log_p);
+
+    for (cur_addr = cur->addr_head; NULL != cur_addr; cur_addr = cur_addr->next)
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                  "Logging peer id %llu address %llu\n",
+                  cur->id, cur_addr->aid);
+      log_a = GNUNET_new (struct LoggingAddress);
+      log_a->aid = cur_addr->aid;
+      log_a->active = cur_addr->ats_addr->active;
+      log_a->network = cur_addr->network;
+      log_a->assigned_bw_in = cur_addr->ats_addr->assigned_bw_in;
+      log_a->assigned_bw_out = cur_addr->ats_addr->assigned_bw_out;
+      for (c = 0; c < GNUNET_ATS_PropertyCount; c++)
+      {
+        log_a->prop_abs[c] = cur_addr->prop_abs[c];
+        log_a->prop_norm[c] = cur_addr->prop_norm[c];
+        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                    "\t %s = %.2f %.2f [abs/rel]\n",
+                    GNUNET_ATS_print_property_type(c),
+                    log_a->prop_abs[c],
+                    log_a->prop_norm[c]);
+      }
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\t Active = %i\n", log_a->active);
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\t BW in = %llu\n", log_a->assigned_bw_in);
+      GNUNET_log (GNUNET_ERROR_TYPE_INFO, "\t BW out = %llu\n", log_a->assigned_bw_out);
 
+      GNUNET_CONTAINER_DLL_insert_tail (log_p->addr_head, log_p->addr_tail, log_a);
+    }
+  }
 }
 
+
 static void
-logging_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+logging_task (void *cls)
 {
   struct LoggingHandle *l = cls;
-  l->logging_task = GNUNET_SCHEDULER_NO_TASK;
 
+  l->logging_task = NULL;
   GNUNET_ATS_solver_logging_now (l);
-
-  l->logging_task = GNUNET_SCHEDULER_add_delayed (l->log_freq, &logging_task, l);
-
+  l->logging_task = GNUNET_SCHEDULER_add_delayed (l->log_freq,
+                                                  &logging_task,
+                                                  l);
 }
 
 struct LoggingHandle *
@@ -173,53 +235,290 @@ GNUNET_ATS_solver_logging_start (struct GNUNET_TIME_Relative freq)
 
   GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Start logging every  %s\n",
       GNUNET_STRINGS_relative_time_to_string(freq, GNUNET_NO));
-
-  /* Iterate over peers */
-
   l->log_freq = freq;
   l->logging_task = GNUNET_SCHEDULER_add_now (&logging_task, l);
-
   return l;
 }
 
 void
 GNUNET_ATS_solver_logging_stop (struct LoggingHandle *l)
 {
-  if (GNUNET_SCHEDULER_NO_TASK != l->logging_task)
+  if (NULL != l->logging_task)
     GNUNET_SCHEDULER_cancel (l->logging_task);
 
   GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Stop logging\n");
 
-  l->logging_task = GNUNET_SCHEDULER_NO_TASK;
+  l->logging_task = NULL;
+}
+
+static struct LoggingFileHandle *
+find_logging_file_handle (struct LoggingFileHandle *lf_head,
+    struct LoggingFileHandle *lf_tail,
+    int peer_id, int address_id)
+{
+  struct LoggingFileHandle *res;
+
+  for (res = lf_head; NULL != res; res = res->next)
+    if ((res->pid == peer_id) && (res->aid == address_id))
+      return res;
+  return NULL;
+
+}
+
+void
+GNUNET_ATS_solver_logging_write_to_disk (struct LoggingHandle *l, int add_time_stamp,
+    char *output_dir)
+{
+  struct LoggingTimeStep *lts;
+  struct LoggingPeer *log_p;
+  struct LoggingAddress *log_a;
+  struct LoggingFileHandle *lf_head;
+  struct LoggingFileHandle *lf_tail;
+  struct LoggingFileHandle *cur;
+  struct LoggingFileHandle *next;
+  char * filename;
+  char * datastring;
+  char * propstring;
+  char * propstring_tmp;
+  char * prefstring;
+  char * prefstring_tmp;
+  int c;
+  int use_dir;
+
+  use_dir = GNUNET_NO;
+  if (NULL != output_dir)
+  {
+    if (GNUNET_OK != GNUNET_DISK_directory_create_for_file (output_dir))
+    {
+      fprintf (stderr, "Failed to create directory `%s'\n", output_dir);
+      return;
+    }
+    else
+    {
+      fprintf (stderr, "Created directory `%s'\n", output_dir);
+      use_dir = GNUNET_YES;
+    }
+  }
+
+  lf_head = NULL;
+  lf_tail = NULL;
+
+  for (lts = l->head; NULL != lts; lts = lts->next)
+  {
+
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Writing log step %llu\n",
+        (long long unsigned int) lts->timestamp.abs_value_us);
+
+    for (log_p = lts->head; NULL != log_p; log_p = log_p->next)
+    {
+      for (log_a = log_p->addr_head; NULL != log_a; log_a = log_a->next)
+      {
+
+        cur = find_logging_file_handle (lf_head, lf_tail, log_p->id,
+            log_a->aid);
+        if (NULL == cur)
+        {
+          cur = GNUNET_new (struct LoggingFileHandle);
+          cur->aid = log_a->aid;
+          cur->pid = log_p->id;
+
+          if (GNUNET_YES == add_time_stamp)
+            GNUNET_asprintf (&filename, "%s%s%s_%s_p%u_a%u_%llu.log",
+                (GNUNET_YES == use_dir) ? output_dir : "",
+                (GNUNET_YES == use_dir) ? DIR_SEPARATOR_STR : "",
+                e->log_prefix,
+                opt_solver,
+                cur->pid,
+                cur->aid,
+                l->head->timestamp.abs_value_us);
+          else
+            GNUNET_asprintf (&filename, "%s%s%s_%s_p%u_a%u.log",
+                (GNUNET_YES == use_dir) ? output_dir : "",
+                (GNUNET_YES == use_dir) ? DIR_SEPARATOR_STR : "",
+                e->log_prefix,
+                opt_solver,
+                cur->pid,
+                cur->aid);
+
+          fprintf (stderr, "Add writing log data for peer %llu address %llu to file `%s'\n",
+              cur->pid, cur->aid, filename);
+
+
+          cur->f_hd = GNUNET_DISK_file_open (filename,
+              GNUNET_DISK_OPEN_READWRITE |
+              GNUNET_DISK_OPEN_CREATE |
+              GNUNET_DISK_OPEN_TRUNCATE,
+              GNUNET_DISK_PERM_USER_READ |
+              GNUNET_DISK_PERM_USER_WRITE |
+              GNUNET_DISK_PERM_GROUP_READ |
+              GNUNET_DISK_PERM_OTHER_READ);
+          if (NULL == cur->f_hd)
+          {
+            fprintf (stderr, "Cannot open `%s' to write log data!\n", filename);
+            GNUNET_free (filename);
+            GNUNET_free (cur);
+            goto cleanup;
+          }
+          GNUNET_free (filename);
+          GNUNET_CONTAINER_DLL_insert (lf_head, lf_tail, cur);
+
+          GNUNET_asprintf(&datastring,"#time delta;log duration;peer_requested;addr net; addr_active; bw in; bw out; " \
+              "UTILIZATION_UP [abs/rel]; UTILIZATION_UP; UTILIZATION_DOWN; UTILIZATION_DOWN; " \
+              "UTILIZATION_PAYLOAD_UP; UTILIZATION_PAYLOAD_UP; UTILIZATION_PAYLOAD_DOWN; UTILIZATION_PAYLOAD_DOWN;"\
+              "DELAY; DELAY; " \
+              "DISTANCE ;DISTANCE ; COST_WAN; COST_WAN; COST_LAN; COST_LAN; " \
+              "COST_WLAN; COST_WLAN;COST_BT; COST_BT; PREF BW abs; PREF BW rel; PREF LATENCY abs; PREF LATENCY rel;\n");
+          GNUNET_DISK_file_write (cur->f_hd, datastring, strlen(datastring));
+          GNUNET_free (datastring);
+
+        }
+
+        prefstring = GNUNET_strdup("");
+        for (c = 1; c < GNUNET_ATS_PreferenceCount; c++)
+        {
+          /*
+          fprintf(stderr,"\t %s = %.2f %.2f [abs/rel]\n",
+              GNUNET_ATS_print_preference_type(c),
+              log_p->pref_abs[c], log_p->pref_norm[c]);
+           */
+          GNUNET_asprintf(&prefstring_tmp,"%s;%.3f;%.3f",
+              prefstring, log_p->pref_abs[c], log_p->pref_norm[c]);
+
+
+          GNUNET_free (prefstring);
+          prefstring = GNUNET_strdup(prefstring_tmp);
+          GNUNET_free (prefstring_tmp);
+        }
+
+
+        propstring = GNUNET_strdup("");
+        for (c = 1; c < GNUNET_ATS_PropertyCount; c++)
+        {
+          if (GNUNET_ATS_NETWORK_TYPE == c)
+            continue;
+          /*
+          fprintf(stderr, "\t %s = %.2f %.2f [abs/rel]\n",
+              GNUNET_ATS_print_property_type(c),
+              log_a->prop_abs[c], log_a->prop_norm[c]);*/
+          GNUNET_asprintf(&propstring_tmp,"%s%.3f;%.3f;",
+                          propstring,
+                          log_a->prop_abs[c],
+                          log_a->prop_norm[c]);
+          GNUNET_free (propstring);
+          propstring = GNUNET_strdup(propstring_tmp);
+          GNUNET_free (propstring_tmp);
+        }
+        GNUNET_asprintf (&datastring, "%llu;%llu;%u;%u;%i;%u;%u;%s;%s\n",
+            GNUNET_TIME_absolute_get_difference (l->head->timestamp,
+                lts->timestamp).rel_value_us / 1000, lts->delta,
+            log_p->is_requested, log_a->network, log_a->active,
+            log_a->assigned_bw_in, log_a->assigned_bw_out, propstring,
+            prefstring);
+
+        GNUNET_DISK_file_write (cur->f_hd, datastring, strlen(datastring));
+        GNUNET_free (datastring);
+        GNUNET_free (prefstring);
+        GNUNET_free (propstring);
+      }
+    }
+  }
+
+cleanup:
+  next = lf_head;
+  for (cur = next; NULL != cur; cur = next)
+  {
+    next = cur->next;
+    GNUNET_CONTAINER_DLL_remove (lf_head, lf_tail, cur);
+    if (NULL != cur->f_hd)
+      GNUNET_DISK_file_close (cur->f_hd);
+    GNUNET_free (cur);
+  }
+
 }
 
 void
 GNUNET_ATS_solver_logging_eval (struct LoggingHandle *l)
 {
   struct LoggingTimeStep *lts;
+  struct LoggingPeer *log_p;
+  struct LoggingAddress *log_a;
+  int c;
 
   for (lts = l->head; NULL != lts; lts = lts->next)
   {
-    fprintf (stderr, "Log %llu: \n", (long long unsigned int) lts->timestamp.abs_value_us);
+    fprintf (stderr, "Log step %llu %llu: \n",
+        (long long unsigned int) lts->timestamp.abs_value_us,
+        (long long unsigned int) lts->delta.rel_value_us);
+
+    for (log_p = lts->head; NULL != log_p; log_p = log_p->next)
+    {
+      fprintf (stderr,"\tLogging peer pid %llu\n", log_p->id);
+      for (c = 1; c < GNUNET_ATS_PreferenceCount; c++)
+      {
+        fprintf(stderr,"\t %s = %.2f %.2f [abs/rel]\n",
+            GNUNET_ATS_print_preference_type(c),
+            log_p->pref_abs[c], log_p->pref_norm[c]);
+      }
+
+      for (log_a = log_p->addr_head; NULL != log_a; log_a = log_a->next)
+      {
+        fprintf (stderr, "\tPeer pid %llu address %llu: %u %u %u\n",
+            log_p->id, log_a->aid, log_a->active,
+            log_a->assigned_bw_in,
+            log_a->assigned_bw_out);
+
+        for (c = 1; c < GNUNET_ATS_PropertyCount; c++)
+        {
+          if (GNUNET_ATS_NETWORK_TYPE == c)
+            continue;
+          fprintf(stderr, "\t %s = %.2f %.2f [abs/rel]\n",
+              GNUNET_ATS_print_property_type(c),
+              log_a->prop_abs[c], log_a->prop_norm[c]);
+        }
+      }
+    }
   }
 }
 
 void
 GNUNET_ATS_solver_logging_free (struct LoggingHandle *l)
 {
-  struct LoggingTimeStep *cur;
-  struct LoggingTimeStep *next;
+  struct LoggingTimeStep *lts_cur;
+  struct LoggingTimeStep *lts_next;
+  struct LoggingPeer *log_p_cur;
+  struct LoggingPeer *log_p_next;
+  struct LoggingAddress *log_a_cur;
+  struct LoggingAddress *log_a_next;
 
-  if (GNUNET_SCHEDULER_NO_TASK != l->logging_task)
+  if (NULL != l->logging_task)
     GNUNET_SCHEDULER_cancel (l->logging_task);
-  l->logging_task = GNUNET_SCHEDULER_NO_TASK;
+  l->logging_task = NULL;
 
-  next = l->head;
-  while (NULL != (cur = next))
+  lts_next = l->head;
+  while (NULL != (lts_cur = lts_next))
   {
-    next = cur->next;
-    GNUNET_CONTAINER_DLL_remove (l->head, l->tail, cur);
-    GNUNET_free (cur);
+    lts_next = lts_cur->next;
+
+    log_p_next = lts_cur->head;
+    while (NULL != (log_p_cur = log_p_next))
+    {
+      log_p_next = log_p_cur->next;
+
+      log_a_next = log_p_cur->addr_head;
+      while (NULL != (log_a_cur = log_a_next))
+      {
+        log_a_next = log_a_cur->next;
+
+        GNUNET_CONTAINER_DLL_remove (log_p_cur->addr_head, log_p_cur->addr_tail, log_a_cur);
+        GNUNET_free (log_a_cur);
+      }
+
+      GNUNET_CONTAINER_DLL_remove (lts_cur->head, lts_cur->tail, log_p_cur);
+      GNUNET_free (log_p_cur);
+    }
+
+    GNUNET_CONTAINER_DLL_remove (l->head, l->tail, lts_cur);
+    GNUNET_free (lts_cur);
   }
 
   GNUNET_free (l);
@@ -228,10 +527,10 @@ GNUNET_ATS_solver_logging_free (struct LoggingHandle *l)
 /**
  * Property Generators
  */
-
 static struct PropertyGenerator *prop_gen_head;
 static struct PropertyGenerator *prop_gen_tail;
 
+
 static double
 get_property (struct PropertyGenerator *pg)
 {
@@ -291,13 +590,15 @@ get_property (struct PropertyGenerator *pg)
 
 
 static void
-set_prop_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+set_prop_task (void *cls)
 {
   struct PropertyGenerator *pg = cls;
-  double pref_value;
+  struct TestPeer *p;
+  struct TestAddress *a;
+  double prop_value;
   struct GNUNET_ATS_Information atsi;
 
-  pg->set_task = GNUNET_SCHEDULER_NO_TASK;
+  pg->set_task = NULL;
 
   if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains_value (sh->addresses,
       &pg->test_peer->peer_id, pg->test_address->ats_addr))
@@ -308,49 +609,66 @@ set_prop_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
         pg->peer, pg->address_id);
     return;
   }
+  if (NULL == (p = find_peer_by_id (pg->peer)))
+  {
+    GNUNET_break (0);
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+        "Setting property generation for unknown peer %u\n",
+        pg->peer);
+    return;
+  }
+  if (NULL == (a = find_address_by_id (p, pg->address_id)))
+  {
+    GNUNET_break (0);
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+        "Setting property generation for unknown peer %u\n",
+        pg->peer);
+    return;
+  }
 
-  pref_value = get_property (pg);
+  prop_value = get_property (pg);
+  a->prop_abs[pg->ats_property] = prop_value;
 
   GNUNET_log(GNUNET_ERROR_TYPE_INFO,
       "Setting property for peer [%u] address [%u] for %s to %f\n",
       pg->peer, pg->address_id,
-      GNUNET_ATS_print_property_type (pg->ats_property), pref_value);
-
+      GNUNET_ATS_print_property_type (pg->ats_property), prop_value);
 
   atsi.type = htonl (pg->ats_property);
-  atsi.value = htonl ((uint32_t) pref_value);
+  atsi.value = htonl ((uint32_t) prop_value);
 
   /* set performance here! */
-  sh->env.sf.s_bulk_start (sh->solver);
-  GAS_normalization_normalize_property (sh->addresses,
-      pg->test_address->ats_addr, &atsi, 1);
-  sh->env.sf.s_bulk_stop (sh->solver);
-
-  switch (pg->ats_property) {
-    case GNUNET_ATS_PREFERENCE_BANDWIDTH:
-      //p->pref_bandwidth = pref_value;
-      break;
-    case GNUNET_ATS_PREFERENCE_LATENCY:
-      //p->pref_delay = pref_value;
-      break;
-    default:
-      break;
+  sh->sf->s_bulk_start (sh->sf->cls);
+  if (GNUNET_YES == opt_disable_normalization)
+  {
+    a->prop_abs[pg->ats_property] = prop_value;
+    a->prop_norm[pg->ats_property] = prop_value;
+    sh->sf->s_address_update_property (sh->sf->cls, a->ats_addr,
+        pg->ats_property, prop_value, prop_value);
   }
+  else
+    GAS_normalization_update_property (pg->test_address->ats_addr, &atsi, 1);
+  sh->sf->s_bulk_stop (sh->sf->cls);
 
   pg->set_task = GNUNET_SCHEDULER_add_delayed (pg->frequency,
       &set_prop_task, pg);
-
 }
 
+
+/**
+ * Set ats_property to 0 to find all pgs
+ */
 static struct PropertyGenerator *
 find_prop_gen (unsigned int peer, unsigned int address,
     uint32_t ats_property)
 {
   struct PropertyGenerator *cur;
   for (cur = prop_gen_head; NULL != cur; cur = cur->next)
-    if ((cur->peer == peer) && (cur->address_id == address) &&
-        (cur->ats_property == ats_property))
-      return cur;
+    if ((cur->peer == peer) && (cur->address_id == address))
+    {
+      if ((cur->ats_property == ats_property) || (0 == ats_property))
+        return cur;
+    }
   return NULL;
 }
 
@@ -359,10 +677,10 @@ GNUNET_ATS_solver_generate_property_stop (struct PropertyGenerator *pg)
 {
   GNUNET_CONTAINER_DLL_remove (prop_gen_head, prop_gen_tail, pg);
 
-  if (GNUNET_SCHEDULER_NO_TASK != pg->set_task)
+  if (NULL != pg->set_task)
   {
     GNUNET_SCHEDULER_cancel (pg->set_task);
-    pg->set_task = GNUNET_SCHEDULER_NO_TASK;
+    pg->set_task = NULL;
   }
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
       "Removing old up preference generator peer [%u] address [%u] `%s'\n",
@@ -374,17 +692,20 @@ GNUNET_ATS_solver_generate_property_stop (struct PropertyGenerator *pg)
 
 
 /**
- * Generate between the source master and the partner and set preferences with a
+ * Generate between the source master and the partner and set property with a
  * value depending on the generator.
  *
- * @param src source
- * @param dest partner
- * @param type type of preferences to generate
- * @param base_rate traffic base rate to send data with
- * @param max_rate  traffic maximum rate to send data with
- * @param period duration of a period of traffic generation (~ 1/frequency)
- * @param duration how long to generate traffic
- * @return the traffic generator
+ * @param peer source
+ * @param address_id partner
+ * @param test_peer the peer
+ * @param test_address the address
+ * @param type type of generator
+ * @param base_value base value
+ * @param value_rate maximum value
+ * @param period duration of a period of generation (~ 1/frequency)
+ * @param frequency how long to generate property
+ * @param ats_property ATS property to generate
+ * @return the property generator
  */
 struct PropertyGenerator *
 GNUNET_ATS_solver_generate_property_start (unsigned int peer,
@@ -456,7 +777,6 @@ GNUNET_ATS_solver_generate_property_start (unsigned int peer,
 }
 
 
-
 /**
  * Stop all preferences generators
  */
@@ -477,10 +797,10 @@ GNUNET_ATS_solver_generate_property_stop_all ()
 /**
  * Preference Generators
  */
-
 static struct PreferenceGenerator *pref_gen_head;
 static struct PreferenceGenerator *pref_gen_tail;
 
+
 static double
 get_preference (struct PreferenceGenerator *pg)
 {
@@ -540,58 +860,142 @@ get_preference (struct PreferenceGenerator *pg)
 
 
 static void
-set_pref_task (void *cls,
-                    const struct GNUNET_SCHEDULER_TaskContext *tc)
+set_feedback_task (void *cls)
 {
   struct PreferenceGenerator *pg = cls;
   struct TestPeer *p;
-  double pref_value;
-  pg->set_task = GNUNET_SCHEDULER_NO_TASK;
+  double feedback;
+  uint32_t bw_acc_out;
+  uint32_t bw_acc_in;
+  uint32_t delay_acc_in;
+  struct GNUNET_TIME_Relative dur;
+  double p_new;
+
+  pg->feedback_task = NULL;
 
   if (NULL == (p = find_peer_by_id (pg->peer)))
   {
     GNUNET_break (0);
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-        "Setting preference for unknown peer %u\n", pg->peer);
+        "Setting feedback for unknown peer %u\n", pg->peer);
     return;
   }
 
-  pref_value = get_preference (pg);
+  switch (pg->kind)
+  {
+    case GNUNET_ATS_PREFERENCE_BANDWIDTH:
+      dur = GNUNET_TIME_absolute_get_duration(pg->feedback_last_bw_update);
+      bw_acc_in = dur.rel_value_us *pg->last_assigned_bw_in +  pg->feedback_bw_in_acc;
+      pg->feedback_bw_in_acc = 0;
+
+      bw_acc_out = dur.rel_value_us *pg->last_assigned_bw_out +  pg->feedback_bw_out_acc;
+      p_new = get_preference (pg);
+      feedback  = (p_new / pg->pref_bw_old) * (bw_acc_in + bw_acc_out) /
+          (2 *GNUNET_TIME_absolute_get_duration(pg->feedback_last).rel_value_us);
 
+      break;
+    case GNUNET_ATS_PREFERENCE_LATENCY:
+      dur = GNUNET_TIME_absolute_get_duration(pg->feedback_last_delay_update);
+      delay_acc_in =dur.rel_value_us *pg->last_delay_value +  pg->feedback_delay_acc;
+      pg->feedback_delay_acc = 0;
+
+      p_new = get_preference (pg);
+      feedback  = (p_new / pg->pref_latency_old) * (delay_acc_in) /
+          (GNUNET_TIME_absolute_get_duration(pg->feedback_last).rel_value_us);
+
+      break;
+    default:
+      GNUNET_break (0);
+      feedback = 0.0;
+      break;
+  }
   GNUNET_log(GNUNET_ERROR_TYPE_INFO,
-      "Setting preference for peer [%u] address [%u] for client %p pref %s to %f\n",
-      pg->peer, pg->address_id, NULL + (pg->client_id),
-      GNUNET_ATS_print_preference_type (pg->kind), pref_value);
+      "Giving feedback for peer [%u] for client %p pref %s of %.3f\n",
+      pg->peer, NULL + (pg->client_id),
+      GNUNET_ATS_print_preference_type (pg->kind),
+      feedback);
+
+  sh->sf->s_feedback (sh->sf->cls, NULL + (pg->client_id), &p->peer_id,
+      pg->feedback_frequency, pg->kind, feedback);
+  pg->feedback_last = GNUNET_TIME_absolute_get();
 
-  sh->env.sf.s_bulk_start (sh->solver);
-  GAS_normalization_normalize_preference (NULL + (pg->client_id), &p->peer_id,
-      pg->kind, pref_value);
-  sh->env.sf.s_bulk_stop (sh->solver);
 
+  pg->feedback_bw_out_acc = 0;
+  pg->feedback_bw_in_acc = 0;
+  pg->feedback_last_bw_update = GNUNET_TIME_absolute_get();
+
+  pg->feedback_delay_acc = 0;
+  pg->feedback_last_delay_update = GNUNET_TIME_absolute_get();
+
+
+  pg->feedback_task = GNUNET_SCHEDULER_add_delayed (pg->feedback_frequency,
+      &set_feedback_task, pg);
+}
+
+
+static void
+set_pref_task (void *cls)
+{
+  struct PreferenceGenerator *pg = cls;
+  struct TestPeer *p;
+  double pref_value;
+  pg->set_task = NULL;
+
+  if (NULL == (p = find_peer_by_id (pg->peer)))
+  {
+    GNUNET_break (0);
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+        "Setting preference for unknown peer %u\n", pg->peer);
+    return;
+  }
+
+  pref_value = get_preference (pg);
   switch (pg->kind) {
     case GNUNET_ATS_PREFERENCE_BANDWIDTH:
-      //p->pref_bandwidth = pref_value;
+      pg->pref_bw_old = pref_value;
       break;
     case GNUNET_ATS_PREFERENCE_LATENCY:
-      //p->pref_delay = pref_value;
+      pg->pref_latency_old = pref_value;
       break;
     default:
       break;
   }
 
-  pg->set_task = GNUNET_SCHEDULER_add_delayed (pg->frequency,
-      set_pref_task, pg);
+  p->pref_abs[pg->kind] = pref_value;
+
+  GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+      "Setting preference for peer [%u] for client %p pref %s to %f\n",
+      pg->peer, NULL + (pg->client_id),
+      GNUNET_ATS_print_preference_type (pg->kind), pref_value);
 
+  if (GNUNET_YES == opt_disable_normalization)
+  {
+    p->pref_abs[pg->kind] = pref_value;
+    p->pref_norm[pg->kind] = pref_value;
+    sh->sf->s_pref (sh->sf->cls, &p->peer_id, pg->kind, pref_value);
+  }
+  else
+    update_preference (NULL + (pg->client_id),
+                       &p->peer_id,
+                       pg->kind,
+                       pref_value);
+
+  pg->set_task = GNUNET_SCHEDULER_add_delayed (pg->frequency,
+                                               &set_pref_task,
+                                               pg);
 }
 
+
 static struct PreferenceGenerator *
-find_pref_gen (unsigned int peer, unsigned int address,
-    enum GNUNET_ATS_PreferenceKind kind)
+find_pref_gen (unsigned int peer, enum GNUNET_ATS_PreferenceKind kind)
 {
   struct PreferenceGenerator *cur;
   for (cur = pref_gen_head; NULL != cur; cur = cur->next)
-    if ((cur->peer == peer) && (cur->address_id == address) && (cur->kind == kind))
-      return cur;
+    if (cur->peer == peer)
+    {
+      if ((cur->kind == kind) || (GNUNET_ATS_PREFERENCE_END == kind))
+        return cur;
+    }
   return NULL;
 }
 
@@ -600,31 +1004,51 @@ GNUNET_ATS_solver_generate_preferences_stop (struct PreferenceGenerator *pg)
 {
   GNUNET_CONTAINER_DLL_remove (pref_gen_head, pref_gen_tail, pg);
 
-  if (GNUNET_SCHEDULER_NO_TASK != pg->set_task)
+  if (NULL != pg->feedback_task)
+  {
+    GNUNET_SCHEDULER_cancel (pg->feedback_task);
+    pg->feedback_task = NULL;
+  }
+
+  if (NULL != pg->set_task)
   {
     GNUNET_SCHEDULER_cancel (pg->set_task);
-    pg->set_task = GNUNET_SCHEDULER_NO_TASK;
+    pg->set_task = NULL;
   }
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-      "Removing old up preference generator peer [%u] address [%u] `%s'\n",
-      pg->peer, pg->address_id, GNUNET_ATS_print_preference_type(pg->kind));
+      "Removing old up preference generator peer [%u] `%s'\n",
+      pg->peer, GNUNET_ATS_print_preference_type(pg->kind));
 
   GNUNET_free (pg);
 }
 
 
+static struct TestAddress*
+find_active_address (struct TestPeer *p)
+{
+  struct TestAddress *cur;
+  for (cur = p->addr_head; NULL != cur; cur = cur->next)
+    if (GNUNET_YES == cur->ats_addr->active)
+      return cur;
+  return NULL;
+}
+
+
 /**
- * Generate between the source master and the partner and set preferences with a
+ * Generate between the source master and the partner and set property with a
  * value depending on the generator.
  *
- * @param src source
- * @param dest partner
- * @param type type of preferences to generate
- * @param base_rate traffic base rate to send data with
- * @param max_rate  traffic maximum rate to send data with
- * @param period duration of a period of traffic generation (~ 1/frequency)
- * @param duration how long to generate traffic
- * @return the traffic generator
+ * @param peer source
+ * @param address_id partner
+ * @param client_id the client
+ * @param type type of generator
+ * @param base_value base value
+ * @param value_rate maximum value
+ * @param period duration of a period of generation (~ 1/frequency)
+ * @param frequency how long to generate property
+ * @param kind ATS preference to generate
+ * @param feedback_frequency how often to give feedback
+ * @return the preference generator
  */
 struct PreferenceGenerator *
 GNUNET_ATS_solver_generate_preferences_start (unsigned int peer,
@@ -635,15 +1059,24 @@ GNUNET_ATS_solver_generate_preferences_start (unsigned int peer,
     long int value_rate,
     struct GNUNET_TIME_Relative period,
     struct GNUNET_TIME_Relative frequency,
-    enum GNUNET_ATS_PreferenceKind kind)
+    enum GNUNET_ATS_PreferenceKind kind,
+    struct GNUNET_TIME_Relative feedback_frequency)
 {
   struct PreferenceGenerator *pg;
+  struct TestPeer *p;
+
+  if (NULL == (p = find_peer_by_id (peer)))
+  {
+    GNUNET_break (0);
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+        "Starting preference for unknown peer %u\n", peer);
+    return NULL;
+  }
 
   pg = GNUNET_new (struct PreferenceGenerator);
   GNUNET_CONTAINER_DLL_insert (pref_gen_head, pref_gen_tail, pg);
   pg->type = type;
   pg->peer = peer;
-  pg->address_id = address_id;
   pg->client_id = client_id;
   pg->kind = kind;
   pg->base_value = base_value;
@@ -651,31 +1084,32 @@ GNUNET_ATS_solver_generate_preferences_start (unsigned int peer,
   pg->duration_period = period;
   pg->frequency = frequency;
   pg->time_start = GNUNET_TIME_absolute_get();
+  pg->feedback_frequency = feedback_frequency;
 
   switch (type) {
     case GNUNET_ATS_TEST_TG_CONSTANT:
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-          "Setting up %s preference generator peer [%u] address [%u] `%s' max %u Bips\n",
-          print_generator_type (type), pg->peer, pg->address_id,
+          "Setting up %s preference generator peer [%u] `%s' max %u Bips\n",
+          print_generator_type (type), pg->peer,
           GNUNET_ATS_print_preference_type(kind),
           base_value);
       break;
     case GNUNET_ATS_TEST_TG_LINEAR:
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-          "Setting up %s preference generator peer [%u] address [%u] `%s' min %u Bips max %u Bips\n",
-          print_generator_type (type), pg->peer, pg->address_id, GNUNET_ATS_print_preference_type(kind),
+          "Setting up %s preference generator peer [%u] `%s' min %u Bips max %u Bips\n",
+          print_generator_type (type), pg->peer, GNUNET_ATS_print_preference_type(kind),
           base_value, value_rate);
       break;
     case GNUNET_ATS_TEST_TG_SINUS:
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-          "Setting up %s preference generator peer [%u] address [%u] `%s' baserate %u Bips, amplitude %u Bps\n",
-          print_generator_type (type), pg->peer, pg->address_id, GNUNET_ATS_print_preference_type(kind),
+          "Setting up %s preference generator peer [%u] `%s' baserate %u Bips, amplitude %u Bps\n",
+          print_generator_type (type), pg->peer, GNUNET_ATS_print_preference_type(kind),
           base_value, value_rate);
       break;
     case GNUNET_ATS_TEST_TG_RANDOM:
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-          "Setting up %s preference generator peer [%u] address [%u] `%s' min %u Bips max %u Bps\n",
-          print_generator_type (type), pg->peer, pg->address_id, GNUNET_ATS_print_preference_type(kind),
+          "Setting up %s preference generator peer [%u] `%s' min %u Bips max %u Bps\n",
+          print_generator_type (type), pg->peer, GNUNET_ATS_print_preference_type(kind),
           base_value, value_rate);
       break;
     default:
@@ -683,6 +1117,24 @@ GNUNET_ATS_solver_generate_preferences_start (unsigned int peer,
   }
 
   pg->set_task = GNUNET_SCHEDULER_add_now (&set_pref_task, pg);
+  if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != feedback_frequency.rel_value_us)
+  {
+    struct TestAddress * addr = find_active_address(p);
+
+    pg->last_assigned_bw_in = p->assigned_bw_in;
+    pg->last_assigned_bw_out = p->assigned_bw_out;
+    pg->feedback_bw_in_acc = 0;
+    pg->feedback_bw_out_acc = 0;
+    pg->last_delay_value = addr->prop_norm[GNUNET_ATS_QUALITY_NET_DELAY];
+    pg->feedback_delay_acc = 0;
+
+    pg->feedback_last_bw_update = GNUNET_TIME_absolute_get();
+    pg->feedback_last_delay_update = GNUNET_TIME_absolute_get();
+    pg->feedback_last = GNUNET_TIME_absolute_get();
+    pg->feedback_task = GNUNET_SCHEDULER_add_delayed (feedback_frequency,
+        &set_feedback_task, pg);
+  }
+
   return pg;
 }
 
@@ -709,8 +1161,7 @@ GNUNET_ATS_solver_generate_preferences_stop_all ()
 /**
  * Experiments
  */
-
-const char *
+static const char *
 print_op (enum OperationType op)
 {
   switch (op) {
@@ -736,6 +1187,7 @@ print_op (enum OperationType op)
   return "";
 }
 
+
 static struct Experiment *
 create_experiment ()
 {
@@ -747,6 +1199,7 @@ create_experiment ()
   return e;
 }
 
+
 static void
 free_experiment (struct Experiment *e)
 {
@@ -772,6 +1225,8 @@ free_experiment (struct Experiment *e)
   }
 
   GNUNET_free_non_null (e->name);
+  GNUNET_free_non_null (e->log_prefix);
+  GNUNET_free_non_null (e->log_output_dir);
   GNUNET_free_non_null (e->cfg_file);
   GNUNET_free (e);
 }
@@ -785,8 +1240,9 @@ load_op_add_address (struct GNUNET_ATS_TEST_Operation *o,
     const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   char *op_name;
+  char *op_network;
 
-  /* peer id */
+  /* peer pid */
   GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
   if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
       sec_name, op_name, &o->peer_id))
@@ -798,7 +1254,7 @@ load_op_add_address (struct GNUNET_ATS_TEST_Operation *o,
   }
   GNUNET_free (op_name);
 
-  /* address id */
+  /* address pid */
   GNUNET_asprintf(&op_name, "op-%u-address-id", op_counter);
   if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
       sec_name, op_name, &o->address_id))
@@ -848,23 +1304,61 @@ load_op_add_address (struct GNUNET_ATS_TEST_Operation *o,
 
   /* network */
   GNUNET_asprintf(&op_name, "op-%u-address-network", op_counter);
-  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
-      sec_name, op_name, &o->address_network))
+  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (cfg,
+      sec_name, op_name, &op_network))
   {
     fprintf (stderr, "Missing address-network in operation %u `%s' in episode `%s'\n",
         op_counter, "ADD_ADDRESS", op_name);
     GNUNET_free (op_name);
     return GNUNET_SYSERR;
   }
+  else
+  {
+    GNUNET_STRINGS_utf8_toupper (op_network,op_network);
+    if (0 == strcmp(op_network, "UNSPECIFIED"))
+    {
+      o->address_network = GNUNET_NT_UNSPECIFIED;
+    }
+    else if (0 == strcmp(op_network, "LOOPBACK"))
+    {
+      o->address_network = GNUNET_NT_LOOPBACK;
+    }
+    else if (0 == strcmp(op_network, "LAN"))
+    {
+      o->address_network = GNUNET_NT_LAN;
+    }
+    else if (0 == strcmp(op_network, "WAN"))
+    {
+      o->address_network = GNUNET_NT_WAN;
+    }
+    else if (0 == strcmp(op_network, "WLAN"))
+    {
+      o->address_network = GNUNET_NT_WLAN;
+    }
+    else if (0 == strcmp(op_network, "BT"))
+    {
+      o->address_network = GNUNET_NT_BT;
+    }
+    else
+    {
+      fprintf (stderr, "Invalid address-network in operation %u `%s' in episode `%s': `%s'\n",
+          op_counter, "ADD_ADDRESS", op_name, op_network);
+      GNUNET_free (op_network);
+      GNUNET_free (op_name);
+      return GNUNET_SYSERR;
+    }
+  }
+  GNUNET_free (op_network);
   GNUNET_free (op_name);
 
-  fprintf (stderr,
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
       "Found operation %s: [%llu:%llu] address `%s' plugin `%s' \n",
       "ADD_ADDRESS", o->peer_id, o->address_id, o->address, o->plugin);
 
   return GNUNET_OK;
 }
 
+
 static int
 load_op_del_address (struct GNUNET_ATS_TEST_Operation *o,
     struct Episode *e,
@@ -873,8 +1367,9 @@ load_op_del_address (struct GNUNET_ATS_TEST_Operation *o,
     const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   char *op_name;
+  //char *op_network;
 
-  /* peer id */
+  /* peer pid */
   GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
   if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
       sec_name, op_name, &o->peer_id))
@@ -886,7 +1381,7 @@ load_op_del_address (struct GNUNET_ATS_TEST_Operation *o,
   }
   GNUNET_free (op_name);
 
-  /* address id */
+  /* address pid */
   GNUNET_asprintf(&op_name, "op-%u-address-id", op_counter);
   if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
       sec_name, op_name, &o->address_id))
@@ -898,6 +1393,7 @@ load_op_del_address (struct GNUNET_ATS_TEST_Operation *o,
   }
   GNUNET_free (op_name);
 
+#if 0
   /* plugin */
   GNUNET_asprintf(&op_name, "op-%u-plugin", op_counter);
   if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (cfg,
@@ -933,26 +1429,16 @@ load_op_del_address (struct GNUNET_ATS_TEST_Operation *o,
     return GNUNET_SYSERR;
   }
   GNUNET_free (op_name);
+#endif
 
-  /* network */
-  GNUNET_asprintf(&op_name, "op-%u-address-network", op_counter);
-  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
-      sec_name, op_name, &o->address_network))
-  {
-    fprintf (stderr, "Missing address-network in operation %u `%s' in episode `%s'\n",
-        op_counter, "DEL_ADDRESS", op_name);
-    GNUNET_free (op_name);
-    return GNUNET_SYSERR;
-  }
-  GNUNET_free (op_name);
-
-  fprintf (stderr,
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
       "Found operation %s: [%llu:%llu] address `%s' plugin `%s' \n",
       "DEL_ADDRESS", o->peer_id, o->address_id, o->address, o->plugin);
 
   return GNUNET_OK;
 }
 
+
 static enum GNUNET_ATS_Property
 parse_preference_string (const char * str)
 {
@@ -963,7 +1449,8 @@ parse_preference_string (const char * str)
     if (0 == strcmp(str, props[c]))
       return c;
   return 0;
-};
+}
+
 
 static int
 load_op_start_set_preference (struct GNUNET_ATS_TEST_Operation *o,
@@ -976,7 +1463,7 @@ load_op_start_set_preference (struct GNUNET_ATS_TEST_Operation *o,
   char *type;
   char *pref;
 
-  /* peer id */
+  /* peer pid */
   GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
   if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
       sec_name, op_name, &o->peer_id))
@@ -988,19 +1475,7 @@ load_op_start_set_preference (struct GNUNET_ATS_TEST_Operation *o,
   }
   GNUNET_free (op_name);
 
-  /* address id */
-  GNUNET_asprintf(&op_name, "op-%u-address-id", op_counter);
-  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
-      sec_name, op_name, &o->address_id))
-  {
-    fprintf (stderr, "Missing address-id in operation %u `%s' in episode `%s'\n",
-        op_counter, "START_SET_PREFERENCE", op_name);
-    GNUNET_free (op_name);
-    return GNUNET_SYSERR;
-  }
-  GNUNET_free (op_name);
-
-  /* address id */
+  /* address pid */
   GNUNET_asprintf(&op_name, "op-%u-client-id", op_counter);
   if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
       sec_name, op_name, &o->client_id))
@@ -1125,7 +1600,20 @@ load_op_start_set_preference (struct GNUNET_ATS_TEST_Operation *o,
   GNUNET_free (pref);
   GNUNET_free (op_name);
 
-  fprintf (stderr,
+  /* Get feedback delay */
+  GNUNET_asprintf(&op_name, "op-%u-feedback_delay", op_counter);
+  if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_time (cfg,
+      sec_name, op_name, &o->feedback_delay))
+  {
+      fprintf (stderr, "Using feedback delay %llu in operation %u `%s' in episode %u\n",
+          (long long unsigned int) o->feedback_delay.rel_value_us,
+          op_counter, op_name, e->id);
+  }
+  else
+    o->feedback_delay = GNUNET_TIME_UNIT_FOREVER_REL;
+  GNUNET_free (op_name);
+
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
       "Found operation %s: [%llu:%llu]: %s = %llu\n",
       "START_SET_PREFERENCE", o->peer_id, o->address_id,
       GNUNET_ATS_print_preference_type(o->pref_type), o->base_rate);
@@ -1133,6 +1621,7 @@ load_op_start_set_preference (struct GNUNET_ATS_TEST_Operation *o,
   return GNUNET_OK;
 }
 
+
 static int
 load_op_stop_set_preference (struct GNUNET_ATS_TEST_Operation *o,
     struct Episode *e,
@@ -1143,7 +1632,7 @@ load_op_stop_set_preference (struct GNUNET_ATS_TEST_Operation *o,
   char *op_name;
   char *pref;
 
-  /* peer id */
+  /* peer pid */
   GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
   if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
       sec_name, op_name, &o->peer_id))
@@ -1155,7 +1644,7 @@ load_op_stop_set_preference (struct GNUNET_ATS_TEST_Operation *o,
   }
   GNUNET_free (op_name);
 
-  /* address id */
+  /* address pid */
   GNUNET_asprintf(&op_name, "op-%u-address-id", op_counter);
   if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
       sec_name, op_name, &o->address_id))
@@ -1189,24 +1678,26 @@ load_op_stop_set_preference (struct GNUNET_ATS_TEST_Operation *o,
   GNUNET_free (pref);
   GNUNET_free (op_name);
 
-  fprintf (stderr,
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
       "Found operation %s: [%llu:%llu]: %s\n",
       "STOP_SET_PREFERENCE", o->peer_id, o->address_id,
       GNUNET_ATS_print_preference_type(o->pref_type));
   return GNUNET_OK;
 }
 
+
 static enum GNUNET_ATS_Property
-parse_property_string (const char * str)
+parse_property_string (const char *str)
 {
-  int c = 0;
-  char *props[GNUNET_ATS_PropertyCount] = GNUNET_ATS_PropertyStrings;
+  enum GNUNET_ATS_Property c;
 
   for (c = 0; c < GNUNET_ATS_PropertyCount; c++)
-    if (0 == strcmp(str, props[c]))
+    if (0 == strcmp(str,
+                    GNUNET_ATS_print_property_type (c)))
       return c;
   return 0;
-};
+}
+
 
 static int
 load_op_start_set_property(struct GNUNET_ATS_TEST_Operation *o,
@@ -1219,7 +1710,7 @@ load_op_start_set_property(struct GNUNET_ATS_TEST_Operation *o,
   char *type;
   char *prop;
 
-  /* peer id */
+  /* peer pid */
   GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
   if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
       sec_name, op_name, &o->peer_id))
@@ -1231,7 +1722,7 @@ load_op_start_set_property(struct GNUNET_ATS_TEST_Operation *o,
   }
   GNUNET_free (op_name);
 
-  /* address id */
+  /* address pid */
   GNUNET_asprintf(&op_name, "op-%u-address-id", op_counter);
   if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
       sec_name, op_name, &o->address_id))
@@ -1358,7 +1849,7 @@ load_op_start_set_property(struct GNUNET_ATS_TEST_Operation *o,
   GNUNET_free (prop);
   GNUNET_free (op_name);
 
-  fprintf (stderr,
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
       "Found operation %s: [%llu:%llu] %s = %llu\n",
       "START_SET_PROPERTY", o->peer_id, o->address_id,
       GNUNET_ATS_print_property_type (o->prop_type), o->base_rate);
@@ -1376,7 +1867,7 @@ load_op_stop_set_property (struct GNUNET_ATS_TEST_Operation *o,
   char *op_name;
   char *pref;
 
-  /* peer id */
+  /* peer pid */
   GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
   if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
       sec_name, op_name, &o->peer_id))
@@ -1388,7 +1879,7 @@ load_op_stop_set_property (struct GNUNET_ATS_TEST_Operation *o,
   }
   GNUNET_free (op_name);
 
-  /* address id */
+  /* address pid */
   GNUNET_asprintf(&op_name, "op-%u-address-id", op_counter);
   if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
       sec_name, op_name, &o->address_id))
@@ -1417,7 +1908,6 @@ load_op_stop_set_property (struct GNUNET_ATS_TEST_Operation *o,
       fprintf (stderr, "Invalid property in operation %u `%s' in episode %u\n",
           op_counter, op_name, e->id);
       GNUNET_free (op_name);
-      GNUNET_free (pref);
       GNUNET_free_non_null (pref);
       return GNUNET_SYSERR;
   }
@@ -1425,7 +1915,7 @@ load_op_stop_set_property (struct GNUNET_ATS_TEST_Operation *o,
   GNUNET_free (pref);
   GNUNET_free (op_name);
 
-  fprintf (stderr,
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
       "Found operation %s: [%llu:%llu] %s\n",
       "STOP_SET_PROPERTY", o->peer_id, o->address_id,
       GNUNET_ATS_print_property_type (o->prop_type));
@@ -1443,7 +1933,7 @@ load_op_start_request (struct GNUNET_ATS_TEST_Operation *o,
 {
   char *op_name;
 
-  /* peer id */
+  /* peer pid */
   GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
   if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
       sec_name, op_name, &o->peer_id))
@@ -1466,7 +1956,7 @@ load_op_stop_request (struct GNUNET_ATS_TEST_Operation *o,
 {
   char *op_name;
 
-  /* peer id */
+  /* peer pid */
   GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
   if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
       sec_name, op_name, &o->peer_id))
@@ -1491,7 +1981,7 @@ load_episode (struct Experiment *e, struct Episode *cur,
   char *op;
   int op_counter = 0;
   int res;
-  fprintf (stderr, "Parsing episode %u\n",cur->id);
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "=== Parsing episode %u\n",cur->id);
   GNUNET_asprintf(&sec_name, "episode-%u", cur->id);
 
   while (1)
@@ -1505,6 +1995,9 @@ load_episode (struct Experiment *e, struct Episode *cur,
       break;
     }
     o = GNUNET_new (struct GNUNET_ATS_TEST_Operation);
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO, "==== Parsing operation %u: `%s'\n",
+        cur->id, op_name);
+
     /* operations = set_rate, start_send, stop_send, set_preference */
     if (0 == strcmp (op, "address_add"))
     {
@@ -1595,7 +2088,6 @@ load_episodes (struct Experiment *e, struct GNUNET_CONFIGURATION_Handle *cfg)
     if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg,
         sec_name, "duration", &e_duration))
     {
-      fprintf (stderr, "Missing duration in episode %u \n",e_counter);
       GNUNET_free (sec_name);
       break;
     }
@@ -1611,7 +2103,7 @@ load_episodes (struct Experiment *e, struct GNUNET_CONFIGURATION_Handle *cfg)
       return GNUNET_SYSERR;
     }
 
-    fprintf (stderr, "Found episode %u with duration %s \n",
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Found episode %u with duration %s \n",
         e_counter,
         GNUNET_STRINGS_relative_time_to_string(cur->duration, GNUNET_YES));
 
@@ -1631,17 +2123,19 @@ load_episodes (struct Experiment *e, struct GNUNET_CONFIGURATION_Handle *cfg)
   return e_counter;
 }
 
+
 static void
-timeout_experiment (void *cls, const struct GNUNET_SCHEDULER_TaskContext* tc)
+timeout_experiment (void *cls)
 {
   struct Experiment *e = cls;
-  e->experiment_timeout_task = GNUNET_SCHEDULER_NO_TASK;
+
+  e->experiment_timeout_task = NULL;
   fprintf (stderr, "Experiment timeout!\n");
 
-  if (GNUNET_SCHEDULER_NO_TASK != e->episode_timeout_task)
+  if (NULL != e->episode_timeout_task)
   {
     GNUNET_SCHEDULER_cancel (e->episode_timeout_task);
-    e->episode_timeout_task = GNUNET_SCHEDULER_NO_TASK;
+    e->episode_timeout_task = NULL;
   }
 
   e->e_done_cb (e, GNUNET_TIME_absolute_get_duration(e->start_time),
@@ -1651,24 +2145,27 @@ timeout_experiment (void *cls, const struct GNUNET_SCHEDULER_TaskContext* tc)
 struct ATS_Address *
 create_ats_address (const struct GNUNET_PeerIdentity *peer,
                 const char *plugin_name,
-                const void *plugin_addr, size_t plugin_addr_len,
-                uint32_t session_id)
+                const void *plugin_addr,
+                size_t plugin_addr_len,
+                uint32_t session_id,
+                uint32_t network)
 {
   struct ATS_Address *aa = NULL;
 
   aa = GNUNET_malloc (sizeof (struct ATS_Address) + plugin_addr_len + strlen (plugin_name) + 1);
+  aa->atsi = GNUNET_new (struct GNUNET_ATS_Information);
+  aa->atsi[0].type = htonl (GNUNET_ATS_NETWORK_TYPE);
+  aa->atsi[0].value = htonl (network);
+  aa->atsi_count = 1;
+
   aa->peer = *peer;
   aa->addr_len = plugin_addr_len;
   aa->addr = &aa[1];
   aa->plugin = (char *) &aa[1] + plugin_addr_len;
-  memcpy (&aa[1], plugin_addr, plugin_addr_len);
-  memcpy (aa->plugin, plugin_name, strlen (plugin_name) + 1);
+  GNUNET_memcpy (&aa[1], plugin_addr, plugin_addr_len);
+  GNUNET_memcpy (aa->plugin, plugin_name, strlen (plugin_name) + 1);
   aa->session_id = session_id;
-  aa->active = GNUNET_NO;
-  aa->used = GNUNET_NO;
-  aa->solver_information = NULL;
-  aa->assigned_bw_in = GNUNET_BANDWIDTH_value_init(0);
-  aa->assigned_bw_out = GNUNET_BANDWIDTH_value_init(0);
+
   return aa;
 }
 
@@ -1679,35 +2176,49 @@ enforce_add_address (struct GNUNET_ATS_TEST_Operation *op)
 {
   struct TestPeer *p;
   struct TestAddress *a;
+  int c;
 
   if (NULL == (p = find_peer_by_id (op->peer_id)))
   {
     p = GNUNET_new (struct TestPeer);
     p->id = op->peer_id;
+    p->assigned_bw_in = 0;
+    p->assigned_bw_out = 0;
     memset (&p->peer_id, op->peer_id, sizeof (p->peer_id));
+    for (c = 0; c < GNUNET_ATS_PreferenceCount; c++)
+    {
+      p->pref_abs[c] = DEFAULT_ABS_PREFERENCE;
+      p->pref_norm[c] = DEFAULT_REL_PREFERENCE;
+    }
+
     GNUNET_CONTAINER_DLL_insert (peer_head, peer_tail, p);
   }
 
-  if (NULL != (a = find_address_by_id (p, op->address_id)))
+  if (NULL != (find_address_by_id (p, op->address_id)))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Duplicate address %u for peer %u\n",
         op->address_id, op->peer_id);
+    return;
   }
 
   a = GNUNET_new (struct TestAddress);
   a->aid = op->address_id;
+  a->network = op->address_network;
   a->ats_addr = create_ats_address (&p->peer_id, op->plugin, op->address,
-      strlen (op->address) + 1, op->address_session);
+      strlen (op->address) + 1, op->address_session, op->address_network);
   memset (&p->peer_id, op->peer_id, sizeof (p->peer_id));
-  GNUNET_CONTAINER_DLL_insert (p->addr_head, p->addr_tail, a);
+  GNUNET_CONTAINER_DLL_insert_tail (p->addr_head, p->addr_tail, a);
+
+  for (c = 0; c < GNUNET_ATS_PropertyCount; c++)
+    a->prop_norm[c] = DEFAULT_REL_QUALITY;
 
   GNUNET_CONTAINER_multipeermap_put (sh->addresses, &p->peer_id, a->ats_addr,
     GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
 
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Adding address %u for peer %u\n",
-    op->address_id, op->peer_id);
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Adding address %u for peer %u in network `%s'\n",
+    op->address_id, op->peer_id, GNUNET_NT_to_string(a->network));
 
-  sh->env.sf.s_add (sh->solver, a->ats_addr, op->address_network);
+  sh->sf->s_add (sh->sf->cls, a->ats_addr, op->address_network);
 
 }
 
@@ -1717,7 +2228,7 @@ enforce_del_address (struct GNUNET_ATS_TEST_Operation *op)
 {
   struct TestPeer *p;
   struct TestAddress *a;
-  struct AddressLookupCtx ctx;
+  struct PropertyGenerator *pg;
 
   if (NULL == (p = find_peer_by_id (op->peer_id)))
   {
@@ -1727,34 +2238,39 @@ enforce_del_address (struct GNUNET_ATS_TEST_Operation *op)
     return;
   }
 
-  ctx.plugin = op->plugin;
-  ctx.addr = op->address;
-  ctx.res = NULL;
-  GNUNET_CONTAINER_multipeermap_get_multiple (sh->addresses, &p->peer_id,
-      find_address_it, &ctx);
-  if (NULL == ctx.res)
+  if (NULL == (a =find_address_by_id (p, op->address_id)))
   {
     GNUNET_break (0);
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-        "Deleting unknown address for peer %u\n", op->peer_id);
+        "Deleting address for unknown peer %u\n", op->peer_id);
     return;
   }
 
-  if (NULL == (a = find_address_by_id (p, op->address_id)))
+  while (NULL != (pg = find_prop_gen (p->id, a->aid, 0)))
   {
-    GNUNET_break (0);
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-        "Deleting address for unknown peer %u\n", op->peer_id);
-    return;
+    GNUNET_ATS_solver_generate_property_stop (pg);
   }
 
-  GNUNET_CONTAINER_multipeermap_remove (sh->addresses, &p->peer_id, ctx.res);
+  GNUNET_assert (GNUNET_YES ==
+                 GNUNET_CONTAINER_multipeermap_remove (sh->addresses,
+                                                       &p->peer_id,
+                                                       a->ats_addr));
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+              "Removing address %u for peer %u\n",
+              op->address_id,
+              op->peer_id);
 
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Removing address %u for peer %u\n",
-      op->address_id, op->peer_id);
+  sh->sf->s_del (sh->sf->cls, a->ats_addr);
 
-  sh->env.sf.s_del (sh->solver, ctx.res, GNUNET_NO);
-  GNUNET_free (ctx.res);
+  if (NULL != l)
+  {
+    GNUNET_ATS_solver_logging_now (l);
+  }
+  GNUNET_CONTAINER_DLL_remove(p->addr_head, p->addr_tail, a);
+
+  GNUNET_free_non_null(a->ats_addr->atsi);
+  GNUNET_free (a->ats_addr);
+  GNUNET_free (a);
 
 }
 
@@ -1804,21 +2320,32 @@ enforce_stop_property (struct GNUNET_ATS_TEST_Operation *op)
   struct PropertyGenerator *pg = find_prop_gen(op->peer_id, op->address_id,
       op->prop_type);
   if (NULL != pg)
-      GNUNET_ATS_solver_generate_property_stop (pg);
+  {
+    GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+        "Stopping preference generation for peer %u address %u\n", op->peer_id,
+        op->address_id);
+    GNUNET_ATS_solver_generate_property_stop (pg);
+  }
+  else
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+        "Cannot find preference generator for peer %u address %u\n",
+        op->peer_id, op->address_id);
+    GNUNET_break (0);
+  }
 }
 
 static void
 enforce_start_preference (struct GNUNET_ATS_TEST_Operation *op)
 {
   struct PreferenceGenerator *pg;
-  struct TestPeer *p;
-  if (NULL != (pg = find_pref_gen (op->peer_id, op->address_id, op->pref_type)))
+  if (NULL != (pg = find_pref_gen (op->peer_id, op->pref_type)))
   {
     GNUNET_ATS_solver_generate_preferences_stop (pg);
     GNUNET_free (pg);
   }
 
-  if (NULL == (p = find_peer_by_id (op->peer_id)))
+  if (NULL == (find_peer_by_id (op->peer_id)))
   {
     GNUNET_break (0);
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -1834,16 +2361,29 @@ enforce_start_preference (struct GNUNET_ATS_TEST_Operation *op)
     op->max_rate,
     op->period,
     op->frequency,
-    op->pref_type);
+    op->pref_type,
+    op->frequency);
 }
 
 static void
 enforce_stop_preference (struct GNUNET_ATS_TEST_Operation *op)
 {
-  struct PreferenceGenerator *pg = find_pref_gen(op->peer_id, op->address_id,
+  struct PreferenceGenerator *pg = find_pref_gen(op->peer_id,
       op->pref_type);
   if (NULL != pg)
-      GNUNET_ATS_solver_generate_preferences_stop (pg);
+  {
+    GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+        "Stopping property generation for peer %u address %u\n", op->peer_id,
+        op->address_id);
+    GNUNET_ATS_solver_generate_preferences_stop (pg);
+  }
+  else
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+        "Cannot find preference generator for peer %u address %u\n",
+        op->peer_id, op->address_id);
+    GNUNET_break (0);
+  }
 }
 
 
@@ -1851,7 +2391,6 @@ static void
 enforce_start_request (struct GNUNET_ATS_TEST_Operation *op)
 {
   struct TestPeer *p;
-  const struct ATS_Address *res;
 
   if (NULL == (p = find_peer_by_id (op->peer_id)))
   {
@@ -1863,15 +2402,12 @@ enforce_start_request (struct GNUNET_ATS_TEST_Operation *op)
 
   GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Requesting address for peer %u\n",
       op->peer_id);
+  p->is_requested = GNUNET_YES;
 
-  res = sh->env.sf.s_get (sh->solver, &p->peer_id);
-  if (NULL != res)
-  {
-
-  }
-
+  sh->sf->s_get (sh->sf->cls, &p->peer_id);
 }
 
+
 static void
 enforce_stop_request (struct GNUNET_ATS_TEST_Operation *op)
 {
@@ -1885,10 +2421,19 @@ enforce_stop_request (struct GNUNET_ATS_TEST_Operation *op)
     return;
   }
 
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Stop requesting address for peer %u\n",
-      op->peer_id);
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+              "Stop requesting address for peer %u\n",
+              op->peer_id);
+  p->is_requested = GNUNET_NO;
+  p->assigned_bw_in = 0;
+  p->assigned_bw_out = 0;
+  sh->sf->s_get_stop (sh->sf->cls, &p->peer_id);
+
+  if (NULL != l)
+  {
+    GNUNET_ATS_solver_logging_now (l);
+  }
 
-  sh->env.sf.s_get_stop (sh->solver, &p->peer_id);
 }
 
 static void enforce_episode (struct Episode *ep)
@@ -1943,11 +2488,13 @@ static void enforce_episode (struct Episode *ep)
   }
 }
 
+
 static void
-timeout_episode (void *cls, const struct GNUNET_SCHEDULER_TaskContext* tc)
+timeout_episode (void *cls)
 {
   struct Experiment *e = cls;
-  e->episode_timeout_task = GNUNET_SCHEDULER_NO_TASK;
+
+  e->episode_timeout_task = NULL;
   if (NULL != e->ep_done_cb)
     e->ep_done_cb (e->cur);
 
@@ -1957,10 +2504,10 @@ timeout_episode (void *cls, const struct GNUNET_SCHEDULER_TaskContext* tc)
   {
     /* done */
     fprintf (stderr, "Last episode done!\n");
-    if (GNUNET_SCHEDULER_NO_TASK != e->experiment_timeout_task)
+    if (NULL != e->experiment_timeout_task)
     {
       GNUNET_SCHEDULER_cancel (e->experiment_timeout_task);
-      e->experiment_timeout_task = GNUNET_SCHEDULER_NO_TASK;
+      e->experiment_timeout_task = NULL;
     }
     e->e_done_cb (e, GNUNET_TIME_absolute_get_duration(e->start_time), GNUNET_OK);
     return;
@@ -1992,13 +2539,13 @@ GNUNET_ATS_solvers_experimentation_run (struct Experiment *e,
   e->experiment_timeout_task = GNUNET_SCHEDULER_add_delayed (e->max_duration,
       &timeout_experiment, e);
 
-
   /* Start */
   if (NULL == e->start)
   {
     GNUNET_break (0);
     return;
   }
+
   e->cur = e->start;
   fprintf (stderr, "Running episode %u with timeout %s\n",
       e->cur->id,
@@ -2012,15 +2559,15 @@ GNUNET_ATS_solvers_experimentation_run (struct Experiment *e,
 void
 GNUNET_ATS_solvers_experimentation_stop (struct Experiment *e)
 {
-  if (GNUNET_SCHEDULER_NO_TASK != e->experiment_timeout_task)
+  if (NULL != e->experiment_timeout_task)
   {
     GNUNET_SCHEDULER_cancel (e->experiment_timeout_task);
-    e->experiment_timeout_task = GNUNET_SCHEDULER_NO_TASK;
+    e->experiment_timeout_task = NULL;
   }
-  if (GNUNET_SCHEDULER_NO_TASK != e->episode_timeout_task)
+  if (NULL != e->episode_timeout_task)
   {
     GNUNET_SCHEDULER_cancel (e->episode_timeout_task);
-    e->episode_timeout_task = GNUNET_SCHEDULER_NO_TASK;
+    e->episode_timeout_task = NULL;
   }
   if (NULL != e->cfg)
   {
@@ -2051,27 +2598,55 @@ GNUNET_ATS_solvers_experimentation_load (char *filename)
   if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, "experiment",
       "name", &e->name))
   {
-    fprintf (stderr, "Invalid %s", "name");
+    fprintf (stderr, "Invalid %s \n", "name");
+    free_experiment (e);
+    return NULL;
+  }
+  else
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment name: `%s'\n", e->name);
+
+  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, "experiment",
+      "log_prefix", &e->log_prefix))
+  {
+    fprintf (stderr, "Invalid %s \n", "log_prefix");
     free_experiment (e);
     return NULL;
   }
   else
-    fprintf (stderr, "Experiment name: `%s'\n", e->name);
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment logging prefix: `%s'\n",
+        e->log_prefix);
+
+  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_filename (cfg, "experiment",
+      "log_output_dir", &e->log_output_dir))
+  {
+    e->log_output_dir = NULL;
+  }
+  else
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment logging output directory: `%s'\n",
+        e->log_output_dir);
+
+
+  if (GNUNET_SYSERR == (e->log_append_time_stamp = GNUNET_CONFIGURATION_get_value_yesno(cfg,
+      "experiment", "log_append_time_stamp")))
+    e->log_append_time_stamp = GNUNET_YES;
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment logging append timestamp: `%s'\n",
+      (GNUNET_YES == e->log_append_time_stamp) ? "yes" : "no");
+
 
   if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_filename (cfg, "experiment",
       "cfg_file", &e->cfg_file))
   {
-    fprintf (stderr, "Invalid %s", "cfg_file");
+    fprintf (stderr, "Invalid %s \n", "cfg_file");
     free_experiment (e);
     return NULL;
   }
   else
   {
-    fprintf (stderr, "Experiment configuration: `%s'\n", e->cfg_file);
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment configuration: `%s'\n", e->cfg_file);
     e->cfg = GNUNET_CONFIGURATION_create();
     if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (e->cfg, e->cfg_file))
     {
-      fprintf (stderr, "Invalid configuration %s", "cfg_file");
+      fprintf (stderr, "Invalid configuration %s \n", "cfg_file");
       free_experiment (e);
       return NULL;
     }
@@ -2081,12 +2656,12 @@ GNUNET_ATS_solvers_experimentation_load (char *filename)
   if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg, "experiment",
       "log_freq", &e->log_freq))
   {
-    fprintf (stderr, "Invalid %s", "log_freq");
+    fprintf (stderr, "Invalid %s \n", "log_freq");
     free_experiment (e);
     return NULL;
   }
   else
-    fprintf (stderr, "Experiment logging frequency: `%s'\n",
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment logging frequency: `%s'\n",
         GNUNET_STRINGS_relative_time_to_string (e->log_freq, GNUNET_YES));
 
   if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg, "experiment",
@@ -2097,7 +2672,7 @@ GNUNET_ATS_solvers_experimentation_load (char *filename)
     return NULL;
   }
   else
-    fprintf (stderr, "Experiment duration: `%s'\n",
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment duration: `%s'\n",
         GNUNET_STRINGS_relative_time_to_string (e->max_duration, GNUNET_YES));
 
   if (GNUNET_SYSERR == load_episodes (e, cfg))
@@ -2108,7 +2683,7 @@ GNUNET_ATS_solvers_experimentation_load (char *filename)
     fprintf (stderr, "Failed to load experiment\n");
     return NULL;
   }
-  fprintf (stderr, "Loaded %u episodes with total duration %s\n",
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Loaded %u episodes with total duration %s\n",
       e->num_episodes,
       GNUNET_STRINGS_relative_time_to_string (e->total_duration, GNUNET_YES));
 
@@ -2128,7 +2703,8 @@ free_all_it (void *cls,
     void *value)
 {
   struct ATS_Address *address = value;
-  GNUNET_CONTAINER_multipeermap_remove (sh->env.addresses, key, value);
+  GNUNET_break (GNUNET_OK == GNUNET_CONTAINER_multipeermap_remove (sh->env.addresses,
+      key, value));
   GNUNET_free (address);
 
   return GNUNET_OK;
@@ -2139,13 +2715,19 @@ GNUNET_ATS_solvers_solver_stop (struct SolverHandle *sh)
 {
  GNUNET_STATISTICS_destroy ((struct GNUNET_STATISTICS_Handle *) sh->env.stats,
      GNUNET_NO);
- GNUNET_PLUGIN_unload (sh->plugin, sh->solver);
- GNUNET_CONTAINER_multipeermap_iterate (sh->addresses, &free_all_it, NULL);
+ GNUNET_PLUGIN_unload (sh->plugin, sh->sf);
+ sh->sf = NULL;
+ GAS_normalization_stop();
+
+ GNUNET_CONTAINER_multipeermap_iterate (sh->addresses,
+                                        &free_all_it,
+                                        NULL);
  GNUNET_CONTAINER_multipeermap_destroy(sh->addresses);
  GNUNET_free (sh->plugin);
  GNUNET_free (sh);
 }
 
+
 /**
  * Load quotas for networks from configuration
  *
@@ -2161,7 +2743,6 @@ GNUNET_ATS_solvers_load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg,
                                                  unsigned long long *in_dest,
                                                  int dest_length)
 {
-  char *network_str[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkTypeString;
   char * entry_in = NULL;
   char * entry_out = NULL;
   char * quota_out_str;
@@ -2169,12 +2750,16 @@ GNUNET_ATS_solvers_load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg,
   int c;
   int res;
 
-  for (c = 0; (c < GNUNET_ATS_NetworkTypeCount) && (c < dest_length); c++)
+  for (c = 0; (c < GNUNET_NT_COUNT) && (c < dest_length); c++)
   {
     in_dest[c] = 0;
     out_dest[c] = 0;
-    GNUNET_asprintf (&entry_out, "%s_QUOTA_OUT", network_str[c]);
-    GNUNET_asprintf (&entry_in, "%s_QUOTA_IN", network_str[c]);
+    GNUNET_asprintf (&entry_out,
+                     "%s_QUOTA_OUT",
+                     GNUNET_NT_to_string (c));
+    GNUNET_asprintf (&entry_in,
+                     "%s_QUOTA_IN",
+                     GNUNET_NT_to_string (c));
 
     /* quota out */
     if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats", entry_out, &quota_out_str))
@@ -2192,21 +2777,28 @@ GNUNET_ATS_solvers_load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg,
 
       if (GNUNET_NO == res)
       {
-          GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Could not load quota for network `%s':  `%s', assigning default bandwidth %llu\n"),
-              network_str[c], quota_out_str, GNUNET_ATS_DefaultBandwidth);
+          GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                      _("Could not load quota for network `%s':  `%s', assigning default bandwidth %llu\n"),
+                      GNUNET_NT_to_string (c),
+                      quota_out_str,
+                      GNUNET_ATS_DefaultBandwidth);
           out_dest[c] = GNUNET_ATS_DefaultBandwidth;
       }
       else
       {
-          GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Outbound quota configure for network `%s' is %llu\n"),
-              network_str[c], out_dest[c]);
+          GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                      "Outbound quota configure for network `%s' is %llu\n",
+                      GNUNET_NT_to_string (c),
+                      out_dest[c]);
       }
       GNUNET_free (quota_out_str);
     }
     else
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("No outbound quota configured for network `%s', assigning default bandwidth %llu\n"),
-          network_str[c], GNUNET_ATS_DefaultBandwidth);
+      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                  _("No outbound quota configured for network `%s', assigning default bandwidth %llu\n"),
+                  GNUNET_NT_to_string (c),
+                  GNUNET_ATS_DefaultBandwidth);
       out_dest[c] = GNUNET_ATS_DefaultBandwidth;
     }
 
@@ -2226,42 +2818,55 @@ GNUNET_ATS_solvers_load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg,
 
       if (GNUNET_NO == res)
       {
-          GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Could not load quota for network `%s':  `%s', assigning default bandwidth %llu\n"),
-              network_str[c], quota_in_str, GNUNET_ATS_DefaultBandwidth);
+          GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                      _("Could not load quota for network `%s':  `%s', assigning default bandwidth %llu\n"),
+                      GNUNET_NT_to_string (c),
+                      quota_in_str,
+                      GNUNET_ATS_DefaultBandwidth);
           in_dest[c] = GNUNET_ATS_DefaultBandwidth;
       }
       else
       {
-          GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Inbound quota configured for network `%s' is %llu\n"),
-              network_str[c], in_dest[c]);
+          GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                      "Inbound quota configured for network `%s' is %llu\n",
+                      GNUNET_NT_to_string (c),
+                      in_dest[c]);
       }
       GNUNET_free (quota_in_str);
     }
     else
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("No outbound quota configure for network `%s', assigning default bandwidth %llu\n"),
-          network_str[c], GNUNET_ATS_DefaultBandwidth);
+      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                  _("No outbound quota configure for network `%s', assigning default bandwidth %llu\n"),
+                  GNUNET_NT_to_string (c),
+                  GNUNET_ATS_DefaultBandwidth);
       out_dest[c] = GNUNET_ATS_DefaultBandwidth;
     }
-    GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Loaded quota for network `%s' (in/out): %llu %llu\n", network_str[c], in_dest[c], out_dest[c]);
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                "Loaded quota for network `%s' (in/out): %llu %llu\n",
+                GNUNET_NT_to_string (c),
+                in_dest[c],
+                out_dest[c]);
     GNUNET_free (entry_out);
     GNUNET_free (entry_in);
   }
-  return GNUNET_ATS_NetworkTypeCount;
+  return GNUNET_NT_COUNT;
 }
 
+
 /**
  * Information callback for the solver
  *
+ * @param cls the closure
  * @param op the solver operation
  * @param stat status of the solver operation
  * @param add additional solver information
  */
 static void
 solver_info_cb (void *cls,
-    enum GAS_Solver_Operation op,
-    enum GAS_Solver_Status stat,
-    enum GAS_Solver_Additional_Information add)
+                enum GAS_Solver_Operation op,
+                enum GAS_Solver_Status stat,
+                enum GAS_Solver_Additional_Information add)
 {
   char *add_info;
   switch (add) {
@@ -2288,56 +2893,56 @@ solver_info_cb (void *cls,
   switch (op)
   {
     case GAS_OP_SOLVE_START:
-      GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+      GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
           "Solver notifies `%s' with result `%s' `%s'\n", "GAS_OP_SOLVE_START",
           (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL", add_info);
       return;
     case GAS_OP_SOLVE_STOP:
-      GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+      GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
           "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_STOP",
           (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL", add_info);
       return;
 
     case GAS_OP_SOLVE_SETUP_START:
-      GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+      GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
           "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_SETUP_START",
           (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
       return;
 
     case GAS_OP_SOLVE_SETUP_STOP:
-      GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+      GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
           "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_SETUP_STOP",
           (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
       return;
 
     case GAS_OP_SOLVE_MLP_LP_START:
-      GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+      GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
           "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_LP_START",
           (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
       return;
     case GAS_OP_SOLVE_MLP_LP_STOP:
-      GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+      GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
           "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_LP_STOP",
           (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
       return;
 
     case GAS_OP_SOLVE_MLP_MLP_START:
-      GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+      GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
           "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_MLP_START",
           (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
       return;
     case GAS_OP_SOLVE_MLP_MLP_STOP:
-      GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+      GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
           "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_MLP_STOP",
           (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
       return;
     case GAS_OP_SOLVE_UPDATE_NOTIFICATION_START:
-      GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+      GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
           "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_UPDATE_NOTIFICATION_START",
           (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
       return;
     case GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP:
-      GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+      GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
           "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP",
           (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
       return;
@@ -2349,64 +2954,65 @@ solver_info_cb (void *cls,
 static void
 solver_bandwidth_changed_cb (void *cls, struct ATS_Address *address)
 {
-  if ( (0 == ntohl (address->assigned_bw_out.value__)) &&
-       (0 == ntohl (address->assigned_bw_in.value__)) )
+  struct GNUNET_TIME_Relative duration;
+  struct TestPeer *p;
+  static struct PreferenceGenerator *pg;
+  uint32_t delta;
+  if ( (0 == address->assigned_bw_out) && (0 == address->assigned_bw_in) )
   {
     GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                 "Solver notified to disconnect peer `%s'\n",
                 GNUNET_i2s (&address->peer));
-    return;
   }
+  p = find_peer_by_pid(&address->peer);
+  if (NULL == p)
+    return;
+  p->assigned_bw_out = address->assigned_bw_out;
+  p->assigned_bw_in = address->assigned_bw_in;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-              "Bandwidth changed addresses %s %p to %u Bps out / %u Bps in\n",
-              GNUNET_i2s (&address->peer),
-              address,
-              (unsigned int) ntohl (address->assigned_bw_out.value__),
-              (unsigned int) ntohl (address->assigned_bw_in.value__));
-  /*if (GNUNET_YES == ph.bulk_running)
-    GNUNET_break (0);*/
-  return;
-}
+  for (pg = pref_gen_head; NULL != pg; pg = pg->next)
+  {
+    if (pg->peer == p->id)
+    {
+      duration = GNUNET_TIME_absolute_get_duration(pg->feedback_last_bw_update);
+      delta = duration.rel_value_us * pg->last_assigned_bw_out;
+      pg->feedback_bw_out_acc += delta;
 
-const double *
-get_preferences_cb (void *cls, const struct GNUNET_PeerIdentity *id)
-{
-  return GAS_normalization_get_preferences_by_peer (id);
-}
+      delta = duration.rel_value_us * pg->last_assigned_bw_in;
+      pg->feedback_bw_in_acc += delta;
 
+      pg->last_assigned_bw_in = address->assigned_bw_in;
+      pg->last_assigned_bw_out = address->assigned_bw_out;
+      pg->feedback_last_bw_update = GNUNET_TIME_absolute_get();
+    }
+  }
 
-const double *
-get_property_cb (void *cls, const struct ATS_Address *address)
-{
-  return GAS_normalization_get_properties ((struct ATS_Address *) address);
-}
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+      "Bandwidth changed addresses %s %p to %u Bps out / %u Bps in\n",
+      GNUNET_i2s (&address->peer),
+      address,
+      address->assigned_bw_out,
+          address->assigned_bw_in);
 
-static void
-normalized_property_changed_cb (void *cls, struct ATS_Address *address,
-    uint32_t type, double prop_rel)
-{
-  GNUNET_log(GNUNET_ERROR_TYPE_INFO,
-      "Normalized property %s for peer `%s' changed to %.3f \n",
-      GNUNET_ATS_print_property_type (type), GNUNET_i2s (&address->peer),
-      prop_rel);
+  if (NULL != l)
+    GNUNET_ATS_solver_logging_now (l);
 
-  sh->env.sf.s_address_update_property (sh->solver, address, type, 0, prop_rel);
+  return;
 }
 
-
-static void
-normalized_preference_changed_cb (void *cls,
-    const struct GNUNET_PeerIdentity *peer,
-    enum GNUNET_ATS_PreferenceKind kind,
-    double pref_rel)
+const double *
+get_preferences_cb (void *cls, const struct GNUNET_PeerIdentity *id)
 {
-  GNUNET_log(GNUNET_ERROR_TYPE_INFO,
-      "Normalized preference %s for peer `%s' changed to %.3f \n",
-      GNUNET_ATS_print_preference_type (kind), GNUNET_i2s (peer),
-      pref_rel);
-
-  sh->env.sf.s_pref (sh->solver, peer, kind, pref_rel);
+  struct TestPeer *p;
+  if (GNUNET_YES == opt_disable_normalization)
+  {
+    if (NULL == (p = find_peer_by_pid (id)))
+      return NULL;
+    return p->pref_abs;
+  }
+  else
+    return GAS_preference_get_by_peer (NULL,
+                                       id);
 }
 
 
@@ -2433,28 +3039,27 @@ GNUNET_ATS_solvers_solver_start (enum GNUNET_ATS_Solvers type)
   }
 
   sh = GNUNET_new (struct SolverHandle);
-  GNUNET_asprintf (&sh->plugin, "libgnunet_plugin_ats_%s", solver_str);
-
+  GNUNET_asprintf (&sh->plugin,
+                   "libgnunet_plugin_ats_%s",
+                   solver_str);
   sh->addresses = GNUNET_CONTAINER_multipeermap_create (128, GNUNET_NO);
+
   /* setup environment */
   sh->env.cfg = e->cfg;
   sh->env.stats = GNUNET_STATISTICS_create ("ats", e->cfg);
   sh->env.addresses = sh->addresses;
   sh->env.bandwidth_changed_cb = &solver_bandwidth_changed_cb;
   sh->env.get_preferences = &get_preferences_cb;
-  sh->env.get_property = &get_property_cb;
-  sh->env.network_count = GNUNET_ATS_NetworkTypeCount;
+  sh->env.network_count = GNUNET_NT_COUNT;
   sh->env.info_cb = &solver_info_cb;
-  sh->env.info_cb_cls = NULL;
-
+  sh->env.network_count = GNUNET_NT_COUNT;
 
   /* start normalization */
-  GAS_normalization_start (&normalized_preference_changed_cb, NULL,
-      &normalized_property_changed_cb, NULL );
+  GAS_normalization_start ();
 
   /* load quotas */
-  if (GNUNET_ATS_NetworkTypeCount != GNUNET_ATS_solvers_load_quotas (e->cfg,
-      sh->env.out_quota, sh->env.in_quota, GNUNET_ATS_NetworkTypeCount))
+  if (GNUNET_NT_COUNT != GNUNET_ATS_solvers_load_quotas (e->cfg,
+      sh->env.out_quota, sh->env.in_quota, GNUNET_NT_COUNT))
   {
     GNUNET_break(0);
     GNUNET_free (sh->plugin);
@@ -2463,8 +3068,8 @@ GNUNET_ATS_solvers_solver_start (enum GNUNET_ATS_Solvers type)
     return NULL;
   }
 
-  sh->solver = GNUNET_PLUGIN_load (sh->plugin, &sh->env);
-  if (NULL == sh->solver)
+  sh->sf = GNUNET_PLUGIN_load (sh->plugin, &sh->env);
+  if (NULL == sh->sf)
   {
     fprintf (stderr, "Failed to load solver `%s'\n", sh->plugin);
     GNUNET_break(0);
@@ -2476,6 +3081,7 @@ GNUNET_ATS_solvers_solver_start (enum GNUNET_ATS_Solvers type)
   return sh;
 }
 
+
 static void
 done ()
 {
@@ -2494,15 +3100,17 @@ done ()
   /* Stop all property generation */
   GNUNET_ATS_solver_generate_property_stop_all ();
 
-  /* Clean up experiment */
-  if (NULL != e)
-  {
-    GNUNET_ATS_solvers_experimentation_stop (e);
-    e = NULL;
-  }
-
   if (opt_print)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO, "== Printing log information \n");
     GNUNET_ATS_solver_logging_eval (l);
+  }
+  if (opt_save)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO, "== Saving log information \n");
+    GNUNET_ATS_solver_logging_write_to_disk (l, e->log_append_time_stamp,
+        e->log_output_dir);
+  }
 
   if (NULL != l)
   {
@@ -2510,6 +3118,13 @@ done ()
     l = NULL;
   }
 
+  /* Clean up experiment */
+  if (NULL != e)
+  {
+    GNUNET_ATS_solvers_experimentation_stop (e);
+    e = NULL;
+  }
+
   next = peer_head;
   while  (NULL != (cur = next))
   {
@@ -2529,6 +3144,7 @@ done ()
     GNUNET_ATS_solvers_solver_stop (sh);
     sh = NULL;
   }
+
   /* Shutdown */
   end_now();
 }
@@ -2576,6 +3192,7 @@ run (void *cls, char * const *args, const char *cfgfile,
     const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   enum GNUNET_ATS_Solvers solver;
+  int c;
 
   if (NULL == opt_exp_file)
   {
@@ -2613,7 +3230,14 @@ run (void *cls, char * const *args, const char *cfgfile,
     return;
   }
 
+  for (c = 0; c < GNUNET_ATS_PropertyCount; c++)
+    default_properties[c] = DEFAULT_REL_QUALITY;
+
+  for (c = 0; c < GNUNET_ATS_PreferenceCount; c++)
+    default_preferences[c] = DEFAULT_REL_PREFERENCE;
+
   /* load experiment */
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "=== Loading experiment\n");
   e = GNUNET_ATS_solvers_experimentation_load (opt_exp_file);
   if (NULL == e)
   {
@@ -2624,6 +3248,7 @@ run (void *cls, char * const *args, const char *cfgfile,
   }
 
   /* load solver */
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "=== Loading solver\n");
   sh = GNUNET_ATS_solvers_solver_start (solver);
   if (NULL == sh)
   {
@@ -2634,9 +3259,11 @@ run (void *cls, char * const *args, const char *cfgfile,
   }
 
   /* start logging */
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "=== Start logging \n");
   l = GNUNET_ATS_solver_logging_start (e->log_freq);
 
   /* run experiment */
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "=== Running experiment \n");
   GNUNET_ATS_solvers_experimentation_run (e, episode_done_cb,
       experiment_done_cb);
 
@@ -2656,24 +3283,39 @@ main (int argc, char *argv[])
   opt_exp_file = NULL;
   opt_solver = NULL;
   opt_log = GNUNET_NO;
-  opt_plot = GNUNET_NO;
+  opt_save = GNUNET_NO;
 
   res = 0;
 
   static struct GNUNET_GETOPT_CommandLineOption options[] =
   {
-    { 's', "solver", NULL,
-        gettext_noop ("solver to use"),
-        1, &GNUNET_GETOPT_set_string, &opt_solver},
-    {  'e', "experiment", NULL,
-      gettext_noop ("experiment to use"),
-      1, &GNUNET_GETOPT_set_string, &opt_exp_file},
-    {  'e', "experiment", NULL,
-      gettext_noop ("experiment to use"),
-      1, &GNUNET_GETOPT_set_one, &opt_verbose},
-    {  'p', "print", NULL,
-      gettext_noop ("print logging"),
-      0, &GNUNET_GETOPT_set_one, &opt_print},
+    GNUNET_GETOPT_option_string ('s',
+                                 "solver",
+                                 gettext_noop ("solver to use"),
+                                 &opt_solver),
+
+    GNUNET_GETOPT_option_string ('e',
+                                 "experiment"
+                                 gettext_noop ("experiment to use"),
+                                 &opt_exp_file),
+
+    GNUNET_GETOPT_option_verbose (&opt_verbose),
+
+    GNUNET_GETOPT_option_flag ('p', 
+                                  "print",
+                                  gettext_noop ("print logging"),
+                                  &opt_print),
+
+    GNUNET_GETOPT_option_flag ('f',
+                                  "file",
+                                  gettext_noop ("save logging to disk"),
+                                  &opt_save),
+
+    GNUNET_GETOPT_option_flag ('d', 
+                                  "dn",
+                                  gettext_noop ("disable normalization"),
+                                  &opt_disable_normalization),
+
     GNUNET_GETOPT_OPTION_END
   };
 
@@ -2683,4 +3325,3 @@ main (int argc, char *argv[])
   return res;
 }
 /* end of file ats-testing-experiment.c*/
-