I built a NetLogo model to simulate the crowd evacuation. The "go" procedure is needed to run forever until the stop condition is met.
Here is the strange thing: sometimes the "go" button works properly, but sometimes the "go" stops after only one run (I do check the "forever" box), and I have to click the "go" button manually and continuously to proceed the model, and no warnings or errors were thrown out, but the tick remains 0, and the print commands in "go" procedure cannot print anything in the output window. And the weird thing is sometimes when I wait for a while and open the model again, it is normal.
I doubt this might relate with the memory issue because the model usually works fine when I reduce the number of agents. But if it is, should it throw out the "out of memory" error?
Could someone give some suggestions about my problem?
Related
When using VSCode to build a Flutter app that makes calls to an API every call auto break points which is incredibly annoying. By auto breaking, I mean that the code halts on lines that do not have break points set on them for code that is not ours - in this case it is framework code (browser_client.dart)
Success Response
Error Response
There is a weird yellow prompt that appears which I guess means current line but its icons pop up all over the place at random locations in code for no discernable reason other than to be very, very annoying. If the code errors out then I would expect the flow to fall through to the try..catch handler wrapping all these calls which it does but not before halting here.
If the call succeeds and it happens to be returning a list of 100 items, it will halt 100 times forcing us to F5 through the loop as it is read. By this I mean it will halt 100 times on the line shown in the success response image above, not in the loop of our application code. It's also only making one call so its not a case of it making 100 calls to the API and halting each time.
Debug only My Own Code is turned on and breakpoints are set only within our own code.
What setting is causing this halting issue and how do we turn it off?
I'm new to Anylogic and created a simple traffic model. Only use 'carSource', 'CarMoveTo', 'Car Dispose' blocks to set the car routes. But After I ran the model, it worked for a while, then all the cars froze without any error occurring. ’Events‘ panel also stopped. How to solve it?
Most likely your model is running into an infinite loop somewhere in the logic. The first place to check would be all your loops that might become infinite,e.g Do loops, Do-while loops, iterator for loops where you perhaps change the counter variable manually...
If you have the professional version of AnyLogic the best option is to run the model in debug mode until you get this to the point where it freezes and then press pause. You will then see where in the code the model is getting stuck.
If this does not work you might need to start putting traceln in major functions and see ing you can spot the last traceln that gets printed and keep on adding more and more until you can find the point between two traceln where the model freezes
I had the same problem, that after a certain time, all cars froze and there wasn't a signle error.
The problem on my side was that the stop line was too close to the intersection, so I moved it a little bit farther.
When you are stepping through Swift code in Xcode (9/10?), there is a green bar on the right with something like:
You are supposed to be able to drag the partial-hamburger-menu upwards to rewind the statement pointer to re-run code. However, every time I try it it moves back as expected, but then 100% of the time I step from that point I get:
Is there a trick to this?
You can move the pointer to the next statement to be executed to either a previously executed statement or a not-yet-executed statement, but in order for that to work the stack needs to be in the correct state, and so do the variables in memory.
In my experience, the outcome is usually a crash.
You'd need to drop down to the assembler code and examine it in order to figure out what's really going on, and might need to patch variables and/or the contents of the stack in order for your code to survive the change of program counter. I've never invested the time to try to do that, however. As a result I find the feature pretty much useless, and have given up on it. (I've worked in assembler a LOT in years past, but never learned enough about ARM assembler to be able to read it well, much less hack registers, memory, and the stack to make moving the program counter work.)
.nlogo file
I am getting this error while running iterations using behavior space
The tick counter has not been started yet. Use RESET-TICKS.
error while observer running TICKS
called by procedure __EVALUATOR
I am not sure why this is happening. I have included reset-ticks in the "set" routine.
In addition in the behavior space dialog wizard, i also included reset-ticks as the final command to be executed. Yet i am getting this error.
Below is my setup and go code:
to setup
clear-all
setup-citizens
setup-parties
update-support
reset-ticks
end
to go
ask parties [ adapt set my-old-size my-size ]
update-support
election
plot-voter-turnout
plot-volatility
if (Turnout-100%? = false) [plot-citizen-comparison]
tick
end
You are using ticks in your BehaviorSpace experiment's "stop condition", so I think it's nearly certain that's where the "error while observer running TICKS" error must be coming from, given that the stack trace doesn't refer to a procedure name.
Here's my best guess at what's going on here: under some conditions, your setup procedure fails, and therefore never reaches the call to reset-ticks at the end of setup. Then BehaviorSpace tries to run your stop condition, resulting in the error you see.
This guess has some problems:
Why BehaviorSpace would only be showing you the eventual ticks error, and not the error causing setup to fail, I don't know.
I have no idea why your setup procedure would be failing.
Nonetheless, that's the best I can offer you without doing a more in-depth investigation.
I was facing the same issue not too long ago. I'm pretty sure that the issue goes back to how Netlogo shares the global variables/states among the threads. I suspect that one thread starts the go procedure while another thread hasn't called the reset-ticks yet.
A temporary fix to this is to call reset-ticks if it hasn't been called already at the beginning of your go procedure.
carefully [let t ticks][reset-ticks]
For those people who found this question by searching for the error "The tick counter has not been started yet. Use RESET-TICKS." but are not actually using BehaviorSpace - the question (and therefore the accepted answer) does not apply to your situation. Instead, you have almost certainly forgotten to initialise the model before trying to run it, probably by hitting the go button without first hitting the setup button.
The reset-ticks command starts the tick counter (makes the internal clock available) so that the tick command can advance the clock. By convention, a procedure named setup has all the commands to initialise the model, including reset-ticks, creating turtles etc. Similarly, a procedure called go contains all the commands to actually run the model like moving turtles around, including tick. Also by convention, these procedures are run by pressing buttons named setup and go respectively.
Earlier this month I asked this question 'What is a runloop?' After reading the answers and did some tries I got it to work, but still I do not understand it completely. If a runloop is just an loop that is associated with an thread and it don't spawn another thread behind the scenes how can any of the other code in my thread(mainthread to keep it simple) execute without getting "blocked"/not run because it somewhere make an infinite loop?
That was question number one. Then over to my second.
If I got something right about this after having worked with this, but not completely understood it a runloop is a loop where you attach 'flags' that notify the runloop that when it comes to the point where the flag is, it "stops" and execute whatever handler that is attached at that point? Then afterwards it keep running to the next in que.
So in this case no events is placed in que in connections, but when it comes to events it take whatever action associated with tap 1 and execute it before it runs to connections again and so on. Or am I as far as I can be from understanding the concept?
"Sort of."
Have you read this particular documentation?
It goes into considerable depth -- quite thorough depth -- into the architecture and operation of run loops.
A run loop will get blocked if it dispatches a method that takes too long or that loops forever.
That's the reason why an iPhone app will want to do everything which won't fit into 1 "tick" of the UI run loop (say at some animation frame rate or UI response rate), and with room to spare for any other event handlers that need to be done in that same "tick", either broken up asynchronously, on dispatched to another thread for execution.
Otherwise stuff will get blocked until control is returned to the run loop.