2 This file is part of GNUnet.
3 (C) 2011 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 ats/gnunet-service-ats_addresses_mlp.h
23 * @brief ats mlp problem solver
24 * @author Matthias Wachs
25 * @author Christian Grothoff
28 #include "gnunet_statistics_service.h"
29 #include "gnunet-service-ats_addresses.h"
34 #ifndef GNUNET_SERVICE_ATS_ADDRESSES_MLP_H
35 #define GNUNET_SERVICE_ATS_ADDRESSES_MLP_H
37 #define VERBOSE GNUNET_EXTRA_LOGGING
38 #define DEBUG_MLP GNUNET_EXTRA_LOGGING
40 #define MLP_MAX_EXEC_DURATION GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 3)
41 #define MLP_MAX_ITERATIONS INT_MAX
51 struct GNUNET_STATISTICS_Handle *stats;
54 * GLPK (MLP) problem object
63 * GLPK LP control parameter
65 glp_smcp control_param_lp;
68 * GLPK LP control parameter
70 glp_iocp control_param_mlp;
73 * Maximum execution time per problem solving
75 struct GNUNET_TIME_Relative max_exec_duration;
78 * Maximum number of LP iterations per problem solving
80 unsigned int max_iterations;
82 /* state information */
85 * Do we need to use the LP presolver?
87 * If the problem addresses were added or removed and the last basis was we
88 * need to use the presolver.
89 * presolver_required == GNUNET_YES
91 * If values were modified, we can reuse a valid basis
92 * presolver_required == GNUNET_NO
94 int presolver_required;
99 * Time of last execution
101 struct GNUNET_TIME_Absolute last_execution;
105 * How often was the LP problem solved
107 unsigned int lp_solved;
110 * total duration of all lp solver executions
112 uint64_t lp_total_duration;
115 * How often was the MLP problem solved
117 unsigned int mlp_solved;
120 * total duration of all mlp solver executions
122 uint64_t mlp_total_duration;
124 /* Information about the problem */
127 /* column index Diversity (D) column */
131 /* column index Utilization (U) column */
135 /* column index Proportionality (R) column */
139 /* column index first quality metric (q_1) column */
142 /* column index last quality metric (q_n) column */
145 /* Array of quality metric coefficients (m elements) */
148 /* number of quality metrics */
151 /* minimum bandwidth assigned to an address */
154 /* minimum number of addresses with bandwidth assigned */
160 * Address specific MLP information
162 struct MLP_information
164 /* bandwidth column index */
167 /* address usage column */
173 * Init the MLP problem solving component
175 * @param stats the GNUNET_STATISTICS handle
176 * @param max_duration maximum numbers of iterations for the LP/MLP Solver
177 * @param max_iterations maximum time limit for the LP/MLP Solver
178 * @param D Diversity coefficient
179 * @param U Utilization coefficient
180 * @param R Proportionality coefficient
181 * @param b_min minimum bandwidth assigned to an address
182 * @param n_min minimum number of addresses with bandwidth assigned
184 * @return struct GAS_MLP_Handle * on success, NULL on fail
186 struct GAS_MLP_Handle *
187 GAS_mlp_init (const struct GNUNET_STATISTICS_Handle *stats,
188 struct GNUNET_TIME_Relative max_duration,
189 unsigned int max_iterations,
190 double D, double U, double R,
196 * Updates a single address in the MLP problem
198 * If the address did not exist before in the problem:
199 * The MLP problem has to be recreated and the problem has to be resolved
201 * Otherwise the addresses' values can be updated and the existing base can
204 * @param mlp the MLP Handle
205 * @param addresses the address hashmap
206 * @param address the address to update
209 GAS_mlp_address_update (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_MultiHashMap * addresses, struct ATS_Address *address);
213 * Deletes a single address in the MLP problem
215 * The MLP problem has to be recreated and the problem has to be resolved
217 * @param mlp the MLP Handle
218 * @param addresses the address hashmap
219 * @param address the address to delete
222 GAS_mlp_address_delete (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_MultiHashMap * addresses, struct ATS_Address *address);
226 * Deletes a single address in the MLP problem
228 * @param mlp the MLP Handle
229 * @param addresses the address hashmap
230 * @param address the address to change the preference
233 GAS_mlp_address_change_preference (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_MultiHashMap * addresses, struct ATS_Address *address);
237 * Shutdown the MLP problem solving component
243 /* end of gnunet-service-ats_addresses_mlp.h */