Traning neural networks with extension R in NetLogo -
i creating supply chain simulation netlogo. putting list of lists netlogo r, represented distributor id (agents who) , sales history (sales of previous ticks). in r train neural network , make predictions. when put answer in same format list of lists. need specify result goes agent. however, not know how in netlogo. assume there should function that, understand functions programmed java , need assign values inside raw code , not in netlogo environment. moreover, think training , predictions occurs multiple times (for each agent) , not once.
variable example: [ [0] [ 100 200 300 100 200] ] [ [1] [ 200 300 100 100 200] ]
where first index agents index , second agent's sales history.
maybe explain how netlogo , r can combined computational purpose , not statistical analysis , plotting? assume netlogo similar parallel programming, while style of r programming more linear.
the last part of question beyond me (and may broad typical stack overflow questions- i'm not sure you'll useful answer here). however, maybe example in right direction you're trying do.
i assume you're using [r]
extension in previous question, using setup:
extensions [r] turtles-own [ rand-num ] setup ca crt 10 [ set rand-num random 5 ] reset-ticks end
in example, turtles have rand-num
instead of sales history, concept same. first, build list of lists first index turtle [who]
, second [rand-num]
, output r (note sort
list, clarity , not needed):
to go let l_list map [ -> list [rand-num] of turtle ] ( sort [ ] of turtles ) r:put "list1" l_list show r:get "list1"
next, use r:eval
whatever need values in r- in example i'm using lapply
square rand-num
value (x[[2]]
)- make sure return x
:
let modified_list ( r:get "lapply(list1, function(x) { x[[2]] <- x[[2]]^2; return(x)})" )
now, assign turtles modified values, use netlogo's foreach
iterate on modified list , ask turtle of index 0 (turtle item 0 x
) set rand-num
index 1 (set rand-num item 1 x
):
foreach modified_list [ x -> ask turtle item 0 x [ set rand-num item 1 x ] ] end
if check sort [rand-num] of turtles
before , after running go, should see rand-num
of each turtle squared after go called.
Comments
Post a Comment