Luzma
Luzma

Reputation: 21

Using a custom distribution to assign states for agents when create it in Anylogic

I am developing a model to evaluate different interventions of population control in animals. I am trying to use a custom distribution to assign the state in which agents should be when they are created or added later to the population.

I have done the following

  1. I have created an option list, listing all the states in my model
  2. I have created a custom distribution for the initial population, using the option list to assign the initial population distribution of agents per state 3 I have created a second custom distribution for immigration (since agents will be continued to be added to the population in regular intervals throughout the simulation), using the same option list but with different distribution values.

For the first 3 states which all have timeout transitions, I use the following code:

For the first timeout transition: stateChart== state1 ? parameter1 : 0

Where StateChart is the name of the state chart in agent State1 is the name assigned in the option list to the fist state Parameter1 is the parameter name, that has the value use for the transtion (for example weaning duration = 2 months)

For my second timeout transition: stateChart == state1 || stateChart == state2 ? parameter2 : 0

And so on.

However my fourth and fifth states (stete4 and state5) have rate and message transition and this codes does not work for such transitions.

As a results my agents do not appear in the fourth and fifth states at the initial population in time zero or during the immigration events.

Is there a different code I can you for the last 2 transition of my model to make my agents appear in all the different states of my model?

Thank you

Upvotes: 2

Views: 377

Answers (1)

Rich Harding
Rich Harding

Reputation: 645

I have to set a State on initialisation of a population of Customers in the Market Dynamics Model for which I'm responsible, and the state is normally changed by a message. To achieve this, I use the following code for each selected Customer:

oCustomer.sc_switchingBehaviour.receiveMessage("moveOn");
oCustomer.onChange();

where the State Chart is sc_switchingBehaviour and the message that would normally cause them to change State is "moveOn".

I don't have a rate transition for which I need to do this, so can't directly answer that query however, for the purposes of State initialisation, could you not (conceptually) transform the rate to a probability and then use that?

Upvotes: 0

Related Questions