logo
down
shadow

Netlogo: How can I obtain the accumulate value in Netlogo?


Netlogo: How can I obtain the accumulate value in Netlogo?

Content Index :

Netlogo: How can I obtain the accumulate value in Netlogo?
Tag : development , By : user161314
Date : January 12 2021, 08:33 AM

fixed the issue. Will look into that further that's much better, thanks- I can now run the code no problem. However, I still don't think I understand what you are wanting cumulative-sum to actually count. Are you just looking for the total number of turtles, including both those still alive and the ones that have died? If so, I think it's just a matter of moving your set cumulative-sum cumulative-sum + 1 line. For example:
EDIT:
globals [num-turtles cumulative-sum average-time number-dead ]
turtles-own [count-up]

to setup
  clear-all
  set num-turtles 5
  reset-ticks
end

to go

  if count turtles < num-turtles [
    ask patch 0 0 [
      sprout 1 [
        set count-up 0
      ]
    ]
  ] 

  if (count turtles > 0) [
    ask min-one-of turtles [who] [
      if count-up >= 6 [
        set number-dead number-dead + 1
        die
      ]
    ]
  ]

  ask turtles-on patch 0 0 [
    set count-up count-up + 1
  ]

  set cumulative-sum cumulative-sum + count turtles
  set average-time ifelse-value (number-dead = 0) [0]  [(cumulative-sum) / (number-dead)]

  tick
end

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Tag : development , By : jazzyfox
Date : March 29 2020, 07:55 AM
To fix the issue you can do random 20 might return 0 or 1, and then the first thing you do to move-distance inside the loop is subtract 1 from it, so the move-distance = 1 check will fail because it's already below 1.
Try replacing move-distance = 1 with move-distance <= 1, and/or replace random 20 with 2 + random 18.

Tag : development , By : Igor Carron
Date : March 29 2020, 07:55 AM
Any of those help You need to store the lagged value (e.g., in a turtle attribute). For example,
turtles-own [x xlag]

to setup
  ca
  crt 1 [set x random-float 1.0]
end

to go
  ask turtles [set xlag x]  
  ask turtles [set x random-float 1.0]
  ask turtle 0 [show x - xlag]
end

Netlogo: Can Netlogo set up an infinite number of turtles for only one specific patch?


Tag : development , By : ganok_tor
Date : March 29 2020, 07:55 AM
I hope this helps . As per Bryan's answer, there is no theoretical restriction on the number of turtles in a single patch, although your computer will have a limit- the more turtles in your model (on any patch) the more memory your model will use. So the short answer is, as far as I know, there is no way to just say to Netlogo, "Spawn infinite turtles on this patch."
If, however, by infinite you really just want enough turtles that you won't run out of them for specific interactions, you could probably get by either by just spawning a large number on that patch or by just sprouting more as needed (my preference).
to setup
  ca
  reset-ticks
  ask patch 0 0 [
    sprout 10000
  ]
  ask patch 0 0 [
    print count turtles-here
  ]
end
to setup
  ca
  reset-ticks
  infinite-sprout
  source-sprout

end

to go

  ask turtles with [ color = red ] [
    fd 0.5
    if any? ( turtles-on patch-ahead 1 ) with [ color = blue ] [
      create-link-with one-of turtles-on patch-ahead 1 [
        tie
      ]        
      set color green        
    ]
  ]
  ask turtles with [color = green] [
    move-to patch-right-and-ahead 90 1
    if pycor = max-pycor [
      ask link-neighbors [ 
        die
      ]
      die
    ]
  ]

  infinite-sprout
  source-sprout
  tick

end


to source-sprout
  ask patch max-pxcor 0 [
    if not any? turtles-here and random 3 = 1 [
      sprout 1 [
        set shape "arrow"
        set color red
        set heading 270
      ]
    ]
  ]
end

to infinite-sprout
  ask patch 0 0 [
    if count turtles-here < 1000 [
      sprout ( 1000 - count turtles-here) [
        set shape "circle"
        set color blue
      ]
    ]
  ]
end

How do I translate my code from Netlogo to Netlogo Web? ('TO or TO-REPORT expected' error)


Tag : development , By : ERaubenheimer
Date : March 29 2020, 07:55 AM

Is NetLogo too slow for big simulations? How can I speed up a NetLogo model?


Tag : performance , By : Aires
Date : March 29 2020, 07:55 AM
Related Posts Related QUESTIONS :
  • SugarCRM Rest API set_relationship between Contacts and Documents
  • Jira dashboard organization
  • Web worker importScripts fails to place script variables in global scope
  • Always errors - The "path" argument must be one of type string, Buffer, or URL. Received type undefined
  • How to create an observable of a stream of infinite items
  • Not efficiently to use multi-Core CPU for training Doc2vec with gensim
  • webGL gl_Position value saving outside shaders
  • Is it okay for a resolver to have side effects besides resolving the type?
  • Move 32bit register into a 8 bit register
  • Is there a way to update, not overwrite, worker_env for a Dask YarnCluster within a script?
  • Lotus Notes Deployment
  • How Do I Add Active Directory To APIM Using Terraform?
  • How to get the old parameter values in Blazor OnParameterSet?
  • How to debug "ERROR: Could not reach the worker node."?
  • How chain indefinite amount of flatMap operators in Reactor?
  • extract dates and times from string in Redshift
  • How do I make a column of 3 cards match in height in bootstrapVue?
  • how to replace missing values from another column in PySpark?
  • only read last line of text file (C++ Builder)
  • Snakemake --forceall --dag results in mysterius Error: <stdin>: syntax error in line 1 near 'File' from Graphvis
  • How Can I Remove Demo Products From APIM Created With Terraform?
  • How to avoid cloning a big integer in rust
  • Break a row of words into word groups in Hive
  • How can I add a path variable to existing files in an Installshield project converted from MSI
  • Certain languages are not available in postman; is there a way to enable it?
  • Concatenation step of U-Net for unequal number of channels
  • HL Fabric - states, transactions but varied keys
  • How to handle "flood wait" errors when using telethon.sync?
  • Any way to make closure which takes a destructured array?
  • What is the Difference between @PeculiarVentures 's `webcrypto` and `node-webcrypto-ossl`?
  • DWG Sheet Combination failing on AutoDesk Forge
  • karate.log(args) on afterScenario hook is not embedded on surefire json file
  • How do I output latest distinct values of specific fields and all other colums?
  • Clarification on lit-element components and where to browse them
  • Will websockets over HTTP2 also be multiplexed in streams?
  • How to apply switch statement for multi columns in datatables
  • frobot framework - Usage outside testing
  • How do I build against the UCRT with mingw-w64?
  • How to use someClass.android.ts and someClass.ios.ts without errors
  • ADB Connection to Samsung smart tv
  • is there a way to 2 create multiple command files in cypress
  • Best way to filter DBpedia results and return a specific results using SPARQL
  • Is it possible to use unicode combining characters to combine arbitrary characters?
  • Antlr4 extremely simple grammar failing
  • Neighbor of 10 wrong answer?
  • PDFlib - setting stroke and fill opacity (transparency)
  • AWS Lambda + Serverless, where/how to deploy js module that couldn't be bundled?
  • how to place mobile call from PWA
  • How to get connected clients and client certificate in node-opcua server
  • Passing dictionary from one template to another in Helm
  • Kivy. Position of GridLayout inside ScrollView
  • How can I try to place a pending order every X minutes till it's successfull?
  • Is there a way to download the SonarLint report generated in Eclipse IDE?
  • How to Open Port in Windows Firewall using C++ Builder?
  • How to put "OR" operator in Karate API assertion statement
  • Get .model.json as String
  • Proof Process busy on combine_split
  • Does memoization work on smple .select with strings?
  • Check if movement ended
  • Determine If a String Is Present in a List or Map?
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com