Printing seed used by the model - netlogo

How can I see (print) the seed that my model uses to generate randomness?
I would like to specify the seed number when presenting the findings.
Thank you.

As far as I know, NetLogo does not provide access to the state of the random number generator. It is a good practice to report the seed. Ordinarily one achieves this by setting it explicitly. E.g., in setup, one can include random-seed behaviorspace-run-number, so that each run uses a different seed. You can then include the run number in your report. If you don't want to set your own seed, you will still have to create it and store it. E.g., create a run-seed global, and then during setup set run-seed new-seed random-seed run-seed.

Related

Set start-time for histogram sample

The usecase
We got multiple changelogs stored in the database, and want to create a histogram monitoring the duration between changes.
The problem
There doesn't seem to be a way to set the start time of a Historgram.Timer, e.g we want to set it to lastUpdated given the current changelog.
Avenues of approach
1 Subclassing Histogram
Should work. However the java-lib use protected/package-private extensively, thus making it hard without copying large portions of the library.
2 Using reflection
After a Histogram.Timer is created it should be possible to use reflection to set the start field. The field is marked as private final, and thus a SecurityManager could stop us in some environments.
Ideas?
Neither of the solutions seems like the correct way to go, and I suspect that I'm overlooking a simpler solution (but could find anything at SO or google). We're using grafana to visualize our metrics, if thats at all helpful in this scenario.
You don't need to subclass Histogram, as you don't need to use Histogram.Timer only because your histogram is measuring times.
Simply call myHistogram.observe(System.now() - lastUpdated) every time you record a new change in the database.

Dynamically Changing Distribution in AnyLogic

I am using AnyLogic to develop a model.
I used the 'distribution' element to initialize values for a parameter in my model. It is working fine, but I want to update these values as my simulation proceeds forward. e.g. if in week 1, the distribution can have values:
Distribution
But in week 2, I wan to update these values, then again in each coming week.
I have some equation based on which I want to make calculations and update these values.
I could not find any functionality in AnyLogic concerning this.
Any ideas how to achieve this?
You may create distribution from scratch, using various constructors. Pass into constructor array with existing and additional values to get the updated custom distribution. Your distribution is created with this constructor:
CustomDistribution(double[] intervalStarts, int[] numberOfObservations, Agent owner)
It may be convenient to store initial array in database, and each next array in model variable.

How to assign an incrementing values to a variable in optplanner?

I am planning to use optplanner to optimize the server usage and if required add additional hardware on demand.
My questions is: How to auto increment one variable if system is not able to find a optimal solution after a certain fixed time?
I don't know if it would work for your specific use case but you could define a custom phase where you modify your Problem Entity.
If you need to modify a Problem Fact then I would set a time on a thread separate from the one where you called solve(). Once the timer hits 0 you can introduce a ProblemFactChange to the solver.

Which agent executes a command given to an agentset first?

If I switch to turtle/patch context and do something like "set pcolor green", in what order do they execute the commands? I tested it out with a wait in there to see if there was an obvious pattern, but couldn't notice any. Is there any difference between that and ask?
I doubt it's completely random, though. How's it actually being handled behind the stage?
It's random--about as random as things get in computer programming, I believe. The NetLogo User Manual says:
An agentset is not in any particular order. In fact, it's always in a random order. And every time you use it, the agentset is in a different random order. This helps you keep your model from treating any particular turtles, patches or links differently from any others (unless you want them to be). Since the order is random every time, no one agent always gets to go first.
I just looked quickly at AgentSet.java in the source code for a recent version of NetLogo (5.0.2), it and looks to me like the order is randomized using a Mersenne Twister algorithm, which is usually considered to be quite good for randomization.
If you want the turtles/patches/links in a particular order, you can use sort, or select elements using e.g. with, or convert the agentset into a list using [self] of <agentset>, for example.

Evolution of Setup Procedure

My question was, is there anyway through Netlogo to be able to include the Setup Procedure WITHIN the go procedure so that each iteration or TICK within the go procedure has a slightly different setup because of agent-evolution?
In my case in particular, i am modeling a flight leg where I have three airlines competing to find the best schedule for the flight during the day based on a utility model, and then a number of passengers that choose which flight is more appropriate for them with another utility model. My aim was to be able to vary the demand of passengers in each iteration through the go procedure even though this is dependant of the setup procedure and have the airline continuously vary their fees in order to attract more passengers and I feel I cannot do this because the Setup procedure limits me into only being to create one possible situation and doesnt allow for the evolution of my agents.
Thank you for your help, I really appreciate it.
The use of procedures named setup and go in NetLogo, and the pattern in which you typically attach them to buttons, is purely a convention. You can make as many procedures as you want, call them whatever you want, and have those procedures call each other in any way you want.
So for example, if you want to call setup from within your go procedure, go right ahead.
If your setup procedure calls clear-all, though, that might not be a smart thing to do. In that case you'd want to split the setup procedure into two separate procedures, where one of the procedures contains only the part you want to reuse. Something like:
to setup
clear-all
...
setup-environment
...
end
to setup-environment
...
end
to go
...
setup-environment
...
end