README.md 2.79 KB
Newer Older
Linxiao Zeng's avatar
Linxiao Zeng committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
# Multi-Agent System

### Automatic Configuration 

For the configuration, we've defined a simple language to simplify the loading.

The syntax can be sum up as :

`type: parameter`

As our system has mainly 2 type of component: machines and lines.

Machine suggest input, transformation and output. Each contain 6 element, i.e., name, in_list, out_list, processing_time,error_rate, coordinate. We mark this type of component as transf.

So, the machine should be expressed as following:

```
transf:transfo_1;[produit1:1];[ligne2:produit2:2];2000;.02;(300,100)
transf:entree_1;[];[ligne1:produit1:1];0;0;(100,100)
transf:sortie_1;[produit2:1];[];0;0;(500,100)
```

As Line connect two machines, and transfer products between them, so the parameters should contain name, source machine, target machine and capacity of products.

```
ligne:ligne1;entree_1;transfo_1;5
ligne:ligne2;transfo_1;sortie_1;1
```



Through the above definition, we can capture the machines' attributes by following regular expression in java:

```
(\\w*);\\[(.*)];\\[(.*)];(\\d*);([\\d.]*);\\((\\d*),(\\d*)\\)
```

and the attributes of lines can be extracted by simply apply split by ";"

We then store the attributes in a HashMap, and all machines forming a Map variable, then we put machines and lines into a HashMap for latter use.

We express the data structure as follows:

confDic: {"Machines": Machines, "Lignes": Lignes}

- Machines: {nameOfMachine: Machine, ...}
  - Machine: {"inputs": inputLists, "outputs": outputLists, "processTime": processTime, "errorProb": errorProb, "x": x, "y": y}
    - inputList: a list of Object Input with attribute {type, quantity}
    - outputList: a list of Object Output with attribute {ligneName, type, quantity}

- Lignes: {nameOfLigne: Ligne, ...}
  - Ligne: {"source": sourceMachineName, "target": targetMachineName, "capacity": capacity}



### Graphic interface

In order to show the process of a multi-agent system, we created a graphical interface. In the gui package, we should mainly focus on two classes: GUI.java, Painting.java.

GUI.java is the agent who in charge with the setup of the graphic interface.

Painting.java is a subclass of JPanel and override the paint function to paint the graphic object. In this class, we set all the graphic component as attribute, i.e. machines, lignes, productList. We can change the output graphic interface by changing these attribute.

And we set the agent to repaint the output graphic in a fixed frequency to adapt these changes.

Therefore, in order to correctly display the progress of the system, we only need other agents to send information to the GUI agent. The GUI agent processes these information, and applies the changed data to the attribute of Painting.java. The graphical interface will then automatically updated by TickerBehaviour (Repaint) of the GUI agent.



##