AgE 2.7 : Sample applications

On this page:

Building the examples

Checkout the platform, then build the examples directory:

git clone git://age.iisg.agh.edu.pl/age.git
cd age/examples
mvn install

While maven downloads the internet, you can check out the structure of the sample applications. They are divided into two maven modules: applications-examples and solutions-examples.

The solutions module contains all the sample code, such as agents, actions and queries. The applications module depends on the solutions one and contain various configuration examples ready to be run.

Running the examples

from Eclipse

  1. Generate Eclipse configuration files by running

    mvn eclipse:eclipse
  2. Import the projects to Eclipse (File -> Import -> Existing project into Workspace) - select both the solutions and applications modules.
  3. In the applications project, the src/main/config directory contains eclipse executables for the different samples. To run any of them, right-click on the specific file and choose Run As and the configurations's name.

from Maven (exec plugin)

  1. Go to the applications-examples directory and use the exec maven plugin:

    cd applications-examples
    mvn exec:java -P examples -Dage.computation.conf=uri_of_config_file

    Configuration files for examples can be found in the directories under /src/main/resources/examples/, for example:

    mvn exec:java -P examples -Dage.computation.conf=file:src/main/resources/examples/helloworld/age.xml

    It's usually easier to load them from the classpath:

    mvn exec:java -P examples -Dage.computation.conf=classpath:examples/helloworld/age.xml

Available examples

  • Hello World

show more

This example presents two agents that take turns in writing a "Hello world" message to the log.

The used code is located in package: org.jage.examples.helloworld.

The configuration file is located in: examples/helloworld/age.xml. (You can see a description of it on the page Sample XML configuration.)

The Eclipse launch file is located in: config/helloworld.launch.

  • Strategies

show more

This example shows how to use strategies.

The used code is located in package: org.jage.examples.strategy.

The configuration file is located in: examples/strategy/age.xml.

The Eclipse launch file is located in: config/strategy.launch.

Behavior

The example defines three agents of the same class. Each of them uses a completely different implementation of the echo strategy to perform its task. Three different strategies are actively used:

  1. The simple counting strategy, that keeps a count of all calls.
  2. The counting strategy that increases a counter by a specified value.
  3. The strategy that simply writes "ABC" to the output.
  • Simple strategy delegation

show more

This example shows how an agent can obtain a strategy dynamically during runtime assuming it is visible in terms described in the page HierarchiaKontenerow. This pattern can be used as simple way to reconfigure agent behavior in the execution time.

The used code is located in package: org.jage.examples.delegation.

The configuration file is located in: examples/delegation/age.xml.

The Eclipse launch file is located in: config/delegation.launch.

Behavior

During initialization a simple agent (class DelegationSimpleLeaf) located in a leaf of the agent hierarchy obtains a name (as a string) of a strategy IEchoStrategy from its parent (class DelegationSimpleAggregate). After that it requests an implementation with this name from the instance provider. The strategy is located directly in the parent container. Then, when performing its actions, it executes this concrete implementation of the strategy.

  • Configuration

show more

Configuration examples shows how to use some of mechanisms provided by jAgE for configuring the system.

Currently available examples:

  • Usage of array
  • Usage of collections

The used code is located in the package: org.jage.examples.configuration.

Configuration files are located in examples/configuration/ directory.

Eclipse launch files are located in config/ directory and starts with configuration- prefix.

Arrays

The configuration file name: age-array.xml.

The Eclipse launch file name: configuration-array.launch.

Behavior

There is one agent configured with two sample arrays: object-array and long-array that contain respectively: three instances of ExampleClass and three instances of longs. The agent obtains both of them during initialization and prints their content to the log.

Collections

The configuration file name: age-collections.xml.

The Eclipse launch file name: configuration-collections.launch.

Behavior

There are two agents:

  • ListAgent is configured with two sample lists: object-list and long-list. They contain respectively: three instances of ExampleClass and three instances of longs.
  • MapAgent uses two maps: object-map and long-map. Both of maps map strings to instances of ExampleClass or instances of longs.

Agents receive both of them by auto-wiring and again obtains them during initialization. Then they print their content to the log.

  • Multiworkplace

show more

It consists of two examples: isolated and non-isolated. The former shows the behavior of agents in the isolated workplace (IsolatedSimpleWorkplace class) and the latter - their behavior during identical actions in a connected (aware of the existence of other workplaces) workplace.

The used code is located in the package: org.jage.examples.multiworkplace.

Configuration files are located in examples/multiworkplace/ directory.

Eclipse launch files are located in config/ directory and starts with multiworkplace- prefix.

  • Distribution and communication

show more

These examples shows AgE capabilities in the domain of distribution and remote (node-node) communication.

The used code is located in package: org.jage.examples.distribution.

Configuration files are located in: examples/distribution/.

These examples do not provide Eclipse launch files because they usually require starting of more than one JVM. You can start them using following commands:

mvn exec:java -Pdistributed -DskipTests
mvn exec:java -Pexamples -DskipTests -Dage.computation.conf=classpath:examples/distributed/age-distributed-computation.xml
  • Monitoring

show more

 TODO