AgE 2.4 : Computation structure

Decomposition of computation

A computation is decomposed into agents, which are responsible for performing a part of or the whole algorithm. Agents are structured into a tree with virtual root agent shown in the figure below according to algorithm decomposition. We assume that all agents at the same level are executed in parallel. To increase performance, the top level agents (called workplaces) along with all their children can be distributed amongst many nodes.

On this page:

The platform introduces two types of agents: thread-based and simple. The former are realized as separate threads so that the parallel processing is managed by Java Virtual Machine (similarly to Jade platform). Such agents can communicate and interact with neighbors via asynchronous messages.

However, a large number of such agents would significantly decrease the efficiency of a computation due to frequent context switching. Therefore, the notion of simple agent was introduced. The concept of simple agent is based on steppable processing which is to simulate pseudo-parallel execution of agents' tasks. The following two phases are distinguished:

  • The execution of tasks related to computation semantics in the step() method. In the case of an aggregate agent all of it's children perform their steps sequentially. While doing so, they can register various events, which may indicate actions to perform or communication messages, in the parent aggregate.
  • The processing of events registered in an event queue. Since events may be registered only in agents that possess children, this phase concerns only aggregate agents.

The described idea of processing ensures that during execution of computational tasks of agents co-existing at the same level in the structure (agents with the same parent), the hierarchy remains unmodified, thus the tasks may be carried out in any order. From the perspective of these agents, they are processed in parallel. All changes to the agent structure are made by aggregates during processing of the events indicating actions such as the addition of new agent, the migration of an agent, the killing of an already existing agent, etc. They are visible for agents while performing the next step.

The processing of a single agent can be seen as choosing and ordering actions to be performed. Execution can be further delegated according to Strategy design pattern. Strategies represent problem-dependent algorithm operators (mutation, evaluation of fitness, etc.) and may be exchanged without intruding agents' implementation. Operations can be executed by external resources, by providing proxies (according to Proxy design pattern).

Agent

Each agent has a unique system-wide address (GUID). The address is generated by an external service (TODO: nameservice). Each agent also has a collection of named properties which can be monitored. Agents can communicate with each other using synchronous requests (asking for property values ​​of individual agents or functions of some set of agents) or by exchanging asynchronously individually interpreted messages. In all cases, the range and possibilities of communication is defined by the parent agent, which acts as an intermediary in the transfer of queries and messages.

Due to possible implementations of concurrent processing there are two types of agents: lightweight and heavyweight ones.

Lightweight Agent

The concept of lightweight agents was created to increase the effectiveness of communication mechanisms. It is based on a step-based processing and allows to run pseudo-parallel agents.

The rest of this section is not yet translated.

Powyższy rysunek przedstawia diagram sekwencji przetwarzania agenta-rodzica posiadającego trzech agentów potomnych. Wyróżnia się dwa etapy przetwarzania:

  • wykonanie operacji związanych z logiką obliczenia (metoda step); w przypadku agregatu, sekwencyjne wykonanie kroku przez wszystkie agenty potomne; podczas tego etapu agenty mogą rejestrować u agenta nadrzędnego różnego typu zdarzenia, które mogą zawierać akcje, wiadomości lub zapytania,
  • przetworzenie zdarzeń zagregowanych w kolejce agregatu (metoda processEvents); ponieważ zdarzenia mogą wystąpić tylko w agentach potomnych, etap ten wykonywany jest tylko przez agregaty.

Takie rozwiązanie zapewnia niezmienność struktury agentów podczas wykonywania wszystkich operacji związanych z logiką obliczenia na danym poziomie w strukturze agentów, dlatego kolejność ich wykonania nie ma znaczenia. Zatem z punktu widzenia agenta przetwarzanie operacji na jego poziomie w drzewie odbywa się równolegle. Wszystkie żądania zmian ułożenia agentów są kolejkowane w agencie nadrzędnym jako zdarzenia. Po zakończeniu wszystkich operacji agentów z danego poziomu hierarchii, agent nadrzędny przetwarza zarejestrowane zdarzenia. Obsługa wszystkich typów zdarzeń, a w szczególności tych, które zawierają akcje, może wpływać na zmianę struktury agentów (np. dodanie nowego agenta, migracja, etc.), która obserwowana będzie w następnym kroku przetwarzania.

Heavyweight Agent

Heavyweight agents are implemented as threads, which parallel processing and synchronization mechanisms are provided by the JVM.

The rest of this section is not yet translated.

Rysunek poniżej przedstawia cykl życia agenta ciężkiego. Po utworzeniu agent przechodzi w stan STOPPED – jest wtedy w pełni zainicjalizowany i gotowy do przeprowadzenia obliczenia. Po uruchomieniu, agent zmienia stan na RUNNING i rozpoczyna wykonywanie obliczenia. W tym stanie może komunikować się z innymi agentami. Jeśli otrzyma żądanie zatrzymania (np. w przypadku spełnienia warunku stopu lub przed migracją), przechodzi w stan STOPPING. W tym stanie wykonuje obliczenie, aż do ukończenia bieżącej fazy obliczeń, a następnie zatrzymuje swoje działanie przechodząc do stanu STOPPED. Wszystkie wartości parametrów agenta ciężkiego (jak i jego potomków) są zapisywane (,,zamrażane''), dlatego istnieje możliwość wznowienia obliczenia z dokładnie takiego samego stanu poprzez ponowne uruchomienie agentów. Agent ciężki może zostać usunięty z systemu tylko, jeśli jest w stanie STOPPED.

Workplace

TODO

Środowisko agenta i środowisko zewnętrzne

Każdy agent działa w środowisku, które udostępnia mu następujące usługi:

  • możliwość rejestrowania adresu agenta; agent przed rozpoczęciem działania musi zarejestrować swój adres tak, aby był jednoznacznie rozpoznawalny w całym środowisku obliczeniowym
  • możliwość wysyłania zapytań o wartości właściwości innych agentów; zapytania mogą być kierowane na dwóch poziomach:
    • agent może odpytać agentów znajdujących się na tym samym poziomie w hierarchii, posiadających tego samego rodzica co agent odpytujący,
    • agent może odpytać agentów znajdujących się na poziomie jego rodzica, posiadających tego samego rodzica co rodzic agenta odpytującego.

Rolę środowiska pełni agregat będący rodzicem agenta. On też podejmuje decyzje co do sposobu realizacji usług. Niektóre usługi mogą być delegowane do środowiska zewnętrznego.

Środowisko zewnętrzne (IWorkplaceEnvironment) jest realizowane przez obiekt zarządzający agentami będącymi korzeniami hierarachii agentów (tzw. workplace'ów). Obiekt ten (WorkplaceManager) jest jednym z komponentów, które rezydują na węźle obliczeniowym. Środowisko zewnętrzne udostępnia agentom zewnętrzne usługi, tj. usługa nazw pozwalająca na lokalizację agentów po ich adresach, usługa komunikacyjna pozwalająca na dostęp do innych węzłów oraz powiadamianie o zatrzymaniu danego workplace'a. Środowisko zewnętrzne może być rozszerzone i pozwalać na dostęp do innych usług.

Attachments: