modified termination condition
[oweals/gnunet.git] / src / ats / gnunet-service-ats-solver_proportional.h
index 180b6c4f43fa607fad65ecd419b7be40cf0c3421..94612b7360b5edc72e582a2beaa13684990c4d5f 100644 (file)
  * General description
  */
 
+/**
+ * Changes the preferences for a peer in the problem
+ *
+ * @param solver the solver handle
+ * @param peer the peer to change the preference for
+ * @param kind the kind to change the preference
+ * @param pref_rel the normalized preference value for this kind over all clients
+ */
+void
+GAS_proportional_address_change_preference (void *solver,
+                                                                                       const struct GNUNET_PeerIdentity *peer,
+                                                                                       enum GNUNET_ATS_PreferenceKind kind,
+                                                                                       double pref_rel);
+
+
+/**
+ * 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_proportional_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);
+
 
 /**
  * Init the proportional problem solver
  * @param cfg configuration handle
  * @param stats the GNUNET_STATISTICS handle
  * @param network array of GNUNET_ATS_NetworkType with length dest_length
+ * @param addresses hashmap containing all addresses
  * @param out_quota array of outbound quotas
  * @param in_quota array of outbound quota
  * @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_cls cls for callback to get relative preferences
+ * @param get_properties_cls for callback to get relative properties
+ * @param get_properties_cls cls for callback to get relative properties
  * @return handle for the solver on success, NULL on fail
  */
 void *
 GAS_proportional_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_quota,
                      unsigned long long *in_quota,
                      int dest_length,
                      GAS_bandwidth_changed_cb bw_changed_cb,
-                     void *bw_changed_cb_cls);
-
+                     void *bw_changed_cb_cls,
+                     GAS_get_preferences get_preference,
+                     void *get_preference_cls,
+                     GAS_get_properties get_properties,
+                     void *get_properties_cls);
 
 /**
  * Shutdown the proportional problem solver
@@ -83,62 +125,114 @@ GAS_proportional_done (void * solver);
  * 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_proportional_address_add (void *solver,
-                                                       struct GNUNET_CONTAINER_MultiHashMap *addresses,
                                                        struct ATS_Address *address,
                                                        uint32_t network);
 
 
 /**
- * Updates a single address in the solve
+ * Transport properties for this address have changed
  *
- * @param solver the solver Handle
- * @param addresses the address hashmap containing all addresses
- * @param address the update address
- * @param session the new session (if changed otherwise current)
- * @param in_use the new address in use state (if changed otherwise current)
- * @param prev_ats the latest ATS information
- * @param prev_atsi_count the atsi count
+ * @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_proportional_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
+ *
+ * NOTE: values in addresses are already updated
+ *
+ * @param solver solver handle
+ * @param address the address
+ * @param cur_session the current session
+ * @param new_session the new session
+ */
+void
+GAS_proportional_address_session_changed (void *solver,
+                                                                                                                       struct ATS_Address *address,
+                                                                                                                       uint32_t cur_session,
+                                                                                                                       uint32_t new_session);
+
+
+/**
+ * Usage for this address has changed
+ *
+ * NOTE: values in addresses are already updated
+ *
+ * @param solver solver handle
+ * @param address the address
+ * @param in_use usage state
  */
 void
-GAS_proportional_address_update (void *solver,
-    struct GNUNET_CONTAINER_MultiHashMap *addresses,
-    struct ATS_Address *address,
-    uint32_t session,
-    int in_use,
-    const struct GNUNET_ATS_Information *atsi,
-    uint32_t atsi_count);
+GAS_proportional_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_proportional_address_change_network (void *solver,
+                                                                                                                                          struct ATS_Address *address,
+                                                                                                                                          uint32_t current_network,
+                                                                                                                                          uint32_t new_network);
 
 /**
  * Remove an address from the solver
  *
  * @param solver the solver handle
- * @param addresses the address hashmap containing all addresses
  * @param address the address to remove
  * @param session_only delete only session not whole address
  */
 void
 GAS_proportional_address_delete (void *solver,
-    struct GNUNET_CONTAINER_MultiHashMap * addresses,
     struct ATS_Address *address, int session_only);
 
 
+/**
+ * Start a bulk operation
+ *
+ * @param solver the solver
+ */
+void
+GAS_proportional_bulk_start (void *solver);
+
+
+/**
+ * Bulk operation done
+ */
+void
+GAS_proportional_bulk_stop (void *solver);
+
 /**
  * Stop notifying about address and bandwidth changes for this peer
  *
- * @param solver the MLP handle
- * @param addresses address hashmap
+ * @param solver the proportional handle
  * @param peer the peer
  */
 void
 GAS_proportional_stop_get_preferred_address (void *solver,
-                                     struct GNUNET_CONTAINER_MultiHashMap *addresses,
                                      const struct GNUNET_PeerIdentity *peer);
 
 
@@ -146,30 +240,10 @@ GAS_proportional_stop_get_preferred_address (void *solver,
  * Get the prefered address for a specific peer
  *
  * @param solver the solver handle
- * @param addresses the address hashmap containing all addresses
  * @param peer the identity of the peer
  */
 const struct ATS_Address *
 GAS_proportional_get_preferred_address (void *solver,
-                               struct GNUNET_CONTAINER_MultiHashMap * addresses,
                                const struct GNUNET_PeerIdentity *peer);
 
-
-/**
- * Changes the preferences for a peer in the problem
- *
- * @param solver the solver handle
- * @param client the client with this preference
- * @param peer the peer to change the preference for
- * @param kind the kind to change the preference
- * @param score the score
- */
-void
-GAS_simplistic_address_change_preference (void *solver,
-                                   void *client,
-                                   const struct GNUNET_PeerIdentity *peer,
-                                   enum GNUNET_ATS_PreferenceKind kind,
-                                   float score);
-
-
 /* end of gnunet-service-ats-solver_proportional.c */