Search the web
Sign In
New User? Sign Up
netlogo-users · NetLogo Users
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want to share photos of your group with the world? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Headless & System Dynamics   Message List  
Reply | Forward Message #9292 of 9893 |
[netlogo-users]stopping condition

Hello,

Here is the code in question:
 if not any? celluloses with [mychainlength > 1] ; check stop conditions for simulations and print outputs
    [
      output-print "All cellulose degraded"
      output-print "Number of iterations required for complete breakdown of cellulose:"
      output-print ticks
 ;    stop
    ]
    if not any? celluloses with [ycor > (- SetMargin) + 1] ; check stop conditions for simulations and print outputs
    [
      if GlucoseIntake = true
      [
        output-print "Glucose intake complete"
        output-print "Number of iterations required for complete glucose intake:"
        output-print ticks
        stop
      ]
    ]

What happens is  if not any? celluloses with [mychainlength > 1] always happens before if not any? celluloses with [ycor > (- SetMargin) + 1] and then till if not any? celluloses with [ycor > (- SetMargin) + 1] happens, all the output inside if not any? celluloses with [mychainlength > 1] are printed . Is there any way to execute if not any? celluloses with [mychainlength > 1] only once? Any method to come out of a procedure without using stop?

Thank you.

Advait
 

Education is a risky business



From: Advait Ashok Apte <advait_apte2002@...>
To: netlogo-users@yahoogroups.com
Sent: Wednesday, 1 July, 2009 17:05:07
Subject: Re: [netlogo-users] Re: concise code

Hello,

Here is the code in question:
 if not any? celluloses with [mychainlength > 1] ; check stop conditions for simulations and print outputs
    [
      output-print "All cellulose degraded"
      output-print "Number of iterations required for complete breakdown of cellulose:"
      output-print ticks
 ;    stop
    ]
    if not any? celluloses with [ycor > (- SetMargin) + 1] ; check stop conditions for simulations and print outputs
    [
      if GlucoseIntake = true
      [
        output-print "Glucose intake complete"
        output-print "Number of iterations required for complete glucose intake:"
        output-print ticks
        stop
      ]
    ]

What happens is  if not any? celluloses with [mychainlength > 1] always happens before if not any? celluloses with [ycor > (- SetMargin) + 1] and then till if not any? celluloses with [ycor > (- SetMargin) + 1] happens, all the output inside if not any? celluloses with [mychainlength > 1] are printed . Is there any way to execute if not any? celluloses with [mychainlength > 1] only once? Any method to come out of a procedure without using stop?

Thank you.

Advait
 

Education is a risky business



From: Jim Lyons <teacherjim42@ gmail.com>
To: netlogo-users@ yahoogroups. com
Sent: Sunday, 28 June, 2009 10:48:47
Subject: Re: [netlogo-users] Re: concise code

Here is yet another approach to the problem. A patch-set of the square's sides is created and then 50 of them sprout the turtles:


breed [ turs tur ]

to test
  let side-patches patches with [abs pycor = 14 and in-range? pxcor -14 14
     or abs pxcor = 14 and in-range? pycor -14 14]
  ask n-of 50 side-patches [ sprout-turs 1 [ set color blue ] ]
end

to-report in-range? [value low high]
  report low <= value and value <= high
end

Jim

On Jun 27, 2009, at 7:49 PM, Advait Ashok Apte wrote:

What I was trying is to create randomness in setting ycor and xcor to 14 or -14. So SOME out of 50 will have xcor set to 14 or -14 and REST will have ycor set.

I was precisely trying not to have more than 1 turtles on same patch!!! Thank you again in advance for answers to my issues.





Thu Jul 2, 2009 5:44 pm

advait_apte2002
Offline Offline
Send Email Send Email

Forward
Message #9292 of 9893 |
Expand Messages Author Sort by Date

Hi, I got some strange behaviour running my System Dynamics Model inside an Headless Workspace (4.1 RC2): Four of five stocks are reseted every tick when...
rob.schr
mrspam@...
Send Email
Jun 26, 2009
1:16 pm

... rob> Hi, I got some strange behaviour running my System Dynamics Model rob> inside an Headless Workspace (4.1 RC2): Four of five stocks are rob> reseted...
Seth Tisue
sethtisue
Offline Send Email
Jun 26, 2009
2:24 pm

Hello, Is there any better way to write following code? repeat random 50 [ create-turs 1 [ set color blue setxy one-of [14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 -1...
Advait Ashok Apte
advait_apte2002
Offline Send Email
Jun 27, 2009
11:23 am

... I don't know if better, but more concise maybe? I think this will do the same thing: create-turs 50 [ set color blue let x one-of [14 (-14)] let y 14 -...
sanbalestrini
Offline
Jun 27, 2009
6:55 pm

Thank you so much all you wonderful guys for the valuable piece of codes! James, you probably answered other 4 to 5 questions I was trying to tackle this...
Advait Ashok Apte
advait_apte2002
Offline Send Email
Jun 28, 2009
1:40 am

Here is yet another approach to the problem. A patch-set of the square's sides is created and then 50 of them sprout the turtles: breed [ turs tur ] to test ...
Jim Lyons
jimlyons37
Offline Send Email
Jun 28, 2009
3:57 pm

Hello, Here is the code in question: if not any? celluloses with [mychainlength > 1] ; check stop conditions for simulations and print outputs [ output-print...
Advait Ashok Apte
advait_apte2002
Offline Send Email
Jul 2, 2009
1:24 am

Hello, Here is the code in question: if not any? celluloses with [mychainlength > 1] ; check stop conditions for simulations and print outputs [ output-print...
Advait Ashok Apte
advait_apte2002
Offline Send Email
Jul 3, 2009
12:26 am

Instead of using stop, you could refactor the code to use IFELSE, so that the second half is not tested when the first condition is true. To control whether...
James Steiner
askturtlezero
Offline Send Email
Jul 4, 2009
5:23 pm

Thanks James. I reconfigured the code. Advait ________________________________ Education is a risky business ________________________________ From: James...
Advait Ashok Apte
advait_apte2002
Offline Send Email
Jul 6, 2009
10:43 pm

How about: crt 50 [ set color blue setxy one-of [14 -14] (random 29 - 14) ] -Steve ... stephen.guerin@... (m) 505.577.5828 (o) 505.995.0206 ...
Stephen Guerin
stephengueri...
Offline Send Email
Jun 27, 2009
6:56 pm

Instead of repeat random 50 [ create-turs 1 [ you can do create-turs random 50 [ Instead of one-of [14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 -1 -2 -3 -4 -5 -6 -7 -8...
James Steiner
askturtlezero
Offline Send Email
Jun 27, 2009
6:56 pm

Whoops. I misread, and didn't notice the "count turs - 50" in the second repeat section. So, where I wrote "n-of random 98" should have been "n-of 50" Sorry, ...
James Steiner
askturtlezero
Offline Send Email
Jun 28, 2009
1:40 am

Thank you all again. I am really thankful for all the discussions and suggestions. You guys rock! Advait ________________________________ Education is a risky...
Advait Ashok Apte
advait_apte2002
Offline Send Email
Jun 29, 2009
2:47 am

Advait, As I read it, you're creating 50 turtles, and placing them more or less randomly at integral coordinates on the perimeter of a square with corners at...
Nick
nickbenn
Offline Send Email
Jun 28, 2009
1:40 am
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help