aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2011-03-29 20:47:08 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2011-03-29 20:47:08 +0000
commit3cb79372f5ef535042f9599c41f1cb01f732be4a (patch)
tree04a082f141cebd14c9e1f9dbda55b41799782f2e
parent7b5a560a6b822e8ad2e32fd7e3f0bf0e0030844e (diff)
downloadgnunet-3cb79372f5ef535042f9599c41f1cb01f732be4a.tar.gz
gnunet-3cb79372f5ef535042f9599c41f1cb01f732be4a.zip
more changes for ats
-rw-r--r--src/transport/gnunet-service-transport.c58
1 files changed, 53 insertions, 5 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index da563e091..71faab685 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -5589,6 +5589,7 @@ static int ats_create_problem (int max_it, int max_dur )
5589 5589
5590 glp_prob *prob; 5590 glp_prob *prob;
5591 5591
5592 int c;
5592 int c_peers = 0; 5593 int c_peers = 0;
5593 int c_mechs = 0; 5594 int c_mechs = 0;
5594 int result; 5595 int result;
@@ -5600,6 +5601,15 @@ static int ats_create_problem (int max_it, int max_dur )
5600 double v_n_min = 2; 5601 double v_n_min = 2;
5601 double M = 1000000000; 5602 double M = 1000000000;
5602 5603
5604 double D = 1;
5605 double U = 1;
5606 double R = 1;
5607 double Q[c_q_metrics+1];
5608 for (c=1; c<=c_q_metrics; c++)
5609 {
5610 Q[c] = 1;
5611 }
5612
5603 struct NeighbourList *next = neighbours; 5613 struct NeighbourList *next = neighbours;
5604 while (next!=NULL) 5614 while (next!=NULL)
5605 { 5615 {
@@ -5681,7 +5691,6 @@ static int ats_create_problem (int max_it, int max_dur )
5681 glp_set_obj_dir(prob, GLP_MAX); 5691 glp_set_obj_dir(prob, GLP_MAX);
5682 5692
5683 /* adding columns */ 5693 /* adding columns */
5684 int c;
5685 char * name; 5694 char * name;
5686 glp_add_cols(prob, 2 * c_mechs); 5695 glp_add_cols(prob, 2 * c_mechs);
5687 for (c=1; c <= c_mechs; c++) 5696 for (c=1; c <= c_mechs; c++)
@@ -5693,10 +5702,10 @@ static int ats_create_problem (int max_it, int max_dur )
5693 glp_set_obj_coef(prob, c, 1.0); 5702 glp_set_obj_coef(prob, c, 1.0);
5694 5703
5695 } 5704 }
5696 for (c=c_mechs; c <= 2*c_mechs; c++) 5705 for (c=c_mechs+1; c <= 2*c_mechs; c++)
5697 { 5706 {
5698 GNUNET_asprintf(&name, "n%i",c); 5707 GNUNET_asprintf(&name, "n%i",(c-c_mechs)+1);
5699 glp_set_col_name(prob, c, "n1"); 5708 glp_set_col_name(prob, c, name);
5700 glp_set_col_bnds(prob, c, GLP_DB, 0.0, 1.0); 5709 glp_set_col_bnds(prob, c, GLP_DB, 0.0, 1.0);
5701 glp_set_col_kind(prob, c, GLP_IV); 5710 glp_set_col_kind(prob, c, GLP_IV);
5702 glp_set_obj_coef(prob, c, 1.0); 5711 glp_set_obj_coef(prob, c, 1.0);
@@ -5820,6 +5829,31 @@ static int ats_create_problem (int max_it, int max_dur )
5820 GNUNET_assert (row_index-1==c_peers+(2*c_mechs)+1); 5829 GNUNET_assert (row_index-1==c_peers+(2*c_mechs)+1);
5821 GNUNET_assert (array_index==6*c_mechs); 5830 GNUNET_assert (array_index==6*c_mechs);
5822 5831
5832 /* optimisation constraints*/
5833
5834 /* adding columns */
5835 glp_add_cols(prob, 3 + c_q_metrics);
5836 glp_set_col_name(prob, (2*c_mechs) + 1, "d");
5837 glp_set_obj_coef(prob, (2*c_mechs) + 1, D);
5838 //glp_set_col_bnds(prob, c, GLP_DB, 0.0, 1.0);
5839 //glp_set_col_kind(prob, c, GLP_IV);
5840 glp_set_col_name(prob, (2*c_mechs) + 2, "u");
5841 glp_set_obj_coef(prob, (2*c_mechs) + 2, U);
5842 //glp_set_col_bnds(prob, c, GLP_DB, 0.0, 1.0);
5843 //glp_set_col_kind(prob, c, GLP_IV);
5844 glp_set_col_name(prob, (2*c_mechs) + 3, "r");
5845 glp_set_obj_coef(prob, (2*c_mechs) + 3, R);
5846 //glp_set_col_bnds(prob, c, GLP_DB, 0.0, 1.0);
5847 //glp_set_col_kind(prob, c, GLP_IV);
5848 for (c=1; c<= c_q_metrics; c++)
5849 {
5850 GNUNET_asprintf(&name, "q%i",c);
5851 glp_set_col_name(prob, c, name);
5852 GNUNET_free (name);
5853 glp_set_col_name(prob, (2*c_mechs) + 3 +c, "q");
5854 glp_set_obj_coef(prob, (2*c_mechs) + 3 +c, Q[c]);
5855 }
5856
5823 glp_load_matrix(prob, array_index-1, ia, ja, ar); 5857 glp_load_matrix(prob, array_index-1, ia, ja, ar);
5824 5858
5825 /* Solve the LP problem */ 5859 /* Solve the LP problem */
@@ -5878,6 +5912,20 @@ static int ats_create_problem (int max_it, int max_dur )
5878 break; 5912 break;
5879 } 5913 }
5880 5914
5915 char * debug_solution = NULL;
5916 char * old = NULL;
5917 for (c=1; c<= 2*c_mechs; c++ )
5918 {
5919 old = debug_solution;
5920 GNUNET_asprintf(&debug_solution, "%s %s = %g;", (debug_solution!=NULL) ? debug_solution : "", glp_get_col_name(prob,c), glp_get_col_prim(prob, c));
5921 if (old!=NULL) GNUNET_free(old);
5922 }
5923 old = debug_solution;
5924 GNUNET_asprintf(&debug_solution, "%s z = %g; \n", debug_solution, glp_get_obj_val(prob));
5925 if (old!=NULL) GNUNET_free(old);
5926 if (DEBUG_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s \n",debug_solution);
5927 GNUNET_free(debug_solution);
5928
5881 glp_delete_prob(prob); 5929 glp_delete_prob(prob);
5882 5930
5883 /* clean up */ 5931 /* clean up */
@@ -5956,7 +6004,7 @@ void ats_benchmark (int peers, int transports, int start_peers, int end_peers)
5956 6004
5957 duration = GNUNET_TIME_absolute_get_difference(start,GNUNET_TIME_absolute_get()); 6005 duration = GNUNET_TIME_absolute_get_difference(start,GNUNET_TIME_absolute_get());
5958 6006
5959 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "benchmark execution time in [ms] for %i mechanisms: %llu\n", c_mechs, duration.rel_value); 6007 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP execution time in [ms] for %i mechanisms: %llu\n", c_mechs, duration.rel_value);
5960 6008
5961 GNUNET_STATISTICS_set (stats, "ATS execution time 100 peers", duration.rel_value, GNUNET_NO); 6009 GNUNET_STATISTICS_set (stats, "ATS execution time 100 peers", duration.rel_value, GNUNET_NO);
5962} 6010}