aboutsummaryrefslogtreecommitdiff
path: root/src/ats
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-12-13 12:05:02 +0000
committerChristian Grothoff <christian@grothoff.org>2013-12-13 12:05:02 +0000
commit7a6122ffb371571584103e54c6287a7da239d6a2 (patch)
tree35535b73782bdc5bbe55e244cdf686140a3080d2 /src/ats
parent6e01f81731ef1abeb1575e507c6fccf4a95328ec (diff)
downloadgnunet-7a6122ffb371571584103e54c6287a7da239d6a2.tar.gz
gnunet-7a6122ffb371571584103e54c6287a7da239d6a2.zip
-doxygen, style fixes
Diffstat (limited to 'src/ats')
-rwxr-xr-xsrc/ats/plugin_ats_ril.c41
1 files changed, 22 insertions, 19 deletions
diff --git a/src/ats/plugin_ats_ril.c b/src/ats/plugin_ats_ril.c
index 88120d517..f9c44c9cf 100755
--- a/src/ats/plugin_ats_ril.c
+++ b/src/ats/plugin_ats_ril.c
@@ -380,6 +380,7 @@ struct GAS_RIL_Handle
380static int 380static int
381ril_count_agents(struct GAS_RIL_Handle * solver); 381ril_count_agents(struct GAS_RIL_Handle * solver);
382 382
383
383/** 384/**
384 * Estimate the current action-value for state s and action a 385 * Estimate the current action-value for state s and action a
385 * 386 *
@@ -405,10 +406,10 @@ agent_estimate_q (struct RIL_Peer_Agent *agent, double *state, int action)
405 { 406 {
406 return isinf(result) * UINT32_MAX; //TODO! fix 407 return isinf(result) * UINT32_MAX; //TODO! fix
407 } 408 }
408
409 return result; 409 return result;
410} 410}
411 411
412
412/** 413/**
413 * Decide whether to do exploration (i.e. taking a new action) or exploitation (i.e. taking the 414 * Decide whether to do exploration (i.e. taking a new action) or exploitation (i.e. taking the
414 * currently estimated best action) in the current step 415 * currently estimated best action) in the current step
@@ -430,13 +431,14 @@ agent_decide_exploration (struct RIL_Peer_Agent *agent)
430 return GNUNET_NO; 431 return GNUNET_NO;
431} 432}
432 433
433 /** 434
434 * Get the index of the address in the agent's list. 435/**
435 * 436 * Get the index of the address in the agent's list.
436 * @param agent agent handle 437 *
437 * @param address address handle 438 * @param agent agent handle
438 * @return the index, starting with zero 439 * @param address address handle
439 */ 440 * @return the index, starting with zero
441 */
440static int 442static int
441agent_address_get_index (struct RIL_Peer_Agent *agent, struct ATS_Address *address) 443agent_address_get_index (struct RIL_Peer_Agent *agent, struct ATS_Address *address)
442{ 444{
@@ -448,14 +450,12 @@ agent_address_get_index (struct RIL_Peer_Agent *agent, struct ATS_Address *addre
448 { 450 {
449 i++; 451 i++;
450 if (cur->address_naked == address) 452 if (cur->address_naked == address)
451 {
452 return i; 453 return i;
453 }
454 } 454 }
455
456 return i; 455 return i;
457} 456}
458 457
458
459/** 459/**
460 * Gets the wrapped address from the agent's list 460 * Gets the wrapped address from the agent's list
461 * 461 *
@@ -469,16 +469,12 @@ agent_address_get (struct RIL_Peer_Agent *agent, struct ATS_Address *address)
469 struct RIL_Address_Wrapped *cur; 469 struct RIL_Address_Wrapped *cur;
470 470
471 for (cur = agent->addresses_head; NULL != cur; cur = cur->next) 471 for (cur = agent->addresses_head; NULL != cur; cur = cur->next)
472 {
473 if (cur->address_naked == address) 472 if (cur->address_naked == address)
474 {
475 return cur; 473 return cur;
476 } 474 return NULL;
477 }
478
479 return NULL ;
480} 475}
481 476
477
482/** 478/**
483 * Gets the action, with the maximal estimated Q-value (i.e. the one currently estimated to bring the 479 * Gets the action, with the maximal estimated Q-value (i.e. the one currently estimated to bring the
484 * most reward in the future) 480 * most reward in the future)
@@ -510,6 +506,7 @@ agent_get_action_best (struct RIL_Peer_Agent *agent, double *state)
510 return max_i; 506 return max_i;
511} 507}
512 508
509
513/** 510/**
514 * Gets any action, to explore the action space from that state 511 * Gets any action, to explore the action space from that state
515 * 512 *
@@ -524,6 +521,7 @@ agent_get_action_explore (struct RIL_Peer_Agent *agent, double *state)
524 return GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, agent->n); 521 return GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, agent->n);
525} 522}
526 523
524
527/** 525/**
528 * Updates the weights (i.e. coefficients) of the weight vector in matrix W for action a 526 * Updates the weights (i.e. coefficients) of the weight vector in matrix W for action a
529 * 527 *
@@ -563,10 +561,11 @@ agent_update_weights (struct RIL_Peer_Agent *agent, double reward, double *s_nex
563 } 561 }
564} 562}
565 563
564
566/** 565/**
567 * Changes the eligibility trace vector e in various manners: 566 * Changes the eligibility trace vector e in various manners:
568 * #RIL_E_ACCUMULATE - adds @a f to each component as in accumulating eligibility traces 567 * #RIL_E_ACCUMULATE - adds @a f to each component as in accumulating eligibility traces
569 * #RIL_E_REPLACE - resets each component to @f as in replacing traces 568 * #RIL_E_REPLACE - resets each component to @a f as in replacing traces
570 * #RIL_E_SET - multiplies e with discount factor and lambda as in the update rule 569 * #RIL_E_SET - multiplies e with discount factor and lambda as in the update rule
571 * #RIL_E_ZERO - sets e to 0 as in Watkin's Q-learning algorithm when exploring and when initializing 570 * #RIL_E_ZERO - sets e to 0 as in Watkin's Q-learning algorithm when exploring and when initializing
572 * 571 *
@@ -575,7 +574,9 @@ agent_update_weights (struct RIL_Peer_Agent *agent, double reward, double *s_nex
575 * @param f how much to change 574 * @param f how much to change
576 */ 575 */
577static void 576static void
578agent_modify_eligibility (struct RIL_Peer_Agent *agent, enum RIL_E_Modification mod, double *f) 577agent_modify_eligibility (struct RIL_Peer_Agent *agent,
578 enum RIL_E_Modification mod,
579 double *f)
579{ 580{
580 int i; 581 int i;
581 double *e = agent->e; 582 double *e = agent->e;
@@ -610,6 +611,7 @@ ril_inform (struct GAS_RIL_Handle *solver,
610 solver->plugin_envi->info_cb (solver->plugin_envi->info_cb_cls, op, stat, GAS_INFO_NONE); 611 solver->plugin_envi->info_cb (solver->plugin_envi->info_cb_cls, op, stat, GAS_INFO_NONE);
611} 612}
612 613
614
613/** 615/**
614 * Changes the active assignment suggestion of the handler and invokes the bw_changed callback to 616 * Changes the active assignment suggestion of the handler and invokes the bw_changed callback to
615 * notify ATS of its new decision 617 * notify ATS of its new decision
@@ -699,6 +701,7 @@ envi_set_active_suggestion (struct GAS_RIL_Handle *solver,
699 agent->address_inuse = new_address; 701 agent->address_inuse = new_address;
700} 702}
701 703
704
702static unsigned long long 705static unsigned long long
703ril_network_get_assigned (struct GAS_RIL_Handle *solver, enum GNUNET_ATS_Network_Type type, int direction_in) 706ril_network_get_assigned (struct GAS_RIL_Handle *solver, enum GNUNET_ATS_Network_Type type, int direction_in)
704{ 707{