anylogicinject

AnyLogic inject agents from existing population with characteristics


I created a population with objects from a database with individual characteristics. my population

I am trying that the objects with a specific value are injected into a source for process-modelling. ("ankunftszeit" means "arrival time")

for (mp_lkw l : pop_mp_lkw){
if (l.ankunftszeit == getTime()){
source_mp_lkw.inject(mp_lkw l, 1, false, false);
}
}

But somehow an Error occurs and I cannot find any solution... It says taht the inject() only accepts integers

The method inject(int) in the type Source<mp_lkw> is not applicable for the arguments (mp_lkw, int, boolean, boolean) Syntax error on token "l", delete this token

Where is my mistake and how can it be corrected?


Solution

  • Not sure I understand your issue, but if the agents already exist, you shouldn't use a source, instead use an enter block, and then change your code to (even though this code seems like a terrible idea... instead you should use dynamic events but I'm not sure your purpose)

    for (mp_lkw l : pop_mp_lkw){
       if (l.ankunftszeit == getTime()){
          enter.take(l);
        }
    }