Factory Simulator

Last updated on 22nd April 2024

Overview

Benjamin Schumann, PhD developed a factory simulation using the Simudyne SDK.

Dr. Schumann wrote two blog posts on the Simudyne SDK, and the model that he implemented in the software that can be found here for more context:

  1. Blog Post 1 - Experience using Simudyne SDK
  2. Blog Post 2 - Model implementation and competition
  3. Blog Post 3 (by Cesc Canet) - Competition Winner's Solution
Download Model Files

The model consists of several agent classes that interact. In essence, it is a linear sequence of conveyors and machines with products flowing through them along the red arrows:

factory flow explain

All agents "live" in the Factory

The Factory

This is the main model file. It loads the input data (which conveyors to connect to which machines), initializes all agents and puts initial products into conveyors and machines. This is also where Simudyne steps through model ticks (i.e. advances time).

As shown below, the main part executes the Simudyne agent paradigm by:

  1. Checking if machines finished products
  2. Pushing them into conveyors as well as push out products to downstream machines
  3. Machines receiving products from their upstream conveyor.

factory step

We also regularly add new products into the very first conveyor at a rate of 1000 products per minute.

The Conveyors

We have 6 conveyors, each with a length of 9000 meters (it is a big factory) and a speed of 2.223 meters per second.

These are stored in the Conveyor class. Conveyors can do various things:

  1. initializeProducts(int numProducts) is called at the start to fill conveyors with 1000 products
  2. addNewProducts() is only called for the first conveyor in the sequence and tries to squeeze in new products into the factory (using the global rate of 1000 products per minute)
  3. receiveProductAndPushOutOldest() is called when the upstream machine of this conveyor finished a product and wants to add it to this conveyor

There are a few more functions that mimic conveyor "physics", such that it is an accumulating conveyor where products need to travel along the length of it before being able to queue or exit.

The Machines

Each machine can always only work on 1 product. It has no built-in queue (that is the purpose of the conveyors). Machines can do 3 things:

  1. isProductFinished() is called each tick to check if the current product finished its assigned cycle time
  2. pushDownstreamAndFlagUpstream() is called if a product is done. It is sent to the downstream conveyor (or logs that a product finished the factory journey if it is the last machine). It also tells the upstream conveyor that it can now accept a new product
  3. receiveProductForWork() will add a product to this machine that was sent from an upstream conveyor

The Products

Each product is an agent with a fixed length of 0.1m (so we determine how many can be stored on conveyors). Each product also tracks how long it already spent on a machine (to trigger exiting a machine after the cycle time is done) as well as its (physical) position on a conveyor until it reaches the exit edge.

Required parameters

You must make sure that your model applies these parameters:

  1. 6 conveyors and 6 machines, sequentially linked (so the flow starts at conveyor 1 and ends after machine 6).
  2. Each conveyor is filled with 1000 products at the start
  3. Each machine is filled with 1 product at the start
  4. The first conveyor receives an additional 1000 products per minute
  5. Product cycle times are uniformly distributed between 10 and 80 milli-seconds.
  6. Products are 0.1m long
  7. Conveyors are 9000 m long and move at 2.223 m/s