Practical stuff

Introduction

You will use (classic) DEVS to model a queueing and load balancing system for a set of waterway locks. A conceptual view of the system is shown here:

Ships move in the direction of the arrows. A generator generates ships at pseudo-random time intervals, which are added to a queue. Whenever the queue has a ship available, and one of the locks has enough remaining capacity for that ship, the load balancer pulls a ship from the queue and sends it to that lock. A lock may fit more than one ship, so as long as it is not filled up to full capacity, it may wait for more ships to arrive before the lock doors close and the ships can pass through to the other side of the lock. At the end of the system, we have a Sink, where all ships are collected, so we can extract statistics to analyse performance.

Ships can have different sizes. For simplicity, the size of a ship is a small integer (e.g., 1 or 2). Locks can have different capacities: for instance, a lock of capacity 3 will fit either:

Specification

We now give an overview of the different DEVS components, and their behavior, and their parameters. Although many of the parameters are fixed, your solution must work with different parameters as well. In other words, don't hardcode the parameter values in your DEVS blocks!

Atomic DEVS blocks

The specification of the semantics of the Atomic DEVS blocks is entirely deterministic. If you implement everything correctly, the system as-a-whole will behave 100% identical to the teacher's solution.

Coupled DEVS

The system as a whole is modeled as a Coupled DEVS block. Its parameters are mostly passed as-is to the underlying Atomic DEVS blocks. They are:

What is expected

First of all, you are given an implementation of the following AtomicDEVS blocks, which you must not edit:

You will:

An indication of the complexity: my own solution of the AtomicDEVS blocks is about 300 lines of code (including comments).

Goal: Performance Analysis

Once you have implemented the system, we will do performance analysis, comparing combinations of the following parameter values:

More specifically, we would like to know under which (combinations of) parameter values the (avg/min/max) duration that ships spend in the system is minimized. Also, we'd like to know if one choice (e.g., prioritize bigger) always better than another choice (e.g., prioritize smaller), or does it depend on the choices made for the other parameters?

Getting Started

  1. Clone the mosis24 branch of this git repository.
  2. Under the assignment directory, you'll find the following files:
    • runner.py This script runs the simulation for all combinations of parameter values as described in the Performance Analysis section. It will generate .csv files with the time durations that each ship has spent in the system. Every row is a ship (500 ships, so 500 rows total), and every column represents a different value for the max_wait_duration parameter. It will also generate a plot.gnuplot file, which you can run with gnuplot as follows:
      gnuplot plot.gnuplot
      which will result in a number of SVG files containing plots of the CSV files.

      You are only allowed to make temporary changes (for debugging) to this file.

    • system.py Contains the full system, modeled as CoupledDEVS. You need to edit this file.
    • atomicdevs.py Contains skeletons for the AtomicDEVS blocks that you must implement. You need to edit this file.
    • environment.py Contains implementations of the Generator, Sink and Ship types. You must not edit this file.
  3. Write a report, where you:
    • explain and motivate the interfaces/protocol of the AtomicDEVS blocks
    • show the plotted results
    • interpret the plotted results
  4. Submit via BlackBoard, a ZIP file, containing:
    • Your code (only the assignment directory)
    • Your report (PDF)
    • The generated CSV- and SVG-files
  5. Deadline: Sunday 5 December 2025, 23:59

Attention!

You must stick to the rules of DEVS:

Any violation of these rules results in an incorrect solution. Points will be subtracted.

Coding Conventions

Please follow these coding conventions:

Tips

Troubleshooting

Common mistakes include:

Extra Material