See also print, type, write, output-show, and Output (programming guide). (This agent is included to help you keep track of what agents are producing which lines of output.) Also, all strings have their quotes included similar to write. If(abs(self.output)>= MAX_PWM-iPWM and (((self.error>=0) and (self.integral_error>=0))or((self. Prints value in the Command Center, preceded by this agent, and followed by a carriage return. Self.output = self.kp*self.error + self.ki*self.integral_error + self.kd*rivative_error rivative_error = (self.error - self.error_last) / dt #self.integral_error += self.error * TIME_STEP IPWM = 20 # initial motor power in duty cycle But it might not be so! For example, if you have undirected links and are interested in knowing the angle from turtle 1 to turtle 0, using link-heading will give you the wrong value: If that's something that you are interested in, fine. If your links are undirected, it reports the heading from the older turtle to the younger turtle.If your links are directed, it reports the heading from the source to the target. However note that this might not be ideal: using link-heading will work spotlessly only if you are interested in knowing the heading from end1 to end2, which means: Since your agents are linked, a first thought could be to use link-heading, which directly reports the heading in degrees from end1 to end2. In NetLogo it is often possible to use turtles' heading to know degrees. For some reason the comment I am referring to has been deleted quickly so I don't know who gave the suggestion, but I read enough of it from the cell notification) Patches already have identifiers so you don't need to assign one, and almost always you should be using agentsets rather than lists.(Following a comment, I replaced the sequence of with just using towards, wich I had overlooked as an option. If that's what you are doing, then there are much better ways of doing it. But you are calling it patch-designation and the procedure is called setup-agents, which makes me think you will be using the numbers you have generated as some sort of identifier for patches where you want agents to be created. You didn't say why you are creating this list. Look up in the dictionary: let, set, loop and n-values to help you understand my comments. The reason you are not getting output is because the stop command exits the whole procedure, not just the loop. Inside the is simply calling the random number generator that gets an integer from 0 up to but not including the number of patches ( count patches) and then adds 1. n-values total-pop says that you want a list of size total-pop that is generated by the expression in. The first part let patch-designation creates a new variable called patch-designation. If you want a list of length total-pop that contains randomly generated numbers from 1 to the number of patches, this single line will do the same thing: let patch-designation n-values total-pop More generally, I have two comments about the code. That is why you are getting an error but you used let in your provided code with the other form of list initiation. Note however that I used let not set because I wanted to declare its existence as well as set the value to empty. The following code works fine for me when I use let patch-designation to initiate the list. If you couldn't tell, I'm a beginner - any criticism on the remaining code is more than welcome. In fact, if I type show length patch-designation inside the console it reads that there is no such variable. However, if I place it outside the loop, I see no output. (2) If I include show length patch-designation inside the loop, I see it updated during each iteration. set patch-designation produces the same error, even though it's almost exactly like the online tutorial. In fact, this happens whenever I use set patch-designation. However, when I try set patch-designation, to create an empty list, I get an error ("Nothing named PATCH-DESIGNATION has been defined"). (1) Online I found that one will define a list like set my-list. I've a number of questions which didn't seem appropriate in individual questions on this site. Set patch-designation lput tmp patch-designation Set tmp tmp + 1 so it's 1 - no-of-patches Let patch-designation list ((random no-of-patches) + 1) ((random no-of-patches) + 1) create list of patch values from 1 - no-of-patches I've the following code, which will (hopefully) generate a list of length total-pop, where each element is a number from 1 - no-of-patches.
0 Comments
Leave a Reply. |