Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Platform generation : Add 2 topology setup functions
authorJean-Baptiste Hervé <jean-baptiste.herve@esial.net>
Fri, 27 Jul 2012 09:53:34 +0000 (11:53 +0200)
committerJean-Baptiste Hervé <jean-baptiste.herve@esial.net>
Fri, 27 Jul 2012 09:53:34 +0000 (11:53 +0200)
Add the "heavy tailed" positionning for the nodes, and the "line" connection between them

include/simgrid/platf_generator.h
src/surf/platf_generator.c
src/surf/platf_generator_private.h

index a1012c5..3b89513 100644 (file)
@@ -20,9 +20,11 @@ typedef enum {
 
 XBT_PUBLIC(void) platf_random_seed(unsigned long seed[6]);
 
-XBT_PUBLIC(void) platf_graph_uniform(int node_count);
+XBT_PUBLIC(void) platf_graph_uniform(unsigned long node_count);
+XBT_PUBLIC(void) platf_graph_heavytailed(unsigned long node_count);
 
 XBT_PUBLIC(void) platf_graph_interconnect_star(void);
+XBT_PUBLIC(void) platf_graph_interconnect_line(void);
 
 // WARNING : Only for debbugging ; should be removed when platform
 // generation works correctly
index 3a2e44b..693e169 100644 (file)
@@ -1,9 +1,10 @@
 
 
-#include <simgrid/platf_generator.h>
+#include "simgrid/platf_generator.h"
 #include "platf_generator_private.h"
-#include <xbt.h>
-#include <xbt/RngStream.h>
+#include "xbt.h"
+#include "xbt/RngStream.h"
+#include <math.h>
 
 static xbt_graph_t platform_graph = NULL;
 
@@ -78,8 +79,22 @@ void platf_graph_uniform(unsigned long node_count) {
   }
 }
 
-void platf_graph_interconnect_star(void) {
+void platf_graph_heavytailed(unsigned long node_count) {
+  xbt_dynar_t dynar_nodes = NULL;
+  xbt_node_t graph_node = NULL;
+  context_node_t node_data = NULL;
+  unsigned int i;
+  platf_graph_init(node_count);
+  dynar_nodes = xbt_graph_get_nodes(platform_graph);
+  xbt_dynar_foreach(dynar_nodes, i, graph_node) {
+    node_data = (context_node_t) xbt_graph_node_get_data(graph_node);
+    node_data->x = random_pareto(0, 1, 1.0/*K*/, 10e9/*P*/, 1.0/*alpha*/);
+    node_data->y = random_pareto(0, 1, 1.0/*K*/, 10e9/*P*/, 1.0/*alpha*/);
+  }
+}
 
+void platf_graph_interconnect_star(void) {
+  /* All the nodes are connected to the first one */
   xbt_dynar_t dynar_nodes = NULL;
   xbt_node_t graph_node = NULL;
   xbt_node_t first_node = NULL;
@@ -96,3 +111,34 @@ void platf_graph_interconnect_star(void) {
     }
   }
 }
+
+void platf_graph_interconnect_line(void) {
+  /* Node are connected to the previous and the next node, in a line */
+  xbt_dynar_t dynar_nodes = NULL;
+  xbt_node_t graph_node = NULL;
+  xbt_node_t old_node = NULL;
+  unsigned int i;
+
+  dynar_nodes = xbt_graph_get_nodes(platform_graph);
+  xbt_dynar_foreach(dynar_nodes, i, graph_node) {
+    if(old_node != NULL) {
+      platf_node_connect(graph_node, old_node);
+    }
+    old_node = graph_node;
+  }
+}
+
+
+
+/* Functions used to generate interesting random values */
+
+double random_pareto(double min, double max, double K, double P, double ALPHA) {
+  double x = RngStream_RandU01(rng_stream);
+  double den = pow(1.0 - x + x*pow(K/P, ALPHA), 1.0/ALPHA);
+  double res = (1/den);
+  res += min - 1; // pareto is on [1, infinity) by default
+  if (res>max) {
+    return max;
+  }
+  return res;
+}
index 77bba79..a1a430f 100644 (file)
@@ -10,8 +10,10 @@ typedef struct {
   e_platf_node_kind kind;
 } s_context_node_t, *context_node_t;
 
-void platf_graph_init(int node_count);
+void platf_graph_init(unsigned long node_count);
 
 void platf_node_connect(xbt_node_t node1, xbt_node_t node2);
 
+double random_pareto(double min, double max, double K, double P, double ALPHA);
+
 #endif      /* SG_PLATF_GEN_PRIVATE_H */