There are 5000 milliseconds in 5 seconds. So if I run this code in Netlogo during that time:
every 0.001 [
some-calls-in-the-middle
tick
]
I expect to get 5000 ticks, but I'm getting no more than 150. Is there any way to map ticks to seconds more efficiently?
Presumably whatever computation you're doing in some-calls-in-the-middle is taking approximately 1/150 second for NetLogo to perform.
every is only useful for making a snippet of code run less often — never for making it run more often. (It might help to give the dictionary entry for every a careful read.)
Related
I am working on a VRPTW and want to minimize the total time (travel time + waiting time) cumulated for all vehicles. So if we have 2 vehicles one that starts at time 0 and returns at time 50 and one that starts at time 25 and returns at time 100, then the objective value would be 50+75=125.
Currently I have implemented the following code:
for i in range(data['num_vehicles']):
routing.AddVariableMinimizedByFinalizer(
time_dimension.CumulVar(routing.End(i)))
However, this seems like it is only minimizing the time we arrive back at the depot.
Also it results in very high waiting times.
How do I implement it correctly in Google OR tools?
This is called the span.
See the SetSpanCostCoefficientForVehicle method for one vehicle.
You can also set it for all vehicles.
I have a periodic backend process and I would like to visualize the history of the length of cycles on my dashboard. Is it possible?
I have full control over the data/metrics I generate, so I could perhaps increment a counter every time a cycle completes (a cycle takes about 3 days), so I would get counter updates every 3 days or so. Then how could I get Grafana to report the length of each cycle? (for instance: 72h; 69h; 74h; etc.) The actual widget doesn't matter, but I need something visual to tell me at once if cycles are getting faster or slower.
Any pointers or ideas are welcome.
It looks like a standard time series: X-axis - time, Y-axis - duration [s]:
Then you may add:
trend line
aggregations (min/max/avg/derivation/diff/...)
moving average
other math functions, which are available in used datasource
I have a simple source to sink model and I am merely altering the "Rate" to 6 per hour. I would expect a fixed 6 agents to be generated each hour, but it seems like in the first hour from 0 to 60min, only 3 agents are generated. Similarly in the time 60-120min, only 5 agents were generated.
Is there a warm up period in Anylogic or something like this that explains what is happening?
Another alternative is to just use the interarrival time with a fixed time. This will give you the same results as Felipe's answer, but with one less object, as you will not need the event.
A few important items to note on this approach:
Instead of 6.0, using a parameter would be better. You could call this parameter dArrivalsPerHour. This would make your source block easier to read in the future, and give you some better flexibility. Your interarrival time would be 1.0 / dArrivalsPerHour.
Make sure you divide by at least (1) double. If you did 1/6, java would actually return 0! This is because in Java two integers divided by each other returns an integer, so java just truncates the decimal. If you use a parameter, just set its type to double. Usually to be extra careful against anyone accidentally changing my parameter type to integer in the future, I would still go ahead and use a 1.0.
AnyLogic does not have an arrival at time zero in this approach. The first arrival would be at 0.166 hours. If you want an arrival at time zero, followed by this pattern (it would still be 6 per hour, just shifting when it starts), then you have a couple of options. First, you can use Felipe's approach and set the first occurrence time to zero. An alternative would be to could call an inject On Startup OR after you have finished any initialization code your model has.
Happy Modeling!
The source block doesn't produce exactly 6 agents per hour, it produces agents using a poisson distribution with mean 6 per hour (lambda=6). So the number of agents per hour you get will be random. But the reason why you always get 3 in the first hour and 5 in the second hour is that you have a fixed seed:
You can find that option clicking on your simulation experiment under the randomness tab. If you change to random seed it will produce different agents per hour instead of always 3 and 5.
To produce EXACTLY 6 per hours you need to use an event. But first create a source that generates agents through injection:
And the event running 6 times per hour, adding 1 agent to the source:
I want to record data while running Behavior Space once within a given period, e.g. once per 1000 ticks. I see that Behavior Space can call reporters once per tick or once at the end of the simulation run. However, I do not want to record once per tick, because that produces too much data, but I also don't want to just have data at the end of the simulation. I cannot change the simulation time represented by tick because of numerical stability. I tried putting code into Behavior space, i.e.
if ticks mod 1000 = 0 [reporter]
but this gave an error ("Syntax, expected reporter") when I started the experiment. Is there a way around this issue, or am I stuck with gathering too much or too little data? Thx.
In your "Go commands", put repeat 1000 [ go ] instead of just go. That way, each "step" is actually 1000 ticks, so recording the data each step records it once every 1000 ticks.
Dear Netlogo community,
I have created a simulation enviornment on Netlogo, which runs around 35000 ticks. It takes around 70 to 80 mins to execute completely. I am facing some errors at the end of simulation (near 25000 ticks). Now I am debugging program by using print command. simulation takes 45 to 50 mins to reach to the desired tick (a ticks that creates problem). Is there any fast way in Netlogo by using which i can reach to the desired tick quickly.
As JenB suggests, use the export-world and import-world primitives to save and restore world state. Or use the equivalent menu items of the same names on NetLogo's File menu.