aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2011-04-12 16:20:32 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2011-04-12 16:20:32 +0000
commitd1012f124a152d33d686487d16c0d2cb64121927 (patch)
tree1376f3453775eb4d1df595bfe19abc3905b9f865 /src/transport
parent69d570f81ce13fa8e15d02b11a4766cc6cf02e24 (diff)
downloadgnunet-d1012f124a152d33d686487d16c0d2cb64121927.tar.gz
gnunet-d1012f124a152d33d686487d16c0d2cb64121927.zip
finished: rebuilding problem only when peers (dis)connect
starting: modififying matrix when qm and cr changes
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/gnunet-service-transport.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index d7fa8ea66..80bdb8edf 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -879,6 +879,13 @@ struct ATS_result
879{ 879{
880 int c_mechs; 880 int c_mechs;
881 int c_peers; 881 int c_peers;
882
883 int begin_qm;
884 int end_qm;
885
886 int begin_cr;
887 int end_cr;
888
882 int solution; 889 int solution;
883 int valid; 890 int valid;
884}; 891};
@@ -5883,7 +5890,7 @@ static void ats_solve_problem (unsigned int max_it, unsigned int max_dur, unsig
5883 5890
5884 // Solving simplex 5891 // Solving simplex
5885 glp_prob *prob = ats->prob; 5892 glp_prob *prob = ats->prob;
5886 /* 5893
5887 glp_smcp opt_lp; 5894 glp_smcp opt_lp;
5888 glp_init_smcp(&opt_lp); 5895 glp_init_smcp(&opt_lp);
5889#if VERBOSE_ATS 5896#if VERBOSE_ATS
@@ -5891,17 +5898,17 @@ static void ats_solve_problem (unsigned int max_it, unsigned int max_dur, unsig
5891#else 5898#else
5892 opt_lp.msg_lev = GLP_MSG_OFF; 5899 opt_lp.msg_lev = GLP_MSG_OFF;
5893#endif 5900#endif
5894 opt_lp.presolve = GLP_ON; 5901 //opt_lp.presolve = GLP_ON;
5895 result = glp_simplex(prob, &opt_lp); 5902 result = glp_simplex(prob, &opt_lp);
5896 solution = glp_get_status (prob); 5903 solution = glp_get_status (prob);
5897 5904
5898 if (GNUNET_YES == ats_evaluate_results(result, solution, "LP")) 5905 if (GNUNET_YES == ats_evaluate_results(result, solution, "LP"))
5899 {*/ 5906 {
5900 /* Solving mlp */ 5907 /* Solving mlp */
5901 glp_iocp opt_mlp; 5908 glp_iocp opt_mlp;
5902 glp_init_iocp(&opt_mlp); 5909 glp_init_iocp(&opt_mlp);
5903 /* maximum duration */ 5910 /* maximum duration */
5904 opt_mlp.presolve = GLP_ON; 5911 //opt_mlp.presolve = GLP_ON;
5905 opt_mlp.tm_lim = max_dur; 5912 opt_mlp.tm_lim = max_dur;
5906 /* output level */ 5913 /* output level */
5907#if VERBOSE_ATS 5914#if VERBOSE_ATS
@@ -5916,14 +5923,14 @@ static void ats_solve_problem (unsigned int max_it, unsigned int max_dur, unsig
5916 if (ats_evaluate_results(result, solution, "MLP") == GNUNET_YES) 5923 if (ats_evaluate_results(result, solution, "MLP") == GNUNET_YES)
5917 res->valid = GNUNET_YES; 5924 res->valid = GNUNET_YES;
5918 /* done */ 5925 /* done */
5919 //} 5926 }
5920 5927
5921 if ((ats->save_mlp == GNUNET_YES) && (c_peers > 1)) 5928 if ((ats->save_mlp == GNUNET_YES) && (c_peers > 1))
5922 { 5929 {
5923 char * filename; 5930 char * filename;
5924 GNUNET_asprintf (&filename, "ats_mlp_p%i_m%i_llu.mlp",c_peers, c_mechs, GNUNET_TIME_absolute_get().abs_value); 5931 GNUNET_asprintf (&filename, "ats_mlp_p%i_m%i_%llu.mlp",c_peers, c_mechs, GNUNET_TIME_absolute_get().abs_value);
5925 if (GNUNET_NO == GNUNET_DISK_file_test(filename)) 5932 if (GNUNET_NO == GNUNET_DISK_file_test(filename))
5926 glp_write_mip (prob, filename); 5933 glp_write_lp (prob, NULL, filename);
5927 GNUNET_free (filename); 5934 GNUNET_free (filename);
5928 } 5935 }
5929 if ((ats->save_solution == GNUNET_YES) && (c_peers > 1)) 5936 if ((ats->save_solution == GNUNET_YES) && (c_peers > 1))
@@ -6205,12 +6212,14 @@ static int ats_create_problem (double D, double U, double R, int v_b_min, int v_
6205 } 6212 }
6206 int c2; 6213 int c2;
6207 /* Constraint 4: max ressource capacity */ 6214 /* Constraint 4: max ressource capacity */
6208 /* V cr: bt * ct_r <= cr_maxsolution 6215 /* V cr: bt * ct_r <= cr_max
6209 * */ 6216 * */
6210 glp_add_rows(ats->prob, available_ressources); 6217 glp_add_rows(ats->prob, available_ressources);
6211 double ct_max = VERY_BIG_DOUBLE_VALUE; 6218 double ct_max = VERY_BIG_DOUBLE_VALUE;
6212 double ct_min = 0.0; 6219 double ct_min = 0.0;
6213 6220
6221 res->begin_cr = array_index;
6222
6214 for (c=0; c<available_ressources; c++) 6223 for (c=0; c<available_ressources; c++)
6215 { 6224 {
6216 ct_max = ressources[c].c_max; 6225 ct_max = ressources[c].c_max;
@@ -6234,6 +6243,7 @@ static int ats_create_problem (double D, double U, double R, int v_b_min, int v_
6234 } 6243 }
6235 row_index ++; 6244 row_index ++;
6236 } 6245 }
6246 res->end_cr = array_index--;
6237 6247
6238 /* Constraint 5: min number of connections*/ 6248 /* Constraint 5: min number of connections*/
6239 glp_add_rows(ats->prob, 1); 6249 glp_add_rows(ats->prob, 1);
@@ -6308,6 +6318,7 @@ static int ats_create_problem (double D, double U, double R, int v_b_min, int v_
6308 6318
6309 // Constraint 7: optimize for quality 6319 // Constraint 7: optimize for quality
6310 glp_add_rows(ats->prob, available_quality_metrics); 6320 glp_add_rows(ats->prob, available_quality_metrics);
6321 res->begin_qm = array_index;
6311 for (c=1; c <= c_q_metrics; c++) 6322 for (c=1; c <= c_q_metrics; c++)
6312 { 6323 {
6313#if VERBOSE_ATS 6324#if VERBOSE_ATS
@@ -6362,6 +6373,7 @@ static int ats_create_problem (double D, double U, double R, int v_b_min, int v_
6362 array_index++; 6373 array_index++;
6363 row_index++; 6374 row_index++;
6364 } 6375 }
6376 res->end_qm = array_index--;
6365 6377
6366 // Constraint 8: optimize bandwidth utility 6378 // Constraint 8: optimize bandwidth utility
6367 glp_add_rows(ats->prob, 1); 6379 glp_add_rows(ats->prob, 1);