gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r33653 - gnunet/po gnunet/src/ats gnunet-fuse/src/fuse


From: gnunet
Subject: [GNUnet-SVN] r33653 - gnunet/po gnunet/src/ats gnunet-fuse/src/fuse
Date: Thu, 12 Jun 2014 11:59:01 +0200

Author: grothoff
Date: 2014-06-12 11:59:00 +0200 (Thu, 12 Jun 2014)
New Revision: 33653

Removed:
   gnunet/src/ats/plugin_ats_mlp.h
   gnunet/src/ats/plugin_ats_ril.h
Modified:
   gnunet-fuse/src/fuse/gnunet-fuse.c
   gnunet-fuse/src/fuse/mutex.c
   gnunet/po/POTFILES.in
   gnunet/src/ats/Makefile.am
   gnunet/src/ats/plugin_ats_mlp.c
   gnunet/src/ats/plugin_ats_ril.c
Log:
code cleanup


Modified: gnunet/po/POTFILES.in
===================================================================
--- gnunet/po/POTFILES.in       2014-06-11 15:07:57 UTC (rev 33652)
+++ gnunet/po/POTFILES.in       2014-06-12 09:59:00 UTC (rev 33653)
@@ -3,11 +3,19 @@
 src/arm/gnunet-arm.c
 src/arm/gnunet-service-arm.c
 src/arm/mockup-service.c
+src/ats-tests/ats-testing-experiment.c
+src/ats-tests/ats-testing-log.c
+src/ats-tests/ats-testing-preferences.c
+src/ats-tests/ats-testing-traffic.c
+src/ats-tests/ats-testing.c
+src/ats-tests/gnunet-ats-sim.c
+src/ats-tests/gnunet-solver-eval.c
+src/ats-tool/gnunet-ats.c
 src/ats/ats_api_performance.c
 src/ats/ats_api_scheduling.c
 src/ats/gnunet-ats-solver-eval.c
+src/ats/gnunet-service-ats.c
 src/ats/gnunet-service-ats_addresses.c
-src/ats/gnunet-service-ats.c
 src/ats/gnunet-service-ats_normalization.c
 src/ats/gnunet-service-ats_performance.c
 src/ats/gnunet-service-ats_reservations.c
@@ -15,14 +23,6 @@
 src/ats/plugin_ats_mlp.c
 src/ats/plugin_ats_proportional.c
 src/ats/plugin_ats_ril.c
-src/ats-tests/ats-testing.c
-src/ats-tests/ats-testing-experiment.c
-src/ats-tests/ats-testing-log.c
-src/ats-tests/ats-testing-preferences.c
-src/ats-tests/ats-testing-traffic.c
-src/ats-tests/gnunet-ats-sim.c
-src/ats-tests/gnunet-solver-eval.c
-src/ats-tool/gnunet-ats.c
 src/block/block.c
 src/block/plugin_block_template.c
 src/block/plugin_block_test.c
@@ -31,8 +31,8 @@
 src/cadet/cadet_path.c
 src/cadet/cadet_test_lib.c
 src/cadet/cadet_tunnel_tree.c
+src/cadet/gnunet-cadet-profiler.c
 src/cadet/gnunet-cadet.c
-src/cadet/gnunet-cadet-profiler.c
 src/cadet/gnunet-service-cadet.c
 src/cadet/gnunet-service-cadet_channel.c
 src/cadet/gnunet-service-cadet_connection.c
@@ -46,12 +46,12 @@
 src/consensus/gnunet-service-consensus.c
 src/conversation/conversation_api.c
 src/conversation/conversation_api_call.c
+src/conversation/gnunet-conversation-test.c
 src/conversation/gnunet-conversation.c
-src/conversation/gnunet-conversation-test.c
+src/conversation/gnunet-helper-audio-playback-gst.c
 src/conversation/gnunet-helper-audio-playback.c
-src/conversation/gnunet-helper-audio-playback-gst.c
+src/conversation/gnunet-helper-audio-record-gst.c
 src/conversation/gnunet-helper-audio-record.c
-src/conversation/gnunet-helper-audio-record-gst.c
 src/conversation/gnunet-service-conversation.c
 src/conversation/microphone.c
 src/conversation/plugin_gnsrecord_conversation.c
@@ -112,8 +112,8 @@
 src/dv/plugin_transport_dv.c
 src/env/env.c
 src/exit/gnunet-daemon-exit.c
+src/exit/gnunet-helper-exit-windows.c
 src/exit/gnunet-helper-exit.c
-src/exit/gnunet-helper-exit-windows.c
 src/experimentation/gnunet-daemon-experimentation.c
 src/experimentation/gnunet-daemon-experimentation_capabilities.c
 src/experimentation/gnunet-daemon-experimentation_experiments.c
@@ -144,8 +144,8 @@
 src/fs/gnunet-daemon-fsprofiler.c
 src/fs/gnunet-directory.c
 src/fs/gnunet-download.c
+src/fs/gnunet-fs-profiler.c
 src/fs/gnunet-fs.c
-src/fs/gnunet-fs-profiler.c
 src/fs/gnunet-helper-fs-publish.c
 src/fs/gnunet-publish.c
 src/fs/gnunet-search.c
@@ -164,10 +164,10 @@
 src/gns/gns_api.c
 src/gns/gnunet-bcd.c
 src/gns/gnunet-dns2gns.c
-src/gns/gnunet-gns.c
 src/gns/gnunet-gns-helper-service-w32.c
 src/gns/gnunet-gns-import.c
 src/gns/gnunet-gns-proxy.c
+src/gns/gnunet-gns.c
 src/gns/gnunet-service-gns.c
 src/gns/gnunet-service-gns_interceptor.c
 src/gns/gnunet-service-gns_resolver.c
@@ -176,15 +176,15 @@
 src/gns/nss/nss_gns_query.c
 src/gns/plugin_block_gns.c
 src/gns/plugin_gnsrecord_gns.c
+src/gns/w32nsp-install.c
+src/gns/w32nsp-resolve.c
+src/gns/w32nsp-uninstall.c
+src/gns/w32nsp.c
 src/gnsrecord/gnsrecord.c
 src/gnsrecord/gnsrecord_crypto.c
 src/gnsrecord/gnsrecord_misc.c
 src/gnsrecord/gnsrecord_serialization.c
 src/gnsrecord/plugin_gnsrecord_dns.c
-src/gns/w32nsp.c
-src/gns/w32nsp-install.c
-src/gns/w32nsp-resolve.c
-src/gns/w32nsp-uninstall.c
 src/hello/address.c
 src/hello/gnunet-hello.c
 src/hello/hello.c
@@ -204,31 +204,31 @@
 src/namecache/namecache_api.c
 src/namecache/plugin_namecache_postgres.c
 src/namecache/plugin_namecache_sqlite.c
+src/namestore/gnunet-namestore-fcfsd.c
 src/namestore/gnunet-namestore.c
-src/namestore/gnunet-namestore-fcfsd.c
 src/namestore/gnunet-service-namestore.c
 src/namestore/namestore_api.c
 src/namestore/namestore_api_monitor.c
 src/namestore/plugin_namestore_postgres.c
 src/namestore/plugin_namestore_sqlite.c
+src/nat/gnunet-helper-nat-client-windows.c
 src/nat/gnunet-helper-nat-client.c
-src/nat/gnunet-helper-nat-client-windows.c
+src/nat/gnunet-helper-nat-server-windows.c
 src/nat/gnunet-helper-nat-server.c
-src/nat/gnunet-helper-nat-server-windows.c
 src/nat/gnunet-nat-server.c
+src/nat/nat.c
 src/nat/nat_auto.c
-src/nat/nat.c
 src/nat/nat_mini.c
 src/nat/nat_test.c
+src/nse/gnunet-nse-profiler.c
 src/nse/gnunet-nse.c
-src/nse/gnunet-nse-profiler.c
 src/nse/gnunet-service-nse.c
 src/nse/nse_api.c
+src/peerinfo-tool/gnunet-peerinfo.c
+src/peerinfo-tool/gnunet-peerinfo_plugins.c
 src/peerinfo/gnunet-service-peerinfo.c
 src/peerinfo/peerinfo_api.c
 src/peerinfo/peerinfo_api_notify.c
-src/peerinfo-tool/gnunet-peerinfo.c
-src/peerinfo-tool/gnunet-peerinfo_plugins.c
 src/peerstore/gnunet-peerstore.c
 src/peerstore/gnunet-service-peerstore.c
 src/peerstore/peerstore_api.c
@@ -288,30 +288,30 @@
 src/testbed/gnunet-daemon-testbed-blacklist.c
 src/testbed/gnunet-daemon-testbed-underlay.c
 src/testbed/gnunet-helper-testbed.c
-src/testbed/gnunet_mpi_test.c
 src/testbed/gnunet-service-test-barriers.c
+src/testbed/gnunet-service-testbed-logger.c
+src/testbed/gnunet-service-testbed.c
 src/testbed/gnunet-service-testbed_barriers.c
-src/testbed/gnunet-service-testbed.c
 src/testbed/gnunet-service-testbed_cache.c
 src/testbed/gnunet-service-testbed_connectionpool.c
 src/testbed/gnunet-service-testbed_cpustatus.c
 src/testbed/gnunet-service-testbed_links.c
-src/testbed/gnunet-service-testbed-logger.c
 src/testbed/gnunet-service-testbed_meminfo.c
 src/testbed/gnunet-service-testbed_oc.c
 src/testbed/gnunet-service-testbed_peers.c
+src/testbed/gnunet-testbed-profiler.c
+src/testbed/gnunet_mpi_test.c
 src/testbed/gnunet_testbed_mpi_spawn.c
-src/testbed/gnunet-testbed-profiler.c
+src/testbed/testbed_api.c
 src/testbed/testbed_api_barriers.c
-src/testbed/testbed_api.c
 src/testbed/testbed_api_hosts.c
 src/testbed/testbed_api_operations.c
 src/testbed/testbed_api_peers.c
 src/testbed/testbed_api_sd.c
 src/testbed/testbed_api_services.c
 src/testbed/testbed_api_statistics.c
+src/testbed/testbed_api_test.c
 src/testbed/testbed_api_testbed.c
-src/testbed/testbed_api_test.c
 src/testbed/testbed_api_topology.c
 src/testbed/testbed_api_underlay.c
 src/testbed/testbed_logger_api.c
@@ -321,20 +321,20 @@
 src/topology/friends.c
 src/topology/gnunet-daemon-topology.c
 src/transport/gnunet-helper-transport-bluetooth.c
+src/transport/gnunet-helper-transport-wlan-dummy.c
 src/transport/gnunet-helper-transport-wlan.c
-src/transport/gnunet-helper-transport-wlan-dummy.c
+src/transport/gnunet-service-transport.c
 src/transport/gnunet-service-transport_blacklist.c
-src/transport/gnunet-service-transport.c
 src/transport/gnunet-service-transport_clients.c
 src/transport/gnunet-service-transport_hello.c
 src/transport/gnunet-service-transport_manipulation.c
 src/transport/gnunet-service-transport_neighbours.c
 src/transport/gnunet-service-transport_plugins.c
 src/transport/gnunet-service-transport_validation.c
-src/transport/gnunet-transport.c
 src/transport/gnunet-transport-certificate-creation.c
 src/transport/gnunet-transport-wlan-receiver.c
 src/transport/gnunet-transport-wlan-sender.c
+src/transport/gnunet-transport.c
 src/transport/plugin_transport_bluetooth.c
 src/transport/plugin_transport_http_client.c
 src/transport/plugin_transport_http_common.c
@@ -342,15 +342,15 @@
 src/transport/plugin_transport_smtp.c
 src/transport/plugin_transport_tcp.c
 src/transport/plugin_transport_template.c
+src/transport/plugin_transport_udp.c
 src/transport/plugin_transport_udp_broadcasting.c
-src/transport/plugin_transport_udp.c
 src/transport/plugin_transport_unix.c
 src/transport/plugin_transport_wlan.c
+src/transport/transport-testing.c
+src/transport/transport_api.c
 src/transport/transport_api_address_to_string.c
 src/transport/transport_api_blacklist.c
-src/transport/transport_api.c
 src/transport/transport_api_monitoring.c
-src/transport/transport-testing.c
 src/tun/regex.c
 src/tun/tun.c
 src/util/bandwidth.c
@@ -365,8 +365,8 @@
 src/util/container_bloomfilter.c
 src/util/container_heap.c
 src/util/container_meta_data.c
+src/util/container_multihashmap.c
 src/util/container_multihashmap32.c
-src/util/container_multihashmap.c
 src/util/container_multipeermap.c
 src/util/container_slist.c
 src/util/crypto_crc.c
@@ -381,8 +381,8 @@
 src/util/disk.c
 src/util/getopt.c
 src/util/getopt_helpers.c
+src/util/gnunet-config-diff.c
 src/util/gnunet-config.c
-src/util/gnunet-config-diff.c
 src/util/gnunet-ecc.c
 src/util/gnunet-helper-w32-console.c
 src/util/gnunet-resolver.c
@@ -413,8 +413,8 @@
 src/util/w32cat.c
 src/util/win.c
 src/util/winproc.c
+src/vpn/gnunet-helper-vpn-windows.c
 src/vpn/gnunet-helper-vpn.c
-src/vpn/gnunet-helper-vpn-windows.c
 src/vpn/gnunet-service-vpn.c
 src/vpn/gnunet-vpn.c
 src/vpn/vpn_api.c

Modified: gnunet/src/ats/Makefile.am
===================================================================
--- gnunet/src/ats/Makefile.am  2014-06-11 15:07:57 UTC (rev 33652)
+++ gnunet/src/ats/Makefile.am  2014-06-12 09:59:00 UTC (rev 33653)
@@ -518,8 +518,6 @@
 
 EXTRA_DIST = \
   ats.h \
-  plugin_ats_mlp.h \
-  plugin_ats_ril.h \
   test_ats_api.conf \
   test_ats_mlp.conf \
   test_ats_solver_default.conf \

Modified: gnunet/src/ats/plugin_ats_mlp.c
===================================================================
--- gnunet/src/ats/plugin_ats_mlp.c     2014-06-11 15:07:57 UTC (rev 33652)
+++ gnunet/src/ats/plugin_ats_mlp.c     2014-06-12 09:59:00 UTC (rev 33653)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2011 Christian Grothoff (and other contributing authors)
+     (C) 2011-2014 Christian Grothoff (and other contributing authors)
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -26,9 +26,401 @@
  */
 
 #include "plugin_ats_mlp.h"
+#include "platform.h"
+#include "gnunet_util_lib.h"
+#include "gnunet_ats_service.h"
+#include "gnunet_ats_plugin.h"
+#include "gnunet-service-ats_addresses.h"
+#include "gnunet_statistics_service.h"
+#include <float.h>
+#include <glpk.h>
 
 
+#define BIG_M_VALUE (UINT32_MAX) /10
+#define BIG_M_STRING "unlimited"
+
+#define MLP_AVERAGING_QUEUE_LENGTH 3
+
+#define MLP_MAX_EXEC_DURATION   
GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10)
+#define MLP_MAX_ITERATIONS      4096
+
+#define DEFAULT_D 1.0
+#define DEFAULT_R 1.0
+#define DEFAULT_U 1.0
+#define DEFAULT_QUALITY 1.0
+#define DEFAULT_MIN_CONNECTIONS 4
+#define DEFAULT_PEER_PREFERENCE 1.0
+
+#define MLP_NaN -1
+#define MLP_UNDEFINED 0
+#define GLP_YES 1.0
+#define GLP_NO  0.0
+
+enum MLP_Output_Format
+{
+  MLP_MPS,
+  MLP_CPLEX,
+  MLP_GLPK
+};
+
+
+struct MLP_Solution
+{
+  int lp_res;
+  int lp_presolv;
+  int mip_res;
+  int mip_presolv;
+
+  double lp_objective_value;
+  double mlp_objective_value;
+  double mlp_gap;
+  double lp_mlp_gap;
+
+  int p_elements;
+  int p_cols;
+  int p_rows;
+
+  int n_peers;
+  int n_addresses;
+
+};
+
+struct ATS_Peer
+{
+  struct GNUNET_PeerIdentity id;
+
+  /* Was this peer already added to the current problem? */
+  int processed;
+
+  /* constraint 2: 1 address per peer*/
+  unsigned int r_c2;
+
+  /* constraint 9: relativity */
+  unsigned int r_c9;
+
+  /* Legacy preference value */
+  double f;
+};
+
+struct MLP_Problem
+{
+  /**
+   * GLPK (MLP) problem object
+   */
+  glp_prob *prob;
+
+  /* Number of addresses in problem */
+  unsigned int num_addresses;
+  /* Number of peers in problem */
+  unsigned int num_peers;
+  /* Number of elements in problem matrix */
+  unsigned int num_elements;
+
+  /* Row index constraint 2: */
+  unsigned int r_c2;
+  /* Row index constraint 4: minimum connections */
+  unsigned int r_c4;
+  /* Row index constraint 6: maximize diversity */
+  unsigned int r_c6;
+  /* Row index constraint 8: utilization*/
+  unsigned int r_c8;
+  /* Row index constraint 9: relativity*/
+  unsigned int r_c9;
+  /* Row indices quality metrics  */
+  int r_q[GNUNET_ATS_QualityPropertiesCount];
+  /* Row indices ATS network quotas */
+  int r_quota[GNUNET_ATS_NetworkTypeCount];
+
+  /* Column index Diversity (D) column */
+  int c_d;
+  /* Column index Utilization (U) column */
+  int c_u;
+  /* Column index Proportionality (R) column */
+  int c_r;
+  /* Column index quality metrics  */
+  int c_q[GNUNET_ATS_QualityPropertiesCount];
+
+  /* Problem matrix */
+  /* Current index */
+  unsigned int ci;
+  /* Row index array */
+  int *ia;
+  /* Column index array */
+  int *ja;
+  /* Column index value */
+  double *ar;
+
+};
+
+struct MLP_Variables
+{
+  /* Big M value for bandwidth capping */
+  double BIG_M;
+
+  /* MIP Gap */
+  double mip_gap;
+
+  /* LP MIP Gap */
+  double lp_mip_gap;
+
+  /* ATS Quality metrics
+   *
+   * Array with GNUNET_ATS_QualityPropertiesCount elements
+   * contains mapping to GNUNET_ATS_Property*/
+  int q[GNUNET_ATS_QualityPropertiesCount];
+
+  /* Number of quality metrics */
+  int m_q;
+
+  /* Number of quality metrics */
+  int m_rc;
+
+  /* Quality metric coefficients*/
+  double co_Q[GNUNET_ATS_QualityPropertiesCount];
+
+  /* Ressource costs coefficients*/
+  double co_RC[GNUNET_ATS_QualityPropertiesCount];
+
+  /* Diversity coefficient */
+  double co_D;
+
+  /* Utility coefficient */
+  double co_U;
+
+  /* Relativity coefficient */
+  double co_R;
+
+  /* Minimum bandwidth assigned to an address */
+  unsigned int b_min;
+
+  /* Minimum number of addresses with bandwidth assigned */
+  unsigned int n_min;
+
+  /* Quotas */
+  /* Array mapping array index to ATS network */
+  int quota_index[GNUNET_ATS_NetworkTypeCount];
+  /* Outbound quotas */
+  unsigned long long quota_out[GNUNET_ATS_NetworkTypeCount];
+  /* Inbound quotas */
+
+  unsigned long long quota_in[GNUNET_ATS_NetworkTypeCount];
+
+  /* ATS ressource costs
+   * array with GNUNET_ATS_QualityPropertiesCount elements
+   * contains mapping to GNUNET_ATS_Property
+   * */
+  int rc[GNUNET_ATS_QualityPropertiesCount];
+
+};
+
 /**
+ * MLP Handle
+ */
+struct GAS_MLP_Handle
+{
+  struct GNUNET_ATS_PluginEnvironment *env;
+
+  /**
+   * Statistics handle
+   */
+  struct GNUNET_STATISTICS_Handle *stats;
+
+  /**
+   * Address hashmap for lookups
+   */
+  const struct GNUNET_CONTAINER_MultiPeerMap *addresses;
+
+  /**
+   * Addresses' bandwidth changed callback
+   */
+  GAS_bandwidth_changed_cb bw_changed_cb;
+
+  /**
+   * Addresses' bandwidth changed callback closure
+   */
+  void *bw_changed_cb_cls;
+
+  /**
+   * ATS function to get preferences
+   */
+  GAS_get_preferences get_preferences;
+
+  /**
+   * Closure for ATS function to get preferences
+   */
+  void *get_preferences_cls;
+
+  /**
+   * ATS function to get properties
+   */
+  GAS_get_properties get_properties;
+
+  /**
+   * Closure for ATS function to get properties
+   */
+  void *get_properties_cls;
+
+  /**
+   * Exclude peer from next result propagation
+   */
+  const struct GNUNET_PeerIdentity *exclude_peer;
+
+  /**
+   * Encapsulation for the MLP problem
+   */
+  struct MLP_Problem p;
+
+  /**
+   * Encapsulation for the MLP problem variables
+   */
+  struct MLP_Variables pv;
+
+  /**
+   * Encapsulation for the MLP solution
+   */
+  struct MLP_Solution ps;
+
+  /**
+   * Bulk lock
+   */
+
+  int stat_bulk_lock;
+
+  /**
+   * Number of changes while solver was locked
+   */
+  int stat_bulk_requests;
+
+  /**
+   * GLPK LP control parameter
+   */
+  glp_smcp control_param_lp;
+
+  /**
+   * GLPK LP control parameter
+   */
+  glp_iocp control_param_mlp;
+
+  /**
+   * Peers with pending address requests
+   */
+  struct GNUNET_CONTAINER_MultiPeerMap *requested_peers;
+
+  /**
+   * Was the problem updated since last solution
+   */
+  int stat_mlp_prob_updated;
+
+  /**
+   * Has the problem size changed since last solution
+   */
+  int stat_mlp_prob_changed;
+
+  /**
+   * Solve the problem automatically when updates occur?
+   * Default: GNUNET_YES
+   * Can be disabled for test and measurements
+   */
+  int opt_mlp_auto_solve;
+
+  /**
+   * Write all MILP problems to a MPS file
+   */
+  int opt_dump_problem_all;
+
+  /**
+   * Write all MILP problem solutions to a file
+   */
+  int opt_dump_solution_all;
+
+  /**
+   * Write MILP problems to a MPS file when solver fails
+   */
+  int opt_dump_problem_on_fail;
+
+  /**
+   * Write MILP problem solutions to a file when solver fails
+   */
+  int opt_dump_solution_on_fail;
+
+  /**
+   * solve feasibility only
+   */
+  int opt_dbg_feasibility_only;
+
+  /**
+   * solve autoscale the problem
+   */
+  int opt_dbg_autoscale_problem;
+
+  /**
+   * use the intopt presolver instead of simplex
+   */
+  int opt_dbg_intopt_presolver;
+
+  /**
+   * Print GLPK output
+   */
+  int opt_dbg_glpk_verbose;
+
+  /**
+   * solve autoscale the problem
+   */
+  int opt_dbg_optimize_relativity;
+
+  /**
+   * solve autoscale the problem
+   */
+  int opt_dbg_optimize_diversity;
+
+  /**
+   * solve autoscale the problem
+   */
+  int opt_dbg_optimize_quality;
+
+  /**
+   * solve autoscale the problem
+   */
+  int opt_dbg_optimize_utility;
+
+
+  /**
+   * Output format
+   */
+  enum MLP_Output_Format opt_log_format;
+};
+
+/**
+ * Address specific MLP information
+ */
+struct MLP_information
+{
+
+  /* Bandwidth assigned */
+  struct GNUNET_BANDWIDTH_Value32NBO b_out;
+  struct GNUNET_BANDWIDTH_Value32NBO b_in;
+
+  /* Address selected */
+  int n;
+
+  /* bandwidth column index */
+  signed int c_b;
+
+  /* address usage column */
+  signed int c_n;
+
+  /* row indexes */
+
+  /* constraint 1: bandwidth capping */
+  unsigned int r_c1;
+
+  /* constraint 3: minimum bandwidth */
+  unsigned int r_c3;
+};
+
+
+
+/**
  *
  * NOTE: Do not modify this documentation. This documentation is based on
  * gnunet.org:/vcs/fsnsg/ats-paper.git/tech-doku/ats-tech-guide.tex
@@ -148,6 +540,7 @@
 mlp_term_hook (void *info, const char *s)
 {
   struct GAS_MLP_Handle *mlp = info;
+
   if (mlp->opt_dbg_glpk_verbose)
     LOG (GNUNET_ERROR_TYPE_ERROR, "%s", s);
   return 1;
@@ -237,7 +630,7 @@
  * @param ats_index the ATS index
  * @return string with result
  */
-const char *
+static const char *
 mlp_ats_to_string (int ats_index)
 {
   switch (ats_index) {
@@ -274,7 +667,7 @@
  * @param retcode return code
  * @return string with result
  */
-const char *
+static const char *
 mlp_status_to_string (int retcode)
 {
   switch (retcode) {
@@ -296,12 +689,13 @@
   }
 }
 
+
 /**
  * Translate glpk solver error codes to text
  * @param retcode return code
  * @return string with result
  */
-const char *
+static const char *
 mlp_solve_to_string (int retcode)
 {
   switch (retcode) {
@@ -798,6 +1192,7 @@
   return GNUNET_OK;
 }
 
+
 /**
  * Create the invariant columns c4, c6, c10, c8, c7
  */
@@ -899,7 +1294,7 @@
  * Create the MLP problem
  *
  * @param mlp the MLP handle
- * @return GNUNET_OK or GNUNET_SYSERR
+ * @return #GNUNET_OK or #GNUNET_SYSERR
  */
 static int
 mlp_create_problem (struct GAS_MLP_Handle *mlp)
@@ -972,11 +1367,12 @@
   return res;
 }
 
+
 /**
  * Solves the LP problem
  *
  * @param mlp the MLP Handle
- * @return GNUNET_OK if could be solved, GNUNET_SYSERR on failure
+ * @return #GNUNET_OK if could be solved, #GNUNET_SYSERR on failure
  */
 static int
 mlp_solve_lp_problem (struct GAS_MLP_Handle *mlp)
@@ -1018,7 +1414,7 @@
  * @param value the address
  * @return #GNUNET_OK to continue
  */
-int
+static int
 mlp_propagate_results (void *cls,
                       const struct GNUNET_PeerIdentity *key,
                       void *value)
@@ -1133,16 +1529,20 @@
   return GNUNET_OK;
 }
 
-static void notify (struct GAS_MLP_Handle *mlp,
-    enum GAS_Solver_Operation op,
-    enum GAS_Solver_Status stat,
-    enum GAS_Solver_Additional_Information add)
+
+static void 
+notify (struct GAS_MLP_Handle *mlp,
+       enum GAS_Solver_Operation op,
+       enum GAS_Solver_Status stat,
+       enum GAS_Solver_Additional_Information add)
 {
   if (NULL != mlp->env->info_cb)
     mlp->env->info_cb (mlp->env->info_cb_cls, op, stat, add);
 }
 
-static void mlp_branch_and_cut_cb (glp_tree *tree, void *info)
+
+static void 
+mlp_branch_and_cut_cb (glp_tree *tree, void *info)
 {
   struct GAS_MLP_Handle *mlp = info;
   double mlp_obj = 0;
@@ -1206,9 +1606,9 @@
  * Solves the MLP problem
  *
  * @param solver the MLP Handle
- * @return GNUNET_OK if could be solved, GNUNET_SYSERR on failure
+ * @return #GNUNET_OK if could be solved, #GNUNET_SYSERR on failure
  */
-int
+static int
 GAS_mlp_solve_problem (void *solver)
 {
   struct GAS_MLP_Handle *mlp = solver;
@@ -1516,7 +1916,7 @@
  * @param address the address to add
  * @param network network type of this address
  */
-void
+static void
 GAS_mlp_address_add (void *solver,
                     struct ATS_Address *address,
                     uint32_t network)
@@ -1567,7 +1967,7 @@
  * @param abs_value the absolute value of the property
  * @param rel_value the normalized value
  */
-void
+static void
 GAS_mlp_address_property_changed (void *solver,
                                   struct ATS_Address *address,
                                   uint32_t type,
@@ -1647,7 +2047,7 @@
  * @param cur_session the current session
  * @param new_session the new session
  */
-void
+static void
 GAS_mlp_address_session_changed (void *solver,
                                   struct ATS_Address *address,
                                   uint32_t cur_session,
@@ -1667,7 +2067,7 @@
  * @param address the address
  * @param in_use usage state
  */
-void
+static void
 GAS_mlp_address_inuse_changed (void *solver,
                                struct ATS_Address *address,
                                int in_use)
@@ -1687,7 +2087,7 @@
  * @param current_network the current network
  * @param new_network the new network
  */
-void
+static void
 GAS_mlp_address_change_network (void *solver,
                                struct ATS_Address *address,
                                uint32_t current_network,
@@ -1790,10 +2190,10 @@
  * @param address the address to delete
  * @param session_only delete only session not whole address
  */
-void
+static void
 GAS_mlp_address_delete (void *solver,
-    struct ATS_Address *address,
-    int session_only)
+                       struct ATS_Address *address,
+                       int session_only)
 {
   struct ATS_Peer *p;
   struct GAS_MLP_Handle *mlp = solver;
@@ -1925,7 +2325,7 @@
  * @param peer the peer
  * @return suggested address
  */
-const struct ATS_Address *
+static const struct ATS_Address *
 GAS_mlp_get_preferred_address (void *solver,
                                const struct GNUNET_PeerIdentity *peer)
 {
@@ -1978,7 +2378,7 @@
  *
  * @param solver the solver
  */
-void
+static void
 GAS_mlp_bulk_start (void *solver)
 {
   LOG (GNUNET_ERROR_TYPE_DEBUG, "Locking solver for bulk operation ...\n");
@@ -1989,7 +2389,8 @@
   s->stat_bulk_lock ++;
 }
 
-void
+
+static void
 GAS_mlp_bulk_stop (void *solver)
 {
   LOG (GNUNET_ERROR_TYPE_DEBUG, "Unlocking solver from bulk operation ...\n");
@@ -2019,7 +2420,7 @@
  * @param solver the MLP handle
  * @param peer the peer
  */
-void
+static void
 GAS_mlp_stop_get_preferred_address (void *solver,
                                      const struct GNUNET_PeerIdentity *peer)
 {
@@ -2050,7 +2451,7 @@
  * @param kind the kind to change the preference
  * @param pref_rel the relative score
  */
-void
+static void
 GAS_mlp_address_change_preference (void *solver,
                    const struct GNUNET_PeerIdentity *peer,
                    enum GNUNET_ATS_PreferenceKind kind,
@@ -2097,7 +2498,7 @@
  * @param kind the kind to change the preference
  * @param score the score
  */
-void
+static void
 GAS_mlp_address_preference_feedback (void *solver,
                                     void *application,
                                     const struct GNUNET_PeerIdentity *peer,
@@ -2139,7 +2540,8 @@
   struct GAS_MLP_Handle *mlp = cls;
   GNUNET_assert (mlp != NULL);
 
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "Shutting down mlp solver\n");
+  LOG (GNUNET_ERROR_TYPE_DEBUG, 
+       "Shutting down mlp solver\n");
   mlp_delete_problem (mlp);
 
   GNUNET_CONTAINER_multipeermap_iterate (mlp->requested_peers,
@@ -2152,7 +2554,8 @@
   glp_free_env();
   GNUNET_free (mlp);
 
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "Shutdown down of mlp solver complete\n");
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "Shutdown down of mlp solver complete\n");
   return NULL;
 }
 

Deleted: gnunet/src/ats/plugin_ats_mlp.h
===================================================================
--- gnunet/src/ats/plugin_ats_mlp.h     2014-06-11 15:07:57 UTC (rev 33652)
+++ gnunet/src/ats/plugin_ats_mlp.h     2014-06-12 09:59:00 UTC (rev 33653)
@@ -1,634 +0,0 @@
-/*
- (C) 2011 Christian Grothoff (and other contributing authors)
-
- 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 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.
-
- 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.
- */
-
-/**
- * @file ats/plugin_ats_mlp.h
- * @brief ats MLP problem solver
- * @author Matthias Wachs
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "gnunet_util_lib.h"
-#include "gnunet_ats_service.h"
-#include "gnunet_ats_plugin.h"
-#include "gnunet-service-ats_addresses.h"
-#include "gnunet_statistics_service.h"
-#include <float.h>
-#if HAVE_LIBGLPK
-#include "glpk.h"
-#endif
-
-#ifndef GNUNET_SERVICE_ATS_ADDRESSES_MLP_H
-#define GNUNET_SERVICE_ATS_ADDRESSES_MLP_H
-
-#define BIG_M_VALUE (UINT32_MAX) /10
-#define BIG_M_STRING "unlimited"
-
-#define MLP_AVERAGING_QUEUE_LENGTH 3
-
-#define MLP_MAX_EXEC_DURATION   
GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10)
-#define MLP_MAX_ITERATIONS      4096
-
-#define DEFAULT_D 1.0
-#define DEFAULT_R 1.0
-#define DEFAULT_U 1.0
-#define DEFAULT_QUALITY 1.0
-#define DEFAULT_MIN_CONNECTIONS 4
-#define DEFAULT_PEER_PREFERENCE 1.0
-
-#define MLP_NaN -1
-#define MLP_UNDEFINED 0
-#define GLP_YES 1.0
-#define GLP_NO  0.0
-
-enum MLP_Output_Format
-{
-  MLP_MPS,
-  MLP_CPLEX,
-  MLP_GLPK
-};
-
-
-struct MLP_Solution
-{
-  int lp_res;
-  int lp_presolv;
-  int mip_res;
-  int mip_presolv;
-
-  double lp_objective_value;
-  double mlp_objective_value;
-  double mlp_gap;
-  double lp_mlp_gap;
-
-  int p_elements;
-  int p_cols;
-  int p_rows;
-
-  int n_peers;
-  int n_addresses;
-
-};
-
-struct ATS_Peer
-{
-  struct GNUNET_PeerIdentity id;
-
-  /* Was this peer already added to the current problem? */
-  int processed;
-
-  /* constraint 2: 1 address per peer*/
-  unsigned int r_c2;
-
-  /* constraint 9: relativity */
-  unsigned int r_c9;
-
-  /* Legacy preference value */
-  double f;
-};
-
-struct MLP_Problem
-{
-  /**
-   * GLPK (MLP) problem object
-   */
-#if HAVE_LIBGLPK
-  glp_prob *prob;
-#else
-  void *prob;
-#endif
-
-  /* Number of addresses in problem */
-  unsigned int num_addresses;
-  /* Number of peers in problem */
-  unsigned int num_peers;
-  /* Number of elements in problem matrix */
-  unsigned int num_elements;
-
-  /* Row index constraint 2: */
-  unsigned int r_c2;
-  /* Row index constraint 4: minimum connections */
-  unsigned int r_c4;
-  /* Row index constraint 6: maximize diversity */
-  unsigned int r_c6;
-  /* Row index constraint 8: utilization*/
-  unsigned int r_c8;
-  /* Row index constraint 9: relativity*/
-  unsigned int r_c9;
-  /* Row indices quality metrics  */
-  int r_q[GNUNET_ATS_QualityPropertiesCount];
-  /* Row indices ATS network quotas */
-  int r_quota[GNUNET_ATS_NetworkTypeCount];
-
-  /* Column index Diversity (D) column */
-  int c_d;
-  /* Column index Utilization (U) column */
-  int c_u;
-  /* Column index Proportionality (R) column */
-  int c_r;
-  /* Column index quality metrics  */
-  int c_q[GNUNET_ATS_QualityPropertiesCount];
-
-  /* Problem matrix */
-  /* Current index */
-  unsigned int ci;
-  /* Row index array */
-  int *ia;
-  /* Column index array */
-  int *ja;
-  /* Column index value */
-  double *ar;
-
-};
-
-struct MLP_Variables
-{
-  /* Big M value for bandwidth capping */
-  double BIG_M;
-
-  /* MIP Gap */
-  double mip_gap;
-
-  /* LP MIP Gap */
-  double lp_mip_gap;
-
-  /* ATS Quality metrics
-   *
-   * Array with GNUNET_ATS_QualityPropertiesCount elements
-   * contains mapping to GNUNET_ATS_Property*/
-  int q[GNUNET_ATS_QualityPropertiesCount];
-
-  /* Number of quality metrics */
-  int m_q;
-
-  /* Number of quality metrics */
-  int m_rc;
-
-  /* Quality metric coefficients*/
-  double co_Q[GNUNET_ATS_QualityPropertiesCount];
-
-  /* Ressource costs coefficients*/
-  double co_RC[GNUNET_ATS_QualityPropertiesCount];
-
-  /* Diversity coefficient */
-  double co_D;
-
-  /* Utility coefficient */
-  double co_U;
-
-  /* Relativity coefficient */
-  double co_R;
-
-  /* Minimum bandwidth assigned to an address */
-  unsigned int b_min;
-
-  /* Minimum number of addresses with bandwidth assigned */
-  unsigned int n_min;
-
-  /* Quotas */
-  /* Array mapping array index to ATS network */
-  int quota_index[GNUNET_ATS_NetworkTypeCount];
-  /* Outbound quotas */
-  unsigned long long quota_out[GNUNET_ATS_NetworkTypeCount];
-  /* Inbound quotas */
-
-  unsigned long long quota_in[GNUNET_ATS_NetworkTypeCount];
-
-  /* ATS ressource costs
-   * array with GNUNET_ATS_QualityPropertiesCount elements
-   * contains mapping to GNUNET_ATS_Property
-   * */
-  int rc[GNUNET_ATS_QualityPropertiesCount];
-
-};
-
-/**
- * MLP Handle
- */
-struct GAS_MLP_Handle
-{
-  struct GNUNET_ATS_PluginEnvironment *env;
-
-  /**
-   * Statistics handle
-   */
-  struct GNUNET_STATISTICS_Handle *stats;
-
-  /**
-   * Address hashmap for lookups
-   */
-  const struct GNUNET_CONTAINER_MultiPeerMap *addresses;
-
-  /**
-   * Addresses' bandwidth changed callback
-   */
-  GAS_bandwidth_changed_cb bw_changed_cb;
-
-  /**
-   * Addresses' bandwidth changed callback closure
-   */
-  void *bw_changed_cb_cls;
-
-  /**
-   * ATS function to get preferences
-   */
-  GAS_get_preferences get_preferences;
-
-  /**
-   * Closure for ATS function to get preferences
-   */
-  void *get_preferences_cls;
-
-  /**
-   * ATS function to get properties
-   */
-  GAS_get_properties get_properties;
-
-  /**
-   * Closure for ATS function to get properties
-   */
-  void *get_properties_cls;
-
-  /**
-   * Exclude peer from next result propagation
-   */
-  const struct GNUNET_PeerIdentity *exclude_peer;
-
-  /**
-   * Encapsulation for the MLP problem
-   */
-  struct MLP_Problem p;
-
-  /**
-   * Encapsulation for the MLP problem variables
-   */
-  struct MLP_Variables pv;
-
-  /**
-   * Encapsulation for the MLP solution
-   */
-  struct MLP_Solution ps;
-
-  /**
-   * Bulk lock
-   */
-
-  int stat_bulk_lock;
-
-  /**
-   * Number of changes while solver was locked
-   */
-  int stat_bulk_requests;
-
-  /**
-   * GLPK LP control parameter
-   */
-#if HAVE_LIBGLPK
-  glp_smcp control_param_lp;
-#else
-  void *control_param_lp;
-#endif
-
-  /**
-   * GLPK LP control parameter
-   */
-#if HAVE_LIBGLPK
-  glp_iocp control_param_mlp;
-#else
-  void *control_param_mlp;
-#endif
-
-  /**
-   * Peers with pending address requests
-   */
-  struct GNUNET_CONTAINER_MultiPeerMap *requested_peers;
-
-  /**
-   * Was the problem updated since last solution
-   */
-  int stat_mlp_prob_updated;
-
-  /**
-   * Has the problem size changed since last solution
-   */
-  int stat_mlp_prob_changed;
-
-  /**
-   * Solve the problem automatically when updates occur?
-   * Default: GNUNET_YES
-   * Can be disabled for test and measurements
-   */
-  int opt_mlp_auto_solve;
-
-  /**
-   * Write all MILP problems to a MPS file
-   */
-  int opt_dump_problem_all;
-
-  /**
-   * Write all MILP problem solutions to a file
-   */
-  int opt_dump_solution_all;
-
-  /**
-   * Write MILP problems to a MPS file when solver fails
-   */
-  int opt_dump_problem_on_fail;
-
-  /**
-   * Write MILP problem solutions to a file when solver fails
-   */
-  int opt_dump_solution_on_fail;
-
-  /**
-   * solve feasibility only
-   */
-  int opt_dbg_feasibility_only;
-
-  /**
-   * solve autoscale the problem
-   */
-  int opt_dbg_autoscale_problem;
-
-  /**
-   * use the intopt presolver instead of simplex
-   */
-  int opt_dbg_intopt_presolver;
-
-  /**
-   * Print GLPK output
-   */
-  int opt_dbg_glpk_verbose;
-
-  /**
-   * solve autoscale the problem
-   */
-  int opt_dbg_optimize_relativity;
-
-  /**
-   * solve autoscale the problem
-   */
-  int opt_dbg_optimize_diversity;
-
-  /**
-   * solve autoscale the problem
-   */
-  int opt_dbg_optimize_quality;
-
-  /**
-   * solve autoscale the problem
-   */
-  int opt_dbg_optimize_utility;
-
-
-  /**
-   * Output format
-   */
-  enum MLP_Output_Format opt_log_format;
-};
-
-/**
- * Address specific MLP information
- */
-struct MLP_information
-{
-
-  /* Bandwidth assigned */
-  struct GNUNET_BANDWIDTH_Value32NBO b_out;
-  struct GNUNET_BANDWIDTH_Value32NBO b_in;
-
-  /* Address selected */
-  int n;
-
-  /* bandwidth column index */
-  signed int c_b;
-
-  /* address usage column */
-  signed int c_n;
-
-  /* row indexes */
-
-  /* constraint 1: bandwidth capping */
-  unsigned int r_c1;
-
-  /* constraint 3: minimum bandwidth */
-  unsigned int r_c3;
-};
-
-
-/**
- * Solves the MLP problem
- *
- * @param solver the MLP Handle
- * @return #GNUNET_OK if could be solved, GNUNET_SYSERR on failure
- */
-int
-GAS_mlp_solve_problem (void *solver);
-
-
-/**
- * Init the MLP problem solving component
- *
- * @param cfg the GNUNET_CONFIGURATION_Handle handle
- * @param stats the GNUNET_STATISTICS handle
- * @param addresses Hashmap containing addresses
- * @param network array of GNUNET_ATS_NetworkType with length dest_length
- * @param out_dest array of outbound quotas
- * @param in_dest array of outbound quota
- * @param dest_length array length for quota arrays
- * @param bw_changed_cb callback for changed bandwidth amounts
- * @param bw_changed_cb_cls cls for callback
- * @param get_preference callback to get relative preferences for a peer
- * @param get_preference_cls cls for callback to get relative preferences for 
a peer
- * @param get_properties callback to get relative properties
- * @param get_properties_cls cls for callback to get relative properties
- * @return struct GAS_MLP_Handle on success, NULL on fail
- */
-void *
-GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
-             const struct GNUNET_STATISTICS_Handle *stats,
-              const struct GNUNET_CONTAINER_MultiPeerMap *addresses,
-              int *network,
-              unsigned long long *out_dest,
-              unsigned long long *in_dest,
-              int dest_length,
-              GAS_bandwidth_changed_cb bw_changed_cb,
-              void *bw_changed_cb_cls,
-              GAS_get_preferences get_preference,
-              void *get_preference_cls,
-              GAS_get_properties get_properties,
-              void *get_properties_cls);
-
-
-/**
- * Add a single address within a network to the solver
- *
- * @param solver the solver Handle
- * @param address the address to add
- * @param network network type of this address
- */
-void
-GAS_mlp_address_add (void *solver, struct ATS_Address *address,
-    uint32_t network);
-
-
-/**
- * Transport properties for this address have changed
- *
- * @param solver solver handle
- * @param address the address
- * @param type the ATSI type in HBO
- * @param abs_value the absolute value of the property
- * @param rel_value the normalized value
- */
-void
-GAS_mlp_address_property_changed (void *solver, struct ATS_Address *address,
-    uint32_t type, uint32_t abs_value, double rel_value);
-
-
-/**
- * Transport session for this address has changed
- *
- * NOTE: values in addresses are already updated
- *
- * @param solver solver handle
- * @param address the address
- * @param cur_session the current session
- * @param new_session the new session
- */
-void
-GAS_mlp_address_session_changed (void *solver, struct ATS_Address *address,
-                                uint32_t cur_session, uint32_t new_session);
-
-
-/**
- * Usage for this address has changed
- *
- * NOTE: values in addresses are already updated
- *
- * @param solver solver handle
- * @param address the address
- * @param in_use usage state
- */
-void
-GAS_mlp_address_inuse_changed (void *solver, struct ATS_Address *address,
-    int in_use);
-
-/**
- * Network scope for this address has changed
- *
- * NOTE: values in addresses are already updated
- *
- * @param solver solver handle
- * @param address the address
- * @param current_network the current network
- * @param new_network the new network
- */
-void
-GAS_mlp_address_change_network (void *solver, struct ATS_Address *address,
-    uint32_t current_network, uint32_t new_network);
-
-/**
- * Deletes a single address in the MLP problem
- *
- * The MLP problem has to be recreated and the problem has to be resolved
- *
- * @param solver the MLP Handle
- * @param address the address to delete
- * @param session_only delete only session not whole address
- */
-void
-GAS_mlp_address_delete (void *solver, struct ATS_Address *address,
-    int session_only);
-
-/**
- * Changes the preferences for a peer in the MLP problem
- *
- * @param solver the MLP Handle
- * @param peer the peer
- * @param kind the kind to change the preference
- * @param pref_rel the relative score
- */
-void
-GAS_mlp_address_change_preference (void *solver,
-    const struct GNUNET_PeerIdentity *peer, enum GNUNET_ATS_PreferenceKind 
kind,
-    double pref_rel);
-
-/**
- * Get application feedback for a peer
- *
- * @param solver the solver handle
- * @param application the application
- * @param peer the peer to change the preference for
- * @param scope the time interval for this feedback: [now - scope .. now]
- * @param kind the kind to change the preference
- * @param score the score
- */
-void
-GAS_mlp_address_preference_feedback (void *solver, void *application,
-    const struct GNUNET_PeerIdentity *peer,
-    const struct GNUNET_TIME_Relative scope,
-    enum GNUNET_ATS_PreferenceKind kind, double score);
-
-/**
- * Start a bulk operation
- *
- * @param solver the solver
- */
-void
-GAS_mlp_bulk_start (void *solver);
-
-/**
- * Bulk operation done
- */
-void
-GAS_mlp_bulk_stop (void *solver);
-
-/**
- * Get the preferred address for a specific peer until
- * GAS_mlp_stop_get_preferred_address is called
- *
- * @param solver the MLP Handle
- * @param peer the peer
- * @return suggested address
- */
-const struct ATS_Address *
-GAS_mlp_get_preferred_address (void *solver,
-    const struct GNUNET_PeerIdentity *peer);
-
-/**
- * Stop notifying about address and bandwidth changes for this peer
- *
- * @param solver the MLP handle
- * @param peer the peer
- */
-void
-GAS_mlp_stop_get_preferred_address (void *solver,
-    const struct GNUNET_PeerIdentity *peer);
-
-/**
- * Shutdown the MLP problem solving component
- *
- * @param solver the solver handle
- */
-void
-GAS_mlp_done (void *solver);
-
-#endif
-/* end of plugin_ats_mlp.h */

Modified: gnunet/src/ats/plugin_ats_ril.c
===================================================================
--- gnunet/src/ats/plugin_ats_ril.c     2014-06-11 15:07:57 UTC (rev 33652)
+++ gnunet/src/ats/plugin_ats_ril.c     2014-06-12 09:59:00 UTC (rev 33653)
@@ -1,6 +1,6 @@
 /*
  This file is part of GNUnet.
- (C) 2011 Christian Grothoff (and other contributing authors)
+ (C) 2011-2014 Christian Grothoff (and other contributing authors)
 
  GNUnet is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published
@@ -24,8 +24,14 @@
  * @author Fabian Oehlmann
  * @author Matthias Wachs
  */
-#include "plugin_ats_ril.h"
+#include "platform.h"
+#include <float.h>
+#include <math.h>
+#include "gnunet_ats_plugin.h"
+#include "gnunet-service-ats_addresses.h"
 
+
+
 #define LOG(kind,...) GNUNET_log_from (kind, "ats-ril",__VA_ARGS__)
 
 #define RIL_MIN_BW                      (5 * ntohl 
(GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__))
@@ -2130,11 +2136,11 @@
  * @param kind the kind to change the preference
  * @param pref_rel the normalized preference value for this kind over all 
clients
  */
-void
+static void
 GAS_ril_address_change_preference (void *solver,
-    const struct GNUNET_PeerIdentity *peer,
-    enum GNUNET_ATS_PreferenceKind kind,
-    double pref_rel)
+                                  const struct GNUNET_PeerIdentity *peer,
+                                  enum GNUNET_ATS_PreferenceKind kind,
+                                  double pref_rel)
 {
   LOG(GNUNET_ERROR_TYPE_DEBUG,
       "API_address_change_preference() Preference '%s' for peer '%s' changed 
to %.2f \n",
@@ -2147,310 +2153,8 @@
   ril_step (s);
 }
 
-/**
- * Entry point for the plugin
- *
- * @param cls pointer to the 'struct GNUNET_ATS_PluginEnvironment'
- */
-void *
-libgnunet_plugin_ats_ril_init (void *cls)
-{
-  struct GNUNET_ATS_PluginEnvironment *env = cls;
-  struct GAS_RIL_Handle *solver = GNUNET_new (struct GAS_RIL_Handle);
-  struct RIL_Scope * cur;
-  int c;
-  char *string;
-  float f_tmp;
 
-  LOG(GNUNET_ERROR_TYPE_DEBUG, "API_init() Initializing RIL solver\n");
-
-  GNUNET_assert(NULL != env);
-  GNUNET_assert(NULL != env->cfg);
-  GNUNET_assert(NULL != env->stats);
-  GNUNET_assert(NULL != env->bandwidth_changed_cb);
-  GNUNET_assert(NULL != env->get_preferences);
-  GNUNET_assert(NULL != env->get_property);
-
-  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number(env->cfg, "ats", 
"RIL_RBF_DIVISOR", &solver->parameters.rbf_divisor))
-  {
-    solver->parameters.rbf_divisor = RIL_DEFAULT_RBF_DIVISOR;
-  }
-
-  if (GNUNET_OK
-      != GNUNET_CONFIGURATION_get_value_time (env->cfg, "ats", 
"RIL_STEP_TIME_MIN",
-          &solver->parameters.step_time_min))
-  {
-    solver->parameters.step_time_min = RIL_DEFAULT_STEP_TIME_MIN;
-  }
-
-  if (GNUNET_OK
-      != GNUNET_CONFIGURATION_get_value_time (env->cfg, "ats", 
"RIL_STEP_TIME_MAX",
-          &solver->parameters.step_time_max))
-  {
-    solver->parameters.step_time_max = RIL_DEFAULT_STEP_TIME_MAX;
-  }
-
-  if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (env->cfg, "ats", 
"RIL_ALGORITHM", &string))
-  {
-    solver->parameters.algorithm = !strcmp (string, "SARSA") ? RIL_ALGO_SARSA 
: RIL_ALGO_Q;
-    GNUNET_free (string);
-  }
-  else
-  {
-    solver->parameters.algorithm = RIL_DEFAULT_ALGORITHM;
-  }
-
-  if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (env->cfg, "ats", 
"RIL_SELECT", &string))
-  {
-    solver->parameters.select = !strcmp (string, "EGREEDY") ? 
RIL_SELECT_EGREEDY : RIL_SELECT_SOFTMAX;
-    GNUNET_free (string);
-  }
-  else
-  {
-    solver->parameters.select = RIL_DEFAULT_SELECT;
-  }
-
-
-  solver->parameters.beta = RIL_DEFAULT_DISCOUNT_BETA;
-  if (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_float (env->cfg, "ats",
-      "RIL_DISCOUNT_BETA", &f_tmp))
-  {
-    if (f_tmp < 0.0)
-    {
-      LOG (GNUNET_ERROR_TYPE_ERROR, _("Invalid %s configuration %f \n"),
-          "RIL_DISCOUNT_BETA", f_tmp);
-    }
-    else
-    {
-      solver->parameters.beta = f_tmp;
-      LOG (GNUNET_ERROR_TYPE_INFO, "Using %s of %.3f\n",
-          "RIL_DISCOUNT_BETA", f_tmp);
-    }
-  }
-
-  solver->parameters.gamma = RIL_DEFAULT_DISCOUNT_GAMMA;
-  if (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_float (env->cfg, "ats",
-      "RIL_DISCOUNT_GAMMA", &f_tmp))
-  {
-    if ((f_tmp < 0.0) || (f_tmp > 1.0))
-    {
-      LOG (GNUNET_ERROR_TYPE_ERROR, _("Invalid %s configuration %f \n"),
-          "RIL_DISCOUNT_GAMMA", f_tmp);
-    }
-    else
-    {
-      solver->parameters.gamma = f_tmp;
-      LOG (GNUNET_ERROR_TYPE_INFO, "Using %s of %.3f\n",
-          "RIL_DISCOUNT_GAMMA", f_tmp);
-    }
-  }
-
-  solver->parameters.alpha = RIL_DEFAULT_GRADIENT_STEP_SIZE;
-  if (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_float (env->cfg, "ats",
-      "RIL_GRADIENT_STEP_SIZE", &f_tmp))
-  {
-    if ((f_tmp < 0.0) || (f_tmp > 1.0))
-    {
-      LOG (GNUNET_ERROR_TYPE_ERROR, _("Invalid %s configuration %f \n"),
-          "RIL_GRADIENT_STEP_SIZE", f_tmp);
-    }
-    else
-    {
-      solver->parameters.alpha = f_tmp;
-      LOG (GNUNET_ERROR_TYPE_INFO, "Using %s of %.3f\n",
-          "RIL_GRADIENT_STEP_SIZE", f_tmp);
-    }
-  }
-
-  solver->parameters.lambda = RIL_DEFAULT_TRACE_DECAY;
-  if (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_float (env->cfg, "ats",
-      "RIL_TRACE_DECAY", &f_tmp))
-  {
-    if ((f_tmp < 0.0) || (f_tmp > 1.0))
-    {
-      LOG (GNUNET_ERROR_TYPE_ERROR, _("Invalid %s configuration %f \n"),
-          "RIL_TRACE_DECAY", f_tmp);
-    }
-    else
-    {
-      solver->parameters.lambda = f_tmp;
-      LOG (GNUNET_ERROR_TYPE_INFO, "Using %s of %.3f\n",
-          "RIL_TRACE_DECAY", f_tmp);
-    }
-  }
-
-  solver->parameters.epsilon_init = RIL_DEFAULT_EXPLORE_RATIO;
-  if (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_float (env->cfg, "ats",
-      "RIL_EXPLORE_RATIO", &f_tmp))
-  {
-    if ((f_tmp < 0.0) || (f_tmp > 1.0))
-    {
-      LOG (GNUNET_ERROR_TYPE_ERROR, _("Invalid %s configuration %f \n"),
-          "RIL_EXPLORE_RATIO", f_tmp);
-    }
-    else
-    {
-      solver->parameters.epsilon_init = f_tmp;
-      LOG (GNUNET_ERROR_TYPE_INFO, "Using %s of %.3f\n",
-          "RIL_EXPLORE_RATIO", f_tmp);
-    }
-  }
-
-  solver->parameters.epsilon_decay = RIL_DEFAULT_EXPLORE_DECAY;
-  if (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_float (env->cfg, "ats",
-      "RIL_EXPLORE_DECAY", &f_tmp))
-  {
-    if ((f_tmp < 0.0) || (f_tmp > 0.0))
-    {
-      LOG (GNUNET_ERROR_TYPE_ERROR, _("Invalid %s configuration %f \n"),
-          "RIL_EXPLORE_DECAY", f_tmp);
-    }
-    else
-    {
-      solver->parameters.epsilon_decay = f_tmp;
-      LOG (GNUNET_ERROR_TYPE_INFO, "Using %s of %.3f\n",
-          "RIL_EXPLORE_DECAY", f_tmp);
-    }
-  }
-
-  solver->parameters.temperature_init = RIL_DEFAULT_TEMPERATURE;
-  if (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_float (env->cfg, "ats",
-      "RIL_TEMPERATURE", &f_tmp))
-  {
-    if (f_tmp <= 0.0)
-    {
-      LOG (GNUNET_ERROR_TYPE_ERROR, _("Invalid %s configuration %f \n"),
-          "RIL_TEMPERATURE", f_tmp);
-    }
-    else
-    {
-      solver->parameters.temperature_init = f_tmp;
-      LOG (GNUNET_ERROR_TYPE_INFO, "Using %s of %.3f\n",
-          "RIL_TEMPERATURE", f_tmp);
-    }
-  }
-
-  solver->parameters.temperature_decay = RIL_DEFAULT_TEMPERATURE_DECAY;
-  if (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_float (env->cfg, "ats",
-      "RIL_TEMPERATURE_DECAY", &f_tmp))
-  {
-    if ((f_tmp <= 0.0) || solver->parameters.temperature_decay > 1)
-    {
-      LOG (GNUNET_ERROR_TYPE_ERROR, _("Invalid %s configuration %f \n"),
-          "RIL_TEMPERATURE_DECAY", f_tmp);
-    }
-    else
-    {
-      solver->parameters.temperature_decay = f_tmp;
-      LOG (GNUNET_ERROR_TYPE_INFO, "Using %s of %.3f\n",
-          "RIL_TEMPERATURE_DECAY", f_tmp);
-    }
-  }
-
-  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (env->cfg, "ats", 
"RIL_SIMULATE", &solver->simulate))
-  {
-    solver->simulate = GNUNET_NO;
-  }
-
-  if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno(env->cfg, "ats", 
"RIL_REPLACE_TRACES"))
-  {
-    solver->parameters.eligibility_trace_mode = RIL_E_REPLACE;
-  }
-  else
-  {
-    solver->parameters.eligibility_trace_mode = RIL_E_ACCUMULATE;
-  }
-
-  if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (env->cfg, "ats", 
"RIL_SOCIAL_WELFARE", &string))
-  {
-    solver->parameters.social_welfare = !strcmp (string, "NASH") ? 
RIL_WELFARE_NASH : RIL_WELFARE_EGALITARIAN;
-    GNUNET_free (string);
-  }
-  else
-  {
-    solver->parameters.social_welfare = RIL_DEFAULT_WELFARE;
-  }
-
-  env->sf.s_add = &GAS_ril_address_add;
-  env->sf.s_address_update_property = &GAS_ril_address_property_changed;
-  env->sf.s_address_update_session = &GAS_ril_address_session_changed;
-  env->sf.s_address_update_inuse = &GAS_ril_address_inuse_changed;
-  env->sf.s_address_update_network = &GAS_ril_address_change_network;
-  env->sf.s_get = &GAS_ril_get_preferred_address;
-  env->sf.s_get_stop = &GAS_ril_stop_get_preferred_address;
-  env->sf.s_pref = &GAS_ril_address_change_preference;
-  env->sf.s_feedback = &GAS_ril_address_preference_feedback;
-  env->sf.s_del = &GAS_ril_address_delete;
-  env->sf.s_bulk_start = &GAS_ril_bulk_start;
-  env->sf.s_bulk_stop = &GAS_ril_bulk_stop;
-
-  solver->plugin_envi = env;
-  solver->networks_count = env->network_count;
-  solver->network_entries = GNUNET_malloc (env->network_count * sizeof (struct 
RIL_Scope));
-  solver->step_count = 0;
-  solver->done = GNUNET_NO;
-
-  for (c = 0; c < env->network_count; c++)
-  {
-    cur = &solver->network_entries[c];
-    cur->type = env->networks[c];
-    cur->bw_in_available = env->in_quota[c];
-    cur->bw_out_available = env->out_quota[c];
-    LOG(GNUNET_ERROR_TYPE_DEBUG, "init()  Quotas for %s network:  IN %llu - 
OUT %llu\n", GNUNET_ATS_print_network_type(cur->type), 
cur->bw_in_available/1024, cur->bw_out_available/1024);
-  }
-
-  LOG(GNUNET_ERROR_TYPE_DEBUG, "init()  Parameters:\n");
-  LOG(GNUNET_ERROR_TYPE_DEBUG, "init()  Algorithm = %s, alpha = %f, beta = %f, 
lambda = %f\n",
-      solver->parameters.algorithm ? "Q" : "SARSA",
-      solver->parameters.alpha,
-      solver->parameters.beta,
-      solver->parameters.lambda);
-  LOG(GNUNET_ERROR_TYPE_DEBUG, "init()  exploration_ratio = %f, temperature = 
%f, ActionSelection = %s\n",
-      solver->parameters.epsilon,
-      solver->parameters.temperature,
-      solver->parameters.select ? "EGREEDY" : "SOFTMAX");
-  LOG(GNUNET_ERROR_TYPE_DEBUG, "init()  RBF_DIVISOR = %llu\n",
-      solver->parameters.rbf_divisor);
-
-  return solver;
-}
-
 /**
- * Exit point for the plugin
- *
- * @param cls the solver handle
- */
-void *
-libgnunet_plugin_ats_ril_done (void *cls)
-{
-  struct GAS_RIL_Handle *s = cls;
-  struct RIL_Peer_Agent *cur_agent;
-  struct RIL_Peer_Agent *next_agent;
-
-  LOG(GNUNET_ERROR_TYPE_DEBUG, "API_done() Shutting down RIL solver\n");
-
-  s->done = GNUNET_YES;
-
-  cur_agent = s->agents_head;
-  while (NULL != cur_agent)
-  {
-    next_agent = cur_agent->next;
-    GNUNET_CONTAINER_DLL_remove(s->agents_head, s->agents_tail, cur_agent);
-    agent_die (s, cur_agent);
-    cur_agent = next_agent;
-  }
-
-  if (GNUNET_SCHEDULER_NO_TASK != s->step_next_task_id)
-  {
-    GNUNET_SCHEDULER_cancel (s->step_next_task_id);
-  }
-  GNUNET_free(s->network_entries);
-  GNUNET_free(s);
-
-  return NULL;
-}
-
-/**
  * Add a new address for a peer to the solver
  *
  * The address is already contained in the addresses hashmap!
@@ -2459,8 +2163,10 @@
  * @param address the address to add
  * @param network network type of this address
  */
-void
-GAS_ril_address_add (void *solver, struct ATS_Address *address, uint32_t 
network)
+static void
+GAS_ril_address_add (void *solver, 
+                    struct ATS_Address *address,
+                    uint32_t network)
 {
   struct GAS_RIL_Handle *s = solver;
   struct RIL_Peer_Agent *agent;
@@ -2473,7 +2179,8 @@
   int i;
   unsigned int zero;
 
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "API_address_add()\n");
+  LOG (GNUNET_ERROR_TYPE_DEBUG, 
+       "API_address_add()\n");
 
   net = ril_get_network (s, network);
   address->solver_information = net;
@@ -2545,8 +2252,10 @@
  * @param address the address to remove
  * @param session_only delete only session not whole address
  */
-void
-GAS_ril_address_delete (void *solver, struct ATS_Address *address, int 
session_only)
+static void
+GAS_ril_address_delete (void *solver,
+                       struct ATS_Address *address, 
+                       int session_only)
 {
   struct GAS_RIL_Handle *s = solver;
   struct RIL_Peer_Agent *agent;
@@ -2558,9 +2267,11 @@
   int i;
   struct RIL_Scope *net;
 
-  LOG(GNUNET_ERROR_TYPE_DEBUG, "API_address_delete() Delete %s%s %s address %s 
for peer '%s'\n",
-      session_only ? "session for " : "", address->active ? "active" : 
"inactive", address->plugin,
-      address->addr, GNUNET_i2s (&address->peer));
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "API_address_delete() Delete %s%s %s address %s for peer '%s'\n",
+       session_only ? "session for " : "", address->active ? "active" : 
"inactive", address->plugin,
+       address->addr, 
+       GNUNET_i2s (&address->peer));
 
   agent = ril_get_agent (s, &address->peer, GNUNET_NO);
   if (NULL == agent)
@@ -2649,25 +2360,29 @@
  * @param abs_value the absolute value of the property
  * @param rel_value the normalized value
  */
-void
+static void
 GAS_ril_address_property_changed (void *solver,
-    struct ATS_Address *address,
-    uint32_t type,
-    uint32_t abs_value,
-    double rel_value)
+                                 struct ATS_Address *address,
+                                 uint32_t type,
+                                 uint32_t abs_value,
+                                 double rel_value)
 {
+  struct GAS_RIL_Handle *s = solver;
+
   LOG(GNUNET_ERROR_TYPE_DEBUG,
       "API_address_property_changed() Property '%s' for peer '%s' address %s 
changed "
-          "to %.2f \n", GNUNET_ATS_print_property_type (type), GNUNET_i2s 
(&address->peer),
+          "to %.2f \n", 
+      GNUNET_ATS_print_property_type (type),
+      GNUNET_i2s (&address->peer),
       address->addr, rel_value);
 
-  struct GAS_RIL_Handle *s = solver;
 
   s->parameters.temperature = s->parameters.temperature_init;
   s->parameters.epsilon = s->parameters.epsilon_init;
   ril_step (s);
 }
 
+
 /**
  * Update the session of an address in the solver
  *
@@ -2678,15 +2393,17 @@
  * @param cur_session the current session
  * @param new_session the new session
  */
-void
+static void
 GAS_ril_address_session_changed (void *solver,
-    struct ATS_Address *address,
-    uint32_t cur_session,
-    uint32_t new_session)
+                                struct ATS_Address *address,
+                                uint32_t cur_session,
+                                uint32_t new_session)
 {
-  LOG(GNUNET_ERROR_TYPE_DEBUG, "API_address_session_changed()\n");
+  LOG(GNUNET_ERROR_TYPE_DEBUG,
+      "API_address_session_changed()\n");
 }
 
+
 /**
  * Notify the solver that an address is (not) actively used by transport
  * to communicate with a remote peer
@@ -2697,14 +2414,17 @@
  * @param address the address
  * @param in_use usage state
  */
-void
-GAS_ril_address_inuse_changed (void *solver, struct ATS_Address *address, int 
in_use)
+static void
+GAS_ril_address_inuse_changed (void *solver,
+                              struct ATS_Address *address,
+                              int in_use)
 {
   LOG(GNUNET_ERROR_TYPE_DEBUG,
       "API_address_inuse_changed() Usage for %s address of peer '%s' changed 
to %s\n",
       address->plugin, GNUNET_i2s (&address->peer), (GNUNET_YES == in_use) ? 
"USED" : "UNUSED");
 }
 
+
 /**
  * Notify solver that the network an address is located in has changed
  *
@@ -2715,16 +2435,17 @@
  * @param current_network the current network
  * @param new_network the new network
  */
-void
+static void
 GAS_ril_address_change_network (void *solver,
-    struct ATS_Address *address,
-    uint32_t current_network,
-    uint32_t new_network)
+                               struct ATS_Address *address,
+                               uint32_t current_network,
+                               uint32_t new_network)
 {
   struct GAS_RIL_Handle *s = solver;
   struct RIL_Peer_Agent *agent;
 
-  LOG(GNUNET_ERROR_TYPE_DEBUG, "API_address_change_network() Network type 
changed, moving "
+  LOG(GNUNET_ERROR_TYPE_DEBUG, 
+      "API_address_change_network() Network type changed, moving "
       "%s address of peer %s from '%s' to '%s'\n",
       (GNUNET_YES == address->active) ? "active" : "inactive", GNUNET_i2s 
(&address->peer),
       GNUNET_ATS_print_network_type (current_network), 
GNUNET_ATS_print_network_type (new_network));
@@ -2750,6 +2471,7 @@
   address->solver_information = ril_get_network(solver, new_network);
 }
 
+
 /**
  * Give feedback about the current assignment
  *
@@ -2760,7 +2482,7 @@
  * @param kind the kind to change the preference
  * @param score the score
  */
-void
+static void
 GAS_ril_address_preference_feedback (void *solver,
     void *application,
     const struct GNUNET_PeerIdentity *peer,
@@ -2774,32 +2496,37 @@
       GNUNET_ATS_print_preference_type (kind), scope.rel_value_us / 1000000);
 }
 
+
 /**
  * Start a bulk operation
  *
  * @param solver the solver
  */
-void
+static void
 GAS_ril_bulk_start (void *solver)
 {
   struct GAS_RIL_Handle *s = solver;
 
-  LOG(GNUNET_ERROR_TYPE_DEBUG, "API_bulk_start() lock: %d\n", s->bulk_lock+1);
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "API_bulk_start() lock: %d\n", s->bulk_lock+1);
 
   s->bulk_lock++;
 }
 
+
 /**
  * Bulk operation done
  *
  * @param solver the solver handle
  */
-void
+static void
 GAS_ril_bulk_stop (void *solver)
 {
   struct GAS_RIL_Handle *s = solver;
 
-  LOG(GNUNET_ERROR_TYPE_DEBUG, "API_bulk_stop() lock: %d\n", s->bulk_lock-1);
+  LOG(GNUNET_ERROR_TYPE_DEBUG, 
+      "API_bulk_stop() lock: %d\n", 
+      s->bulk_lock - 1);
 
   if (s->bulk_lock < 1)
   {
@@ -2815,6 +2542,7 @@
   }
 }
 
+
 /**
  * Tell solver to notify ATS if the address to use changes for a specific
  * peer using the bandwidth changed callback
@@ -2825,8 +2553,9 @@
  * @param solver the solver handle
  * @param peer the identity of the peer
  */
-const struct ATS_Address *
-GAS_ril_get_preferred_address (void *solver, const struct GNUNET_PeerIdentity 
*peer)
+static const struct ATS_Address *
+GAS_ril_get_preferred_address (void *solver,
+                              const struct GNUNET_PeerIdentity *peer)
 {
   struct GAS_RIL_Handle *s = solver;
   struct RIL_Peer_Agent *agent;
@@ -2866,13 +2595,15 @@
  * @param solver the solver handle
  * @param peer the peer
  */
-void
-GAS_ril_stop_get_preferred_address (void *solver, const struct 
GNUNET_PeerIdentity *peer)
+static void
+GAS_ril_stop_get_preferred_address (void *solver,
+                                   const struct GNUNET_PeerIdentity *peer)
 {
   struct GAS_RIL_Handle *s = solver;
   struct RIL_Peer_Agent *agent;
 
-  LOG(GNUNET_ERROR_TYPE_DEBUG, "API_stop_get_preferred_address()");
+  LOG (GNUNET_ERROR_TYPE_DEBUG, 
+       "API_stop_get_preferred_address()");
 
   agent = ril_get_agent (s, peer, GNUNET_NO);
 
@@ -2902,4 +2633,310 @@
       GNUNET_i2s (peer), agent->address_inuse->plugin);
 }
 
+
+/**
+ * Entry point for the plugin
+ *
+ * @param cls pointer to the 'struct GNUNET_ATS_PluginEnvironment'
+ */
+void *
+libgnunet_plugin_ats_ril_init (void *cls)
+{
+  struct GNUNET_ATS_PluginEnvironment *env = cls;
+  struct GAS_RIL_Handle *solver = GNUNET_new (struct GAS_RIL_Handle);
+  struct RIL_Scope * cur;
+  int c;
+  char *string;
+  float f_tmp;
+
+  LOG(GNUNET_ERROR_TYPE_DEBUG, "API_init() Initializing RIL solver\n");
+
+  GNUNET_assert(NULL != env);
+  GNUNET_assert(NULL != env->cfg);
+  GNUNET_assert(NULL != env->stats);
+  GNUNET_assert(NULL != env->bandwidth_changed_cb);
+  GNUNET_assert(NULL != env->get_preferences);
+  GNUNET_assert(NULL != env->get_property);
+
+  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number(env->cfg, "ats", 
"RIL_RBF_DIVISOR", &solver->parameters.rbf_divisor))
+  {
+    solver->parameters.rbf_divisor = RIL_DEFAULT_RBF_DIVISOR;
+  }
+
+  if (GNUNET_OK
+      != GNUNET_CONFIGURATION_get_value_time (env->cfg, "ats", 
"RIL_STEP_TIME_MIN",
+          &solver->parameters.step_time_min))
+  {
+    solver->parameters.step_time_min = RIL_DEFAULT_STEP_TIME_MIN;
+  }
+
+  if (GNUNET_OK
+      != GNUNET_CONFIGURATION_get_value_time (env->cfg, "ats", 
"RIL_STEP_TIME_MAX",
+          &solver->parameters.step_time_max))
+  {
+    solver->parameters.step_time_max = RIL_DEFAULT_STEP_TIME_MAX;
+  }
+
+  if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (env->cfg, "ats", 
"RIL_ALGORITHM", &string))
+  {
+    solver->parameters.algorithm = !strcmp (string, "SARSA") ? RIL_ALGO_SARSA 
: RIL_ALGO_Q;
+    GNUNET_free (string);
+  }
+  else
+  {
+    solver->parameters.algorithm = RIL_DEFAULT_ALGORITHM;
+  }
+
+  if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (env->cfg, "ats", 
"RIL_SELECT", &string))
+  {
+    solver->parameters.select = !strcmp (string, "EGREEDY") ? 
RIL_SELECT_EGREEDY : RIL_SELECT_SOFTMAX;
+    GNUNET_free (string);
+  }
+  else
+  {
+    solver->parameters.select = RIL_DEFAULT_SELECT;
+  }
+
+
+  solver->parameters.beta = RIL_DEFAULT_DISCOUNT_BETA;
+  if (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_float (env->cfg, "ats",
+      "RIL_DISCOUNT_BETA", &f_tmp))
+  {
+    if (f_tmp < 0.0)
+    {
+      LOG (GNUNET_ERROR_TYPE_ERROR, _("Invalid %s configuration %f \n"),
+          "RIL_DISCOUNT_BETA", f_tmp);
+    }
+    else
+    {
+      solver->parameters.beta = f_tmp;
+      LOG (GNUNET_ERROR_TYPE_INFO, "Using %s of %.3f\n",
+          "RIL_DISCOUNT_BETA", f_tmp);
+    }
+  }
+
+  solver->parameters.gamma = RIL_DEFAULT_DISCOUNT_GAMMA;
+  if (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_float (env->cfg, "ats",
+      "RIL_DISCOUNT_GAMMA", &f_tmp))
+  {
+    if ((f_tmp < 0.0) || (f_tmp > 1.0))
+    {
+      LOG (GNUNET_ERROR_TYPE_ERROR, _("Invalid %s configuration %f \n"),
+          "RIL_DISCOUNT_GAMMA", f_tmp);
+    }
+    else
+    {
+      solver->parameters.gamma = f_tmp;
+      LOG (GNUNET_ERROR_TYPE_INFO, "Using %s of %.3f\n",
+          "RIL_DISCOUNT_GAMMA", f_tmp);
+    }
+  }
+
+  solver->parameters.alpha = RIL_DEFAULT_GRADIENT_STEP_SIZE;
+  if (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_float (env->cfg, "ats",
+      "RIL_GRADIENT_STEP_SIZE", &f_tmp))
+  {
+    if ((f_tmp < 0.0) || (f_tmp > 1.0))
+    {
+      LOG (GNUNET_ERROR_TYPE_ERROR, _("Invalid %s configuration %f \n"),
+          "RIL_GRADIENT_STEP_SIZE", f_tmp);
+    }
+    else
+    {
+      solver->parameters.alpha = f_tmp;
+      LOG (GNUNET_ERROR_TYPE_INFO, "Using %s of %.3f\n",
+          "RIL_GRADIENT_STEP_SIZE", f_tmp);
+    }
+  }
+
+  solver->parameters.lambda = RIL_DEFAULT_TRACE_DECAY;
+  if (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_float (env->cfg, "ats",
+      "RIL_TRACE_DECAY", &f_tmp))
+  {
+    if ((f_tmp < 0.0) || (f_tmp > 1.0))
+    {
+      LOG (GNUNET_ERROR_TYPE_ERROR, _("Invalid %s configuration %f \n"),
+          "RIL_TRACE_DECAY", f_tmp);
+    }
+    else
+    {
+      solver->parameters.lambda = f_tmp;
+      LOG (GNUNET_ERROR_TYPE_INFO, "Using %s of %.3f\n",
+          "RIL_TRACE_DECAY", f_tmp);
+    }
+  }
+
+  solver->parameters.epsilon_init = RIL_DEFAULT_EXPLORE_RATIO;
+  if (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_float (env->cfg, "ats",
+      "RIL_EXPLORE_RATIO", &f_tmp))
+  {
+    if ((f_tmp < 0.0) || (f_tmp > 1.0))
+    {
+      LOG (GNUNET_ERROR_TYPE_ERROR, _("Invalid %s configuration %f \n"),
+          "RIL_EXPLORE_RATIO", f_tmp);
+    }
+    else
+    {
+      solver->parameters.epsilon_init = f_tmp;
+      LOG (GNUNET_ERROR_TYPE_INFO, "Using %s of %.3f\n",
+          "RIL_EXPLORE_RATIO", f_tmp);
+    }
+  }
+
+  solver->parameters.epsilon_decay = RIL_DEFAULT_EXPLORE_DECAY;
+  if (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_float (env->cfg, "ats",
+      "RIL_EXPLORE_DECAY", &f_tmp))
+  {
+    if ((f_tmp < 0.0) || (f_tmp > 0.0))
+    {
+      LOG (GNUNET_ERROR_TYPE_ERROR, _("Invalid %s configuration %f \n"),
+          "RIL_EXPLORE_DECAY", f_tmp);
+    }
+    else
+    {
+      solver->parameters.epsilon_decay = f_tmp;
+      LOG (GNUNET_ERROR_TYPE_INFO, "Using %s of %.3f\n",
+          "RIL_EXPLORE_DECAY", f_tmp);
+    }
+  }
+
+  solver->parameters.temperature_init = RIL_DEFAULT_TEMPERATURE;
+  if (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_float (env->cfg, "ats",
+      "RIL_TEMPERATURE", &f_tmp))
+  {
+    if (f_tmp <= 0.0)
+    {
+      LOG (GNUNET_ERROR_TYPE_ERROR, _("Invalid %s configuration %f \n"),
+          "RIL_TEMPERATURE", f_tmp);
+    }
+    else
+    {
+      solver->parameters.temperature_init = f_tmp;
+      LOG (GNUNET_ERROR_TYPE_INFO, "Using %s of %.3f\n",
+          "RIL_TEMPERATURE", f_tmp);
+    }
+  }
+
+  solver->parameters.temperature_decay = RIL_DEFAULT_TEMPERATURE_DECAY;
+  if (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_float (env->cfg, "ats",
+      "RIL_TEMPERATURE_DECAY", &f_tmp))
+  {
+    if ((f_tmp <= 0.0) || solver->parameters.temperature_decay > 1)
+    {
+      LOG (GNUNET_ERROR_TYPE_ERROR, _("Invalid %s configuration %f \n"),
+          "RIL_TEMPERATURE_DECAY", f_tmp);
+    }
+    else
+    {
+      solver->parameters.temperature_decay = f_tmp;
+      LOG (GNUNET_ERROR_TYPE_INFO, "Using %s of %.3f\n",
+          "RIL_TEMPERATURE_DECAY", f_tmp);
+    }
+  }
+
+  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (env->cfg, "ats", 
"RIL_SIMULATE", &solver->simulate))
+  {
+    solver->simulate = GNUNET_NO;
+  }
+
+  if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno(env->cfg, "ats", 
"RIL_REPLACE_TRACES"))
+  {
+    solver->parameters.eligibility_trace_mode = RIL_E_REPLACE;
+  }
+  else
+  {
+    solver->parameters.eligibility_trace_mode = RIL_E_ACCUMULATE;
+  }
+
+  if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (env->cfg, "ats", 
"RIL_SOCIAL_WELFARE", &string))
+  {
+    solver->parameters.social_welfare = !strcmp (string, "NASH") ? 
RIL_WELFARE_NASH : RIL_WELFARE_EGALITARIAN;
+    GNUNET_free (string);
+  }
+  else
+  {
+    solver->parameters.social_welfare = RIL_DEFAULT_WELFARE;
+  }
+
+  env->sf.s_add = &GAS_ril_address_add;
+  env->sf.s_address_update_property = &GAS_ril_address_property_changed;
+  env->sf.s_address_update_session = &GAS_ril_address_session_changed;
+  env->sf.s_address_update_inuse = &GAS_ril_address_inuse_changed;
+  env->sf.s_address_update_network = &GAS_ril_address_change_network;
+  env->sf.s_get = &GAS_ril_get_preferred_address;
+  env->sf.s_get_stop = &GAS_ril_stop_get_preferred_address;
+  env->sf.s_pref = &GAS_ril_address_change_preference;
+  env->sf.s_feedback = &GAS_ril_address_preference_feedback;
+  env->sf.s_del = &GAS_ril_address_delete;
+  env->sf.s_bulk_start = &GAS_ril_bulk_start;
+  env->sf.s_bulk_stop = &GAS_ril_bulk_stop;
+
+  solver->plugin_envi = env;
+  solver->networks_count = env->network_count;
+  solver->network_entries = GNUNET_malloc (env->network_count * sizeof (struct 
RIL_Scope));
+  solver->step_count = 0;
+  solver->done = GNUNET_NO;
+
+  for (c = 0; c < env->network_count; c++)
+  {
+    cur = &solver->network_entries[c];
+    cur->type = env->networks[c];
+    cur->bw_in_available = env->in_quota[c];
+    cur->bw_out_available = env->out_quota[c];
+    LOG(GNUNET_ERROR_TYPE_DEBUG, "init()  Quotas for %s network:  IN %llu - 
OUT %llu\n", GNUNET_ATS_print_network_type(cur->type), 
cur->bw_in_available/1024, cur->bw_out_available/1024);
+  }
+
+  LOG(GNUNET_ERROR_TYPE_DEBUG, "init()  Parameters:\n");
+  LOG(GNUNET_ERROR_TYPE_DEBUG, "init()  Algorithm = %s, alpha = %f, beta = %f, 
lambda = %f\n",
+      solver->parameters.algorithm ? "Q" : "SARSA",
+      solver->parameters.alpha,
+      solver->parameters.beta,
+      solver->parameters.lambda);
+  LOG(GNUNET_ERROR_TYPE_DEBUG, "init()  exploration_ratio = %f, temperature = 
%f, ActionSelection = %s\n",
+      solver->parameters.epsilon,
+      solver->parameters.temperature,
+      solver->parameters.select ? "EGREEDY" : "SOFTMAX");
+  LOG(GNUNET_ERROR_TYPE_DEBUG, "init()  RBF_DIVISOR = %llu\n",
+      solver->parameters.rbf_divisor);
+
+  return solver;
+}
+
+
+/**
+ * Exit point for the plugin
+ *
+ * @param cls the solver handle
+ */
+void *
+libgnunet_plugin_ats_ril_done (void *cls)
+{
+  struct GAS_RIL_Handle *s = cls;
+  struct RIL_Peer_Agent *cur_agent;
+  struct RIL_Peer_Agent *next_agent;
+
+  LOG(GNUNET_ERROR_TYPE_DEBUG, "API_done() Shutting down RIL solver\n");
+
+  s->done = GNUNET_YES;
+
+  cur_agent = s->agents_head;
+  while (NULL != cur_agent)
+  {
+    next_agent = cur_agent->next;
+    GNUNET_CONTAINER_DLL_remove(s->agents_head, s->agents_tail, cur_agent);
+    agent_die (s, cur_agent);
+    cur_agent = next_agent;
+  }
+
+  if (GNUNET_SCHEDULER_NO_TASK != s->step_next_task_id)
+  {
+    GNUNET_SCHEDULER_cancel (s->step_next_task_id);
+  }
+  GNUNET_free(s->network_entries);
+  GNUNET_free(s);
+
+  return NULL;
+}
+
+
 /* end of plugin_ats_ril.c */

Deleted: gnunet/src/ats/plugin_ats_ril.h
===================================================================
--- gnunet/src/ats/plugin_ats_ril.h     2014-06-11 15:07:57 UTC (rev 33652)
+++ gnunet/src/ats/plugin_ats_ril.h     2014-06-12 09:59:00 UTC (rev 33653)
@@ -1,191 +0,0 @@
-/*
- This file is part of GNUnet.
- (C) 2011 Christian Grothoff (and other contributing authors)
-
- 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 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.
-
- 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.
- */
-
-/**
- * @file ats/plugin_ats_ril.h
- * @brief ATS reinforcement learning solver
- * @author Fabian Oehlmann
- * @author Matthias Wachs
- */
-#include "platform.h"
-#include <float.h>
-#include <math.h>
-#include "gnunet_ats_plugin.h"
-#include "gnunet-service-ats_addresses.h"
-
-/**
- * ATS reinforcement learning solver
- *
- * General description
- */
-
-/**
- * Changes the preferences for a peer in the problem
- *
- * @param solver the solver handle
- * @param peer the peer to change the preference for
- * @param kind the kind to change the preference
- * @param pref_rel the normalized preference value for this kind over all 
clients
- */
-void
-GAS_ril_address_change_preference (void *solver,
-    const struct GNUNET_PeerIdentity *peer,
-    enum GNUNET_ATS_PreferenceKind kind,
-    double pref_rel);
-
-/**
- * Add a single address within a network to the solver
- *
- * @param solver the solver Handle
- * @param address the address to add
- * @param network network type of this address
- */
-void
-GAS_ril_address_add (void *solver,
-    struct ATS_Address *address,
-    uint32_t network);
-
-/**
- * Transport properties for this address have changed
- *
- * @param solver solver handle
- * @param address the address
- * @param type the ATSI type in HBO
- * @param abs_value the absolute value of the property
- * @param rel_value the normalized value
- */
-void
-GAS_ril_address_property_changed (void *solver,
-    struct ATS_Address *address,
-    uint32_t type,
-    uint32_t abs_value,
-    double rel_value);
-
-/**
- * Transport session for this address has changed
- *
- * NOTE: values in addresses are already updated
- *
- * @param solver solver handle
- * @param address the address
- * @param cur_session the current session
- * @param new_session the new session
- */
-void
-GAS_ril_address_session_changed (void *solver,
-    struct ATS_Address *address,
-    uint32_t cur_session,
-    uint32_t new_session);
-
-/**
- * Usage for this address has changed
- *
- * NOTE: values in addresses are already updated
- *
- * @param solver solver handle
- * @param address the address
- * @param in_use usage state
- */
-void
-GAS_ril_address_inuse_changed (void *solver,
-    struct ATS_Address *address,
-    int in_use);
-
-/**
- * Network scope for this address has changed
- *
- * NOTE: values in addresses are already updated
- *
- * @param solver solver handle
- * @param address the address
- * @param current_network the current network
- * @param new_network the new network
- */
-void
-GAS_ril_address_change_network (void *solver,
-    struct ATS_Address *address,
-    uint32_t current_network,
-    uint32_t new_network);
-
-/**
- * Remove an address from the solver
- *
- * @param solver the solver handle
- * @param address the address to remove
- * @param session_only delete only session not whole address
- */
-void
-GAS_ril_address_delete (void *solver,
-    struct ATS_Address *address,
-    int session_only);
-
-/**
- * Get application feedback for a peer
- *
- * @param solver the solver handle
- * @param application the application
- * @param peer the peer to change the preference for
- * @param scope the time interval for this feedback: [now - scope .. now]
- * @param kind the kind to change the preference
- * @param score the score
- */
-void
-GAS_ril_address_preference_feedback (void *solver,
-    void *application,
-    const struct GNUNET_PeerIdentity *peer,
-    const struct GNUNET_TIME_Relative scope,
-    enum GNUNET_ATS_PreferenceKind kind,
-    double score);
-
-/**
- * Start a bulk operation
- *
- * @param solver the solver
- */
-void
-GAS_ril_bulk_start (void *solver);
-
-/**
- * Bulk operation done
- */
-void
-GAS_ril_bulk_stop (void *solver);
-
-/**
- * Stop notifying about address and bandwidth changes for this peer
- *
- * @param solver the solver handle
- * @param peer the peer
- */
-void
-GAS_ril_stop_get_preferred_address (void *solver,
-    const struct GNUNET_PeerIdentity *peer);
-
-/**
- * Get the prefered address for a specific peer
- *
- * @param solver the solver handle
- * @param peer the identity of the peer
- */
-const struct ATS_Address *
-GAS_ril_get_preferred_address (void *solver,
-    const struct GNUNET_PeerIdentity *peer);
-
-/* end of plugin_ats_ril.h */

Modified: gnunet-fuse/src/fuse/gnunet-fuse.c
===================================================================
--- gnunet-fuse/src/fuse/gnunet-fuse.c  2014-06-11 15:07:57 UTC (rev 33652)
+++ gnunet-fuse/src/fuse/gnunet-fuse.c  2014-06-12 09:59:00 UTC (rev 33653)
@@ -262,7 +262,7 @@
     GNUNET_mutex_lock (parent->lock);
   }
 
-  pi = GNUNET_malloc (sizeof (struct GNUNET_FUSE_PathInfo));
+  pi = GNUNET_new (struct GNUNET_FUSE_PathInfo);
   pi->parent = parent;
   pi->filename = GNUNET_strdup (filename);
   len = strlen (pi->filename);

Modified: gnunet-fuse/src/fuse/mutex.c
===================================================================
--- gnunet-fuse/src/fuse/mutex.c        2014-06-11 15:07:57 UTC (rev 33652)
+++ gnunet-fuse/src/fuse/mutex.c        2014-06-12 09:59:00 UTC (rev 33653)
@@ -91,7 +91,7 @@
                     (&attr, PTHREAD_MUTEX_ERRORCHECK));
 #endif
     }
-  mut = GNUNET_malloc (sizeof (struct GNUNET_Mutex));
+  mut = GNUNET_new (struct GNUNET_Mutex);
   GNUNET_assert (0 == pthread_mutex_init (&mut->pt, &attr));
   return mut;
 }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]