gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r35164 - gnunet/src/ats


From: gnunet
Subject: [GNUnet-SVN] r35164 - gnunet/src/ats
Date: Sun, 8 Feb 2015 17:26:49 +0100

Author: grothoff
Date: 2015-02-08 17:26:48 +0100 (Sun, 08 Feb 2015)
New Revision: 35164

Modified:
   gnunet/src/ats/plugin_ats_ril.c
Log:
check for nan

Modified: gnunet/src/ats/plugin_ats_ril.c
===================================================================
--- gnunet/src/ats/plugin_ats_ril.c     2015-02-08 16:24:51 UTC (rev 35163)
+++ gnunet/src/ats/plugin_ats_ril.c     2015-02-08 16:26:48 UTC (rev 35164)
@@ -477,23 +477,20 @@
  */
 static double
 agent_q (struct RIL_Peer_Agent *agent,
-         const double *state, int action)
+         const double *state,
+         int action)
 {
-  int i;
-  double result = 0;
+  unsigned int i;
+  double result = 0.0;
 
   for (i = 0; i < agent->m; i++)
-  {
     result += state[i] * agent->W[action][i];
-  }
 
-  GNUNET_assert(!isnan(result));
-
-  //prevent crash when learning diverges
+  /* prevent crashes if learning diverges */
+  if (isnan(result))
+      return isnan(result) * UINT32_MAX;
   if (isinf(result))
-  {
     return isinf(result) * UINT32_MAX;
-  }
   return result;
 }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]