TransitScheduler - a command line tool that can read .json data formulated for tracking transit patterns to a multithreaded concurrent simulation of passengers boarding and unboarding trains that constantly move to the next station on the line. The trick here, is that two trains cannot occupy the same station at any time.

Related tags

CLI TransitScheduler
Overview

TransitScheduler

This project is a command line tool that can read .json data formulated for tracking transit patterns to a multithreaded concurrent simulation of passengers boarding and unboarding trains that constantly move to the next station on the line. The trick here, is that two trains cannot occupy the same station at any time.

You will need the java SDK to run this. Once that's done...

How to Run

Run this project with: ./sim

All arguments are optional: defaults to sampleBOS.json, defaults to 500 ms, and defaults to 200.

Recompile this project with: javac -cp "gson-2.8.9.jar:junit-4.13.2.jar" BoardEvent.java DeboardEvent.java Entity.java Event.java Log.java Transit.java TransitGlobalCache.java TransitScheduler.java MoveEvent.java Passenger.java PassengerBuffer.java Sim.java Station.java Tests.java Train.java TrainBuffer.java Verify.java LogJson.java

How to Create Valid Json Data for this Project

This system is expecting a .json file with lines and trips provided. each line consists of one train moving to each stations, and each trip consists of one passenger boarding and deboarding trains that go to the next station on their trip.

The data formatting expected for the program aligns with typical json syntax. Please format the data like so:

{
  "lines": {
    "red": [ "Davis", "Harvard", "Kendall", "Park", "Downtown Crossing",
      "South Station", "Broadway", "Andrew", "JFK" ],
    "orange": [ "Ruggles", "Back Bay", "Tufts Medical Center", "Chinatown",
      "Downtown Crossing", "State", "North Station",  "Sullivan" ],
    "green": [ "Tufts", "East Sommerville", "Lechmere", "North Station",
      "Government Center", "Park", "Boylston", "Arlington", "Copley" ],
    "blue": [ "Bowdoin", "Government Center", "State", "Aquarium",
      "Maverick", "Airport" ]
  },
  "trips": {
    "Bob": [ "Park", "Tufts" ],
    "Alice": [ "Davis", "Kendall" ],
    "Carol": [ "Maverick", "Government Center", "Tufts" ],
    "Emmet": [ "Copley", "Government Center", "Airport" ],
    "Sally": [ "Airport", "Government Center", "North Station", "Downtown Crossing", "Davis" ]
  }
}

Each line will spawn a train and each trip will spawn a passenger. Each train will move to the next station, unless the next station is already occupied. Each passenger will wait at their starting station for a train that travels to their next destination, and board that train until their stop.

Important Notes

Any specific order of train movement is not guaranteed, and its important to remember that trains will always attempt to move as quickly as possible.

It is recommended that users do not supply data that has impossible deadlocking scenarios, such as two trains that share the same next station but could end up going in opposite directions. That can cause both trains to block each other, with no possibility of either one ever moving forward! see this example:

{
  "lines": {
    "red": [ "west", "central", "east"],
    "green": [ "east", "central", "west"]
  },
  "trips": {
    "Adam": ["west", "northeast"]
  }
}

for the first iteration, we can imagine that either the red or green line will go first, occupying the central station. Then what? If red goes first to central, then green will have to wait until central is no longer occupied. BUT, since red can never move out of central and into east because green is still waiting at east for central to clear, we have an impossible deadlock.

Just to be thorough lets see what happens if green goes first...

If green goes first to central, then red will have to wait until central is no longer occupied. BUT, since green can never move out of central and into west because red is still waiting at west for central to clear, we have an impossible deadlock yet again.

You might also like...

Minecraft configurable plugin , which sends messages the first time a player logs into the server or the next time they log in.

JoinMessages Minecraft configurable plugin , which sends messages the first time a player logs into the server or the next time they log in or leave.

Aug 30, 2022

Minecraft Spigot 1.16 - plugin for compass tracking other players. MVP contains tracking closest player available.

Compass Tracker Overview Minecraft Spigot 1.16 Plugin. Plugin sets compass target to closest player in the overworld. Created to use with my friends t

Nov 15, 2021

AWS JSON TRANSLATOR CLI is a command line application to translate JSON files using AWS Translate

AWS JSON TRANSLATOR CLI is a command line application to translate JSON files using AWS Translate

A command line tool to translate JSON files using AWS Translate.

May 30, 2022

Convert Java to JSON. Convert JSON to Java. Pretty print JSON. Java JSON serializer.

Convert Java to JSON. Convert JSON to Java.  Pretty print JSON.  Java JSON serializer.

json-io Perfect Java serialization to and from JSON format (available on Maven Central). To include in your project: dependency groupIdcom.cedar

Dec 30, 2022

MapNeat is a JVM library written in Kotlin that provides an easy to use DSL (Domain Specific Language) for transforming JSON to JSON, XML to JSON, POJO to JSON in a declarative way.

MapNeat is a JVM library written in Kotlin that provides an easy to use DSL (Domain Specific Language) for transforming JSON to JSON, XML to JSON, POJ

Sep 17, 2022

This sample shows how to implement two-way text chat over Bluetooth between two Android devices, using all the fundamental Bluetooth API capabilities.

This sample shows how to implement two-way text chat over Bluetooth between two Android devices, using all the fundamental Bluetooth API capabilities.

Zenitsu-Bluetooth Chat Application This sample shows how to implement two-way text chat over Bluetooth between two Android devices, using all the fund

Jan 16, 2022

A maven plugin to include features from jmeter-plugins.org for JMeterPluginsCMD Command Line Tool to create graphs, export csv files from jmeter result files and Filter Result tool.

A maven plugin to include features from jmeter-plugins.org for JMeterPluginsCMD Command Line Tool to create graphs, export csv files from jmeter result files and Filter Result tool.

jmeter-graph-tool-maven-plugin A maven plugin to create graphs using the JMeter Plugins CMDRunner from JMeter result files (*.jtl or *.csv) or using F

Nov 3, 2022

Utility for developers and QAs what helps minimize time wasting on writing the same data for testing over and over again. Made by Stfalcon

 Utility for developers and QAs what helps minimize time wasting on writing the same data for testing over and over again. Made by Stfalcon

Stfalcon Fixturer A Utility for developers and QAs which helps minimize time wasting on writing the same data for testing over and over again. You can

Nov 29, 2021

This tool can read the QR code from the Remote Admin menu and copy the ID of the User to the Clipboard.

SCP-SL-QR-Reader Tool for easy copying This tool can read the QR code from the Remote Admin menu and copy the ID of the User to the Clipboard. Detecta

Aug 14, 2021

Jacksum (JAva ChecKSUM) is a free, open source, cross-platform, feature-rich, multi-threaded command line tool for calculating hash values, verifying data integrity, finding files by their fingerprints, and finding algorithms to a hash value.

Jacksum (JAva ChecKSUM) is a free, open source, cross-platform, feature-rich, multi-threaded command line tool for calculating hash values, verifying data integrity, finding files by their fingerprints, and finding algorithms to a hash value.

Dec 26, 2022

A minecraft minigame where you have to defend your bed and destroy the others. Once your bed is destroyed, you cannot respawn.

A minecraft minigame where you have to defend your bed and destroy the others. Once your bed is destroyed, you cannot respawn.

As from November 1st 2021 BedWars1058 by Andrei Dascălu becomes open source under GNU GPL 3.0 license. If you are a developer I would really appreciat

Dec 26, 2022

A recreation of Discord's Trick'ord Treat bot!

TrickordTreat A recreation of Discord's Trick'ord Treat bot! Don't feel like setting up the bot? Use our publicly hosted version: https://discord.com/

Nov 29, 2022
Owner
Emmet Hayes
Software Engineer / Musician
Emmet Hayes
Java annotation-based framework for parsing Git like command line structures

Airline Airline is a Java annotation-based framework for parsing Git like command line structures. Latest release is 0.8, available from Maven Central

null 847 Nov 26, 2022
A command line parser generator

jbock is a command line parser that works similar to airline and picocli. While most of these other tools scan for annotations at runtime, jbock is an

H90 73 Dec 13, 2022
Command line parsing framework for Java

JCommander This is an annotation based parameter parsing framework for Java 8. Here is a quick example: public class JCommanderTest { @Parameter

Cedric Beust 1.8k Dec 29, 2022
Command-line API for Atlassian JIRA using the Tomitribe CREST library

Atlassian JIRA Command-Line (CLI) Jamira is a command-line API for Atlassian JIRA using the Tomitribe CREST library. Installation Jamira can be downlo

Tomitribe 12 Sep 10, 2022
DeV Tools - Swiss Army Knife of command line utilities

dvt aims to bundle all small utilities used by developers (typically a mix of cli and online tools) into one binary that you can simply use in the console. No need for complex pipe-ing, copy-pasting on different sites or keep installing cli utilities for every need.

Madalin Ilie 13 Sep 15, 2022
Wrapper around ping command for Windows and MacOS

Wrapper around ping command for Windows and MacOS. Extended with functionality to intercept results provided by the ping command output (latency, ttl and etc.)

Vladislav Kozlov 1 Jan 6, 2022
Annotation-based command framework for Minestom

Minestand Annotation-based command framework for Minestom Advantages over other frameworks Minestand works by converting your classes into Minestom co

null 6 Aug 27, 2022
Several implementations of a text table, originally using ASCII and UTF-8 characters for borders.

ASCII Table ASCII table - A simple tool to format tables with various row/column options for indentation, indentation character, alignment, padding (l

Sven van der Meer 415 Dec 26, 2022
Mp4grep - a CLI for transcribing and searching audio/video files

mp4grep mp4grep is a tool that transcribes and searches audio and video files for a regex pattern. mp4grep isn't just for mp4 files! It also supports

ooc 250 Dec 23, 2022