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
45 struct ATS_Peer *next;
46 struct ATS_Peer *prev;
48 struct GNUNET_PeerIdentity id;
50 struct ATS_Address *head;
51 struct ATS_Address *tail;
62 struct GNUNET_STATISTICS_Handle *stats;
65 * GLPK (MLP) problem object
74 * GLPK LP control parameter
76 glp_smcp control_param_lp;
79 * GLPK LP control parameter
81 glp_iocp control_param_mlp;
84 * Solves the task in an regular interval
86 GNUNET_SCHEDULER_TaskIdentifier mlp_task;
89 * Interval between scheduled problem solving
91 struct GNUNET_TIME_Relative exec_interval;
94 * Maximum execution time per problem solving
96 struct GNUNET_TIME_Relative max_exec_duration;
99 * Maximum number of LP iterations per problem solving
101 unsigned int max_iterations;
103 /* state information */
106 * Do we need to use the LP presolver?
108 * If the problem addresses were added or removed and the last basis was we
109 * need to use the presolver.
110 * presolver_required == GNUNET_YES
112 * If values were modified, we can reuse a valid basis
113 * presolver_required == GNUNET_NO
115 int presolver_required;
120 * Time of last execution
122 struct GNUNET_TIME_Absolute last_execution;
126 * How often was the LP problem solved
128 unsigned int lp_solved;
131 * total duration of all lp solver executions
133 uint64_t lp_total_duration;
136 * How often was the MLP problem solved
138 unsigned int mlp_solved;
141 * total duration of all mlp solver executions
143 uint64_t mlp_total_duration;
145 unsigned int addr_in_problem;
147 /* Information about the problem */
149 struct ATS_Peer *peer_head;
150 struct ATS_Peer *peer_tail;
152 /* current problem matrix */
153 /* row index array */
155 /* column index array */
157 /* column index array */
159 /* current size of the constraint matrix |indices| */
160 unsigned int cm_size;
163 /* Row index constraint 4: minimum connections */
166 /* column index Diversity (D) column */
170 /* column index Utilization (U) column */
174 /* column index Proportionality (R) column */
178 /* ATS Quality metrics
179 * array with GNUNET_ATS_QualityPropertiesCount elements
180 * contains mapping to GNUNET_ATS_Property*/
181 int q[GNUNET_ATS_QualityPropertiesCount];
183 /* column index quality metrics */
184 int c_q[GNUNET_ATS_QualityPropertiesCount];
186 /* quality metric coefficients*/
187 double co_Q[GNUNET_ATS_QualityPropertiesCount];
189 /* number of quality metrics */
192 /* minimum bandwidth assigned to an address */
195 /* minimum number of addresses with bandwidth assigned */
201 * Address specific MLP information
203 struct MLP_information
205 /* bandwidth column index */
208 /* address usage column */
213 /* constraint 1: bandwidth capping */
216 /* constraint 3: minimum bandwidth */
222 * Init the MLP problem solving component
224 * @param cfg configuration handle
225 * @param stats the GNUNET_STATISTICS handle
226 * @param max_duration maximum numbers of iterations for the LP/MLP Solver
227 * @param max_iterations maximum time limit for the LP/MLP Solver
228 * @return struct GAS_MLP_Handle * on success, NULL on fail
230 struct GAS_MLP_Handle *
231 GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
232 const struct GNUNET_STATISTICS_Handle *stats,
233 struct GNUNET_TIME_Relative max_duration,
234 unsigned int max_iterations);
238 * Updates a single address in the MLP problem
240 * If the address did not exist before in the problem:
241 * The MLP problem has to be recreated and the problem has to be resolved
243 * Otherwise the addresses' values can be updated and the existing base can
246 * @param mlp the MLP Handle
247 * @param addresses the address hashmap
248 * @param address the address to update
251 GAS_mlp_address_update (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_MultiHashMap * addresses, struct ATS_Address *address);
255 * Deletes a single address in the MLP problem
257 * The MLP problem has to be recreated and the problem has to be resolved
259 * @param mlp the MLP Handle
260 * @param addresses the address hashmap
261 * @param address the address to delete
264 GAS_mlp_address_delete (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_MultiHashMap * addresses, struct ATS_Address *address);
268 * Deletes a single address in the MLP problem
270 * @param mlp the MLP Handle
271 * @param addresses the address hashmap
272 * @param address the address to change the preference
275 GAS_mlp_address_change_preference (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_MultiHashMap * addresses, struct ATS_Address *address);
279 * Shutdown the MLP problem solving component
285 /* end of gnunet-service-ats_addresses_mlp.h */