swarm
play

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


  1. 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 environment designed for multi-agent simulation. applications: simulated virtual creatures, artificial ecosystems, simulations of • Allows users to define the behaviors of autonomous agents in a continuous 3D molecular biology, visualization and much world, then observe how they interact. more. • Includes support for a rich visualization • Facilitates the construction of complex engine, realistic physical simulation and agent-based simulations by automatically an easy-to-use scripting language. handling agent communication, • Used as a tool to explore any type of representation in 3D space, graphical simulated world. rendering, physical simulation and a number of other features which are useful to agent-based simulations. 3 4 The Origin of Breve Multi-Agent Simulation • The term agent refers to any object in a • Initiated by Jon Klein as a thesis simulated world, but in particular, an object project at Hampshire College and with autonomous behaviors which interacts was developed further into a with its environment and other agents. Master's thesis at Chalmers • A multi-agent simulation is a simulation in which multiple agents exist and interact in the University simulated world. • Platform for a project building • An example of a multi-agent simulation is an large scale simulations of ecosystem simulation: a large number of autonomous agents (animals) interacting with evolutionary dynamics each other (eating and breeding) and the environment. 5 6

  2. Physical Simulation 3D Spatial Simulation • breve is capable of realistic physical • breve simulates 3D physical space and simulation . that simulated agents occupy and interact • Agents in the simulated world can be in this physical space. configured to behave just as real • Used for realistic simulations involving objects do, according to the laws of space, such as physical simulations. physics. • Contrast to simulation environments • Used for realistic simulation of robots, which model space in 2D or which treat vehicles and animals. "space" only as an abstract concept. 7 8 Installation on Unix(Linux) and Install and Run breve on Mac OS X Windows • Install OpenGL and GLUT libraries • Simply drag the application – Put the glut32.dll to your windows/system/ directory • Setting Up Your Environment - BREVE_CLASS_PATH (breve.app) into your /Applications – # tcsh users (Linux & OSX): setenv BREVE_CLASS_PATH / <path to breve> /lib/classes folder (or to any other folder where – # bash users (Linux & OSX): you wish to put the program). export BREVE_CLASS_PATH=/ <path to breve> /lib/classes – # Windows console users: SET BREVE_CLASS_PATH=C:\ <path to • To get started with breve, simply breve> \LIB\CLASSES double-click the breve application. – <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 9 10 Running on Unix(Linux) and Controls of simulation Windows • Space bar: pause/resume the simulation • Running the Demo Simulations • F1: run simulation forward one iteration step • Left mouse: rotate simulation and select objects – # Linux & OSX % ./bin/breve • Right mouse click: display the simulation menu ./demos/Swarm/ArrowSwarm.tz • Right mouse click (when an object is selected): – # Windows display a contextual menu for the object • Control (or F2) + left mouse: zoom in and out of > bin\breve.exe the simulation demos\Swarm\ArrowSwarm.tz • 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 11 12

  3. “steve" Language Reference Building Classes • Defining Classes • Simulations in breve are written using a – superClass:subclass {} language called "steve" – # first without the alias... Mobile : myMobile { } – # now with the alias... Mobile : myMobile (aka • steve aims to allow rapid construction of myMobiles) { } advanced simulations • Defining Instance Variables – variable_name ( variable_type ) • "steve" is an object-oriented language – Mobile : myMobile { + variables: myInt, myOtherInt (int). myObject (object). myFloat (float). } • Objects can be either real , meaning they • Defining Methods have a presence in the simulated world; – + to methodName : or abstract • Creating and Destroying Instances – new object_type. number new object_type. – free instance. 13 14 Defining Basic Agents A Simple Mobile Agent • To create a simple agent in breve, you'll Mobile : Bird { need to subclass one of the basic agent classes, all subclasses of Real + variables: • Stationary, an immobile object in the myShape (object). simulated world. + to init: • Mobile, an object which moves around the myShape = (new Cube init-with size (1, 1, 1)). simulated world. self set-shape to myShape. • Link, a physically simulated mobile object. + to iterate: } 15 16 Moving Agents Around the 3D Change Appearance of Agents World • Shape • # move the agent to the location (10, 0, 0) in 3D space... – init-with-cube – init-with-polygon-cone – self move to (10, 0, 0). – init-with-polygon-disk • # set the agent's velocity to (0, 0, 10) – init-with-sphere – self set-velocity to (0, 0, 10). • Color • # set the agent's acceleration to (0, - 9.8, 0) – self set-color to (0.0, 1.0, 0.0). – self set-acceleration to (0, -9.8, 0). 17 18

  4. Scheduling Events for a Specific Hello world Time • # call a method after the simulation @include "Control.tz" clock hits 100.0... – self schedule method-call "sing-and- Controller HelloWorld. dance" at-time 100.0. • # call a method 100.0 seconds from Control : HelloWorld { now... + to iterate: – self schedule method-call "sing-and- print "Hello, world!". dance" at-time ((controller get-time) + } 100.0). 19 20 Randomwalk Controller Object @use Control. @use Mobile. • Foundation of a breve simulation - first Controller myControl. Control : myControl { step in writing a breve + variables: • "boss" for the simulation--create and set walkerShape (object). + to init: up the rest of the simulation. print "Setting up the simulation.". self point-camera at (0, 0, 0) from (0, 60, 0). • The only object which is automatically walkerShape = (new Sphere init-with radius 1). instantiated when the simulation begins 200 new RandomWalker. + to get-walker-shape: • Like the main function in C or C++ return walkerShape. } • Must be a subclass of the class Control or Mobile : RandomWalker { + to init: one of its subclasses. self set-shape to (controller get-walker-shape). self set-color to random[(1.0, 1.0, 1.0)]. + to iterate: 21 22 self set-velocity to random[(60, 60, 60)] - (30, 30, 30). } Interactions Between Agents Origin of Swarm • Speak to controller object • Started in 1994 by Chris Langton, • Agents collide at Santa Fe Institute (SFI)in New – handle-collisions method in Real.tz Mexico • Finding Neighboring Objects 1. Set each agent's "neighborhood size". • The aim was to develop both a 2. Ask the engine to update the neighbors at each iteration. vocabulary and a set of standard 3. Retrieve each agents list of neighbors at each timestep. computer tools for the development • Finding the Closest Object – possible that the closest object is not within an object's of multi-agent simulation models neighborhood • Finding All Objects of a Given Type – using the "all" expression – myMobile = all Mobiles 23 24

  5. Introduction To Swarm Agent-based Modeling • Swarm Code is Object-Oriented • Swarm Programs are Hierarchical • Swarm Provides Many Handy Tools http://lark.cc.ku.edu/~pauljohn/Swarm/Beta/SwarmUserGuide 25 26 /swarm.user.user1.02.chapter.html Object in Swarm Merging Schedule • 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 This multi-level array, a pointer, and so forth. integration of swarm schedules means that – Of type id -- be instances of classes the model can indeed • Methods. be thought of as a – Methods determine what the object can do nested hierarchy of models. – Receive information from the "outside world" – Send messages to the outside – Process information http://lark.cc.ku.edu/~pauljohn/Swarm/Beta/SwarmUser Guide/swarm.user.user1.04-schedule.sect1.html 27 28 Element of Swarm GUI A Swarm as a Virtual Computer Line graph (time series) Histogram Raster http://lark.cc.ku.edu/~pauljohn/Swarm/Beta/SwarmU serGuide/swarm.user.user1.04-schedule.sect1.html http://lark.cc.ku.edu/~pauljohn/Swarm/Beta/SwarmUser 29 30 Guide/swarm.user.user1.05.chapter.html

Recommend


More recommend