1

so my model works fine, but since I introduced conditional events (= an event that triggers once a specified condition is met), I find that the computational performance is decreased.

This is especially annoying when I run experiments with many iterations...

Is there an alternative way to trigger an event at a specified condition?

Thank you :)

1 Answer 1

1

The answer to this will be triggering events directly by the mechanism that are influencing the conditions you are monitoring. So instead of having the "permanent" condition check, make sure that each time the condition changes you are triggering a check. If that is not possible, because there are too many influencing factors, or it is continuosly changing, consider a cyclic check in discrete timesteps at an interval that suits you. Even this will be much more performant (depending on your choosen time check interval) then the current continous monitoring.

Example on how to do an event trigger monitoring instead of continous monitoring:

In your main, add global counter variable of type int (here: nrAgentsState1) and create a function to update that variable (here: updateStateCounter). Also in the function: a check that triggers a function whenever your threeshold is reached.

Global count variable and update function in Main[1]

In your transition leading into the state you want to monitor (here: state1), call the function in main that updates the global counter. For the transition leading out of the monitored state, add the same action, but with a -1 as parameter.

Update counter on transition

6
  • Just to underline Florian's correct assessment: You should actually NEVER use conditonal transitions and ALWAYS replace them with alternative monitoring. It is always possible and will help your performance a lot.
    – Benjamin
    Apr 6, 2020 at 12:52
  • Thank you for your answers! My problem is that the condition changes continuously. Specifically, I monitor the number of agents in a given state and want to execute the event once this number reaches a threshold. I want to execute the event only once. I have tried to use a simple if-statement within a rate-triggered event, however, this executes the event continuously after the condition is met... Is it possible to stop the rate triggered event once this condition is met? If not, do you have other ideas how I could achieve this? Thank you very much!
    – jonas_fe
    Apr 8, 2020 at 10:24
  • Instead of a rate triggered event, monitor all transitions that are leading in and out of the state you are interested in. Whenever such a transition occurs execute a function in main that increase / decrease a global counter variable in your main and if threeshold is met for first time, it manually triggers the event that you want.
    – Florian
    Apr 8, 2020 at 13:45
  • Sounds very smart, I will try that! Thank you @Florian :)
    – jonas_fe
    Apr 8, 2020 at 17:52
  • @LondonCalling ,I added screenshots to an example of what I explained above
    – Florian
    Apr 9, 2020 at 8:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.