/**
* Whether the agent is active or not
*/
- int active; //TODO? rename into something better. It reflects the state whether get_preferred_address() has been called for the according peer or not
+ int active;
/**
* Number of performed time-steps
solver->plugin_envi->bandwidth_changed_cb (solver->plugin_envi->bw_changed_cb_cls,
new_address);
}
- else
+ else if (agent->address_inuse)
{
GNUNET_assert(0 == ntohl (agent->address_inuse->assigned_bw_in.value__));
GNUNET_assert(0 == ntohl (agent->address_inuse->assigned_bw_out.value__));
envi_get_reward (struct GAS_RIL_Handle *solver, struct RIL_Peer_Agent *agent)
{
/*
- * Match the preferences of the peer with the current assignment.
+ * - Match the preferences of the peer with the current assignment
+ * - Validity of the solution
*/
const double *preferences;
const double *properties;
properties = solver->plugin_envi->get_property (solver->plugin_envi->get_property_cls,
agent->address_inuse);
prop_index = ril_find_property_index (GNUNET_ATS_QUALITY_NET_DELAY);
- pref_match += preferences[GNUNET_ATS_PREFERENCE_LATENCY] * properties[prop_index];
+ pref_match += preferences[GNUNET_ATS_PREFERENCE_LATENCY] * (3 - properties[prop_index]); //invert property as we want to maximize for lower latencies
bw_norm = GNUNET_MAX(2, (((
((double) agent->bw_in / (double) ril_get_max_bw(agent, GNUNET_YES)) +
((double) agent->bw_out / (double) ril_get_max_bw(agent, GNUNET_NO))
pref_match += preferences[GNUNET_ATS_PREFERENCE_BANDWIDTH] * bw_norm;
net = agent->address_inuse->solver_information;
- if ((net->bw_in_assigned > net->bw_in_available) || net->bw_out_assigned > net->bw_out_available)
+ if ((net->bw_in_assigned > net->bw_in_available) || (net->bw_out_assigned > net->bw_out_available))
{
return -1;
}
static void
envi_do_action (struct GAS_RIL_Handle *solver, struct RIL_Peer_Agent *agent, int action)
{
- unsigned int address_index;
+ int address_index;
switch (action)
{
agent->active = GNUNET_NO;
agent->n = RIL_ACTION_TYPE_NUM;
agent->m = solver->networks_count * RIL_FEATURES_NETWORK_COUNT;
- agent->W = (double **) GNUNET_malloc (sizeof (double) * agent->n);
+ agent->W = (double **) GNUNET_malloc (sizeof (double *) * agent->n);
for (i = 0; i < agent->n; i++)
{
agent->W[i] = (double *) GNUNET_malloc (sizeof (double) * agent->m);
//increase size of old state vector
agent->m = m_old;
- GNUNET_array_grow(agent->s_old, agent->m, m_new); //TODO random instead of zero-initialization of state features
+ GNUNET_array_grow(agent->s_old, agent->m, m_new);
agent->m = m_old;
GNUNET_array_grow(agent->e, agent->m, m_new);
enum GNUNET_ATS_PreferenceKind kind,
double score)
{
- //TODO! collect feedback
LOG(GNUNET_ERROR_TYPE_DEBUG,
"API_address_preference_feedback() Peer '%s' got a feedback of %+.3f from application %s for "
"preference %s for %d seconds\n", GNUNET_i2s (peer), "UNKNOWN",
*/
struct GAS_RIL_Handle *s = solver;
struct RIL_Peer_Agent *agent;
+ struct RIL_Network *net;
agent = ril_get_agent (s, peer, GNUNET_YES);
agent->active = GNUNET_YES;
+ if (agent->address_inuse)
+ {
+ net = agent->address_inuse->solver_information;
+ net->bw_in_assigned += agent->bw_in;
+ net->bw_out_assigned += agent->bw_out;
+ }
envi_set_active_suggestion (s, agent, agent->address_inuse, agent->bw_in, agent->bw_out,
GNUNET_YES);
{
struct GAS_RIL_Handle *s = solver;
struct RIL_Peer_Agent *agent;
+ struct RIL_Network *net;
agent = ril_get_agent (s, peer, GNUNET_NO);
}
agent->active = GNUNET_NO;
+ if (agent->address_inuse)
+ {
+ net = agent->address_inuse->solver_information;
+ net->bw_in_assigned -= agent->bw_in;
+ net->bw_out_assigned -= agent->bw_out;
+ }
envi_set_active_suggestion (s, agent, agent->address_inuse, agent->bw_in, agent->bw_out,
GNUNET_YES);