diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-02-08 16:26:48 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-02-08 16:26:48 +0000 |
commit | acbb6a5bebd11b6c741b0b9ce1b6eb75f4cee61f (patch) | |
tree | 6112530cfe6e88882b1e10392380ab6f43d4f54e /src | |
parent | 3ed995ff5cf8549446f35c93e90f898185abfb43 (diff) | |
download | gnunet-acbb6a5bebd11b6c741b0b9ce1b6eb75f4cee61f.tar.gz gnunet-acbb6a5bebd11b6c741b0b9ce1b6eb75f4cee61f.zip |
check for nan
Diffstat (limited to 'src')
-rw-r--r-- | src/ats/plugin_ats_ril.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/ats/plugin_ats_ril.c b/src/ats/plugin_ats_ril.c index 047be865c..cd867b95c 100644 --- a/src/ats/plugin_ats_ril.c +++ b/src/ats/plugin_ats_ril.c | |||
@@ -477,23 +477,20 @@ struct GAS_RIL_Handle | |||
477 | */ | 477 | */ |
478 | static double | 478 | static double |
479 | agent_q (struct RIL_Peer_Agent *agent, | 479 | agent_q (struct RIL_Peer_Agent *agent, |
480 | const double *state, int action) | 480 | const double *state, |
481 | int action) | ||
481 | { | 482 | { |
482 | int i; | 483 | unsigned int i; |
483 | double result = 0; | 484 | double result = 0.0; |
484 | 485 | ||
485 | for (i = 0; i < agent->m; i++) | 486 | for (i = 0; i < agent->m; i++) |
486 | { | ||
487 | result += state[i] * agent->W[action][i]; | 487 | result += state[i] * agent->W[action][i]; |
488 | } | ||
489 | 488 | ||
490 | GNUNET_assert(!isnan(result)); | 489 | /* prevent crashes if learning diverges */ |
491 | 490 | if (isnan(result)) | |
492 | //prevent crash when learning diverges | 491 | return isnan(result) * UINT32_MAX; |
493 | if (isinf(result)) | 492 | if (isinf(result)) |
494 | { | ||
495 | return isinf(result) * UINT32_MAX; | 493 | return isinf(result) * UINT32_MAX; |
496 | } | ||
497 | return result; | 494 | return result; |
498 | } | 495 | } |
499 | 496 | ||