netlogo

Comparing two agent variables

半世苍凉 提交于 2019-12-11 18:42:28
问题 I am currently making a simulation (for homework) using genetic algorithms. What I want to do is compare the fitness of agents on a specific patch and the one with the lowest fitness will die. I have scoured the net and found this code: if any? breed1-here with [fitness > fitness-of myself] [die]] But this doesn't seem to work and now I'm completely out of ideas. 回答1: let goner min-one-of breed1-here [fitness] if is-turtle? goner [ ask goner [ die ] ]` the is-turtle? check is necessary

proucedure of pheromone end its variation 2

穿精又带淫゛_ 提交于 2019-12-11 18:41:17
问题 this is our procedure but we have a problem , the pheromone never be 0 and we need it to be 0 what should 'i do ? LayPheromone if (pheromone < maxPheroPerSite-Forage) [set pheromone (pheromone + amtPheroLay-Forage)] end to UpdatePatches ask patch nestX nestY [ set pcolor pink ] ask patches [ if (pheromone < 0) [set pheromone 0] if (pheromone > 0) [ set pheromone (pheromone - pheromone * evaporation-rate) ifelse showPhero? [ set pcolor scale-color yellow pheromone 0 (maxPheroPerSite-Forage)] [

NetLogo: How to export the mean value of a plot to BehaviourSpace directly?

三世轮回 提交于 2019-12-11 17:52:17
问题 I was wondering if there is a way to add mean of a plot to BehaviourSpace measure , I was thinking to add that value to a list and then use the mean value of that list in my experiment, but I just wanted to double check if this is the only way I can do it. I can use variable [] and update the value each tick and export mean value of this variable as an output for my experiment. Any other suggestions are really welcomed: set Gi lput Gini-v1 "Village1" Gi ; this is in go procedure to-report

Netlogo - add one more digit to the string automatically

别说谁变了你拦得住时间么 提交于 2019-12-11 17:19:44
问题 I am modelling a warehouse. each cell has been assigned to a id in a format like below. The standard format of the external data is four digits. However, there are some ids which are only 3 like "A05". Is there a easy way to automatically add one more "0' to make it like "A005"? 回答1: Maybe this reporter will work for you- it should just add a zero in the second position until the string length is 4 or greater. to setup ca print map add-zero [ "A" "A1" "A01" "A001" "A123" ] reset-ticks end to

NetLogo - no more than 5 % of population has a certain value of variable

痴心易碎 提交于 2019-12-11 17:18:07
问题 How can I give each tick a random amount of turtles a change in a binary variable (1 or 0), whereas no more than 5 % of the existing population at all times has a value of 0 in that variable? In other words, I wish to have that the total amount of turtles having a variable value of 0 is between 0 % or 5 % of the total amount of turtles at every tick. How can I achieve this? My code is: to setup create-turtles 100 set var random 1 (only 5 % max shall have a 0 at start) end to start change end

Movement of turtles between nodes following the shortest path

橙三吉。 提交于 2019-12-11 17:13:19
问题 I am trying to move my citizens from one node (slocation) to another node (new-location) calculating the shortest path. I could only calculate the distance from slocation to new-location using set total-expected-path [distance [slocation] of myself] of new-location. However, I am pretty sure that the following line after to set total-expected-path are not correct. I got the following error: this code can't be run by a turtle, only a link error while node 35 running LINK-LENGTH How can I

Netlogo list updated in time

泪湿孤枕 提交于 2019-12-11 14:26:31
问题 I'm writing up a code in Netlogo that basically should do the following: Amongst directed links, interact and seek out their cooperative behavior (coop_b). Store coop_b in a list variable together with the time of the interaction (reputation_now) Every interaction, add the reputation_now to a bigger list, reputation_h (reputation history) Now, add a time-weight to the reputation, so that the more recently had interactions weigh more in the total reputation. I do this by dividing the encounter

How to run several procedures simultaneously in NetLogo?

痞子三分冷 提交于 2019-12-11 13:54:41
问题 There are different colored turtles in my model each operating under different rules. I want procedures governing the movement of one turtle(say, red turtle) to run simultaneously with other procedures governing the movement of different colored turtles. 回答1: Alan's answer is the correct one. However, just FYI - each turtle (whether red or blue) will act in turn with the above procedure, and none with act "at the same time." That just doesn't happen in NetLogo, by default. However, you can

How to change agent's variable by passing variable name and value to a function?

僤鯓⒐⒋嵵緔 提交于 2019-12-11 13:33:45
问题 How is it possible to change specific variable of an agent by passing variable name to a function? for example I have turtles with variable MONEY and the following function: to setVariable [varname varvalue] [ ask one-of turtles [ set varname varvalue ] ] end Now I want to run: observer> ask one-of turtles [setVariable MONEY 100] ;; I need to ask via another turtle since I cannot use MONEY directly in observer context And it does not set my variable without giving any errors. Interestingly,

NetLogo video capturing file size and format

只愿长相守 提交于 2019-12-11 13:09:58
问题 Following http://ccl.northwestern.edu/netlogo/docs/programming.html#movies . I created video of my model comprising of run 2351 ticks. It created a video of size 1GB!. The video lasts only two and half minutes. I don't seem to understand why. I tried varying frame-rate still the huge file size. It gives a file-size of 560 Mb for a 10 sec movie! What am I missing something here? Also, Is it possible to extract the video in some other format than .mov like .mp4 or .avi which are Windows