Search code examples
anylogic

Piechart of agents with special characteristics


I have three sources that generate packages. Each source gets a special tyo assigned to it:

agent.p_type = 0;
agent.p_type = 1;
agent.p_type = 2; 

After processing a package, I want to formulate a command in the block: "moveByCrane", which gives me the number of packages by specific type in a pie chart.

My attempt was this:

auftrag1 = count(agent.p_type == 0);

order1 is a variable that is then called in the pie chart.

However, I get an error message that it doesn't work that way. What is the problem? pie chart

My error message is: error message

It appears in "MovebyCrane"

My Code is:

code in MovebyTrain


Solution

    1. turn your auftragX variables into type int
    2. in your "on at enter" code in MovebyCrane, count each passing agent as below

    code:

    if (agent.p_Type == 0) {
        auftrag1 ++;
    } else if (agent.p_Type == 1) {
        auftrag2 ++;
    } else if (agent.p_Type == 2) {
        auftrag3 ++;
    } else {
        error("dsafsdf");
    }
    
    1. do all AnyLogic tutorials, they go deep into how to use charts correctly :)