Swarm MPM Simulation Tools -- Breve and Swarm Anguo Dong Computer - - PDF document

swarm
SMART_READER_LITE
LIVE PREVIEW

Swarm MPM Simulation Tools -- Breve and Swarm Anguo Dong Computer - - PDF document

Swarm MPM Simulation Tools -- Breve and Swarm Anguo Dong Computer Science Department University of Calgary donga@cpsc.ucalgary.ca 1 2 What is Breve (I) What is Breve (II) Used for a wide variety of simulation A free simulation


slide-1
SLIDE 1

1

MPM Simulation Tools -- Breve and Swarm

Anguo Dong Computer Science Department University of Calgary donga@cpsc.ucalgary.ca

2

Swarm

3

What is Breve (I)

  • A free simulation environment designed

for multi-agent simulation.

  • Allows users to define the behaviors of

autonomous agents in a continuous 3D world, then observe how they interact.

  • Includes support for a rich visualization

engine, realistic physical simulation and an easy-to-use scripting language.

  • Used as a tool to explore any type of

simulated world.

4

What is Breve (II)

  • Used for a wide variety of simulation

applications: simulated virtual creatures, artificial ecosystems, simulations of molecular biology, visualization and much more.

  • Facilitates the construction of complex

agent-based simulations by automatically handling agent communication, representation in 3D space, graphical rendering, physical simulation and a number of other features which are useful to agent-based simulations.

5

The Origin of Breve

  • Initiated by Jon Klein as a thesis

project at Hampshire College and was developed further into a Master's thesis at Chalmers University

  • Platform for a project building

large scale simulations of evolutionary dynamics

6

Multi-Agent Simulation

  • The term agent refers to any object in a

simulated world, but in particular, an object with autonomous behaviors which interacts with its environment and other agents.

  • A multi-agent simulation is a simulation in

which multiple agents exist and interact in the simulated world.

  • An example of a multi-agent simulation is an

ecosystem simulation: a large number of autonomous agents (animals) interacting with each other (eating and breeding) and the environment.

slide-2
SLIDE 2

7

Physical Simulation

  • breve is capable of realistic physical

simulation.

  • Agents in the simulated world can be

configured to behave just as real

  • bjects do, according to the laws of

physics.

  • Used for realistic simulation of robots,

vehicles and animals.

8

3D Spatial Simulation

  • breve simulates 3D physical space and

that simulated agents occupy and interact in this physical space.

  • Used for realistic simulations involving

space, such as physical simulations.

  • Contrast to simulation environments

which model space in 2D or which treat "space" only as an abstract concept.

9

Install and Run breve on Mac OS X

  • Simply drag the application

(breve.app) into your /Applications folder (or to any other folder where you wish to put the program).

  • To get started with breve, simply

double-click the breve application.

10

Installation on Unix(Linux) and Windows

  • Install OpenGL and GLUT libraries

– Put the glut32.dll to your windows/system/ directory

  • Setting Up Your Environment - BREVE_CLASS_PATH

– # tcsh users (Linux & OSX): setenv BREVE_CLASS_PATH /<path to breve>/lib/classes – # bash users (Linux & OSX): export BREVE_CLASS_PATH=/<path to breve>/lib/classes – # Windows console users: SET BREVE_CLASS_PATH=C:\<path to breve>\LIB\CLASSES – <path to breve> -- location of the breve distribution folder that you downloaded

  • For this machine

– C:\WINDOWS\system\glut32.dll – In AUTOEXEC.BAT SET BREVE_CLASS_PATH=D:\Anguo\Courses\CPSC607\MBM- tool\breve\breve_2.1\lib\classes

11

Running on Unix(Linux) and Windows

  • Running the Demo Simulations

– # Linux & OSX % ./bin/breve ./demos/Swarm/ArrowSwarm.tz – # Windows

> bin\breve.exe demos\Swarm\ArrowSwarm.tz

12

Controls of simulation

  • Space bar: pause/resume the simulation
  • F1: run simulation forward one iteration step
  • Left mouse: rotate simulation and select objects
  • Right mouse click: display the simulation menu
  • Right mouse click (when an object is selected):

display a contextual menu for the object

  • Control (or F2) + left mouse: zoom in and out of

the simulation

  • Alt (or F3) + left mouse: move the camera
  • Shift (or F4) + left mouse: select and drag objects

in the simulation

  • Escape: to quit the simulation, or access the breve

command prompt

slide-3
SLIDE 3

13

“steve" Language Reference

  • Simulations in breve are written using a

language called "steve"

  • steve aims to allow rapid construction of

advanced simulations

  • "steve" is an object-oriented language
  • Objects can be either real, meaning they

have a presence in the simulated world;

  • r abstract

14

Building Classes

  • Defining Classes

– superClass:subclass {} – # first without the alias... Mobile : myMobile { } – # now with the alias... Mobile : myMobile (aka myMobiles) { }

  • Defining Instance Variables

– variable_name (variable_type) – Mobile : myMobile { + variables: myInt, myOtherInt (int). myObject (object). myFloat (float). }

  • Defining Methods

– + to methodName:

  • Creating and Destroying Instances

– new object_type. number new object_type. – free instance.

15

Defining Basic Agents

  • To create a simple agent in breve, you'll

need to subclass one of the basic agent classes, all subclasses of Real

  • Stationary, an immobile object in the

simulated world.

  • Mobile, an object which moves around the

simulated world.

  • Link, a physically simulated mobile object.

16

A Simple Mobile Agent

Mobile : Bird {

+ variables: myShape (object). + to init: myShape = (new Cube init-with size (1, 1, 1)). self set-shape to myShape. + to iterate: }

17

Change Appearance of Agents

  • Shape

– init-with-cube – init-with-polygon-cone – init-with-polygon-disk – init-with-sphere

  • Color

– self set-color to (0.0, 1.0, 0.0).

18

Moving Agents Around the 3D World

  • # move the agent to the location (10,

0, 0) in 3D space...

– self move to (10, 0, 0).

  • # set the agent's velocity to (0, 0, 10)

– self set-velocity to (0, 0, 10).

  • # set the agent's acceleration to (0, -

9.8, 0)

– self set-acceleration to (0, -9.8, 0).

slide-4
SLIDE 4

19

Scheduling Events for a Specific Time

  • # call a method after the simulation

clock hits 100.0...

– self schedule method-call "sing-and- dance" at-time 100.0.

  • # call a method 100.0 seconds from

now...

– self schedule method-call "sing-and- dance" at-time ((controller get-time) + 100.0).

20

Hello world

@include "Control.tz" Controller HelloWorld. Control : HelloWorld { + to iterate: print "Hello, world!". }

21

Randomwalk

@use Control. @use Mobile. Controller myControl. Control : myControl { + variables: walkerShape (object). + to init: print "Setting up the simulation.". self point-camera at (0, 0, 0) from (0, 60, 0). walkerShape = (new Sphere init-with radius 1). 200 new RandomWalker. + to get-walker-shape: return walkerShape. } Mobile : RandomWalker { + to init: self set-shape to (controller get-walker-shape). self set-color to random[(1.0, 1.0, 1.0)]. + to iterate: self set-velocity to random[(60, 60, 60)] - (30, 30, 30). }

22

Controller Object

  • Foundation of a breve simulation - first

step in writing a breve

  • "boss" for the simulation--create and set

up the rest of the simulation.

  • The only object which is automatically

instantiated when the simulation begins

  • Like the main function in C or C++
  • Must be a subclass of the class Control or
  • ne of its subclasses.

23

Interactions Between Agents

  • Speak to controller object
  • Agents collide

– handle-collisions method in Real.tz

  • Finding Neighboring Objects

1. Set each agent's "neighborhood size". 2. Ask the engine to update the neighbors at each iteration. 3. Retrieve each agents list of neighbors at each timestep.

  • Finding the Closest Object

– possible that the closest object is not within an object's neighborhood

  • Finding All Objects of a Given Type

– using the "all" expression – myMobile = all Mobiles

24

Origin of Swarm

  • Started in 1994 by Chris Langton,

at Santa Fe Institute (SFI)in New Mexico

  • The aim was to develop both a

vocabulary and a set of standard computer tools for the development

  • f multi-agent simulation models
slide-5
SLIDE 5

25

Introduction To Swarm

  • Swarm Code is Object-Oriented
  • Swarm Programs are Hierarchical
  • Swarm Provides Many Handy

Tools

26

Agent-based Modeling

http://lark.cc.ku.edu/~pauljohn/Swarm/Beta/SwarmUserGuide /swarm.user.user1.02.chapter.html

27

Object in Swarm

  • Variables.

– "state" of the agent--its age, wealth, its ability, and so forth. – Of any type that is allowed in C, such as integer (int), floating-point number (float), an array, a pointer, and so forth. – Of type id -- be instances of classes

  • Methods.

– Methods determine what the object can do – Receive information from the "outside world" – Send messages to the outside – Process information

28

Merging Schedule

http://lark.cc.ku.edu/~pauljohn/Swarm/Beta/SwarmUser Guide/swarm.user.user1.04-schedule.sect1.html This multi-level integration of swarm schedules means that the model can indeed be thought of as a nested hierarchy of models.

29

A Swarm as a Virtual Computer

http://lark.cc.ku.edu/~pauljohn/Swarm/Beta/SwarmU serGuide/swarm.user.user1.04-schedule.sect1.html

30

Element of Swarm GUI

http://lark.cc.ku.edu/~pauljohn/Swarm/Beta/SwarmUser Guide/swarm.user.user1.05.chapter.html Line graph (time series) Histogram Raster

slide-6
SLIDE 6

31

Install and Run Swarm

  • GNU/Linux binaries
  • MacOS X 10.3 binaries
  • Swarm Windows binaries

– Distributed as an executable file that installed Cygwin and Swarm on your computer – Swarm works within the Unix-like environment provided by Cygwin – With latest Version 2.2, including Swarm as a package within a special Cygwin distribution.

32

Uninstall Swarm and Cygwin

  • Cygwin does not come with an

uninstaller

  • Must be manually uninstalled.

– Delete all its files manually – Manually remove any entries related to Cygwin in the Windows registry (via the command-line program "regedit")

  • Big size – 115mb

33

Resources

  • http://www.spiderland.org
  • http://www.santafe.edu/
  • http://www.swarm.org/index.html
  • http://lark.cc.ku.edu/~pauljohn/Swarm

/Beta/SwarmUserGuide/userbook.ht ml

  • Braitenberg Vehicles tutorial -- as a

quick way to get started with a fun simulation in breve