[an error occurred while processing this directive]

Project
Being the Fat Controller

Specification

Version: 1.0 Project spec released

Overview

In Task 2 you wrote a simple network simulator to allow the fat controller to interact with Thomas and his friends.

The simulator had a function to set the lights on the fat controller's panel (so she could work out the location of the trains (to some extent)), and a function to set the signals and points on the network.

The Project is to implement the fat controller. Or rather, the brains of the fat controller - via the function Strategy.ai().

To be more precise - you will write a function, ai(), which, given some data about the network and given the state of all the lights immediately before a tick, determines the best way of setting the points and signals to "optimally" control the trains for the next few ticks.

"Optimally" means to maximise the profit of the network whilst ensuring complete safety.

The "profit of the network" we define to be the profit of the least profitable train. In this project we do not include running costs when determining train profit.

"Ensuring complete safety" means that networks which have an accident, or which from the point of view of the fat controller might have an accident save for events beyond her control, have a profit of negative infinity.

We will provide a top level wrapper module, FatController.hs, which will repeatedly call your functions, to allow you to:

The Train Network

Unless otherwise stated the network structure, definitions, and assumptions are the same as for Task2.

What you are to do (3 labours)

  1. Design the interface for two types to assist the fat controller optimally control the network;
  2. Implement these two types and their interface functions; and
  3. Finish the Network simulator module from task2.

Labour 1 is a joint effort by the entire tutorial in week 8, the remaining labours are done by your group (pair).

Labour 1: Interface design

Design the interfaces for the types Location and Strategy.

We *require* some functions to be in the interfaces (see labour 2 below) but you will most probably need to add some more in your design.

To come up with a good interface design you should think carefully about what you need to write the required interface functions.

The design is to be a joint effort by your entire tutorial class in the week 8 and 9 tutorial and lab. Everyone in the tutorial must comply with the agreed interface specification.

Prepare for this carefully in advance. Participate in the design process in the tutorial. You do NOT want to end up with a flawed or overly difficult interface.

Your tutorial's interface will then be published by the week 8 tutorial presenter/s.

Any subsequent changes to the published interface for your tutorial must be agreed to by a 2/3 majority of tutorial members. This is most unlikely to happen, so make sure you get it right the first time.

Labour 2: Implementing the Interface

You are required to implement the Location and Strategy types and the functions required by our FatController module (2 per module - these are listed below).

You must also implement any other functions your tutorial decides to put in the interfaces for the Location and Strategy ADTs.

The Types

Each type is to be defined in a module named after itself (ie Location.hs & Strategy.hs).

The two types are to be abstract. Thus:

  1. Do not "derive" any functions for the abstract types (such as show etc).
  2. Your Location/Strategy modules must be able to be mixed and matched with any other Location/Strategy modules from your tutorial and have everything still work.

The functions *required* by FatController.hs

You must include the following functions in your interface and implement them:

makeLocation and makeStrategy are permitted to take a minute or so to run (we'll run them before starting the simulation). ai and updateLocation should be faster since they are run during the simulation. (I'll post some timing data but the limit will only be a few seconds on a lab machine,)

In addition to your interface functions you may write any other helper functions you require. In addition to the Location and Strategy modules you may write (and submit) any other helper modules you require.

Your modules may not import the Network module. If you really need to make use of its interface functions then copy it into a module with a different name (which you also submit), and import that. It is extremely unlikely you will need to do this.

Labour 3: Network Simulator

Write implementations of the remaining 3 Network interface functions, and alter the behaviour of Network.getProfit() to ignore running costs (we will not count running costs in the project).

The functions isAccident(), getMessages(), and getTicks() are the only Network functions whose behaviour is defined after an accident.


Bonus Marks

We will be awarding two sets of bonus marks for the project:

Files to download

Download the library file ThomasLib.hs. You may not alter this file. Import it in your module to access the shared types used in task 2 and the project.

Assumptions you may make about the assignment.

Note these files have changed since task2 so download fresh copies. Check back from time to time to ensure you have the latest copies.


 

Update History
1.0: 5-5-03 Spec released. Minor wording changes and clarifications. No running costs in computation of profit. Indicitive speed limits to be eligible for physical simulation reduced.
0.3: 1-5-03 two cases added to definition of an accident, minor wording changes.
0.2: 28-4-03 minor alterations, safety functions explained, types for updateLocation altered, reference to updated ThomasLib.hs, time limits on ai and updateLocation set to "a few seconds"
0.1: 26-4-03 preliminary version
[an error occurred while processing this directive]