Software Agent Metrics Analyzer (SAMA)


1. What is SAMA?
2. Where to get SAMA?
3. What are the files in SAMA?
4. How to set up the environment to run SAMA?
5. Run SAMA?
6. What metrics do SAMA measured?
7. Latest Version?
8. How to run Agent Program?


1. What is SAMA?

SAMA, Software Agent Metrics Analyzer is an application which will parse agent program written in Java. After parsing, it analyzes the program and computes the metrics about the agent. The parsing functionality is based on the ANTLR framework while the agent program to be analyzed should be developed under the JADE framework (version 3.1). The analyzer is written in Java version 1.4.2. SAMA current version is 1.3 (Released on 11/03/04). I have been working on SAMA since August 2003.

2. Where to get SAMA?

You can download SAMA from here.

3. What are the files in SAMA?

There are three main files to be download, the lib.jar, parser.jar and example.jar or you can download just the main jar file (SAMA.jar), which will contains every files needed. After download SAMA.jar into your home directory, run jar -xfv SAMA.jar to unzip the files. It will create a new directory (Agents) automatically for all the files unzipped.

Files Contents Description
SAMA.jar (1.50 MB) lib.jar, application.jar and example.jar It contains all three jar files which formed the SAMA.

lib.jar
(1.46 MB)

jade.jar, jadeTools,jar, Base64.jar, iiop.jar and antlr.jar It contains the five libraries. Antlr.jar is required for the java lexer and parser. The rest of the libraries served as the JADE environment for the agents applications. (jade.jar, jadeTools.jar, Base64.jar and iiop.jar)
parser.jar
(34 kB)
JavaLexer, JavaRecognizer, JavaTokenTypes, JavaTreeParser, JavaTreeParserTokenTypes, Class, ClassMgt, Method, Variable, Main and agentAnalyzer It contains all the files for the SAMA. These include the java parser, the respective component class, the agent program analyzer and the main program.
example.jar
(1 kB)
Simple1.java, TwoSteps.java It contains the sample agent program, which used in the analysis by SAMA. The files is based on the JADE Primer Tutorial 2 and 3 examples.

BookTradingVer3.jar (7 kB)

BookBuyer.java, BookBuyerGui.java, BookSeller.java, BookSellerGui.java

It contains an agent application used in the analysis by SAMA. This application presents a multi agent system where there are two types of trading agent: Buyer and Seller agents. The agents will act on behalf for the user to buy or sell the books at the price with as much profit as possible. More details could be found here The application is based on the JADE examples.


4. How to set up the environment to run SAMA?

After you have downloaded and unzipped SAMA.jar, you might need to setup the Java CLASSPATH so that the correct libraries are used.

For Win XP:

Assume that the files are under c drive and inside the directory named c:\Agents, using Control Panel > System > Advanced > Environment Variables and create the CLASSPATH System variable and add the following values. (If the variable is already exists, append the values into the variable.)

c:\Agents\lib\jade.jar;c:\Agents\lib\jadeTools.jar;c:\Agents\lib\Base64.jar;c:\Agents\lib\iiop.jar;c:\Agents\lib\antlr.jar;

5. Run SAMA?

Before you can run SAMA, you need to compile the java files inside Parser directory. (You can use the command javac *.java) Type the following command to run the application.

For Win XP: java SAMA

6. What metrics do SAMA measured?

Currently, SAMA is able to calculate  the following attributes:

System Level *Only available in SAMA 1.2 onwards

  1. Average number of local variables per method
  2. Number of packages, classes, methods.
  3. System Size (Number of executable statements in the file)

Class Level

  1. Number of inner class
  2. Number of class method and constructor
  3. Number and type of variables
  4. Number of interface
  5. Class Size (Number of executable statements in each class)

Method Level

  1. Number and type of parameters
  2. Number and type of local/global variables
  3. Number and type of variables read/write
  4. Number inner/outer method calls
  5. Number of loop statements (while, do & for)
  6. Number of condition statements (if)
  7. Maximum depth
  8. Method Size (Number of executable statements in each method)
  9. Number and type of Exception
  10. Number of Message Types Exists
  11. Number of Casting
  12. Number and type of Exception throw and catch by the method

Variables Level *Only available in SAMA 1.1 onwards.

  1. Data Type
  2. Number of read/write statements
  3. Number of read/write methods
  • Function 1-2 are available in SAMA 1.1.
  • Function 3 is available in SAMA 1.2.

7. Latest Version?

You could download SAMA final version here. It contains only the parser.jar, which will replaced the older parser files in SAMA 1.0, 1.1 and 1.2. The rest of the files remain unchanged.

New Changes for SAMA 1.1

  1. Abstract manager class is created for Class, Method and Variable manager.
  2. Method manager and Variable manager is added to keep track of all the methods and variables in the agent. 
  3. New attributes are included in the method and variable class to store more information about the agent program.
  4. New tokens are added for computation of agent message types and behaviors in the JavaTreeParserTokenTypes.java.
  5. A new class (TokenName) is included to return token description, depending on the token value.

New Changes for SAMA 1.2

  1. A graphical user interface is provided for user. (SAMA.java, TableSorter.java and TableMap.java is added)
  2. A prefix S is added to the files name for Class, Method, Variable and the respective manager for clarity.

New Changes for SAMA 1.3

  1. User can now view the abstract syntax tree.
  2. A report for the anlaysis results can be printed. 

8. How to run Agent Program?

The Java CLASSPATH must be set so that the correct libraries are used before the agent can run. (As shown in previous section 4) We would show how to run BookTradingVer3.jar in Windows environment. We would create two sellers and one buyer, sellers have to be created first as buyer will exist the system if it could not find any seller. Agents can't be executed directly like a normal java program, an environment container (jade.Boot) is needed to provide the necessary services to run an agent. Assume that BookTradingVer3.jar is under c drive and inside the directory named c:\Agents, here is the list of commands needed to run the book trading program: *Although SAMA analyzes agent program, it is not an agent. Please refer to section 5 on running SAMA.

  1. jar -xfv BookTradingVer3.jar to unzip the file.
  2. Add c:\Agents\BookTrading; inside CLASSPATH System variable
  3. java jade.Boot to start the environment container
  4. javac *.java to compile the java files.
  5. java jade.Boot -container Seller1:BookSeller to create the first seller
  6. java jade.Boot -container Seller2:BookSeller to create the second seller
  7. java jade.Boot -container Buyer:BookBuyer to create the buyer

Last updated on 30 Mar 2004 PM