Search code examples
anylogic

How can I know if the row, position, and level value is already occupied or not?


I am working on a model, where I need to define the cell of the pallet rack manually. Currently, I am using the function,

   // Increment the coordinates
    if(main.lastRow<main.numRows){
    main.lastRow++;
    setRow = main.lastRow-1;}
    if (main.lastRow >= main.numRows) {
        main.lastRow = 0;
        }
        
     if(main.lastPosition<main.numPositions){
        main.lastPosition++;
        setPosition = main.lastPosition-1;}
     if (main.lastPosition >= main.numPositions) {
            main.lastPosition = 0;
            }
        
     if(main.lastLevel<main.numLevels){
            main.lastLevel++;
            setLevel = main.lastLevel-1;
            }
     if (main.lastLevel >= main.numLevels) {
                main.lastLevel = 0;
                } // Wrap around to the first row

String coordinates = setRow + "-" + setPosition + "-" + setLevel;
// Check if coordinates already exist           
if (!main.assignedCoordinates.contains(coordinates)) {
// Add the coordinates to the set
main.assignedCoordinates.add(coordinates);  
}

These one has its disadvantages. So I am imagining of a way, if I can check the co-ordinates that I am generating in a pallet rack are empty or not in reality.

Suppose my row value is 2, position is 30, and level is 5. I want to cross check this position in my pallet rack, and if not empty i want iterate and choose a value that is empty.


Solution

  • How can I know if the row, position, and level value is already occupied or not?

    Use the PalletRack.isFree(int row, int position, int level) call on your pallet rack.

    Always use code-complete or check the help to see what functions are available to you, for example for Pallet Racks: https://anylogic.help/api/com/anylogic/engine/markup/PalletRack.html