Table of Contents

Industry

The industry class is a skeleton for all of the industries since all of them have the same functionality. The only difference comes from the psySpec.xml file, which in a way behaves like the Government sending out rules and initial values to the other modules.

Functionality

The industries start by connecting to Psyclone, and initializing variables by getting the parameters from the psySpec.xml file. These variables distinguish different industries from each other.

The industries can send two kinds of messages: carbon.quota.buy and carbon.quota.sell.

<buy
    name="The buyers name same as in type of industry"
    units="How many units(tons) it wants to buy"
    price="The Max price it is willing to pay"
    exp="The expiration time of the bid"

/>

<sell
    name="The sellers name same as in type of industry"
    units"How many units(tons) it is willing to sell"
    price="The Min price it is willing to sell for"
    exp="The expiration time of the bid"

/>

The industries listen to all messages from the market of the form: carbon.quota.response, but they are only interested in the messages that have the sentTo with their name in it. The industries also listen to the message simulation.time from the timer.

Market

For every bid that the market receives it stores it in the bids vector. It then checks daily if the bids have a matching offer or are expiring. If the bid is expiring it marks it in the removeListBid and then checks for the last time if it has any offers for it. If it has an offer for it it sends both the seller and the buyer a carbon.quota.response message saying that they have bought or sold some units and for the asking price of the offer.
If there are differences in the units the market checks the units number. If the offer units are higher then the bid, the market sells the offer the amount of units the bids are then renews the offer for the lasting units. This is also done for the other way around. That is if the bids number of units is higher then offer units, the bid gets renewed with the number of units left.
The bids and offer prices are a match if the bid price is higher or equal to the price of the offer. This means that the closest price always gets matched.

The market is able to send one kind of message. carbon.quota.response with the content:

<buyer sentTo=“The Buyer Is” bought=“Yes” units=“amount of units” price=“the selling price” />

and the seller gets similar message

<sell sentTo=“The Seller Is” bought=“Yes” units=“amount of units” price=“the selling price” />

The market can receive three kinds of messages: Two types from the Industries: carbon.quota.bids and carbon.quota.offer. It receives one kind of message from the Timer: simulation.time. When the market receives this type of message it starts by updating the date variable and then checks what bids and offer are expiring.

Timer

The Timer sends out message to tell everyone what day it is. Everybody gets a new message when a new day starts. It is best to start the timer last when running the simulation because everybody are just waiting until the timer sends out the initial date.

Timer message

Type: simulation.time

Content:
<Time Date=“LongNumber” />


LongNumber: Is the date of the simulation represented in milliseconds since the 1st of January 1970.

Tester

Tester is just a module in psyclone that can be used for testing strange behavior or other tests with the numbers. To start a tester just start an Industry class with the name set to “Tester” then it automatically retrieves all the initial values from psySpec. This is very useful so you don't need to be changing the values in all of the other Industries while you are testing some strange behaviors or anything else you need to test.

GUIForKristinn

This class is based on the monitor class from the last year project. It uses JFreeChart to represent graphs. This class takes all of the messages it receives and uses the content to create graphs to display while the simulation is running.

RunGUI

This class signs into psyclone and triggers all the messages that are sent while the simulation is running. It creates an instance of the GUIForKristinn class and sends every message it receives to it the instance. This class is based on the MonitorRunner from last years project.

Debug

This class has no purpose for the simulation it only useful for the programming part where you write Debug.print(“The string you want to print out”) and when you want the debug messages to appear you do Debug.set(true) and Debug.set(false) when you don't want the debugging messages.

Newest Picture

This picture shows the messages how they go from the Industries to the white board and then to the market and wise versa. It also shows how the messages come from the Timer and go through the white-board to all of the modules

psySpec

The newest psySpec file has three new modules: Timer, Tester and the GUIForKristinn. The Timer module has one parameter name=“Timer” and only posts messages but triggers none. The Tester is just a copy of the Industry modules and it can be used for playing with the numbers and if you wanted someone to behave in a strange way then the Tester is good for that. GUIForKristinn module has no parameters and it triggers all of the message types since it is only going to be observing the simulation.

Messages

There are 4 kinds of message types:
carbon.quota.bid
This message is sent out by the Industries to the market. The content of this message is how much the Industry wants to buy of carbon quota units, for which price and expiration time in days.

carbon.quota.offer
This message is sent out by the Industries to the market. The content of this message is how much the Industry wants to sell of carbon quota units, for which price and expiration time in days.

carbon.quota.response
This message is sent by the market as an response to the buyer and sellers telling them how much they bought and how much they sold. The market does not send out messages if your bid/offer has expired or that they did not buy anything.

simulation.time
This message is sent to the white-board and it contains the date of the simulation in milliseconds. This message makes everybody know when new day is starting.

Screenshots of running system

Below screehshots of the running system are taken to show the trend of the prices during the simulation.

The next two images refer to the bids prices in two different moments.

The next two images show the trend of the offers prices.

The next two screenshots are taken from market responses.