Entities and virtual entities (VE)

Updated: 2025-10-08

By now we have more than enough clarity on what an entity is: a little dot moving on the screen. We know it is born from a GENERATE, it traverses blocks, advances through positions, and can enter resources.

So what is a virtual entity? An entity that does not move on the screen.

That difference sounds simple, but it is essentially that—while carrying many implications. Imagine an invisible dot that does not occupy space but still executes instructions.

Let’s define them formally:

  • Virtual entities are not born from a GENERATE. Instead, they are created by COMMANDS such as TIMER, PRE_RUN, TRIGGER (ON_ENTER, ON_QUEUE, ON_*...), or by the block TIMEOUT.
  • Their identifier (D$N) is not a positive sequential number (1, 2, ... n) but the opposite: (-1, -2, ... -n).
  • Their TERMINATE does not subtract terminations. In fact, you will see TERMINATE_VE, which ends only virtual entities.
  • They have no direct visual representation, but they can interact with the graphical layer just like any other entity.

What are they for?

They have countless uses.

Even if it may not look like it, they are the reason GPSS-Plus does not rely on secondary languages to program complementary elements such as Python or Java.

You program them in GPSS-Plus like any other subprogram. They take care of all accessory tasks around entity life cycles. For example, if you want a clock, it makes little sense for it to depend on the birth or movement of entities that already have plenty to worry about while entering and leaving resources.
Instead, a TIMER that automatically fires every N instants can do those tasks.
If you want control over multiple resources and the state of their queues, you can have a virtual entity acting as a controller each time an entity enters a queue.

Virtual entities work behind the scenes. You don’t see them move, but without them, many processes simply would not happen.

In the example:

A normal entity, number 1 (D$N==1), creates a virtual entity that will be born in 30 time units to execute a procedure:

TIMEOUT updateCounter,30

It does not traverse flow positions nor use resources. It only appears after being requested by an entity and, from then on, the virtual entity schedules a new virtual entity every 3 time units.
Its only job: counting.
The first calls the second, which calls the third... all through the TIMEOUT block, which only needs the name of the procedure to be executed by the virtual entity and the time at which it will occur.
You can see the text changing even though there are no visible entities updating it. That is because a virtual entity does it, working in the background like a small autonomous process.

This example shows how a VE can act as a recurring process without any human intervention or physical entity. From now on, you will see that many system decisions, alarms, or statistics will be managed by this type of invisible entity.

Example

/* Virtual entities:
Invisible processes operating in the background.
The first entity will create a VE after a delay of 30 time units.
That VE will create the next one every 3 time units.
Only entities are visible, not VEs.
*/

POSITION {NAME:POS1,X:321,Y:332}
POSITION {NAME:POS2,X:517,Y:326}
GRAPHIC {NAME:Text1,Type:TEXT,X:366,Y:454,Text:"Counter: 0"}

INITIAL counter,0

START 200

;*****************************************************
GENERATE 20,0 {NAME:GEN1,X:101,Y:332}
ADVANCE 10 {TO:POS1}
; Launch a virtual entity that will update the counter
IF (D$N==1)
	TIMEOUT updateCounter,30
ENDIF
ADVANCE 10 {TO:POS2}

ENDGENERATE 1

;*****************************************************
PROCEDURE updateCounter
    SAVEVALUE counter, X$counter + 1
    MOVE {NAME:Text1, TEXT:"I am Virtual Entity D$N. Counter: X$counter"}
    TIMEOUT updateCounter, 3
    TERMINATE_VE
ENDPROCEDURE