[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r30818 - gnunet/src/ats
From: |
gnunet |
Subject: |
[GNUnet-SVN] r30818 - gnunet/src/ats |
Date: |
Tue, 19 Nov 2013 18:38:28 +0100 |
Author: oehlmann
Date: 2013-11-19 18:38:27 +0100 (Tue, 19 Nov 2013)
New Revision: 30818
Modified:
gnunet/src/ats/libgnunet_plugin_ats_ril.c
Log:
globalized networks state
Modified: gnunet/src/ats/libgnunet_plugin_ats_ril.c
===================================================================
--- gnunet/src/ats/libgnunet_plugin_ats_ril.c 2013-11-19 17:03:44 UTC (rev
30817)
+++ gnunet/src/ats/libgnunet_plugin_ats_ril.c 2013-11-19 17:38:27 UTC (rev
30818)
@@ -305,6 +305,11 @@
double discount_integrated;
/**
+ * State vector for networks for the current step
+ */
+ double *state_networks;
+
+ /**
* Lock for bulk operations
*/
int bulk_lock;
@@ -661,6 +666,22 @@
return sum;
}
+static void
+envi_state_networks (struct GAS_RIL_Handle *solver)
+{
+ int i;
+ struct RIL_Network net;
+
+ for (i = 0; i < solver->networks_count; i++)
+ {
+ net = solver->network_entries[i];
+ solver->state_networks[i * RIL_FEATURES_NETWORK_COUNT + 0] = (double)
ril_network_get_assigned(solver, net.type, GNUNET_YES);
+ solver->state_networks[i * RIL_FEATURES_NETWORK_COUNT + 1] = (double)
net.bw_in_available;
+ solver->state_networks[i * RIL_FEATURES_NETWORK_COUNT + 2] = (double)
ril_network_get_assigned(solver, net.type, GNUNET_NO);
+ solver->state_networks[i * RIL_FEATURES_NETWORK_COUNT + 3] = (double)
net.bw_out_available;
+ }
+}
+
/**
* Allocates a state vector and fills it with the features present
* @param solver the solver handle
@@ -672,18 +693,17 @@
{
int i;
int k;
- struct RIL_Network net;
double *state = GNUNET_malloc (sizeof (double) * agent->m);
struct RIL_Address_Wrapped *cur_address;
const double *properties;
+ //copy global networks state
for (i = 0; i < solver->networks_count; i++)
{
- net = solver->network_entries[i];
- state[i * RIL_FEATURES_NETWORK_COUNT + 0] = (double)
ril_network_get_assigned(solver, net.type, GNUNET_YES);
- state[i * RIL_FEATURES_NETWORK_COUNT + 1] = (double) net.bw_in_available;
- state[i * RIL_FEATURES_NETWORK_COUNT + 2] = (double)
ril_network_get_assigned(solver, net.type, GNUNET_NO);
- state[i * RIL_FEATURES_NETWORK_COUNT + 3] = (double) net.bw_out_available;
+ state[i * RIL_FEATURES_NETWORK_COUNT + 0] = solver->state_networks[i *
RIL_FEATURES_NETWORK_COUNT + 0];
+ state[i * RIL_FEATURES_NETWORK_COUNT + 1] = solver->state_networks[i *
RIL_FEATURES_NETWORK_COUNT + 1];
+ state[i * RIL_FEATURES_NETWORK_COUNT + 2] = solver->state_networks[i *
RIL_FEATURES_NETWORK_COUNT + 2];
+ state[i * RIL_FEATURES_NETWORK_COUNT + 3] = solver->state_networks[i *
RIL_FEATURES_NETWORK_COUNT + 3];
}
i = i * RIL_FEATURES_NETWORK_COUNT; //first address feature
@@ -1292,6 +1312,9 @@
solver->discount_integrated = (1 - solver->discount_variable)
/ ((double) solver->parameters.beta);
+ //calculate network state vector
+ envi_state_networks(solver);
+
//trigger one step per active agent
for (cur = solver->agents_head; NULL != cur; cur = cur->next)
{
@@ -1665,6 +1688,7 @@
solver->networks_count = env->network_count;
solver->network_entries = GNUNET_malloc (env->network_count * sizeof (struct
RIL_Network));
solver->step_count = 0;
+ solver->state_networks = GNUNET_malloc (solver->networks_count *
RIL_FEATURES_NETWORK_COUNT * sizeof (double));
for (c = 0; c < env->network_count; c++)
{
@@ -1710,6 +1734,7 @@
GNUNET_SCHEDULER_cancel (s->step_next_task_id);
}
GNUNET_free(s->network_entries);
+ GNUNET_free(s->state_networks);
GNUNET_free(s);
return NULL ;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r30818 - gnunet/src/ats,
gnunet <=