MAS course practice

Arithmetic System

Tandil, Argentina, nov. 1999

Professor: Yves Damazeu
Student: Adrián Allende ( aallende@exa.unicen.edu.ar )
 

IMPLEMENTATION INSTALLATION, USAGE AND DEVELOP

Introduction

This demo is part of examination in the course of Multi Agent Systems (MAS) to see an implementation of the problem descripted below. Was developed in MadKit 1.3.2 and is not compatible with early MadKit versions.

Contents

The problem

Installation

Usage

Results analysis

Developing

 

The problem (arithmetic system)

- Ramdomly generated X individuals having each the knowledge of a given number of operators.
- Global set of possible operators: +, -, *, /, exp, ln.
- A mathematical formula (including parenthesis) is ramdomly given to one individual that has to compute the result and to deliver it to the user.
- (Options) learning other's skills, optimizing interactions between individuals.

To see design and model detail, follow this link.
 

Installation

This demo is packed in a zip file named "MAS-Practice.zip".

Create a "MAS" directory in  "<madkit root>\src" (eg.: C:\madkit1.3.2\src\MAS).
Decompress the zip in the previously created "MAS" directory.
Copy <madkit root>\src\MAS\practice.jar to <madkit root>\autoload\
Copy <madkit root>\src\MAS\practice\Exp.jar to <madkit root>\
Copy <madkit root>\src\MAS\r.bat to <madkit root>\
 

Usage

Run <madkit root>\src\MAS\r.bat. This bat replaces the run-gbox.bat only to add Exp.jar in the classpath.
[Tip: call the r.bat inside a console window (not with a shortcut), to see errors more easily]
In the G-Box environmet, launch the system.jar/GraphAgent [this is optional but nice!].
Launch the practice.jar/Launcher
The launcher interface will present the following parameters to edit:

"Formula (takes precedence if random != 0): "

    This is a formula to solve (eg.: 1 + 1) . The sintax is the usual, with exp( ) and log() operations as usual. Be careful in not to put a minus operator without a space, cause the java.StreamTokenizer takes the minus as the sign of the number (ie.: not as the operator) (eg.: 1-2 is not parsed as usual, is parsed as [number = 1] and [number = -2] without a operator, of course, an error. To avoid this, simply put a space between - and 2.).
    If this parameter is not blank, the following parameter is ignored.

"Random formula operators quantity = Random 1 to: "

    Ignored if parameter above is not blank.
    A random formula will be crated with the specified operators. The constants are random [0..100].

"Individual Agents quantity = Random 1 to: "

    The launcher launch as many 'math skilled individual' (Ind) agents as [Random * this_parameter + 1].

"Per Individual Agents skills quantity = Random 1 to (max 7): "

    The Ind agents assigns itself as many skills in operation evaluation as [Random * this_parameter + 1].
    If after the assignment nobody has an operator skill, the launcher puts all the unasigned skills in the first (named "Ind[0]") Ind, to avoid an infinite execution.

"Verbose level (0 or 1): "

    The Ind agents can be VERY verbose in inform the formula traverses with 1, but is sufficient with 0. The last words of each Ind is the only useful (except to develop and test).

Now, you can use the  "Result!-->" button, after execution an Ind puts the result in the edit at right.
Be pacient! may be several minutes without feddback, but the system works fine!.

Not be surprised for a NaN (not a number) result, is not an error. Very often a 100 operators random formula involves a log() of a number < 0.
 

Results analysis

When the execution finishes, each Ind shows:

The formula to solve.
The skills he has.
The total team of Inds.
(When the Ind traversed the formula first time, remembers the nodes of his interest)
  The total number of nodes he can solve.
(When the Ind traverses his nodes list)
  The total number of nodes he encounters solved.
  The total number of nodes he encounters marked for another Ind solving this node.
  The total number of nodes he encounters still unevaluabled (cause sub-tree(s) are unevaluated).
  The total number of his nodes he traverses in the cycle.
The guy that solves the root of the formula, shows the result too.
This implies that :
Showing the result for the launcher is done only for comodity of usage, and is made with comunication. If you want to be "purist" and not to use explicit communication (not needed in this aproach) you can comment all the communication stuff (well marked with comments in the Ind and Launcher classes), recompile and show the results in the Ind[i] that evaluated the root.
 

Developing

First, you nedd to include
<madkit root>madkit.jar;<madkit root>\libs\swingall.jar
in your classpath.
(see init.bat)

The <madkit root>\src\MAS\practice\Exp\ contains the Expression classes that models the formula.
If change something there, you nedd to

<madkit root>\src\MAS\practice\Exp > javac *.java
<madkit root>\src\MAS\practice > jar cf Exp.jar Exp/*.class
<madkit root>\src\MAS\practice > copy Exp.jar ..\..\.. [to madkit root]
(see jarExp.bat)

The <madkit root>\src\MAS\practice\ contains the Ind, Launch and LaunchBean classes that models the individuals.
If change something there, you nedd to

<madkit root>\src\MAS\practice > javac *.java
<madkit root>\src\MAS > jar cfm practice.jar Manifest.txt practice/*.class (see <madkit root>\src\MAS\manifest.txt)
<madkit root>\src\MAS > copy *.jar ..\..\autoload [to <madkit root>\autoload]
(see <madkit root>\src\MAS\practice\j.bat)

The guy that solves the root of the formula, shows the result too. Showing the result for the launcher is done only for comodity of usage, and is made with comunication. If you want to be "purist" and not to use explicit communication (not needed in this aproach) you can comment all the communication stuff (well marked with comments in the Ind and Launcher classes), recompile and see the results in the Ind[i] that evaluated the root at usage time.