Starting.. | How to configure ? | How to use ? |
Scripting module | Sensing definition |
In order to run the simulator, you need to have the following structure:
Lets assume that you have this file (we provide a
basic one), just type make
run or mass and if everything is correct you
should have 4 windows appear, the Event Queue,
Global Environment Display, Script control and Simulator. That's all...the simulator will now
be waiting for agents to connect. If you get an error message,
or no windows appear, please add "LEVEL 5" and "FLUSH" to the LOGFILE
option in the simulator.cfg and rerun it. Hopefully
this will help you determine the error.
In the main window (see figure 1), a line with an
icon, the name, the internal simulator ID, the status (false = idle,
true = running) and two buttons () that kill or pulse this agent
independently of the simulation. When you pulse an agent, only this agent will
receive the pulse. The simulator does
not process any of the events in its queue at this time,
because the simulation state as a whole has not advanced (only that one
agent will think time has passed).
This button is really only for debugging
or testing a connection with a specific agent. The kill button sends a disconnect
message to this agent, stopping all executions requested by this
agent and freeing all resources used by those executions.
The simulator is controlled by the row of buttons at the bottom: Note to MASS 1.1x Users
We have changed some entries in the configuration file, please make
sure to read the
section on configuration, sensors and scripting.
How to use ?
Using the simulator is fairly simple, the general idea is to have a
process - the simulation controller - start listening to a port.
Agents can then connect at anytime and take part in the simulation
run. Connecting agents must therefore support the handshake sequence
expected by the simulator, and recognize the various control and
information messages sent by the simulator at runtime. During
simulation, agents will route their communication activity, as well
as method execution requests, through the controller.
Top level files
Unix-bin
This directory contains shell scripts and configuration files for Unix
machines. We assume that you know how to run a shell script.
lib
In order to run MASS need an configuration file. The section How to configure ? explains you how to make
this file. How to run ?
When an agent successfully connects to the simulator (if you get a connection
error check the Agent HOWTO.) A
new icon representing the agent should appear in the simulator main window and in the global
environment display. The figure 2 shows
what the global environment looks like in the IHome example.
The start button runs the simulation by periodically sending a pulse to all connected agents waiting for their acknowledgments. Following each pulse, the controller will process all internal events and scripts before progressing to the next time slice. This loop may be broken by clicking on the pause button (which replaces the start while running). If an agent does not acknowledge the pulse sent to it before the timeout (configured in the simulator.cfg file) this agent is booted from the simulation (same as if it had been killed). That means that this agent has been removed from the current simulation run, and will no longer be reachable.
When you want to control every pulse by hand, the step button causes the simulator to just send one pulse to each agent, and processing the events after those pulses are acknowledged.
The button step to works with the text field near it. As one might expect, you simply specify the time when you want the simulator to stop progressing in the text box, and then hit step to to cause the simulator to run to that point in time.. This feature can be very handy during a demonstration for jumping from one interesting spot to the next automaticaly (although this behavior can also be exhibited using the scripting mechanism). The about button just pops up you a window with the copyright information. This is not particularly useful on an everyday basis.
The quit button sends to all agents a disconnecting message and closes all connection ports and sockets before halting the simulator. This is the preferred way to exit the simulator.
The last button (which may sometimes be hidden by the MASL logo) is the reset. It will stop all executing methods, freeing their resources, and send an reset messages to all agents. (Note this hasn't been fully tested. This "feature" is known as bug 37.)
On startup, the simulator instantiates all the sensors and scripts you have defined in the configuration files, and then waits for incoming agent connections. The exact protocol of handshaking is defined here. Different from previous versions of MASS, the agent is now responsible for providing its objective view to the simulator, which is needed to simulate it method executions. This has several advantages:
After the simulator receives the task structure, the agent may request that the simulator simulate the execution of one of the agent's actions. To be able to do so, the agent should send its request during what we call its pulse time. In order to be sure that the simulation is deterministic, we need to explicitly control the time when each event occurs. To do this, MASS then controls the time by telling the agents when they can run: the pulsing time, which is bounded by a "pulse" message arriving from the simulator and an "ack" message responding to the pulse when the agent has finished acting.
Getting back to the method execution simulation, when the simulator receives the execution request it begins by computes the eventual cost/quality/duration of the method in using the requesting agent's objective view. Because the task structure used by the agent to select this course of action may differ from the objective view held by the simulator, the performance perceived by the agent may not meet its expectations. Resource load across the simulation in particular may widely affect the distribution of the method. After getting values for cost/duration/quality the method execution will be added in the event queue where the current quality and cost are displayed. The time left before completion is also shown. It should be noted that these values are not definitive, as any event may interact with the metehod and thus change these values as time progresses (especially if a resource is overloaded). Figure 4 shows the event queue of the IHome example at time 12.
Now your simulation is running...let your agents get to work!
; Random number generator seed, use the keyword TIME to have a random seed
; (generated from the system clock)
; to set the SEED use this : RANDOM SEED: 889210829049
; to unset it and used a time-based setting
RANDOM SEED: TIME
; Log file name and logging level, default is System.err
; The logging level is 1 for minimum and 3 maximum.
; LOGFILE: stream/filename [FLUSH] LEVEL level
; FLUSH is optional and when set means that the simulator will flush
; the log buffer at each new message. This option is useful in debugging mode
; but consumes a lot of time.
; To redeviate the log in a file called run.log with a level 2, put this:
; LOGFILE: run.log LEVEL 2
; To use the standart error, write this:
LOGFILE: System.err LEVEL 1
; Timeout to decide to boot an agent from the simulation
; in milliseconds.........
; Optional : by defaut 5 minutes (300000ms).
TIMEOUT: 30000
; Resources definition
; RESOURCE: NAME minimum maximum start_value unit
RESOURCE: Electricity 0 15 0 Kw
RESOURCE: Noise 0 120 20 Db.
; You could also define CONSUMABLE resources
; like Hot Water Tank
CONSUMABLE: HotWater 0 200 20 Gal.
CONSUMABLE: BedRoom_Temp 20 100 50 F
CONSUMABLE: BathRoom_Temp 20 100 90 F
CONSUMABLE: Kitchen_Temp 20 100 90 F
CONSUMABLE: LivingRoom_Temp 20 100 50 F
; Other scripts
SCRIPTS: scripts.cfg
; Sensing definition
SENSORS: sensors.cfg
; NLEs patch
QUALITYFACTOR: true
; Server port number
; The default is 25000
PORT: 25000
; Environmental background
; This is the GIF file used as the background in the global environment
; window. You must have a background !
BACKGROUND: http://mas.cs.umass.edu/research/mass/graphics/home/background.GIF
We have added a new sensing mechanism, now each agents could sense only
what it allow to. You have to add this line in the simulator.cfg file
use:
SENSORS: sensors.cfg
Here the sensor file :
; Format is simple
; Separator is comma
; Sensor comma
; ClassType comma
; Free String matching
; Free list of parameter separated by colon. Like Type:Value
; Deviation parameter is defined like that:
; Error function as (prob token min max unit) token is from (= + -) and
; unit is (# for fixed percent, ! for fixed value,
; % random percent , ~ for random value )
Sensor , ResourceSensor , Resource Hotwater, Resource :HotWater, Deviation :((0.2
= 2 5 #)(0.8 + 1 5 !))
Sensor, ResourceSensor, Sensor, Deviation:(1.0 + 1 5 %)
Scripting module