Backpack

Updated: 2025-11-23

Backpack is not a resource as such because it does not perform internal logic; it is more of an entity-transport tool, although it does retain entities.

To move entities from one point to another in the simulation (for example, a van carrying packages), you need something that tells the system those entities are no longer available in the event chain nor in any other queue.

This concept can be thought of as a backpack where one entity can carry other entities. There are two limitations:

You can only load from a RESTROOM because it is a holding resource where entities do not leave on their own, and you can only unload into a GENERATE because it is the only safe point with respect to the entity call/return stack (see SCAPE).

It has two associated blocks:

  • LOAD backpackName, restroomName[, entityNumber]
  • UNLOAD backpackName, generateName[, entityNumber]

The first loads into the backpack either all the contents of a Restroom or the specific entity with that number, and the second is the inverse operation at the GENERATE.

The entities inside the backpack can be obtained through the ASSIGN created with the same name as the backpack. It is an array containing the entity numbers.

The example shows a van route that stops at two pickup points and carries the packages to the distribution point.

Example

RESTROOM {NAME:receiverWarehouse1,X:220,Y:348,E_BIN_SIZE:1,E_BIN_COUNT:10}
RESTROOM {NAME:receiverWarehouse2,X:217,Y:182,E_BIN_SIZE:1,E_BIN_COUNT:10}
RESTROOM {NAME:distributionWarehouse,X:662,Y:93}

Graphic {NAME:Text1,Type:TEXT,X:100,Y:100,Text:"Finished: NO",font:"20",color:red}


START 1000
;************************************************************************

GENERATE 8,3 {NAME:Reception1,X:66,Y:356}
ADVANCE 20,0 {TO:receiverWarehouse1}
rest receiverWarehouse1
terminate 1

;************************************************************************

GENERATE 5,3 {NAME:Reception2,X:65,Y:181}
ADVANCE 20,0 {TO:receiverWarehouse2}
rest receiverWarehouse2
terminate 1

;************************************************************************

GENERATE 40,0,0,1 {NAME:Vans,X:40,Y:567
		,eradio:16,ecolor:red,visible:0
		,esubtitle:"P$(backpack1.LENGTH)"}
ADVANCE0 {TO:DistributionPoint}
while (1==1)
    ADVANCE 20,30 {TO:receiverWarehouse1}
    load backpack1,receiverWarehouse1
    ADVANCE 20,30 {TO:receiverWarehouse2}
    load backpack1,receiverWarehouse2

	ADVANCE 20,30 {TO:DistributionPoint}
    unload backpack1,DistributionPoint
endwhile
terminate 1

;************************************************************************

GENERATE 0,0,0,0 {NAME:DistributionPoint,X:669,Y:434}
ADVANCE0 {TO:DistributionPoint}

ADVANCE 20,50 {TO:distributionWarehouse}
if (D$N>1000)
move {name:Text1,text:"FINISHED: YES",color:green}
stop
endif
rest distributionWarehouse

terminate 1