aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2011-03-30 15:27:52 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2011-03-30 15:27:52 +0000
commitf8b496014cede5649ce1a545d54ad63b81b7da7f (patch)
tree0fe10b2c0cad737b032c87d95f7f664e7cc2fa90 /src/transport
parent5d665839858da08ee47cd724faed399b6bfde7fd (diff)
downloadgnunet-f8b496014cede5649ce1a545d54ad63b81b7da7f.tar.gz
gnunet-f8b496014cede5649ce1a545d54ad63b81b7da7f.zip
constraint 8
Diffstat (limited to 'src/transport')
-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 e75720aaa..87fb1d34d 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -5651,6 +5651,8 @@ static int ats_create_problem (int max_it, int max_dur )
5651 peers[c_peers].peer = next->id; 5651 peers[c_peers].peer = next->id;
5652 peers[c_peers].m_head = NULL; 5652 peers[c_peers].m_head = NULL;
5653 peers[c_peers].m_tail = NULL; 5653 peers[c_peers].m_tail = NULL;
5654 // FIXME
5655 peers[c_peers].f = 1.0 / c_mechs;
5654 5656
5655 struct ReadyList *r_next = next->plugins; 5657 struct ReadyList *r_next = next->plugins;
5656 while (r_next != NULL) 5658 while (r_next != NULL)
@@ -5687,7 +5689,7 @@ static int ats_create_problem (int max_it, int max_dur )
5687 5689
5688 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Creating problem with: %i peers, %i mechanisms\n", c_peers, c_mechs); 5690 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Creating problem with: %i peers, %i mechanisms\n", c_peers, c_mechs);
5689 5691
5690 int size = 1 + 7 *c_mechs +1; 5692 int size = 1 + 8 *c_mechs +2;
5691 int row_index; 5693 int row_index;
5692 int array_index=1; 5694 int array_index=1;
5693 int * ia = GNUNET_malloc (size * sizeof (int)); 5695 int * ia = GNUNET_malloc (size * sizeof (int));
@@ -5848,11 +5850,12 @@ static int ats_create_problem (int max_it, int max_dur )
5848 glp_set_col_bnds(prob, (2*c_mechs) + 1, GLP_LO, 0.0, 0); 5850 glp_set_col_bnds(prob, (2*c_mechs) + 1, GLP_LO, 0.0, 0);
5849 //glp_set_col_kind(prob, c, GLP_IV); 5851 //glp_set_col_kind(prob, c, GLP_IV);
5850 glp_set_col_name(prob, (2*c_mechs) + 2, "u"); 5852 glp_set_col_name(prob, (2*c_mechs) + 2, "u");
5851 glp_set_obj_coef(prob, (2*c_mechs) + 2, 0); 5853 glp_set_obj_coef(prob, (2*c_mechs) + 2, U);
5854 glp_set_col_bnds(prob, (2*c_mechs) + 2, GLP_LO, 0.0, 0);
5852 //glp_set_col_bnds(prob, c, GLP_DB, 0.0, 1.0); 5855 //glp_set_col_bnds(prob, c, GLP_DB, 0.0, 1.0);
5853 //glp_set_col_kind(prob, c, GLP_IV); 5856 //glp_set_col_kind(prob, c, GLP_IV);
5854 glp_set_col_name(prob, (2*c_mechs) + 3, "r"); 5857 glp_set_col_name(prob, (2*c_mechs) + 3, "r");
5855 glp_set_obj_coef(prob, (2*c_mechs) + 3, 0); 5858 glp_set_obj_coef(prob, (2*c_mechs) + 3, R);
5856 //glp_set_col_bnds(prob, (2*c_mechs) + 3, GLP_DB, 0.0, 100.0); 5859 //glp_set_col_bnds(prob, (2*c_mechs) + 3, GLP_DB, 0.0, 100.0);
5857 //glp_set_col_kind(prob, c, GLP_IV); 5860 //glp_set_col_kind(prob, c, GLP_IV);
5858 for (c=1; c<= c_q_metrics; c++) 5861 for (c=1; c<= c_q_metrics; c++)
@@ -5879,19 +5882,64 @@ static int ats_create_problem (int max_it, int max_dur )
5879 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]); 5882 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]);
5880 array_index++; 5883 array_index++;
5881 } 5884 }
5882
5883 ia[array_index] = row_index; 5885 ia[array_index] = row_index;
5884 ja[array_index] = (2*c_mechs) + 1; 5886 ja[array_index] = (2*c_mechs) + 1;
5885 ar[array_index] = -1; 5887 ar[array_index] = -1;
5886
5887 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]); 5888 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]);
5888 array_index++; 5889 array_index++;
5889 row_index ++; 5890 row_index ++;
5891 GNUNET_assert (row_index-1==c_peers+(2*c_mechs)+2);
5892 GNUNET_assert (array_index-1==7*c_mechs+1);
5890 5893
5894 // Constraint 7: optimize for quality
5895 /*
5896 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Constraint 7\n");
5897 glp_add_rows(prob, 1);
5898 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "bounds [row]=[%i] \n",row_index);
5899 glp_set_row_bnds(prob, row_index, GLP_FX, 0.0, 0.0);
5900 //glp_set_row_bnds(prob, row_index, GLP_UP, 0.0, 0.0);
5901 for (c=1; c<=c_mechs; c++)
5902 {
5903 // b_t - n_t * b_min >= 0
5904 ia[array_index] = row_index;
5905 ja[array_index] = c_mechs + mechanisms[c].col_index;
5906 ar[array_index] = 1;
5907 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]);
5908 array_index++;
5909 }
5910 ia[array_index] = row_index;
5911 ja[array_index] = (2*c_mechs) + 1;
5912 ar[array_index] = -1;
5913 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]);
5914 array_index++;
5915 row_index ++;
5891 GNUNET_assert (row_index-1==c_peers+(2*c_mechs)+2); 5916 GNUNET_assert (row_index-1==c_peers+(2*c_mechs)+2);
5892 GNUNET_assert (array_index-1==7*c_mechs+1); 5917 GNUNET_assert (array_index-1==7*c_mechs+1);
5918 */
5919
5920 // Constraint 8: optimize bandwidth utility
5921 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Constraint 8\n");
5922 glp_add_rows(prob, 1);
5923 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "bounds [row]=[%i] \n",row_index);
5924 glp_set_row_bnds(prob, row_index, GLP_FX, 0.0, 0.0);
5925 for (c=1; c<=c_mechs; c++)
5926 {
5927 ia[array_index] = row_index;
5928 ja[array_index] = c;
5929 ar[array_index] = mechanisms[c].peer->f;
5930 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]);
5931 array_index++;
5932 }
5933 ia[array_index] = row_index;
5934 ja[array_index] = (2*c_mechs) + 2;
5935 ar[array_index] = -1;
5936 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]);
5893 5937
5938 array_index++;
5939 row_index ++;
5894 5940
5941 GNUNET_assert (row_index-1==c_peers+(2*c_mechs)+3);
5942 GNUNET_assert (array_index-1==8*c_mechs+2);
5895 5943
5896 glp_load_matrix(prob, array_index-1, ia, ja, ar); 5944 glp_load_matrix(prob, array_index-1, ia, ja, ar);
5897 5945