aboutsummaryrefslogtreecommitdiff
path: root/src/ats
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2014-05-13 19:18:09 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2014-05-13 19:18:09 +0000
commitc273677dba890bab5fc60215c55c2a5b949ea601 (patch)
tree3ae090cd8e172c015729c8e55f5b433eebfb68b1 /src/ats
parentcd0227d96dda179b959cdf752f7b2f72223b649c (diff)
downloadgnunet-c273677dba890bab5fc60215c55c2a5b949ea601.tar.gz
gnunet-c273677dba890bab5fc60215c55c2a5b949ea601.zip
option to disable objectives
Diffstat (limited to 'src/ats')
-rw-r--r--src/ats/plugin_ats_mlp.c173
-rw-r--r--src/ats/plugin_ats_mlp.h24
2 files changed, 140 insertions, 57 deletions
diff --git a/src/ats/plugin_ats_mlp.c b/src/ats/plugin_ats_mlp.c
index 4780daa8a..385b14a16 100644
--- a/src/ats/plugin_ats_mlp.c
+++ b/src/ats/plugin_ats_mlp.c
@@ -633,8 +633,10 @@ mlp_create_problem_add_address_information (void *cls,
633 char *name; 633 char *name;
634 const double *props; 634 const double *props;
635 double cur_bigm; 635 double cur_bigm;
636
636 uint32_t addr_net; 637 uint32_t addr_net;
637 uint32_t addr_net_index; 638 uint32_t addr_net_index;
639 unsigned long long max_quota;
638 int c; 640 int c;
639 641
640 /* Check if we have to add this peer due to a pending request */ 642 /* Check if we have to add this peer due to a pending request */
@@ -662,6 +664,20 @@ mlp_create_problem_add_address_information (void *cls,
662 return GNUNET_OK; 664 return GNUNET_OK;
663 } 665 }
664 666
667 max_quota = 0;
668 for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++)
669 {
670 if (mlp->pv.quota_out[c] > max_quota)
671 max_quota = mlp->pv.quota_out[c];
672 if (mlp->pv.quota_in[c] > max_quota)
673 max_quota = mlp->pv.quota_in[c];
674 }
675 if (max_quota > mlp->pv.BIG_M)
676 cur_bigm = (double) mlp->pv.BIG_M;
677 else
678 cur_bigm = max_quota;
679
680
665 /* Get peer */ 681 /* Get peer */
666 peer = GNUNET_CONTAINER_multipeermap_get (mlp->requested_peers, key); 682 peer = GNUNET_CONTAINER_multipeermap_get (mlp->requested_peers, key);
667 if (peer->processed == GNUNET_NO) 683 if (peer->processed == GNUNET_NO)
@@ -673,12 +689,15 @@ mlp_create_problem_add_address_information (void *cls,
673 GNUNET_free (name); 689 GNUNET_free (name);
674 if (GNUNET_NO == mlp->opt_dbg_feasibility_only) 690 if (GNUNET_NO == mlp->opt_dbg_feasibility_only)
675 { 691 {
676 /* Add c9) Relativity */ 692 if (GNUNET_YES == mlp->opt_dbg_optimize_relativity)
677 GNUNET_asprintf(&name, "c9_%s", GNUNET_i2s(&address->peer)); 693 {
678 peer->r_c9 = mlp_create_problem_create_constraint (p, name, GLP_LO, 0.0, 0.0); 694 /* Add c9) Relativity */
679 GNUNET_free (name); 695 GNUNET_asprintf(&name, "c9_%s", GNUNET_i2s(&address->peer));
680 /* c9) set coefficient */ 696 peer->r_c9 = mlp_create_problem_create_constraint (p, name, GLP_LO, 0.0, 0.0);
681 mlp_create_problem_set_value (p, peer->r_c9, p->c_r, -peer->f, __LINE__); 697 GNUNET_free (name);
698 /* c9) set coefficient */
699 mlp_create_problem_set_value (p, peer->r_c9, p->c_r, -peer->f , __LINE__);
700 }
682 } 701 }
683 peer->processed = GNUNET_YES; 702 peer->processed = GNUNET_YES;
684 } 703 }
@@ -715,7 +734,7 @@ mlp_create_problem_add_address_information (void *cls,
715 GNUNET_free (name); 734 GNUNET_free (name);
716 /* c1) set b = 1 coefficient */ 735 /* c1) set b = 1 coefficient */
717 mlp_create_problem_set_value (p, mlpi->r_c1, mlpi->c_b, 1, __LINE__); 736 mlp_create_problem_set_value (p, mlpi->r_c1, mlpi->c_b, 1, __LINE__);
718 /* c1) set n = -M coefficient */ 737 /* c1) set n = - min (M, quota) coefficient */
719 cur_bigm = (double) mlp->pv.quota_out[addr_net_index]; 738 cur_bigm = (double) mlp->pv.quota_out[addr_net_index];
720 if (cur_bigm > mlp->pv.BIG_M) 739 if (cur_bigm > mlp->pv.BIG_M)
721 cur_bigm = (double) mlp->pv.BIG_M; 740 cur_bigm = (double) mlp->pv.BIG_M;
@@ -747,44 +766,31 @@ mlp_create_problem_add_address_information (void *cls,
747 */ 766 */
748 mlp_create_problem_set_value (p, p->r_quota[addr_net_index], mlpi->c_b, 1, __LINE__); 767 mlp_create_problem_set_value (p, p->r_quota[addr_net_index], mlpi->c_b, 1, __LINE__);
749 768
750#if 0
751 for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++)
752 {
753 addr_net = get_performance_info (address, GNUNET_ATS_NETWORK_TYPE);
754
755 if (GNUNET_ATS_VALUE_UNDEFINED == addr_net)
756 {
757 GNUNET_break (0);
758 addr_net = GNUNET_ATS_NET_UNSPECIFIED;
759 }
760 if (mlp->pv.quota_index[c] == addr_net)
761 {
762 mlp_create_problem_set_value (p, p->r_quota[c], mlpi->c_b, 1, __LINE__);
763 break;
764 }
765 }
766#endif
767
768 /* Optimality */ 769 /* Optimality */
769 if (GNUNET_NO == mlp->opt_dbg_feasibility_only) 770 if (GNUNET_NO == mlp->opt_dbg_feasibility_only)
770 { 771 {
771 /* c 6) maximize diversity */ 772 /* c 6) maximize diversity */
772 mlp_create_problem_set_value (p, p->r_c6, mlpi->c_n, 1, __LINE__); 773 mlp_create_problem_set_value (p, p->r_c6, mlpi->c_n, 1, __LINE__);
773 /* c 9) relativity */ 774 /* c 9) relativity */
774 mlp_create_problem_set_value (p, peer->r_c9, mlpi->c_b, 1, __LINE__); 775 if (GNUNET_YES == mlp->opt_dbg_optimize_relativity)
776 mlp_create_problem_set_value (p, peer->r_c9, mlpi->c_b, 1, __LINE__);
775 /* c 8) utility */ 777 /* c 8) utility */
776 mlp_create_problem_set_value (p, p->r_c8, mlpi->c_b, 1, __LINE__); 778 if (GNUNET_YES == mlp->opt_dbg_optimize_utility)
779 mlp_create_problem_set_value (p, p->r_c8, mlpi->c_b, 1, __LINE__);
777 /* c 7) Optimize quality */ 780 /* c 7) Optimize quality */
778 /* For all quality metrics, set quality of this address */ 781 /* For all quality metrics, set quality of this address */
779 props = mlp->get_properties (mlp->get_properties_cls, address); 782 if (GNUNET_YES == mlp->opt_dbg_optimize_quality)
780 for (c = 0; c < mlp->pv.m_q; c++)
781 { 783 {
782 if ((props[c] < 1.0) && (props[c] > 2.0)) 784 props = mlp->get_properties (mlp->get_properties_cls, address);
785 for (c = 0; c < mlp->pv.m_q; c++)
783 { 786 {
784 fprintf (stderr, "PROP == %.3f \t ", props[c]); 787 if ((props[c] < 1.0) && (props[c] > 2.0))
785 GNUNET_break (0); 788 {
789 fprintf (stderr, "PROP == %.3f \t ", props[c]);
790 GNUNET_break (0);
791 }
792 mlp_create_problem_set_value (p, p->r_q[c], mlpi->c_b, props[c], __LINE__);
786 } 793 }
787 mlp_create_problem_set_value (p, p->r_q[c], mlpi->c_b, props[c], __LINE__);
788 } 794 }
789 } 795 }
790 796
@@ -820,23 +826,32 @@ mlp_create_problem_add_invariant_rows (struct GAS_MLP_Handle *mlp, struct MLP_Pr
820 { 826 {
821 char *name; 827 char *name;
822 /* Add row for c6) Maximize for diversity */ 828 /* Add row for c6) Maximize for diversity */
823 p->r_c6 = mlp_create_problem_create_constraint (p, "c6", GLP_FX, 0.0, 0.0); 829 if (GNUNET_YES == mlp->opt_dbg_optimize_diversity)
824 /* Set c6 ) Setting -D */ 830 {
825 mlp_create_problem_set_value (p, p->r_c6, p->c_d, -1, __LINE__); 831 p->r_c6 = mlp_create_problem_create_constraint (p, "c6", GLP_FX, 0.0, 0.0);
832 /* Set c6 ) Setting -D */
833 mlp_create_problem_set_value (p, p->r_c6, p->c_d, -1, __LINE__);
834 }
826 835
827 /* Adding rows for c 8) Maximize utility */ 836 /* Adding rows for c 8) Maximize utility */
828 p->r_c8 = mlp_create_problem_create_constraint (p, "c8", GLP_FX, 0.0, 0.0); 837 if (GNUNET_YES == mlp->opt_dbg_optimize_utility)
829 /* -u */ 838 {
830 mlp_create_problem_set_value (p, p->r_c8, p->c_u, -1, __LINE__); 839 p->r_c8 = mlp_create_problem_create_constraint (p, "c8", GLP_FX, 0.0, 0.0);
840 /* -u */
841 mlp_create_problem_set_value (p, p->r_c8, p->c_u, -1, __LINE__);
842 }
831 843
832 /* For all quality metrics: 844 /* For all quality metrics:
833 * c 7) Maximize utilization, austerity */ 845 * c 7) Maximize quality, austerity */
834 for (c = 0; c < mlp->pv.m_q; c++) 846 if (GNUNET_YES == mlp->opt_dbg_optimize_quality)
835 { 847 {
836 GNUNET_asprintf(&name, "c7_q%i_%s", c, mlp_ats_to_string(mlp->pv.q[c])); 848 for (c = 0; c < mlp->pv.m_q; c++)
837 p->r_q[c] = mlp_create_problem_create_constraint (p, name, GLP_FX, 0.0, 0.0); 849 {
838 GNUNET_free (name); 850 GNUNET_asprintf(&name, "c7_q%i_%s", c, mlp_ats_to_string(mlp->pv.q[c]));
839 mlp_create_problem_set_value (p, p->r_q[c], p->c_q[c], -1, __LINE__); 851 p->r_q[c] = mlp_create_problem_create_constraint (p, name, GLP_FX, 0.0, 0.0);
852 GNUNET_free (name);
853 mlp_create_problem_set_value (p, p->r_q[c], p->c_q[c], -1, __LINE__);
854 }
840 } 855 }
841 } 856 }
842} 857}
@@ -854,20 +869,26 @@ mlp_create_problem_add_invariant_columns (struct GAS_MLP_Handle *mlp, struct MLP
854 int c; 869 int c;
855 870
856 /* Diversity d column */ 871 /* Diversity d column */
857 p->c_d = mlp_create_problem_create_column (p, "d", GLP_CV, GLP_LO, 0.0, 0.0, mlp->pv.co_D); 872 if (GNUNET_YES == mlp->opt_dbg_optimize_diversity)
873 p->c_d = mlp_create_problem_create_column (p, "d", GLP_CV, GLP_LO, 0.0, 0.0, mlp->pv.co_D);
858 874
859 /* Utilization u column */ 875 /* Utilization u column */
860 p->c_u = mlp_create_problem_create_column (p, "u", GLP_CV, GLP_LO, 0.0, 0.0, mlp->pv.co_U); 876 if (GNUNET_YES == mlp->opt_dbg_optimize_utility)
877 p->c_u = mlp_create_problem_create_column (p, "u", GLP_CV, GLP_LO, 0.0, 0.0, mlp->pv.co_U);
861 878
862 /* Relativity r column */ 879 /* Relativity r column */
863 p->c_r = mlp_create_problem_create_column (p, "r", GLP_CV, GLP_LO, 0.0, 0.0, mlp->pv.co_R); 880 if (GNUNET_YES == mlp->opt_dbg_optimize_relativity)
881 p->c_r = mlp_create_problem_create_column (p, "r", GLP_CV, GLP_LO, 0.0, 0.0, mlp->pv.co_R);
864 882
865 /* Quality metric columns */ 883 /* Quality metric columns */
866 for (c = 0; c < mlp->pv.m_q; c++) 884 if (GNUNET_YES == mlp->opt_dbg_optimize_quality)
867 { 885 {
868 GNUNET_asprintf (&name, "q_%u", mlp->pv.q[c]); 886 for (c = 0; c < mlp->pv.m_q; c++)
869 p->c_q[c] = mlp_create_problem_create_column (p, name, GLP_CV, GLP_LO, 0.0, 0.0, mlp->pv.co_Q[c]); 887 {
870 GNUNET_free (name); 888 GNUNET_asprintf (&name, "q_%u", mlp->pv.q[c]);
889 p->c_q[c] = mlp_create_problem_create_column (p, name, GLP_CV, GLP_LO, 0.0, 0.0, mlp->pv.co_Q[c]);
890 GNUNET_free (name);
891 }
871 } 892 }
872 } 893 }
873} 894}
@@ -1350,8 +1371,6 @@ GAS_mlp_solve_problem (void *solver)
1350 default: 1371 default:
1351 break; 1372 break;
1352 } 1373 }
1353
1354
1355 LOG(GNUNET_ERROR_TYPE_ERROR, "Dumped problem to file: `%s' \n", filename); 1374 LOG(GNUNET_ERROR_TYPE_ERROR, "Dumped problem to file: `%s' \n", filename);
1356 GNUNET_free(filename); 1375 GNUNET_free(filename);
1357 } 1376 }
@@ -2082,9 +2101,6 @@ libgnunet_plugin_ats_mlp_init (void *cls)
2082 "ats", "MLP_DUMP_PROBLEM_ALL"); 2101 "ats", "MLP_DUMP_PROBLEM_ALL");
2083 if (GNUNET_SYSERR == mlp->opt_dump_problem_all) 2102 if (GNUNET_SYSERR == mlp->opt_dump_problem_all)
2084 mlp->opt_dump_problem_all = GNUNET_NO; 2103 mlp->opt_dump_problem_all = GNUNET_NO;
2085 if (GNUNET_YES == mlp->opt_dump_problem_all)
2086 GNUNET_break (0);
2087
2088 2104
2089 mlp->opt_dump_solution_all = GNUNET_CONFIGURATION_get_value_yesno (env->cfg, 2105 mlp->opt_dump_solution_all = GNUNET_CONFIGURATION_get_value_yesno (env->cfg,
2090 "ats", "MLP_DUMP_SOLUTION_ALL"); 2106 "ats", "MLP_DUMP_SOLUTION_ALL");
@@ -2130,6 +2146,49 @@ libgnunet_plugin_ats_mlp_init (void *cls)
2130 LOG (GNUNET_ERROR_TYPE_WARNING, 2146 LOG (GNUNET_ERROR_TYPE_WARNING,
2131 "MLP solver is configured use the mlp presolver\n"); 2147 "MLP solver is configured use the mlp presolver\n");
2132 2148
2149 mlp->opt_dbg_optimize_diversity = GNUNET_CONFIGURATION_get_value_yesno (env->cfg,
2150 "ats", "MLP_DBG_OPTIMIZE_DIVERSITY");
2151 if (GNUNET_SYSERR == mlp->opt_dbg_optimize_diversity)
2152 mlp->opt_dbg_optimize_diversity = GNUNET_YES;
2153 if (GNUNET_NO == mlp->opt_dbg_optimize_diversity)
2154 LOG (GNUNET_ERROR_TYPE_WARNING,
2155 "MLP solver is not optimizing for diversity\n");
2156
2157 mlp->opt_dbg_optimize_relativity= GNUNET_CONFIGURATION_get_value_yesno (env->cfg,
2158 "ats", "MLP_DBG_OPTIMIZE_RELATIVITY");
2159 if (GNUNET_SYSERR == mlp->opt_dbg_optimize_relativity)
2160 mlp->opt_dbg_optimize_relativity = GNUNET_YES;
2161 if (GNUNET_NO == mlp->opt_dbg_optimize_relativity)
2162 LOG (GNUNET_ERROR_TYPE_WARNING,
2163 "MLP solver is not optimizing for relativity\n");
2164
2165 mlp->opt_dbg_optimize_quality = GNUNET_CONFIGURATION_get_value_yesno (env->cfg,
2166 "ats", "MLP_DBG_OPTIMIZE_QUALITY");
2167 if (GNUNET_SYSERR == mlp->opt_dbg_optimize_quality)
2168 mlp->opt_dbg_optimize_quality = GNUNET_YES;
2169 if (GNUNET_NO == mlp->opt_dbg_optimize_quality)
2170 LOG (GNUNET_ERROR_TYPE_WARNING,
2171 "MLP solver is not optimizing for quality\n");
2172
2173 mlp->opt_dbg_optimize_utility = GNUNET_CONFIGURATION_get_value_yesno (env->cfg,
2174 "ats", "MLP_DBG_OPTIMIZE_UTILITY");
2175 if (GNUNET_SYSERR == mlp->opt_dbg_optimize_utility)
2176 mlp->opt_dbg_optimize_utility = GNUNET_YES;
2177 if (GNUNET_NO == mlp->opt_dbg_optimize_utility)
2178 LOG (GNUNET_ERROR_TYPE_WARNING,
2179 "MLP solver is not optimizing for utility\n");
2180
2181 if ( (GNUNET_NO == mlp->opt_dbg_optimize_utility) &&
2182 (GNUNET_NO == mlp->opt_dbg_optimize_quality) &&
2183 (GNUNET_NO == mlp->opt_dbg_optimize_relativity) &&
2184 (GNUNET_NO == mlp->opt_dbg_optimize_utility) &&
2185 (GNUNET_NO == mlp->opt_dbg_feasibility_only))
2186 {
2187 LOG (GNUNET_ERROR_TYPE_ERROR,
2188 _("MLP solver is not optimizing for anything, changing to feasibility check\n"));
2189 mlp->opt_dbg_feasibility_only = GNUNET_YES;
2190 }
2191
2133 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (env->cfg, 2192 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (env->cfg,
2134 "ats", "MLP_LOG_FORMAT", &outputformat)) 2193 "ats", "MLP_LOG_FORMAT", &outputformat))
2135 mlp->opt_log_format = MLP_CPLEX; 2194 mlp->opt_log_format = MLP_CPLEX;
diff --git a/src/ats/plugin_ats_mlp.h b/src/ats/plugin_ats_mlp.h
index 99895365a..b53c0d674 100644
--- a/src/ats/plugin_ats_mlp.h
+++ b/src/ats/plugin_ats_mlp.h
@@ -364,6 +364,30 @@ struct GAS_MLP_Handle
364 */ 364 */
365 int opt_dbg_glpk_verbose; 365 int opt_dbg_glpk_verbose;
366 366
367 /**
368 * solve autoscale the problem
369 */
370 int opt_dbg_optimize_relativity;
371
372 /**
373 * solve autoscale the problem
374 */
375 int opt_dbg_optimize_diversity;
376
377 /**
378 * solve autoscale the problem
379 */
380 int opt_dbg_optimize_quality;
381
382 /**
383 * solve autoscale the problem
384 */
385 int opt_dbg_optimize_utility;
386
387
388 /**
389 * Output format
390 */
367 enum MLP_Output_Format opt_log_format; 391 enum MLP_Output_Format opt_log_format;
368}; 392};
369 393