1
$\begingroup$

My Problem is having to work with real-time server in a DES model. I have the following situation:

I want to build a discrete event simulation model (Using event scheduling world view). However, this model needs to be connected to another real-time program.

Within this model, the event routines create next events based on the answer, that the model gets from a 3rd Party software. In better words, the model needs to make a TCP/IP connection to a server at the beginning and generate next events based on the answers which it receives from the other program.
As an example: The model executes event A and within its event routine code, there will be a TCP/IP call to a server which asks "Should I generate the event B or C?". Assume the answer from the server is B, an event of type B will be generated, and so on. Based on my knowledge, the simulation model has a virtual time, which it shifts to the next event time in the event list, upon executing the current event.

Now imagine the following scenario:
Event A (event time: 11:00:00) & B (event time: 11:00:01) are on the event list. Event A gets to be executed first, virtual simulation time is now 11:00:00. It makes a call to the server to find out which event to generate next. The Server takes 2 seconds to answer.

How should the virtual time of model be shifted?

  • If I consider that 2s delay and shift the virtual time to 11:00:02, the event B will be overpassed (See Edit). But the clock will be the same as it would be in a real-world system.
  • If I ignore this 2s response time, the model will shift the clock to 11:00:01 and execute event B, although the time in the real-world scenario is now 11:00:02. This means, the model does not behave similarly to the real-world.

I was wondering if someone can guide me to the right direction? How should I deal with the real-time scheduling issue of the DES model? I tried searching online and in literature, but I found nothing which seems to be the solution to my problem. I would appreciate it if anyone can tell me where I can find some useful material on this matter.

Regards

Edit: By "overpassed" I meant the event will be skipped by the simulation model and not get executed because the simulation time will be set to 11:00:02 which is later than 11:00:01 (execution time of event B). In real world, System does event A and sends a request to server at 11:00:01 and while waiting for the server response for event A, goes on and executes event B on the next second. Later when the response for A is there, it will then decide which event to put on event list. Can't figure out how this "waiting for response from server while executing the next event" could be modelled.

$\endgroup$
4
  • $\begingroup$ What do you mean by "overpassed" and why is that a problem? What would happen in the real world? $\endgroup$
    – D.W.
    Nov 7, 2022 at 21:42
  • $\begingroup$ By "overpassed" I meant the event will be skipped by the simulation model and not get executed because the simulation time will be set to 11:00:02 which is later than 11:00:01 (execution time of event B). In real world, System does event A and sends a request to server at 11:00:01 and while waiting for the server response for event A, goes on and executes event B on the next second. Later when the response for A is there, it will then decide which event to put on event list. Can't figure out how this "waiting for response from server while executing the next event" could be modelled. $\endgroup$
    – M. Pour
    Nov 7, 2022 at 22:08
  • $\begingroup$ Thank you! Please edit your question to incorporate this information into the question. We want questions to be self-contained, so people don't have to read the comments to understand what you're asking. Thank you. $\endgroup$
    – D.W.
    Nov 7, 2022 at 22:46
  • $\begingroup$ Thanks. I edited the question. $\endgroup$
    – M. Pour
    Nov 9, 2022 at 15:46

1 Answer 1

0
$\begingroup$

In the real world, different objects are concurrently doing stuff. In simulation, you just need to simulate that.

When an event happens that affects object O, your simulate should calculate what will O will do in response, and what is the next action (if any) that object O will take, and at what time O will take it. Let's say O will take action A at some time t' in the future. Then, insert an event into the priority queue, with key t', and value A.

At each step of the simulation, you pop off the earlier item from the priority key, simulate the action specified by that item, and simulate the effect of that action (which might involve some other objects that will transition state in response, so you simulate what their next action will do and the time at which it'll occur and insert those into the priority queue).

How does this apply to your situation?

Initially, the priority queue contains event A at time 11:00:00 and event B at time 11:00:01.

You pop off the earliest item in the priority queue. This is event A at time 11:00:00. So, at virtual time 11:00:00, you simulate event A and discover that it will make a call to the server. Presumably this involves sending a message to the server, which will arrive at the server at time 11:00:02. So, you add an event (let's call it event C) to the priority queue, with time 11:00:02, indicating that at that time, the server will receive a message telling it to determine what event to do next.

Now the priority queue contains event B at time 11:00:01 and event C at time 11:00:02.

You pop off the earliest item in the queue. This is event B at time 11:00:01. So, at virtual time 11:00:01, you simulate the effect of B. It does whatever it does - maybe inserting some more events into the priority queue, or changing the state of some objects, or who knows what.

Now the priority queue contains event C at time 11:00:02 (and possibly other stuff, if B added other events).

You pop off the earliest item in the queue. This is event C at time 11:00:02. So, at virtual time 11:00:02, you simulate the effect of C. This involves a message arriving at the server. The server presumably does some computation and determines what event to issue next. So, you insert that event into the queue, with the appropriate time (based on how long it would take the server to perform the next action/event).

And so on. Everything continues from there. Nothing is overpassed. Everything behaves similarly to the real world.

All that this simulation loop does is let you "skip over" quiet periods where nothing is happening and where you'd be waiting for the next event to happen.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.