2 This file is part of GNUnet.
3 (C) 2009, 2010 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file transport/transport_ats.c
23 * @brief automatic transport selection
24 * @author Matthias Wachs
29 #include "gnunet-service-transport_ats.h"
30 #include "gnunet_transport_service.h"
31 #include "gnunet_statistics_service.h"
32 #include "gnunet_container_lib.h"
38 /* LP/MIP problem object */
42 #ifndef GLP_PROB_DEFINED
43 #define GLP_PROB_DEFINED
44 typedef struct { double _opaque_prob[100]; } glp_prob;
48 { /* integer optimizer control parameters */
49 int msg_lev; /* message level (see glp_smcp) */
50 int br_tech; /* branching technique: */
51 #define GLP_BR_FFV 1 /* first fractional variable */
52 #define GLP_BR_LFV 2 /* last fractional variable */
53 #define GLP_BR_MFV 3 /* most fractional variable */
54 #define GLP_BR_DTH 4 /* heuristic by Driebeck and Tomlin */
55 #define GLP_BR_PCH 5 /* hybrid pseudocost heuristic */
56 int bt_tech; /* backtracking technique: */
57 #define GLP_BT_DFS 1 /* depth first search */
58 #define GLP_BT_BFS 2 /* breadth first search */
59 #define GLP_BT_BLB 3 /* best local bound */
60 #define GLP_BT_BPH 4 /* best projection heuristic */
61 double tol_int; /* mip.tol_int */
62 double tol_obj; /* mip.tol_obj */
63 int tm_lim; /* mip.tm_lim (milliseconds) */
64 int out_frq; /* mip.out_frq (milliseconds) */
65 int out_dly; /* mip.out_dly (milliseconds) */
67 void *cb_info; /* mip.cb_info */
68 int cb_size; /* mip.cb_size */
69 int pp_tech; /* preprocessing technique: */
70 #define GLP_PP_NONE 0 /* disable preprocessing */
71 #define GLP_PP_ROOT 1 /* preprocessing only on root level */
72 #define GLP_PP_ALL 2 /* preprocessing on all levels */
73 double mip_gap; /* relative MIP gap tolerance */
74 int mir_cuts; /* MIR cuts (GLP_ON/GLP_OFF) */
75 int gmi_cuts; /* Gomory's cuts (GLP_ON/GLP_OFF) */
76 int cov_cuts; /* cover cuts (GLP_ON/GLP_OFF) */
77 int clq_cuts; /* clique cuts (GLP_ON/GLP_OFF) */
78 int presolve; /* enable/disable using MIP presolver */
79 int binarize; /* try to binarize integer variables */
80 int fp_heur; /* feasibility pump heuristic */
82 int alien; /* use alien solver */
84 double foo_bar[29]; /* (reserved) */
88 { /* simplex method control parameters */
89 int msg_lev; /* message level: */
90 #define GLP_MSG_OFF 0 /* no output */
91 #define GLP_MSG_ERR 1 /* warning and error messages only */
92 #define GLP_MSG_ON 2 /* normal output */
93 #define GLP_MSG_ALL 3 /* full output */
94 #define GLP_MSG_DBG 4 /* debug output */
95 int meth; /* simplex method option: */
96 #define GLP_PRIMAL 1 /* use primal simplex */
97 #define GLP_DUALP 2 /* use dual; if it fails, use primal */
98 #define GLP_DUAL 3 /* use dual simplex */
99 int pricing; /* pricing technique: */
100 #define GLP_PT_STD 0x11 /* standard (Dantzig rule) */
101 #define GLP_PT_PSE 0x22 /* projected steepest edge */
102 int r_test; /* ratio test technique: */
103 #define GLP_RT_STD 0x11 /* standard (textbook) */
104 #define GLP_RT_HAR 0x22 /* two-pass Harris' ratio test */
105 double tol_bnd; /* spx.tol_bnd */
106 double tol_dj; /* spx.tol_dj */
107 double tol_piv; /* spx.tol_piv */
108 double obj_ll; /* spx.obj_ll */
109 double obj_ul; /* spx.obj_ul */
110 int it_lim; /* spx.it_lim */
111 int tm_lim; /* spx.tm_lim (milliseconds) */
112 int out_frq; /* spx.out_frq */
113 int out_dly; /* spx.out_dly (milliseconds) */
114 int presolve; /* enable/disable using LP presolver */
115 double foo_bar[36]; /* (reserved) */
118 /* optimization direction flag: */
119 #define GLP_MIN 1 /* minimization */
120 #define GLP_MAX 2 /* maximization */
122 /* kind of structural variable: */
123 #define GLP_CV 1 /* continuous variable */
124 #define GLP_IV 2 /* integer variable */
125 #define GLP_BV 3 /* binary variable */
127 /* type of auxiliary/structural variable: */
128 #define GLP_FR 1 /* free variable */
129 #define GLP_LO 2 /* variable with lower bound */
130 #define GLP_UP 3 /* variable with upper bound */
131 #define GLP_DB 4 /* double-bounded variable */
132 #define GLP_FX 5 /* fixed variable */
134 /* solution indicator: */
135 #define GLP_SOL 1 /* basic solution */
136 #define GLP_IPT 2 /* interior-point solution */
137 #define GLP_MIP 3 /* mixed integer solution */
139 /* solution status: */
140 #define GLP_UNDEF 1 /* solution is undefined */
141 #define GLP_FEAS 2 /* solution is feasible */
142 #define GLP_INFEAS 3 /* solution is infeasible */
143 #define GLP_NOFEAS 4 /* no feasible solution exists */
144 #define GLP_OPT 5 /* solution is optimal */
145 #define GLP_UNBND 6 /* solution is unbounded */
148 #define GLP_EBADB 0x01 /* invalid basis */
149 #define GLP_ESING 0x02 /* singular matrix */
150 #define GLP_ECOND 0x03 /* ill-conditioned matrix */
151 #define GLP_EBOUND 0x04 /* invalid bounds */
152 #define GLP_EFAIL 0x05 /* solver failed */
153 #define GLP_EOBJLL 0x06 /* objective lower limit reached */
154 #define GLP_EOBJUL 0x07 /* objective upper limit reached */
155 #define GLP_EITLIM 0x08 /* iteration limit exceeded */
156 #define GLP_ETMLIM 0x09 /* time limit exceeded */
157 #define GLP_ENOPFS 0x0A /* no primal feasible solution */
158 #define GLP_ENODFS 0x0B /* no dual feasible solution */
159 #define GLP_EROOT 0x0C /* root LP optimum not provided */
160 #define GLP_ESTOP 0x0D /* search terminated by application */
161 #define GLP_EMIPGAP 0x0E /* relative mip gap tolerance reached */
162 #define GLP_ENOFEAS 0x0F /* no primal/dual feasible solution */
163 #define GLP_ENOCVG 0x10 /* no convergence */
164 #define GLP_EINSTAB 0x11 /* numerical instability */
165 #define GLP_EDATA 0x12 /* invalid data */
166 #define GLP_ERANGE 0x13 /* result out of range */
168 /* enable/disable flag: */
169 #define GLP_ON 1 /* enable something */
170 #define GLP_OFF 0 /* disable something */
175 * Wrappers for GLPK Functions
179 void * _lp_create_prob ( void )
182 return glp_create_prob( );
184 // Function not implemented
190 void _lp_set_obj_dir (glp_prob *P, int dir)
193 return glp_set_obj_dir (P, dir);
195 // Function not implemented
200 void _lp_set_prob_name (glp_prob *P, const char *name)
203 glp_set_prob_name(P, name);
205 // Function not implemented
210 int _lp_add_cols (glp_prob *P, int ncs)
213 return glp_add_cols(P, ncs);
215 // Function not implemented
221 int _lp_add_rows (glp_prob *P, int nrs)
224 return glp_add_rows (P, nrs);
226 // Function not implemented
233 void _lp_set_row_bnds (glp_prob *P, int i, int type, double lb, double ub)
236 glp_set_row_bnds(P, i , type, lb, ub);
238 // Function not implemented
243 void _lp_init_smcp (void * parm)
248 // Function not implemented
253 void _lp_set_col_name (glp_prob *P, int j, const char *name)
256 glp_set_col_name (P, j, name);
258 // Function not implemented
263 void _lp_set_col_bnds (glp_prob *P, int j, int type, double lb,
267 glp_set_col_bnds(P, j, type, lb, ub);
269 // Function not implemented
274 void _lp_set_obj_coef(glp_prob *P, int j, double coef)
277 glp_set_obj_coef(P, j, coef);
279 // Function not implemented
284 void _lp_delete_prob (void * P)
289 // Function not implemented
294 static int _lp_simplex(glp_prob *P, void *parm)
297 return glp_simplex (P, parm);
299 // Function not implemented
305 static void _lp_load_matrix (glp_prob *P, int ne, const int ia[],
306 const int ja[], const double ar[])
309 glp_load_matrix(P, ne, ia, ja, ar);
311 // Function not implemented
316 static void _lp_set_mat_row (glp_prob *P, int i, int len, const int ind[],
320 glp_set_mat_row (P, i, len, ind, val);
322 // Function not implemented
327 static int _lp_write_lp (glp_prob *P, const void *parm, const char *fname)
330 return glp_write_lp ( P, parm, fname);
332 // Function not implemented
338 static void _lp_init_iocp (void *parm)
341 glp_init_iocp (parm);
343 // Function not implemented
348 static int _lp_intopt (glp_prob *P, const void *parm)
351 return glp_intopt (P, parm);
353 // Function not implemented
359 static int _lp_get_status (glp_prob *P)
362 return glp_get_status (P);
364 // Function not implemented
370 static int _lp_mip_status (glp_prob *P)
373 return glp_mip_status (P);
375 // Function not implemented
381 static void _lp_set_col_kind (glp_prob *P, int j, int kind)
384 glp_set_col_kind (P, j, kind);
386 // Function not implemented
391 static void _lp_free_env (void)
396 // Function not implemented
401 static const char * _lp_get_col_name ( glp_prob *P, int j)
404 return glp_get_col_name (P, j);
406 // Function not implemented
412 static double _lp_mip_obj_val (glp_prob *P)
415 return glp_mip_obj_val (P);
417 // Function not implemented
424 static double _lp_get_col_prim (glp_prob *P, int j)
427 return glp_get_col_prim (P , j);
429 // Function not implemented
435 static int _lp_print_sol(glp_prob *P, const char *fname)
439 // Function not implemented
446 * Dummy functions for CFLAGS
449 static void _dummy2 ();
450 static void _dummy ()
453 _lp_get_col_name (NULL, 0);
454 _lp_mip_obj_val (NULL);
455 _lp_get_col_prim (NULL, 0);
456 _lp_set_mat_row(NULL,0,0,NULL,NULL);
460 static void _dummy2 ()
462 ats_modify_problem_state (NULL, 0);
464 int t = ATS_COST_UPDATED + ATS_MODIFIED + ATS_NEW;
475 * @param cfg configuration handle to retrieve configuration (to be removed)
479 struct ATS_Handle * ats_init (double D,
485 struct GNUNET_TIME_Relative max_duration,
486 GNUNET_TRANSPORT_ATS_AddressNotification address_not,
487 GNUNET_TRANSPORT_ATS_ResultCallback res_cb)
489 struct ATS_Handle * ats = NULL;
491 ats = GNUNET_malloc(sizeof (struct ATS_Handle));
495 ats->addr_notification = address_not;
496 ats->result_cb = res_cb;
498 ats->max_iterations = max_iterations;
499 ats->max_exec_duration = max_duration;
504 ats->v_b_min = v_b_min;
505 ats->v_n_min = v_n_min;
506 ats->dump_min_peers = 0;
507 ats->dump_min_addr = 0;
508 ats->dump_overwrite = GNUNET_NO;
509 ats->mechanisms = NULL;
511 ats->successful_executions = 0;
512 ats->invalid_executions = 0;
518 /** solve the bandwidth distribution problem
519 * @param max_it maximum iterations
520 * @param max_dur maximum duration in ms
521 * @param D weight for diversity
522 * @param U weight for utility
523 * @param R weight for relativity
524 * @param v_b_min minimal bandwidth per peer
525 * @param v_n_min minimum number of connections
526 * @param stat result struct
527 * @return GNUNET_SYSERR if glpk is not available, number of mechanisms used
529 int ats_create_problem (struct ATS_Handle *ats,
530 struct ATS_internals *stat,
531 struct ATS_peer *peers,
533 struct ATS_mechanism *mechanisms,
536 if ((c_p == 0) || (c_m == 0))
537 return GNUNET_SYSERR;
539 ats->prob = _lp_create_prob();
542 int c_c_ressources = available_ressources;
543 int c_q_metrics = available_quality_metrics;
545 double M = VERY_BIG_DOUBLE_VALUE;
546 double Q[c_q_metrics+1];
547 for (c=1; c<=c_q_metrics; c++)
552 if (ats->v_n_min > c_p)
555 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Creating problem with: %i peers, %i mechanisms, %i resource entries, %i quality metrics \n",
562 int size = 1 + 3 + 10 *c_m + c_p +
563 (c_q_metrics*c_m)+ c_q_metrics + c_c_ressources * c_m ;
566 int * ia = GNUNET_malloc (size * sizeof (int));
567 int * ja = GNUNET_malloc (size * sizeof (int));
568 double * ar = GNUNET_malloc(size* sizeof (double));
570 _lp_set_prob_name (ats->prob, "gnunet ats bandwidth distribution");
571 _lp_set_obj_dir(ats->prob, GLP_MAX);
575 _lp_add_cols(ats->prob, 2 * c_m);
576 /* adding b_t cols */
577 for (c=1; c <= c_m; c++)
579 GNUNET_asprintf(&name,
580 "p_%s_b%i",GNUNET_i2s(&(mechanisms[c].peer->peer)), c);
581 _lp_set_col_name(ats->prob, c, name);
583 _lp_set_col_bnds(ats->prob, c, GLP_LO, 0.0, 0.0);
584 _lp_set_col_kind(ats->prob, c, GLP_CV);
585 _lp_set_obj_coef(ats->prob, c, 0);
588 /* adding n_t cols */
589 for (c=c_m+1; c <= 2*c_m; c++)
591 GNUNET_asprintf(&name,
592 "p_%s_n%i",GNUNET_i2s(&(mechanisms[c-c_m].peer->peer)),(c-c_m));
593 _lp_set_col_name(ats->prob, c, name);
595 _lp_set_col_bnds(ats->prob, c, GLP_DB, 0.0, 1.0);
596 _lp_set_col_kind(ats->prob, c, GLP_IV);
597 _lp_set_obj_coef(ats->prob, c, 0);
600 /* feasibility constraints */
601 /* Constraint 1: one address per peer*/
604 _lp_add_rows(ats->prob, c_p);
606 for (c=1; c<=c_p; c++)
609 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "bounds [row]=[%i] \n",
613 _lp_set_row_bnds(ats->prob, row_index, GLP_FX, 1.0, 1.0);
614 struct ATS_mechanism *m = peers[c].m_head;
617 ia[array_index] = row_index;
618 ja[array_index] = (c_m + m->col_index);
621 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",
633 /* Constraint 2: only active mechanism gets bandwidth assigned */
634 _lp_add_rows(ats->prob, c_m);
635 for (c=1; c<=c_m; c++)
637 /* b_t - n_t * M <= 0 */
639 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "bounds [row]=[%i] \n",
642 _lp_set_row_bnds(ats->prob, row_index, GLP_UP, 0.0, 0.0);
643 ia[array_index] = row_index;
644 ja[array_index] = mechanisms[c].col_index;
647 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",
654 ia[array_index] = row_index;
655 ja[array_index] = c_m + mechanisms[c].col_index;
656 ar[array_index] = -M;
658 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",
668 /* Constraint 3: minimum bandwidth*/
669 _lp_add_rows(ats->prob, c_m);
671 for (c=1; c<=c_m; c++)
673 /* b_t - n_t * b_min <= 0 */
675 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "bounds [row]=[%i] \n",
679 _lp_set_row_bnds(ats->prob, row_index, GLP_LO, 0.0, 0.0);
681 ia[array_index] = row_index;
682 ja[array_index] = mechanisms[c].col_index;
685 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",
692 ia[array_index] = row_index;
693 ja[array_index] = c_m + mechanisms[c].col_index;
694 ar[array_index] = -ats->v_b_min;
696 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",
707 /* Constraint 4: max ressource capacity */
708 /* V cr: bt * ct_r <= cr_max
711 _lp_add_rows(ats->prob, available_ressources);
713 double ct_max = VERY_BIG_DOUBLE_VALUE;
716 stat->begin_cr = array_index;
718 for (c=0; c<available_ressources; c++)
720 ct_max = ressources[c].c_max;
721 ct_min = ressources[c].c_min;
723 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "bounds [row]=[%i] %f..%f\n",
729 _lp_set_row_bnds(ats->prob, row_index, GLP_DB, ct_min, ct_max);
731 for (c2=1; c2<=c_m; c2++)
734 ia[array_index] = row_index;
735 ja[array_index] = c2;
736 value = mechanisms[c2].ressources[c].c;
737 ar[array_index] = value;
739 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",
740 array_index, ia[array_index],
748 stat->end_cr = array_index--;
750 /* Constraint 5: min number of connections*/
751 _lp_add_rows(ats->prob, 1);
753 for (c=1; c<=c_m; c++)
755 // b_t - n_t * b_min >= 0
757 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "bounds [row]=[%i] \n",
760 _lp_set_row_bnds(ats->prob, row_index, GLP_LO, ats->v_n_min, 0.0);
761 ia[array_index] = row_index;
762 ja[array_index] = c_m + mechanisms[c].col_index;
765 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",
775 // optimisation constraints
779 // Constraint 6: optimize for diversity
781 col_d = _lp_add_cols(ats->prob, 1);
783 _lp_set_col_name(ats->prob, col_d, "d");
784 _lp_set_obj_coef(ats->prob, col_d, ats->D);
785 _lp_set_col_bnds(ats->prob, col_d, GLP_LO, 0.0, 0.0);
786 _lp_add_rows(ats->prob, 1);
787 _lp_set_row_bnds(ats->prob, row_index, GLP_FX, 0.0, 0.0);
791 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "bounds [row]=[%i] \n",row_index);
793 for (c=1; c<=c_m; c++)
795 ia[array_index] = row_index;
796 ja[array_index] = c_m + mechanisms[c].col_index;
799 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",
807 ia[array_index] = row_index;
808 ja[array_index] = col_d;
809 ar[array_index] = -1;
811 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",
820 // Constraint 7: optimize for quality
822 col_qm = _lp_add_cols(ats->prob, c_q_metrics);
824 stat->col_qm = col_qm;
825 //GNUNET_assert (col_qm == (2*c_mechs) + 3 + 1);
826 for (c=0; c< c_q_metrics; c++)
828 GNUNET_asprintf(&name, "Q_%s",qm[c].name);
829 _lp_set_col_name (ats->prob, col_qm + c, name);
830 _lp_set_col_bnds (ats->prob, col_qm + c, GLP_LO, 0.0, 0.0);
832 _lp_set_obj_coef (ats->prob, col_qm + c, Q[c]);
835 _lp_add_rows(ats->prob, available_quality_metrics);
837 stat->begin_qm = row_index;
838 for (c=1; c <= c_q_metrics; c++)
841 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "bounds [row]=[%i] \n",
845 _lp_set_row_bnds(ats->prob, row_index, GLP_FX, 0.0, 0.0);
846 for (c2=1; c2<=c_m; c2++)
848 ia[array_index] = row_index;
849 ja[array_index] = c2;
850 if (qm[c-1].atis_index == GNUNET_TRANSPORT_ATS_QUALITY_NET_DELAY)
852 double v0 = 0, v1 = 0, v2 = 0;
853 v0 = mechanisms[c2].quality[c-1].values[0];
854 if (v1 < 1) v0 = 0.1;
855 v1 = mechanisms[c2].quality[c-1].values[1];
856 if (v1 < 1) v0 = 0.1;
857 v2 = mechanisms[c2].quality[c-1].values[2];
858 if (v1 < 1) v0 = 0.1;
859 value = 100.0 / ((v0 + 2 * v1 + 3 * v2) / 6.0);
862 if (qm[c-1].atis_index == GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE)
864 double v0 = 0, v1 = 0, v2 = 0;
865 v0 = mechanisms[c2].quality[c-1].values[0];
867 v1 = mechanisms[c2].quality[c-1].values[1];
869 v2 = mechanisms[c2].quality[c-1].values[2];
871 value = (v0 + 2 * v1 + 3 * v2) / 6.0;
873 value = (double) 10 / value;
877 ar[array_index] = (mechanisms[c2].peer->f) * value ;
879 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: %s [%i,%i]=%f \n",
888 ia[array_index] = row_index;
889 ja[array_index] = col_qm + c - 1;
890 ar[array_index] = -1;
892 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",
901 stat->end_qm = row_index-1;
903 // Constraint 8: optimize bandwidth utility
906 col_u = _lp_add_cols(ats->prob, 1);
908 _lp_set_col_name(ats->prob, col_u, "u");
909 _lp_set_obj_coef(ats->prob, col_u, ats->U);
910 _lp_set_col_bnds(ats->prob, col_u, GLP_LO, 0.0, 0.0);
911 _lp_add_rows(ats->prob, 1);
914 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "bounds [row]=[%i] \n",row_index);
916 _lp_set_row_bnds(ats->prob, row_index, GLP_FX, 0.0, 0.0);
917 for (c=1; c<=c_m; c++)
919 ia[array_index] = row_index;
921 ar[array_index] = mechanisms[c].peer->f;
923 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",
931 ia[array_index] = row_index;
932 ja[array_index] = col_u;
933 ar[array_index] = -1;
935 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",
936 array_index, ia[array_index],
944 // Constraint 9: optimize relativity
947 col_r = _lp_add_cols(ats->prob, 1);
949 _lp_set_col_name(ats->prob, col_r, "r");
950 _lp_set_obj_coef(ats->prob, col_r, ats->R);
951 _lp_set_col_bnds(ats->prob, col_r, GLP_LO, 0.0, 0.0);
952 _lp_add_rows(ats->prob, c_p);
955 for (c=1; c<=c_p; c++)
957 _lp_set_row_bnds(ats->prob, row_index, GLP_LO, 0.0, 0.0);
958 struct ATS_mechanism *m = peers[c].m_head;
961 ia[array_index] = row_index;
962 ja[array_index] = m->col_index;
963 ar[array_index] = 1 / mechanisms[c].peer->f;
965 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",
974 ia[array_index] = row_index;
975 ja[array_index] = col_r;
976 ar[array_index] = -1;
978 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",
988 /* Loading the matrix */
989 _lp_load_matrix(ats->prob, array_index-1, ia, ja, ar);
994 stat->valid = GNUNET_YES;
1005 void ats_delete_problem (struct ATS_Handle * ats)
1008 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Deleting problem\n");
1012 for (c=0; c< (ats->internal).c_mechs; c++)
1013 GNUNET_free_non_null (ats->mechanisms[c].rc);
1014 if (ats->mechanisms!=NULL)
1016 GNUNET_free(ats->mechanisms);
1017 ats->mechanisms = NULL;
1020 if (ats->peers!=NULL)
1022 GNUNET_free(ats->peers);
1026 if (ats->prob != NULL)
1028 _lp_delete_prob(ats->prob);
1032 ats->internal.begin_cr = GNUNET_SYSERR;
1033 ats->internal.begin_qm = GNUNET_SYSERR;
1034 ats->internal.c_mechs = 0;
1035 ats->internal.c_peers = 0;
1036 ats->internal.end_cr = GNUNET_SYSERR;
1037 ats->internal.end_qm = GNUNET_SYSERR;
1038 ats->internal.solution = GNUNET_SYSERR;
1039 ats->internal.valid = GNUNET_SYSERR;
1042 void ats_modify_problem_state (struct ATS_Handle * ats, enum ATS_problem_state s)
1049 ats->internal.recreate_problem = GNUNET_NO;
1050 ats->internal.modified_quality = GNUNET_NO;
1051 ats->internal.modified_resources = GNUNET_NO;
1054 ats->internal.recreate_problem = GNUNET_YES;
1056 case ATS_QUALITY_UPDATED :
1057 ats->internal.modified_quality = GNUNET_YES;
1059 case ATS_COST_UPDATED :
1060 ats->internal.modified_resources = GNUNET_YES;
1062 case ATS_QUALITY_COST_UPDATED:
1063 ats->internal.modified_resources = GNUNET_YES;
1064 ats->internal.modified_quality = GNUNET_YES;
1074 void ats_solve_problem (struct ATS_Handle * ats,
1075 unsigned int max_it,
1076 unsigned int max_dur,
1077 unsigned int c_peers,
1078 unsigned int c_mechs,
1079 struct ATS_internals *stat)
1081 int result = GNUNET_SYSERR;
1082 int lp_solution = GNUNET_SYSERR;
1083 int mlp_solution = GNUNET_SYSERR;
1088 _lp_init_smcp(&opt_lp);
1090 opt_lp.msg_lev = GLP_MSG_ALL;
1092 opt_lp.msg_lev = GLP_MSG_OFF;
1094 // setting iteration limit
1095 opt_lp.it_lim = max_it;
1097 opt_lp.tm_lim = max_dur;
1099 if (ats->internal.recreate_problem == GNUNET_YES)
1100 opt_lp.presolve = GLP_ON;
1102 result = _lp_simplex(ats->prob, &opt_lp);
1103 lp_solution = _lp_get_status (ats->prob);
1105 if ((result == GLP_ETMLIM) || (result == GLP_EITLIM))
1107 ats->internal.valid = GNUNET_NO;
1108 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1109 "ATS exceeded time or iteration limit!\n");
1113 if (ats_evaluate_results(result, lp_solution, "LP") == GNUNET_YES)
1115 stat->valid = GNUNET_YES;
1119 ats->internal.simplex_rerun_required = GNUNET_YES;
1120 opt_lp.presolve = GLP_ON;
1121 result = _lp_simplex(ats->prob, &opt_lp);
1122 lp_solution = _lp_get_status (ats->prob);
1124 // TODO: Remove if this does not appear until release
1125 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, ""
1126 "EXECUTED SIMPLEX WITH PRESOLVER! %i \n",
1129 if (ats_evaluate_results(result, lp_solution, "LP") != GNUNET_YES)
1131 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1132 "After execution simplex with presolver: STILL INVALID!\n");
1134 GNUNET_asprintf (&filename,
1135 "ats_mlp_p%i_m%i_%llu.mlp",
1136 ats->internal.c_peers,
1137 ats->internal.c_mechs,
1138 GNUNET_TIME_absolute_get().abs_value);
1139 _lp_write_lp ((void *)ats->prob, NULL, filename);
1140 GNUNET_free (filename);
1141 stat->valid = GNUNET_NO;
1142 ats->internal.recreate_problem = GNUNET_YES;
1145 stat->valid = GNUNET_YES;
1150 _lp_init_iocp(&opt_mlp);
1152 opt_mlp.tm_lim = max_dur;
1155 opt_mlp.msg_lev = GLP_MSG_ALL;
1157 opt_mlp.msg_lev = GLP_MSG_OFF;
1160 result = _lp_intopt (ats->prob, &opt_mlp);
1161 mlp_solution = _lp_mip_status (ats->prob);
1162 stat->solution = mlp_solution;
1164 if (ats_evaluate_results(result, mlp_solution, "MLP") == GNUNET_YES)
1166 stat->valid = GNUNET_YES;
1170 // TODO: Remove if this does not appear until release
1171 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1172 "MLP solution for %i peers, %i mechs is invalid: %i\n",
1173 ats->internal.c_peers,
1174 ats->internal.c_mechs,
1176 stat->valid = GNUNET_NO;
1180 if (_lp_get_col_prim(ats->prob,2*c_mechs+1) != 1)
1183 for (c=1; c<= available_quality_metrics; c++ )
1185 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s %f\n",
1186 _lp_get_col_name(ats->prob,2*c_mechs+3+c),
1187 _lp_get_col_prim(ats->prob,2*c_mechs+3+c));
1189 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s %f\n",
1190 _lp_get_col_name(ats->prob,2*c_mechs+1),
1191 _lp_get_col_prim(ats->prob,2*c_mechs+1));
1192 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s %f\n",
1193 _lp_get_col_name(ats->prob,2*c_mechs+2),
1194 _lp_get_col_prim(ats->prob,2*c_mechs+2));
1195 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s %f\n",
1196 _lp_get_col_name(ats->prob,2*c_mechs+3),
1197 _lp_get_col_prim(ats->prob,2*c_mechs+3));
1198 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "objective value: %f\n",
1199 _lp_mip_obj_val(ats->prob));
1205 void ats_shutdown (struct ATS_Handle * ats)
1208 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ATS shutdown\n");
1210 ats_delete_problem (ats);
1216 void ats_update_problem_qm (struct ATS_Handle * ats)
1221 int c_q_metrics = available_quality_metrics;
1223 int *ja = GNUNET_malloc ((1 + ats->internal.c_mechs*2 + 3 +
1224 available_quality_metrics) * sizeof (int));
1225 double *ar = GNUNET_malloc ((1 + ats->internal.c_mechs*2 + 3 +
1226 available_quality_metrics) * sizeof (double));
1228 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Updating problem quality metrics\n");
1230 row_index = ats->internal.begin_qm;
1232 for (c=1; c <= c_q_metrics; c++)
1237 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "bounds [row]=[%i] \n",row_index);
1239 _lp_set_row_bnds(ats->prob, row_index, GLP_FX, 0.0, 0.0);
1240 for (c2=1; c2<=ats->internal.c_mechs; c2++)
1242 ja[array_index] = c2;
1243 GNUNET_assert (ats->mechanisms[c2].addr != NULL);
1244 GNUNET_assert (ats->mechanisms[c2].peer != NULL);
1246 if (qm[c-1].atis_index == GNUNET_TRANSPORT_ATS_QUALITY_NET_DELAY)
1248 double v0 = 0, v1 = 0, v2 = 0;
1250 v0 = ats->mechanisms[c2].quality[c-1].values[0];
1251 if (v1 < 1) v0 = 0.1;
1252 v1 = ats->mechanisms[c2].quality[c-1].values[1];
1253 if (v1 < 1) v0 = 0.1;
1254 v2 = ats->mechanisms[c2].quality[c-1].values[2];
1255 if (v1 < 1) v0 = 0.1;
1256 value = 100.0 / ((v0 + 2 * v1 + 3 * v2) / 6.0);
1259 if (qm[c-1].atis_index == GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE)
1261 double v0 = 0, v1 = 0, v2 = 0;
1262 v0 = ats->mechanisms[c2].quality[c-1].values[0];
1264 v1 = ats->mechanisms[c2].quality[c-1].values[1];
1266 v2 = ats->mechanisms[c2].quality[c-1].values[2];
1268 value = (v0 + 2 * v1 + 3 * v2) / 6.0;
1270 value = (double) 10 / value;
1274 ar[array_index] = (ats->mechanisms[c2].peer->f) * value;
1276 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: %s [%i,%i]=%f \n",
1285 ja[array_index] = ats->internal.col_qm + c - 1;
1286 ar[array_index] = -1;
1289 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",
1295 _lp_set_mat_row (ats->prob, row_index, array_index, ja, ar);
1299 GNUNET_free_non_null (ja);
1300 GNUNET_free_non_null (ar);
1306 ats_calculate_bandwidth_distribution (struct ATS_Handle * ats,
1307 struct GNUNET_STATISTICS_Handle *stats)
1309 struct GNUNET_TIME_Absolute start;
1310 struct GNUNET_TIME_Relative creation;
1311 struct GNUNET_TIME_Relative solving;
1314 char *text = "unmodified";
1318 if (INT_MAX < ats->max_exec_duration.rel_value)
1321 dur = (int) ats->max_exec_duration.rel_value;
1324 ats->internal.simplex_rerun_required = GNUNET_NO;
1325 start = GNUNET_TIME_absolute_get();
1326 if ((ats->internal.recreate_problem == GNUNET_YES) ||
1327 (ats->prob==NULL) ||
1328 (ats->internal.valid == GNUNET_NO))
1331 ats->internal.recreate_problem = GNUNET_YES;
1332 ats_delete_problem (ats);
1333 ats->addr_notification(&ats->peers , &c_p, &ats->mechanisms, &c_m);
1335 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1336 "Service returned: %i peer, %i mechs\n",
1340 ats_create_problem (ats, &ats->internal, ats->peers, c_p, ats->mechanisms, c_m);
1344 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1345 "Peers/Addresses were modified... new problem: %i peer, %i mechs\n",
1346 ats->internal.c_peers,
1347 ats->internal.c_mechs);
1351 else if ((ats->internal.recreate_problem == GNUNET_NO) &&
1352 (ats->internal.modified_resources == GNUNET_YES) &&
1353 (ats->internal.valid == GNUNET_YES))
1355 text = "modified resources";
1356 ats_update_problem_cr (ats);
1358 else if ((ats->internal.recreate_problem == GNUNET_NO) &&
1359 (ats->internal.modified_quality == GNUNET_YES) &&
1360 (ats->internal.valid == GNUNET_YES))
1362 text = "modified quality";
1363 ats_update_problem_qm (ats);
1364 //ats_update_problem_qm_TEST ();
1367 else GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Problem is %s\n", text);
1370 creation = GNUNET_TIME_absolute_get_difference(start,GNUNET_TIME_absolute_get());
1371 start = GNUNET_TIME_absolute_get();
1373 ats->internal.solution = GLP_UNDEF;
1374 if (ats->internal.valid == GNUNET_YES)
1376 ats_solve_problem(ats,
1377 ats->max_iterations,
1378 ats->max_exec_duration.rel_value,
1379 ats->internal.c_peers,
1380 ats->internal.c_mechs,
1383 solving = GNUNET_TIME_absolute_get_difference(start,GNUNET_TIME_absolute_get());
1385 if (ats->internal.valid == GNUNET_YES)
1387 /* Telling about new distribution*/
1390 int msg_type = GNUNET_ERROR_TYPE_DEBUG;
1392 msg_type = GNUNET_ERROR_TYPE_ERROR;
1394 GNUNET_log (msg_type,
1395 "MLP %s: creation time: %llu, execution time: %llu, %i peers, %i mechanisms, simplex rerun: %s, solution %s\n",
1399 ats->internal.c_peers,
1400 ats->internal.c_mechs,
1401 (ats->internal.simplex_rerun_required == GNUNET_NO) ? "NO" : "YES",
1402 (ats->internal.solution == 5) ? "OPTIMAL" : "INVALID");
1403 ats->successful_executions ++;
1404 GNUNET_STATISTICS_set (stats, "# ATS successful executions",
1405 ats->successful_executions,
1408 if ((ats->internal.recreate_problem == GNUNET_YES) || (ats->prob==NULL))
1409 GNUNET_STATISTICS_set (stats, "ATS state",ATS_NEW, GNUNET_NO);
1410 else if ((ats->internal.modified_resources == GNUNET_YES) &&
1411 (ats->internal.modified_quality == GNUNET_NO))
1412 GNUNET_STATISTICS_set (stats, "ATS state", ATS_COST_UPDATED, GNUNET_NO);
1413 else if ((ats->internal.modified_resources == GNUNET_NO) &&
1414 (ats->internal.modified_quality == GNUNET_YES) &&
1415 (ats->internal.simplex_rerun_required == GNUNET_NO))
1416 GNUNET_STATISTICS_set (stats, "ATS state", ATS_QUALITY_UPDATED, GNUNET_NO);
1417 else if ((ats->internal.modified_resources == GNUNET_YES) &&
1418 (ats->internal.modified_quality == GNUNET_YES) &&
1419 (ats->internal.simplex_rerun_required == GNUNET_NO))
1420 GNUNET_STATISTICS_set (stats, "ATS state", ATS_QUALITY_COST_UPDATED, GNUNET_NO);
1421 else if (ats->internal.simplex_rerun_required == GNUNET_NO)
1422 GNUNET_STATISTICS_set (stats, "ATS state", ATS_UNMODIFIED, GNUNET_NO);
1426 if (ats->internal.c_peers != 0)
1428 ats->invalid_executions ++;
1429 GNUNET_STATISTICS_set (stats, "# ATS invalid executions",
1430 ats->invalid_executions, GNUNET_NO);
1434 GNUNET_STATISTICS_set (stats, "# ATS successful executions",
1435 ats->successful_executions, GNUNET_NO);
1439 GNUNET_STATISTICS_set (stats,
1440 "ATS duration", solving.rel_value + creation.rel_value, GNUNET_NO);
1441 GNUNET_STATISTICS_set (stats,
1442 "ATS mechanisms", ats->internal.c_mechs, GNUNET_NO);
1443 GNUNET_STATISTICS_set (stats,
1444 "ATS peers", ats->internal.c_peers, GNUNET_NO);
1445 GNUNET_STATISTICS_set (stats,
1446 "ATS solution", ats->internal.solution, GNUNET_NO);
1447 GNUNET_STATISTICS_set (stats,
1448 "ATS timestamp", start.abs_value, GNUNET_NO);
1450 if ((ats->save_mlp == GNUNET_YES) &&
1451 (ats->internal.c_mechs >= ats->dump_min_peers) &&
1452 (ats->internal.c_mechs >= ats->dump_min_addr))
1455 if (ats->dump_overwrite == GNUNET_NO)
1457 GNUNET_asprintf (&filename, "ats_mlp_p%i_m%i_%s_%llu.mlp",
1458 ats->internal.c_peers,
1459 ats->internal.c_mechs,
1461 GNUNET_TIME_absolute_get().abs_value);
1462 _lp_write_lp ((void *) ats->prob, NULL, filename);
1466 GNUNET_asprintf (&filename, "ats_mlp_p%i_m%i.mlp",
1467 ats->internal.c_peers, ats->internal.c_mechs );
1468 _lp_write_lp ((void *) ats->prob, NULL, filename);
1470 GNUNET_free (filename);
1472 if ((ats->save_solution == GNUNET_YES) &&
1473 (ats->internal.c_mechs >= ats->dump_min_peers) &&
1474 (ats->internal.c_mechs >= ats->dump_min_addr))
1477 if (ats->dump_overwrite == GNUNET_NO)
1479 GNUNET_asprintf (&filename, "ats_mlp_p%i_m%i_%s_%llu.sol",
1480 ats->internal.c_peers,
1481 ats->internal.c_mechs,
1483 GNUNET_TIME_absolute_get().abs_value);
1484 _lp_print_sol (ats->prob, filename);
1488 GNUNET_asprintf (&filename, "ats_mlp_p%i_m%i.sol",
1489 ats->internal.c_peers, ats->internal.c_mechs);
1490 _lp_print_sol (ats->prob, filename);
1492 GNUNET_free (filename);
1495 ats->internal.recreate_problem = GNUNET_NO;
1496 ats->internal.modified_resources = GNUNET_NO;
1497 ats->internal.modified_quality = GNUNET_NO;
1501 * Evaluate the result of the last simplex or mlp solving
1502 * @param result return value returned by the solver
1503 * @param solution solution state
1504 * @param problem mlp or lp
1505 * @return GNUNET_NO if solution is invalid, GNUNET_YES if solution is
1509 int ats_evaluate_results (int result, int solution, char * problem)
1511 int cont = GNUNET_NO;
1512 #if DEBUG_ATS || VERBOSE_ATS
1513 int error_kind = GNUNET_ERROR_TYPE_DEBUG;
1516 error_kind = GNUNET_ERROR_TYPE_ERROR;
1519 case GNUNET_SYSERR : /* GNUNET problem, not GLPK related */
1520 #if DEBUG_ATS || VERBOSE_ATS
1521 GNUNET_log (error_kind,
1522 "%s, GLPK solving not executed\n", problem);
1525 case GLP_ESTOP : /* search terminated by application */
1526 #if DEBUG_ATS || VERBOSE_ATS
1527 GNUNET_log (error_kind,
1528 "%s , Search terminated by application\n", problem);
1531 case GLP_EITLIM : /* iteration limit exceeded */
1532 #if DEBUG_ATS || VERBOSE_ATS
1533 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1534 "%s Iteration limit exceeded\n", problem);
1537 case GLP_ETMLIM : /* time limit exceeded */
1538 #if DEBUG_ATS || VERBOSE_ATS
1539 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1540 "%s Time limit exceeded\n", problem);
1543 case GLP_ENOPFS : /* no primal feasible solution */
1544 case GLP_ENODFS : /* no dual feasible solution */
1545 #if DEBUG_ATS || VERBOSE_ATS
1546 GNUNET_log (error_kind,
1547 "%s No feasible solution\n", problem);
1550 case GLP_EBADB : /* invalid basis */
1551 case GLP_ESING : /* singular matrix */
1552 case GLP_ECOND : /* ill-conditioned matrix */
1553 case GLP_EBOUND : /* invalid bounds */
1554 case GLP_EFAIL : /* solver failed */
1555 case GLP_EOBJLL : /* objective lower limit reached */
1556 case GLP_EOBJUL : /* objective upper limit reached */
1557 case GLP_EROOT : /* root LP optimum not provided */
1558 #if DEBUG_ATS || VERBOSE_ATS
1559 GNUNET_log (error_kind,
1560 "%s Invalid Input data: %i\n",
1565 #if DEBUG_ATS || VERBOSE_ATS
1566 GNUNET_log (error_kind,
1567 "%s Problem has been solved\n", problem);
1574 #if DEBUG_ATS || VERBOSE_ATS
1575 GNUNET_log (error_kind,
1576 "%s solution is undefined\n", problem);
1580 #if DEBUG_ATS || VERBOSE_ATS
1581 GNUNET_log (error_kind,
1582 "%s solution is optimal\n", problem);
1587 #if DEBUG_ATS || VERBOSE_ATS
1588 GNUNET_log (error_kind,
1589 "%s solution is %s feasible, however, its optimality (or non-optimality) has not been proven\n",
1590 problem, (0==strcmp(problem,"LP")?"":"integer"));
1595 #if DEBUG_ATS || VERBOSE_ATS
1596 GNUNET_log (error_kind, "%s problem has no %sfeasible solution\n",
1597 problem, (0==strcmp(problem,"LP")?"":"integer "));
1601 #if DEBUG_ATS || VERBOSE_ATS
1602 GNUNET_log (error_kind, "%s problem is infeasible \n", problem);
1606 #if DEBUG_ATS || VERBOSE_ATS
1607 GNUNET_log (error_kind, "%s problem is unbounded \n", problem);
1615 void ats_update_problem_cr (struct ATS_Handle * ats)
1620 double ct_max, ct_min;
1622 int *ja = GNUNET_malloc ((1 + ats->internal.c_mechs*2 + 3 +
1623 available_quality_metrics) * sizeof (int));
1624 double *ar = GNUNET_malloc ((1 + ats->internal.c_mechs*2 + 3 +
1625 available_quality_metrics) * sizeof (double));
1627 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Updating problem quality metrics\n");
1628 row_index = ats->internal.begin_cr;
1631 for (c=0; c<available_ressources; c++)
1633 ct_max = ressources[c].c_max;
1634 ct_min = ressources[c].c_min;
1636 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "bounds [row]=[%i] %f..%f\n",
1641 _lp_set_row_bnds(ats->prob, row_index, GLP_DB, ct_min, ct_max);
1642 for (c2=1; c2<=ats->internal.c_mechs; c2++)
1645 GNUNET_assert (ats->mechanisms[c2].addr != NULL);
1646 GNUNET_assert (ats->mechanisms[c2].peer != NULL);
1648 ja[array_index] = c2;
1649 value = ats->mechanisms[c2].ressources[c].c;
1650 ar[array_index] = value;
1652 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",
1660 _lp_set_mat_row (ats->prob, row_index, array_index, ja, ar);
1663 GNUNET_free_non_null (ja);
1664 GNUNET_free_non_null (ar);
1668 void ats_set_logging_options (struct ATS_Handle * ats,
1669 int minimum_addresses,
1678 ats->dump_min_addr = minimum_addresses;
1679 ats->dump_min_peers = minimum_peers;
1680 ats->dump_overwrite = overwrite_dump;
1681 ats->save_mlp = log_problem;
1682 ats->save_solution = log_solution;
1686 static void ats_update_problem_qm_TEST ()
1694 int old_ja[ats->internal.c_mechs + 2];
1695 double old_ar[ats->internal.c_mechs + 2];
1697 int *ja = GNUNET_malloc ((1 + ats->internal.c_mechs*2 + 3 +
1698 available_quality_metrics) * sizeof (int));
1699 double *ar = GNUNET_malloc ((1 + ats->internal.c_mechs*2 + 3 +
1700 available_quality_metrics) * sizeof (double));
1702 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1703 "Updating problem quality metrics TEST\n");
1705 if (ats->internal.begin_qm >0)
1706 row_index = ats->internal.begin_qm;
1709 for (c=0; c<available_quality_metrics; c++)
1711 c_old = _lp_get_mat_row (ats->prob, row_index, old_ja, old_ar);
1712 _lp_set_row_bnds(ats->prob, row_index, GLP_FX, 0.0, 0.0);
1713 for (c2=1; c2<=c_old; c2++)
1715 ja[c2] = old_ja[c2];
1716 if ((changed < 3) && (c2>2) && (old_ar[c2] != -1))
1718 ar[c2] = old_ar[c2] + 5 - changed;
1722 ar[c2] = old_ar[c2];
1724 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1725 "[index]=[%i]: old [%i,%i]=%f new [%i,%i]=%f\n",
1735 _lp_set_mat_row (ats->prob, row_index, c_old, ja, ar);
1738 GNUNET_free_non_null (ja);
1739 GNUNET_free_non_null (ar);
1745 /* end of transport_ats.c */