How do I store all values of a variable in AnyLogic? - simulation

I am using discrete event simulation methodology in my project. I have a variable in my simulation called RuleBreak which can be either 0 or 1 which is evaluated for each Agent upon entering the Sink block. I am trying to store every value of the RuleBreak variable in a data frame. I have already tried using the Data Set element in the Analytics palette. However, this only allows you to obtain the value of the variable at a specific recurring time. I need the value of RuleBreak only when an agent enters the Sink block. Can anyone help me with this?
Below is an image of the Sink block, where I set the value of RuleBreak to be either 0 or 1.
Then here is an image of the Data Set element that I use from the Analytics palette. Notice, that I can only collect the value of RuleBreak at a specific recurring time and cannot obtain the values for all Agents that enter the Sink block.
Thanks!

in your dataset element use "Do not update data automatically" and at the end of your "on enter" action of your sink do:
dataset.update();
And that's it :)

Related

Persistable key value pair storage in Synapse or ADF

I am using Synapse and have a lot of scenarios where I need to read a value at the beginning of a pipeline then save a value at the end of a pipeline as a key value pair (kvp). e.g. when the pipeline begins I read a value from a kvp store to get the max date from the last time the pipeline ran, I use that value to get all values from a table that are greater than or equal to that datetime. when the pipeline finishes doing what it has to do, I save the max modified date from this run. wash, rise, dry. I have a few ideas, like parquet file, redis (this seems a bit much). Just trying to see if anyone has come up with a more elegant/simple approach.
You can use Global Parameters which can be used in different pipelines and the values can be modified in the run time.
Go to Manage in Azure Data Factory and click on Global Parameters in the left panel options. Then click on + New.
Create a new Global Parameter.
Later you use this global parameter in any pipeline and can change its value in runtime. Refer below image for the same.

Add variable as value in schedule ANYLOGIC

In my model I use a schedule to define the capacity of a transporter fleet. Now I want the capacity to be a variable which can change based on the user input, but when I want to type the variable name (see red circle in inmage) in the value function of schedule block this will not work is there a method to do this?
The only way to so this is to use the load from database option and read in the values from the database.
Alternative is to create the schedules programmatically

AnyLogic: Empty agent parameter in the function

I was faced with a problem in AnyLogic.
I created a function with an argument. The argument is agent Message. However, the function doesn't get the current agent. It seems that the argument is empty. Why?
this is one of the most confusing things in anylogic that things get calculated in reverse order compared to what you expect.
First the condition is calculated in order for the agent to decide where to go, and after that the agent exits the source...
Based on what we see here, the volume is probably calculated on the "on exit" action of your source and you should calculate it on the "on at exit" or you can also put a delay of 1 milisecond after the source and everything will be ok

Is there a way to stop the "Source" block from generating agents after a specific time in AnyLogic?

Utilizing a source generating agents on an Interarrival time basis, I would like to stop the source block from generating agents after a certain amount of time passing so that the model can continue to process the agents.
One option to encapsulate all the logic inside the source block, without external events or variables, would be to select Multiple agents per arrival as true and then have a conditional statement for the number of agents, for example time() > 10 ? 0 : 1, so that after 10 model time units there will no agents arriving
Sure. If it is a inter-arrival source block, make it use a variable as the interrarrival time, of type double:
Then, create an event that triggers once only, after your specific time. Make it change the variable to 0 as below. Make SURE to trigger it not at time 0 (as in the screen but when you need it!):
NOTE: Do not set myRate = 0;. Instead, set it to infinity` to actually have no more arrivals.

How to update database and let delay block reference delay duration to updated value?

I have created a UI page for user to input the delay duration in edit boxes for certain activities at the simulation screen. The input values should update the database value and amend the delay duration. However, while the database does get updated, the delay block in the main screen keeps capturing the non-updated database value (eg. initial database value is 100, then a user inputs 200. The database value updates to 200, however, my delay block still captures 100.) Is this an issue with AnyLogic database or am I using it wrongly?
You need to specify in the unique result formula that you do not want to make use of the cached result.
(This image is from the local AnyLogic help, you can search for "uniqueResult". I could not find it on the new online help.
The default value is to use true, i.e. use the previous value that was retrieved from the DB for the same query
Simply add false as the first argument in your uniqueResult() code.