separating out feedback from preferences
[oweals/gnunet.git] / src / ats / gnunet-service-ats_plugins.h
1 /*
2  This file is part of GNUnet.
3  (C) 2011-2014 Christian Grothoff (and other contributing authors)
4
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.
9
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.
14
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.
19  */
20
21 /**
22  * @file ats/gnunet-service-ats_plugins.h
23  * @brief ats service plugin management
24  * @author Matthias Wachs
25  * @author Christian Grothoff
26  */
27 #ifndef GNUNET_SERVICE_ATS_PLUGINS_H
28 #define GNUNET_SERVICE_ATS_PLUGINS_H
29
30 #include "gnunet_util_lib.h"
31 #include "gnunet_ats_service.h"
32 #include "gnunet-service-ats.h"
33 #include "gnunet-service-ats_addresses.h"
34 #include "gnunet_statistics_service.h"
35 #include "ats.h"
36
37
38 /**
39  * Available ressource assignment modes
40  */
41 enum ATS_Mode
42 {
43   /**
44    * proportional mode:
45    *
46    * Assign each peer an equal amount of bandwidth (bw)
47    *
48    * bw_per_peer = bw_total / #active addresses
49    */
50   MODE_PROPORTIONAL,
51
52   /**
53    * MLP mode:
54    *
55    * Solve ressource assignment as an optimization problem
56    * Uses an mixed integer programming solver
57    */
58   MODE_MLP,
59
60   /**
61    * Reinforcement Learning mode:
62    *
63    * Solve resource assignment using a learning agent
64    */
65   MODE_RIL
66 };
67
68
69 /**
70  * Initialize address subsystem. The addresses subsystem manages the addresses
71  * known and current performance information. It has a solver component
72  * responsible for the resource allocation. It tells the solver about changes
73  * and receives updates when the solver changes the ressource allocation.
74  *
75  * @param cfg configuration to use
76  * @return #GNUNET_OK on success, #GNUNET_SYSERR on error (failed to load
77  *         solver plugin)
78  */
79 int
80 GAS_plugins_init (const struct GNUNET_CONFIGURATION_Handle *cfg);
81
82
83 /**
84  * Shutdown address subsystem.
85  */
86 void
87 GAS_plugins_done (void);
88
89
90 /**
91  * The preference changed for a peer, update solver.
92  *
93  * @param peer the peer
94  * @param kind the ATS kind
95  * @param pref_rel the new relative preference value
96  */
97 void
98 GAS_normalized_preference_changed (const struct GNUNET_PeerIdentity *peer,
99                                    enum GNUNET_ATS_PreferenceKind kind,
100                                    double pref_rel);
101
102
103 /**
104  * The relative value for a property changed
105  *
106  * @param address the peer
107  * @param type the ATS type
108  * @param prop_rel the new relative preference value
109  */
110 void
111 GAS_normalized_property_changed (struct ATS_Address *address,
112                                  uint32_t type,
113                                  double prop_rel);
114
115
116 void
117 GAS_plugin_new_address (struct ATS_Address *new_address,
118                         enum GNUNET_ATS_Network_Type addr_net,
119                         const struct GNUNET_ATS_Information *atsi,
120                         uint32_t atsi_count);
121
122
123 void
124 GAS_plugin_update_address (struct ATS_Address *address,
125                            const struct GNUNET_ATS_Information *atsi,
126                            uint32_t atsi_count);
127
128
129 void
130 GAS_plugin_update_preferences (void *client,
131                                const struct GNUNET_PeerIdentity *peer,
132                                enum GNUNET_ATS_PreferenceKind kind,
133                                float score_abs);
134
135
136 void
137 GAS_plugin_preference_feedback (void *application,
138                                 const struct GNUNET_PeerIdentity *peer,
139                                 const struct GNUNET_TIME_Relative scope,
140                                 enum GNUNET_ATS_PreferenceKind kind,
141                                 float score_abs);
142
143
144 void
145 GAS_plugin_delete_address (struct ATS_Address *address);
146
147
148 void
149 GAS_plugin_request_connect_start (const struct GNUNET_PeerIdentity *pid);
150
151
152 void
153 GAS_plugin_request_connect_stop (const struct GNUNET_PeerIdentity *pid);
154
155
156 void
157 GAS_plugin_solver_lock (void);
158
159
160 void
161 GAS_plugin_solver_unlock (void);
162
163
164 #endif