How to run ? | How to configure ? | How to use ? | MASS Documentation |
How to script ? | How to talk to ? |
In order to run the simulator, you need to have the following structure:
Let assumes that you have this file (we provide a basic one), just type
make run or mass and if everything is correct you
should have 3 windows poping up,
the Event Queue, the Global
Environment Display and the Simulator.
That's all... Now the simulator is waiting for agent to connect.
If you get an error or no windows, please add the LEVEL 5 with the FLUSH
option in the simulator.cfg and
rerun it in order to determine the error.
In the main window (see grab 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 and will ack to it. The
simulator DOES NOT process any events because the simulator
central DID NOT CHANGED ! This button is only for debugging or
testing a connection with a specific agent. The kill button sends a disconnecting message to
this agent, stopping all executions requested by this agent and freeying all
resources used by these executions.
The simulator is controlled by the six buttons at the bottom: How to use ?
To use the simulator is quite simple, the idea is to start a process listen
to a port. Every agent could connect at anytime and take part to the run. The
agent should respect the identification protocol. After that, an agent well
registred routes all its messages through the simulator.
Top level files
Unix-bin
This directory contains shell script 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.) It
should add an new icon in the simulator main window and in the global
environment display. For example the grab 2 shows
the global environment in the Warren example.
The start button run the simulation. When you click on start the simulator sends a pulse to all agents connected and wait for their acknowledgements. The next step is to process all internal events and after the loop goes on with the next pulse. This loop may be stop by clicking on the pause button (which replace the start). If an agent does not ack to the pulse before the timeout (configured in the simulator.cfg file) this agent is booted off (similar as killed). That means that this agent may not participate anymore to this simulation.
When you want to control every pulse by hand, the step button made the simulator just sending one pulse and processing the event at this time.
The button step to works with the textfield near it. Simple, you specify the time when the simulator has to pause, and you step to this time. This feature is very "handy" in a demonstration for jumping from interesting part to others automaticly. We even use this step to function in the events scripting mechanism, but chutt, that's MASS 1.2 and I'm not supposed to talk about it. The about button just pops up you a window with the copyright information. This is really not useful.
The quit button sends to all agents a disconnecting message and close every connections port and sockets before exiting of the simulator. This is the normal way to exit of the simulator.
The last button (which may sometimes be hidden by the MASL logo) is the reset. It stops every executions, freeying every resources, and send an reset messages to all agents. This reset is not fully tested. See this "bug" is known as bug 37.
The simulator instiate all the sensors and all the events you have defined in the simulator.cfg, then it waits for the agents to connect to. The exact protocol of handskaking is defined here. As the opposite to the previous of MASS, now the agent has to send the objective view to the simulator, in order to simulate it. This has several advantages:
After the simulator receives the task structure, the agent may after that request the simulator for one or several executions. To be able to do so, teh agent should send its request during what we call its pulsing time. What the heck is the pulsing time ? Simple in order to be sure that the simulation is determinic, we need to control the time when the event occurs. So MASS controls the time by telling the agents when they have to run: the pulsing time. When the agent has finshed to run it sends back to the simulator an end pulsing time message.
Getting back to the method execution simulation, when the simulator receives the request and compute the cost/quality/duration of the method in using its objective view of this method. So the distribution used may differ from the one used by the agent to schedule. Especially the resources load may affect widely the distribution of the method. After getting values for cost/duration/quality the execution is added in the event queue where the current quality and cost are displayed. The time left before completion is also shown. These values are not definitive, any event may modifying theses values (especially resources overload). The grab 4 shows the event queue of the Warren example at time 27.
Now your simulation is running... We did our job, let your agents do their !
; 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
; The time at which the sim will stop running
; In this case, the simulation run for 100 clicks only
STOPTIME: 100
; Wait for keyword is an extension (valid since MASS 1.11) that
; force the simulator to wait for a number of agent to connect to
; before automaticly starting.
; In this case, the simulator waits for 2 agents to connect before
; starting.
WAITFOR: 2
; Resources definition
; RESOURCE: NAME minimum maximum start_value unit
RESOURCE: CPU 0 100 0 percent
RESOURCE: Network 0 10 0 M/s
; You could also define CONSUMABLE resources
; like Hot Water Tank
CONSUMABLE: Water 0 100 100 gal.
; Resource scripts file
RESOURCESCRIPT: example.script
; 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/warren/background.JPG
This file to use is define in the configuration file by these field:
; Resource scripts
RESOURCESCRIPT: example.script
Here what you can define in this file:
; Example resource script file
;
; Supported commands:
;
; REFRESH time
; time (int) - the clock time to refresh at
; Sets the cycle time. Every "time" pulses the resource script
; will be run again.
;
; SET start duration resource current min max
; start (int) - the start time of the event
; duration (int) - the duration of the event
; resource (str) - the name of the affected resource
; current (int) - the new current value of the resource
; min (int) - the new max value of the resource
; max (int) - the new max value of the resource
; Sets a given resource's quantitative (current, min, max) values.
; If you don't want to adjust one of these three values, enter
; NO_CHANGE instead of a numeric value.
;
; ADJUST start duration resource current min max
; - params same as for SET
; Adjusts a given resource's quantitative (current, min, max) values.
; For instace, a "current" value of -3 would mean that the resource's
; current value would be decremented by 3 during each time slice
; the event is active.
; This will simulate a leak in the Water Tank of 0.1 gallon per click
ADJUST 1 1000 HotWater -0.1 NO_CHANGE NO_CHANGE
; If you want to simulate an upgrade of the tank at time 2000
SET 2000 1 HotWater NO_CHANGE NO_CHANGE 400.0
How to talk to the simulator ?
The connection mechanism is in seven steps:
[0:WaterHeater] Trying to connect to masl.cs.umass.edu at port 25000
[0:WaterHeater] Connected to masl.cs.umass.edu at port 25000
[0:WaterHeater] Message (from WaterHeater) (to simulator) "(register :type control :sender WaterHeater :content :receiver simulator :language KQML)"
[0:simulator](RootServer) Waiting for client connection
[0:simulator](Server) Reset time to 0 pulse.
[0:simulator] Looking for agent WaterHeater
[0:simulator] Didn't find WaterHeater
[0:simulator](Server) Adding agent WaterHeater
[0:simulator](Server) Sending Message (from simulator) (to WaterHeater) "(tell :type control :sender simulator :content (Name WaterHeater) :receiver WaterHeater :language KQML)"
[0:simulator](Server) Sending Message (from simulator) (to WaterHeater)
"(tell :type control :sender simulator :content (RandomSeed 880596746373) :receiver WaterHeater :language KQML)"
[0:simulator] (Server) Sending Message (from simulator) (to WaterHeater)
"(tell :type control :sender simulator :content (Time 17 ) :receiver WaterHeater :language KQML )"
[0:simulator](Listener: WaterHeater) Listener registered with agent WaterHeater
[0:simulator] Adding agent WaterHeater
[0:WaterHeater] Message (from WaterHeater) (to simulator) "(tell :sender WaterHeater :content (Location 118,5) :receiver simulator :language KQML)"
[0:WaterHeater] Message (from WaterHeater) (to simulator) "(tell :sender WaterHeater :content (Display http://mas.cs.umass.edu/research/mass/graphics/home/waterheateroff.GIF) :receiver simulator :language KQML)"
[1:WaterHeater] Message (from simulator) (to WaterHeater) "(ask :type
control :sender simulator :content (pulse) :receiver WaterHeater :reply-with
(pulse) :language KQML)"
The agent should answer, when it has finished its run:
[1:WaterHeater] Message (from WaterHeater) (to simulator) "(reply :type
control :sender WaterHeater :content (ack pulse) :receiver simulator :in-reply-to pulse :language KQML)"
In version 1.1x, the simulator has to received from the
agent what structure it has to simulate. The agent sends to the simulator
a TÆMS structure in Textual
TAEMS:
[0:Simulator] (Listener: OtherAppliances) Received message (from OtherAppliances) (to simulator) :
(tell :sender OtherAppliances :content (TextualTaems
(spec_method
(label Use-45-Noise)
(agent OtherAppliances)
(supertasks Other-Appliances )
(outcomes
(Use-45-Noise_o0
(density 1.0)
(quality_distribution 10.0 1.0 )
(duration_distribution 1.0 1.0 )
(cost_distribution 0.0 1.0 )
)
)
)
.....
VERY LONG MESSAGE NOT SHOWN
.....
) :receiver simulator :language KQML)
[12:OldYeller] Message (to simulator) "(ask :sender
OldYeller :content (ExecuteStart Use-35-Water) :receiver simulator :reply-with
4435747129655456929 :language KQML)"
[13:OldYeller] Message (from simulator) "(reply :sender simulator :content
(ExecuteEnd Use-35-Water 1 0.0 10.0 Used HotWater 35.0) :receiver OldYeller
:language KQML :in-reply-to 4435747129655456929)"
[0:simulator]: (Listener: WaterHeater) Sending message from
simulator "(ask :type control :sender simulator :content
(disconnect) :receiver WaterHeater :reply-with (disconnect) :language
KQML)" to WaterHeater
The agent should ack to this message like that:
[0:WaterHeater] Message (from simulator) "(ask :type control :sender simulator :content (disconnect) :receiver WaterHeater :reply-with (disconnect) :language KQML)"
[0:WaterHeater] Disconnect message received
[0:WaterHeater] Message (from WaterHeater) (to simulator) "(reply
:sender WaterHeater :content (ack disconnect) :receiver simulator :language
KQML :in-reply-to disconnect)"