*/
/**
- * @file ats/gnunet-service-ats_addresses_mlp.h
+ * @file ats/gnunet-service-ats-solver_mlp.h
* @brief ats MLP problem solver
* @author Matthias Wachs
* @author Christian Grothoff
/* Legacy preference value */
double f;
-
-#if 0
- /* Array of quality preferences */
- double f_q[GNUNET_ATS_QualityPropertiesCount];
-
-#endif
};
#else
void *prob;
#endif
+
/* Number of addresses in problem */
unsigned int num_addresses;
/* Number of peers in problem */
int *ja;
/* Column index value */
double *ar;
+
};
struct MLP_Variables
*/
struct GNUNET_STATISTICS_Handle *stats;
+ /**
+ * Address hashmap for lookups
+ */
+ const struct GNUNET_CONTAINER_MultiHashMap *addresses;
+
/**
* Addresses' bandwidth changed callback
*/
*/
void *bw_changed_cb_cls;
+
+
+ /**
+ * ATS function to get preferences
+ */
GAS_get_preferences get_preferences;
+ /**
+ * Closure for ATS function to get preferences
+ */
void *get_preferences_cls;
+ /**
+ * ATS function to get properties
+ */
+ GAS_get_properties get_properties;
+
+ /**
+ * Closure for ATS function to get properties
+ */
+ void *get_properties_cls;
+
struct MLP_Problem p;
struct MLP_Variables pv;
struct MLP_Solution ps;
+ /**
+ * Bulk lock
+ */
+
+ int bulk_lock;
+
+ /**
+ * Number of changes while solver was locked
+ */
+ int bulk_request;
+
/**
* GLPK LP control parameter
*/
/**
* Peers with pending address requests
*/
- struct GNUNET_CONTAINER_MultiHashMap *peers;
+ struct GNUNET_CONTAINER_MultiHashMap *requested_peers;
/**
* Was the problem updated since last solution
/* constraint 3: minimum bandwidth */
unsigned int r_c3;
-
- /* Quality information row indices */
- unsigned int r_q[GNUNET_ATS_QualityPropertiesCount];
-
- /* Quality information */
- double q[GNUNET_ATS_QualityPropertiesCount][MLP_AVERAGING_QUEUE_LENGTH];
-
- /* Quality information averaged */
- double q_averaged[GNUNET_ATS_QualityPropertiesCount];
-
- /* Averaging index */
- int q_avg_i[GNUNET_ATS_QualityPropertiesCount];
};
/**
* Solves the MLP problem
*
* @param solver the MLP Handle
- * @param addresses the address hashmap
* @return GNUNET_OK if could be solved, GNUNET_SYSERR on failure
*/
int
-GAS_mlp_solve_problem (void *solver, struct GNUNET_CONTAINER_MultiHashMap * addresses);
+GAS_mlp_solve_problem (void *solver);
/**
* Init the MLP problem solving component
*
- * @param cfg configuration handle
+ * @param cfg the GNUNET_CONFIGURATION_Handle handle
* @param stats the GNUNET_STATISTICS handle
* @param network array of GNUNET_ATS_NetworkType with length dest_length
* @param out_dest array of outbound quotas
* @param dest_length array length for quota arrays
* @param bw_changed_cb callback for changed bandwidth amounts
* @param bw_changed_cb_cls cls for callback
+ * @param get_preference callback to get relative preferences for a peer
+ * @param get_preference callback to get relative preferences for a peer
+ * @param get_properties_cls for callback to get relative properties
+ * @param get_properties_cls cls for callback to get relative properties
* @return struct GAS_MLP_Handle on success, NULL on fail
*/
void *
GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
const struct GNUNET_STATISTICS_Handle *stats,
+ const struct GNUNET_CONTAINER_MultiHashMap *addresses,
int *network,
unsigned long long *out_dest,
unsigned long long *in_dest,
GAS_bandwidth_changed_cb bw_changed_cb,
void *bw_changed_cb_cls,
GAS_get_preferences get_preference,
- void *get_preference_cls);
+ void *get_preference_cls,
+ GAS_get_properties get_properties,
+ void *get_properties_cls);
/**
* Add a single address within a network to the solver
*
* @param solver the solver Handle
- * @param addresses the address hashmap containing all addresses
* @param address the address to add
* @param network network type of this address
*/
void
GAS_mlp_address_add (void *solver,
- struct GNUNET_CONTAINER_MultiHashMap *addresses,
struct ATS_Address *address,
uint32_t network);
+
/**
- * Updates a single address in the MLP problem
+ * Transport properties for this address have changed
*
- * If the address did not exist before in the problem:
- * The MLP problem has to be recreated and the problem has to be resolved
+ * @param solver solver handle
+ * @param address the address
+ * @param type the ATSI type in HBO
+ * @param abs_value the absolute value of the property
+ * @param rel_value the normalized value
+ */
+void
+GAS_mlp_address_property_changed (void *solver,
+ struct ATS_Address *address,
+ uint32_t type,
+ uint32_t abs_value,
+ double rel_value);
+
+
+/**
+ * Transport session for this address has changed
*
- * ATS performance information in address are already updated, delta + previous
- * values are included in atsi_prev (value GNUNET_ATS_VALUE_UNDEFINED if not existing before)
+ * NOTE: values in addresses are already updated
*
- * Otherwise the addresses' values can be updated and the existing base can
- * be reused
+ * @param solver solver handle
+ * @param address the address
+ * @param cur_session the current session
+ * @param new_session the new session
+ */
+void
+GAS_mlp_address_session_changed (void *solver,
+ struct ATS_Address *address,
+ uint32_t cur_session,
+ uint32_t new_session);
+
+
+/**
+ * Usage for this address has changed
*
- * @param solver the solver Handle
- * @param addresses the address hashmap containing all addresses
- * @param address the update address
- * @param prev_session the new session (if changed otherwise current)
- * @param prev_in_use the new address in use state (if changed otherwise current)
- * @param prev_atsi ATS information updated + previous values, GNUNET_ATS_VALUE_UNDEFINED if not existing before
- * @param prev_atsi_count number of atsi values updated
+ * NOTE: values in addresses are already updated
+ *
+ * @param solver solver handle
+ * @param address the address
+ * @param in_use usage state
*/
void
-GAS_mlp_address_update (void *solver,
- struct GNUNET_CONTAINER_MultiHashMap *addresses,
- struct ATS_Address *address,
- uint32_t prev_session,
- int prev_in_use,
- const struct GNUNET_ATS_Information *prev_atsi,
- uint32_t prev_atsi_count);
+GAS_mlp_address_inuse_changed (void *solver,
+ struct ATS_Address *address,
+ int in_use);
+/**
+ * Network scope for this address has changed
+ *
+ * NOTE: values in addresses are already updated
+ *
+ * @param solver solver handle
+ * @param address the address
+ * @param current_network the current network
+ * @param new_network the new network
+ */
+void
+GAS_mlp_address_change_network (void *solver,
+ struct ATS_Address *address,
+ uint32_t current_network,
+ uint32_t new_network);
+
/**
* Deletes a single address in the MLP problem
*
* The MLP problem has to be recreated and the problem has to be resolved
*
* @param solver the MLP Handle
- * @param addresses the address hashmap
- * the address has to be already removed from the hashmap
* @param address the address to delete
* @param session_only delete only session not whole address
*/
void
GAS_mlp_address_delete (void *solver,
- struct GNUNET_CONTAINER_MultiHashMap *addresses,
struct ATS_Address *address,
int session_only);
* Changes the preferences for a peer in the MLP problem
*
* @param solver the MLP Handle
- * @param addresses the address hashmap
* @param peer the peer
* @param kind the kind to change the preference
* @param pref_rel the relative score
*/
void
GAS_mlp_address_change_preference (void *solver,
- struct GNUNET_CONTAINER_MultiHashMap *addresses,
const struct GNUNET_PeerIdentity *peer,
enum GNUNET_ATS_PreferenceKind kind,
double pref_rel);
/**
- * Get the preferred address for a specific peer
+ * Get application feedback for a peer
+ *
+ * @param solver the solver handle
+ * @param application the application
+ * @param peer the peer to change the preference for
+ * @param scope the time interval for this feedback: [now - scope .. now]
+ * @param kind the kind to change the preference
+ * @param score the score
+ */
+void
+GAS_mlp_address_preference_feedback (void *solver,
+ void *application,
+ const struct GNUNET_PeerIdentity *peer,
+ const struct GNUNET_TIME_Relative scope,
+ enum GNUNET_ATS_PreferenceKind kind,
+ double score);
+
+
+
+/**
+ * Start a bulk operation
+ *
+ * @param solver the solver
+ */
+void
+GAS_mlp_bulk_start (void *solver);
+
+
+/**
+ * Bulk operation done
+ */
+void
+GAS_mlp_bulk_stop (void *solver);
+
+
+/**
+ * Get the preferred address for a specific peer until
+ * GAS_mlp_stop_get_preferred_address is called
*
* @param solver the MLP Handle
- * @param addresses address hashmap
* @param peer the peer
* @return suggested address
*/
const struct ATS_Address *
GAS_mlp_get_preferred_address (void *solver,
- struct GNUNET_CONTAINER_MultiHashMap * addresses,
const struct GNUNET_PeerIdentity *peer);
* Stop notifying about address and bandwidth changes for this peer
*
* @param solver the MLP handle
- * @param addresses address hashmap
* @param peer the peer
*/
-
void
GAS_mlp_stop_get_preferred_address (void *solver,
- struct GNUNET_CONTAINER_MultiHashMap *addresses,
const struct GNUNET_PeerIdentity *peer);