0

I have RackStore block to store agents where the cells are chosen explicitly with the help of a function. I am getting this error when I run the simulation. Here,cells were assigned to all four agents that entered the block, but I think it throws this error when resources arrive for an agent.

I can't understand the reason for this error as all the agents that entered the block were already assigned to cells and it's not trying to put anything again. I have tried the simulation with various no. of agents (5-150 agents), the error always appears after all the agents arrive at rackStore block and an agent is trying to exit.

My rackStore properties are: rackStore property_part_1, rackStore property_part_2 The getCell(double weight, Carrier carrier) function is defined below. It returns an integer array of size 3.

//Iterate through rows
int lev=0;
int row=0;

for (int r=0; r<=1; ++r) {
    // Iterate through positions
    for(int p=0; p<=9; ++p){
        //Check which level it belongs to as per weight
        lev=getLevel(weight);

        //Check if cell is free
        if(carrier==Truck){
            if (palletRack4.isFree(r,p,lev)== true ){
                int[] arr={r,p,lev};
                //traceln("truck pos: "+ arr);
                if(arr==null){traceln("truckPos NULL");}
                return arr; }
            else {continue;}}
        else{
            if (palletRack5.isFree(r,p,lev)== true ){
                int[] arr={r,p,lev};
                //traceln("train pos: "+ arr);
                if(arr==null){traceln("trainPos NULL");}
                return arr; }
            else {continue;}}
        }
    }

if(carrier==Truck){
PalletRackLocation ploc=palletRack4.getFreeCell(true);
//traceln("Carrier: " + carrier);
//traceln("Free cell from P4: "+ ploc);
int[] arr1={ploc.row,ploc.position,ploc.level};
if(arr1==null){traceln("randTruckPos NULL");}
return arr1;}

else{
PalletRackLocation ploc=palletRack5.getFreeCell(true);
//traceln("Carrier: " + carrier);
//traceln("Free cell from P5: "+ ploc);
int[] arr1={ploc.row,ploc.position,ploc.level};
if(arr1==null){traceln("randTrainPos NULL");}
return arr1;}
  • from the error code it appears that the error starts with the pallett rack, see line `...markup.PalletRack.put()` It seems that your formula for `getCell` is providing a position that is already taken and in your onEnterCode you are calling `PalletRack.put` So I assume there is an issue with the `getCell` formula. Also in your formula you have some tracelns that would never be executed, like `if(arr1==null){traceln("randTruckPos NULL");}`, since you explicitly assign arr1 to an array just the line of code before. – Jaco-Ben Vosloo Jul 26 '21 at 05:02
  • Yes, I was just trying to check in case something is Null with the traceln(), but that's for another issue. But in the error snap, 4 agents entered the rackStore block & all four of them were assigned a cell, the 5th agent didn't even enter the block. Do you see something incorrect with my rackStore properties or getCell() function? – Chhandosee Bhattacharya Jul 26 '21 at 09:12
  • It is hard to tell but how sure are you that you are not simply assigning the same location to agent 1 and agent 5? If I look at your tracelns from the error snap it appears the first agents get location (0,0,)0 in rack 5 and then agent 5 gets that location as well – Jaco-Ben Vosloo Jul 26 '21 at 10:04

1 Answers1

0

You're not setting up your RackStore block properly. As the properties state, you have to specify expressions for the row, position and level when you choose "The cell is specified explicitly". But you are trying to use 'internal' pallet rack put functions to do this (inside your "on enter" actions for the block) and leaving those expressions blank. So likely the blank settings means it tries to add agents to location (0,0,0) after having already added them somewhere else (and thus subsequent agents will try to get added there giving you the error shown).

If the block's "on enter" actions occur before those row, position and level expressions are evaluated (do some traceln statements to check; I imagine they are but this is really an internal block sequencing detail that can't be explicitly 'knowable' a priori) you can then keep your on-enter code as-is (but remove the put calls) and then specify the row, position and level from the agent parameters you just set up.

(P.S. The error trace shows that the error is in the rack storage stage—it's occurring inside the onEnter method of the RackStore block—not when an agent tries to leave the rack. It's probable at a Java level that the block performs the user-specified on-enter action code and then the cell allocation and pallet rack 'put' inside the onEnter method that the error trace shows— presumably in that order, but you should check that as mentioned.)

Stuart Rossiter
  • 2,432
  • 1
  • 17
  • 20