Programmation avec Netlogo

Fermé
Romeric - Modifié par KX le 31/12/2016 à 22:13
KX Messages postés 16734 Date d'inscription samedi 31 mai 2008 Statut Modérateur Dernière intervention 24 avril 2024 - 31 déc. 2016 à 22:21
Salut! S'il vous plait voici un bout de code que je n'arrive pas à interpréter:
Set prediction predict-attendance? Sublist history week(week + memory-size)
Set score score+abs(item(week-1) history-prediction

Et aussi
Set prediction predict-attendance? Best-strategy sublist history 0 memory-size

NB:
predict-attendance
est une fonction je pense, voici son code:
To report predict-attendance [strategy subhistory]
Report 100*first strategy + sum(map [?1*?2] butfirst strategy subhistory)

Ce code est tiré du code source de El Farol dans les bibliotheques Netlogo. S'il est possible de l'expliquer à l'aide d'un algorithme, il me sera surement plus compréhensible. Merci
A voir également:

1 réponse

KX Messages postés 16734 Date d'inscription samedi 31 mai 2008 Statut Modérateur Dernière intervention 24 avril 2024 3 015
31 déc. 2016 à 22:21
Bonsoir,

Si tu as le code, tu dois aussi avoir les commentaires qui vont avec :

;; This reports an agent's prediction of the current attendance
;; using a particular strategy and portion of the attendance history.
;; More specifically, the strategy is then described by the formula
;; p(t) = x(t - 1) * a(t - 1) + x(t - 2) * a(t -2) +..
;;      ... + x(t - MEMORY-SIZE) * a(t - MEMORY-SIZE) + c * 100,
;; where p(t) is the prediction at time t, x(t) is the attendance of the bar at time t,
;; a(t) is the weight for time t, c is a constant, and MEMORY-SIZE is an external parameter.
to-report predict-attendance [strategy subhistory]
  ;; the first element of the strategy is the constant, c, in the prediction formula.
  ;; one can think of it as the the agent's prediction of the bar's attendance
  ;; in the absence of any other data
  ;; then we multiply each week in the history by its respective weight
  report 100 * first strategy + sum (map [?1 * ?2] butfirst strategy subhistory)
end

Et plus globalement, tu as la description du modèle sur le site de NetLogo
http://ccl.northwestern.edu/netlogo/models/ElFarol
0