Simulation Environment for the JavaScript Agent Machine

Introduction

The design and technological implementation of smart adaptive materials is a challenge. Fundamental concepts has to be proven before any real system can br developed. Due to the strong coupling of sensing, reactive control, and information processing a multi-domain and multi-scale simulation has to be performed.

Combining physical world with MAS simulation is a challenge. Such a multi-domain simulation enables the direct derivation of sensor data from a physical model (sensing part) provision to a computational system, and the investigation of the action of this computational system on the physical system (actuating part). The goal of this multi-domain simulation is to investigate the behaviour of MAS on dynamic (or semi-static) changes of mechanical structures and vice versa.

The physical world consists of the mechanical structure given by a physical model (FEM or mass-spring multi-body), sensors, and external loading having impact on the static and dynamic reaction of the structure, including gravity. For the sake of simplicity, the mechanical structure under test is modelled with a mass-spring multi-body system. The multi-body physics simulation is well known from computer games and animations. It can be easily and efficiently integrated in computational systems like MAS simulators.

To this end, the SEJAM simulator (JAM platform + GUI + simulation control) was extended with a modified physics engine (based on Cannon.js and Three.js) enabling the direct coupling of the physical model with the computation of agents. The JAM platform and the SEJAM simulator are entirely implemented in JavaScript, executed with the Node Webkit (node.js+Chromium HTML browser).

A simulation model consists basically of three parts:

  1. The MAS behaviour models;
  2. The JAM virtual network world;
  3. The phyiscal model.

All parts are specified in JavaScript.

In this environment, the physical model can be accessed by all agents. A distributed MAS simulation consists of node and worker agents executed on different virtual JAM nodes. There is commonly one artificial agent (world agent) representing the world and managing the simulation, i.e., generating and updating sensor data accessed by the node and worker agents by using the unified tuple-space interface. The world agent can read and modify physical simulation variables, i.e., reading strain, force parameters, and setting material/structure properties (e.g., stiffness).

SEJAM2 Architecture

sejam-arch

Simulation Model

The simulation model is specified in JSON+ format (JSON + function code) and is used to provide definitions of agent classes, the simulations world, nodes, composition of networks with nodes, initialization and initial instantiation of agents, and optionally physical multi-body physics models.

Agent classes can be embedded in the simulation or can be imported from external files by using the open statement. Each behavioural agent class is associated with a visual definition.

The following definitions give the basic structure of a simulation model and the semantic type interface.

Definition. SeJAM Simulation Model Template

simulation : model = {
  // Physical MBP model
  physics : { plate : {..}},
  // Computation and Communication: Agent behaviour Classes
  classes: {
    node :   { behaviour: function () {..}, visiual:{..} },
    ac1 : { behaviour: function () {..}, visiual:{..} },
    ac2 : { behaviour: function () {..}, visiual:{..} },
    ..
    world :  { behaviour: function () {..}, visiual:{..} },
  },
  // Global simulation parameters used by agent and physical simu.
  parameter : {
    p1 : v1,
    p2 : v2,
    ..
  },
  // Simulation set-up and initialization
  world: { ..
    init : { agents: {..}, physics: {..}},
    meshgrid : { node:{..}, port = {..},
    link:{..} .. } } // Network model
  }

Definition. Semantic Type Model

type model = {
    name?      : string,
    agents     : model.classes,
    resources? : model.resource,
    patches?   : model.resource,
    parameter? : model.parameter,
    world : model.world,
    physics? : physics,
}
type model.classes = model.agents = {
    $ac: {
      behaviour: agent constructor function | open(file),
      visual : visual,
      type? : 'computational'|'phyiscal'
      on?: { $event : visual },
    }
}
type model.world = {
    init? : {
        agents? : { 
          $ac : function (nodeid:string,position) -> 
                {level:number,args:[]|{}|null}  
        },
        nodes? : function (node),
        resources? : function (resource),
        patches? : function (resource),
        world? : {},
        physics? : function (physics),
    },
    start?: function (env),
    stop? : function (env),
    data? : {},
    nodes? : function () -> simobj [],
    resources? : function () -> simobj [],
    meshgrid? : meshgrid,
    patchgrid? : patchgrid,
}

A simulation world consists of agent processing nodes (logical/virtual JAM nodes) and some communication links between nodes enabling migration of agents and propagation of signals between nodes. Nodes are placed in a two-dimensional spatial simulation world, and each node has a distinct position.

There are computational and physical agents. The latter represent physical entities (although virtual in the simulation) like, e.g., humans, ants, cars. The default agent type is computational and agents represent mobile software.

A meshgrid network arranges nodes in a two-dimensional grid (that can be irregular and incomplete).

A patchgrid network is similar to a NetLogo simulation world. There are two different patchgrid models: Fixed and floating. In the fixed model a patch grid arranges nodes in a two-dimensional grid, too, but with an implicit global virtual communication link that enables migration of phyiscal agents between any of the nodes in the grid. Migration of computational agents (default) and propagation of message signals still require explicit links between nodes. In the floating model a physical agent is associated with a mobile tuple (logical node,behavioural agent).

Communication ports and links have either (static or dynamic) point-to-point or broad/multicast characteristics, i.e., nodes within a specific spatial range can communicate with each other (computational agents).

Nodes (except in mesh- and fixed patch grid worlds) can be moved within the two-dimensional world carrying their agents.

Example

SEJAM2 Multi-window GUI

sejam-ex

Download

SEJAM2
SeJAM application package (platform independent) not including required node webkit (nw.js), Version 1.6.7
At least nw-js versions 0.13.4 is required.
The simulator is started by changing in the sejam2 top-level directory and executing nw.js ./.
ZIP