Search code examples
integerdoubleanylogicinject

How do you write an inject argument with a non-integer number in Anylogic


I am trying to write code for my Anylogic discrete events model which injects a specific number of agents, and then after 4 weeks, this injected number of agents is conditional on other numbers of agents in the model (circled in red on the screenshot). One of the sources of agents that I want to account for is a Double (it is on a slider), and the inject call will not accept it, it only wants int values.

weeklyLeavingNursing = 0;

if (time()<4) {

    enterHerd.inject(10);

}
 
else {

    enterHerd.inject(10 - (slider.getValue() + weeklyLeavingOpen + weeklyLeavingNursing));

}

Is there a way to write the code with both int and Double values? Any ideas would be greatly appreciated. Image of the coding and the Anykogic error Image of the full model and the 3 areas where agents enter the Source


Solution

  • Just use the following function:

    getIntValue()
    

    enter image description here