Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

AMP/UserGuide/Escape

< AMP‎ | UserGuide
Revision as of 22:17, 14 December 2009 by Milesparker.gmail.com (Talk | contribs)

Overview

Escape is a full-featured Agent-Based Modeling (ABM) integrated development environment (IDE) with a Java based API and end user modeling tools. It's based on Ascape, which has been in use for more than 10 years. The core API is very stable, and that should give users a way to explore the features of AMP without concerns about keeping in synch with the rapidly evolving AXF /AGF API. It allows modelers to code in Java and/or generate models with AMF and then execute those models within the same development environment.

AMPScreenshot.png

A primary purpose of the Escape project -- apart from the obvious goal of providing a nice Eclipse hosted ABM toolkit -- is to provide an exemplar to demonstrate how any arbitrary agent modeling framework can be integrated within the AMP environment. A cool aspect of this is that AMP has no dependencies on Escape, but also that the underlying ABM modeling framework for Escape has no dependencies on AMP -- instead Escape simply provides the runtime glue between AMP and the ABM framework. The underlying ABM framework uses the Ascape API, an API that first began development more than ten years ago and that has not been modified at all in order for it to work within the AMP environment.

(Well, not quite.. Ascape was refactored into separate non-UI core and a Swing UI projects. This involved a bit of repackaging, but was really straightforward as Ascape follows a strict MVC architecture. Note that currently Escape is bulkier than it will eventually be -- over time we will be generalizing more aspects of Escape into the AMP AXF and AGF components.)

Getting Started

Documentation and other Resources

Because it's API is based on Ascape, Escape is one component of AMP that already has extensive documentation. There is complete Javadoc as well as a manual and other web resources. See the Ascape Website to locate these resources. The documentation on the main page is a good place to start. It's written for Ascape so ignore all of the bits about project setup, and a lot of the UI is different, but the basics apply to Escape just as well. The Ascape Manual written by Damon Centola should be very helpful. Take a look at the conversion link below for ideas on how to make the models form the manual work under Ascape. (Converting these models is a great opportunity for a community contribution!)

Installation

Escape is installed by default with the other model components. If you want to do 3D (really 2 1/2) visualizations, you will want AGF3D and the LWJGL dependency. You can build from source but in that case you'l need to launch a self-hosted runtime, so it's best to simply install from the update site if you're not actually doing AMP development.


Exploring Example ABM Models

The first thing most people will want to do in AMP is to play with the example models. You don't need to do any programming for this, and the setup is really straightforward. Of course, the first think you'll need to do is Install AMP. (You don't need any of the optional components unless you want to play with the 3D visualizations, Ascape, or Repast.) You can explore AMF models as well as some really interesting classic ABM models.

AMF Models

There are a number of models developed with AMF that can automatically generate example models to run in Escape. There are two ways to run the example models:

Setup Escape Projects

Creating a New Escape Project

The best option is to simply create a new Escape project and drag the models into it! We're working on a simple cheat sheet for this, but until then, just follow these simple steps:

  1. If you're not already there, open the Agent Modeling Perspective. Select Window > Open Perspective > Other.. and then Agent Modeling. (Or you can choose Window > Reset Perspective and the Agent Modeling perspective should appear in the Open Perspective list itself.)
  2. Next, let's create the project where we'll place our model. Select File > New > Escape AMF Project. Give it a name like "escape.tutorial", then click Finish.
  3. Finally grab the Epidemic.metaabm model at http://download.eclipse.org/amp/models/Epidemic.metaabm and drag it into the project. (Depending on your browser the file may load as text directly into your browser, in which case just right-click on the link and save it to a file.)
Using an Pre-Built Example Project

If you get really stuck somewhere, you can also get ready made projects from CVS. See this page for information on CVS setup. The project for Escape example models are located at:

org.eclipse.amp/org.eclipse.amp.amf/examples/org.eclipse.amp.amf.examples.escape

Run the Model

Right-click on the model, and select "Execute"! You should see something like this:

EpidemicModelRunning.png

We're working on more end-user documentaiton, but hopefully you'll find model control pretty self-explanatory. The toolbar buttons allow you to control model execution.

EpidemicModelControls.png

From right to left, you can start, restart, pause, step, stop and close a model. You can even run multiple models and control them independently. You can also move views around, close them and so on as with any other Eclipse views. Here we're running two separate models for comparison.

EpidemicModelComparison.png

If you want to find out more about an agent, show the properties view, and click on agent.

EpidemicModelAgentProperties.png

You can experiment with different parameters (settings) for models by then clicking in the gray area away within the view.

EpidemicModelProperties.png

There are a number of other things to play around with, such as zooming the agent view or selecting other chart series to display using the Chart Customizer, so just explore. You can always close an active model by clicking on the close toolbar button. Or if you can't access the models controls for some reason, you can open the progress view and close projects form there.

Next Steps

Other models are located at: (to do)

To understand the capabilities of AMF, you might also want to try out running the same models automatically generated for Ascape or Repast.

org.eclipse.amp/org.eclipse.amp.amf/examples/org.eclipse.amp.amf.examples.ascape
org.eclipse.amp/org.eclipse.amp.amf/examples/org.eclipse.amp.amf.examples.repast

Classic Java ABM Models

Many models have been created using Ascape over the years, including all of the classic models created at Brookings and some other cool models such as Craig Reynold's Boids and a pretty cool little traffic model, and they've all been converted to run in Escape. They're in Java but you can execute and explore them in exactly the same way as the Epidemic model above. All of the Ascape example models have been converted (a straightforward process) from their intial Ascape incarnations. For licensing reasons (they're BSD, not EPL) we can't host them directly on the Eclipse site. You can get the projects in two ways:

From Project Archive

From SVN

  • Import the SVN projects from the sourceforge SVN. For help, see [this page].
http://ascape.svn.sourceforge.net/svnroot/ascape/org.ascape.escape.models.brook
http://ascape.svn.sourceforge.net/svnroot/ascape/org.ascape.escape.models.examples

Once you've downloaded the projects, open up the src folder and navigate to the Java files for the actual models. For example, to run Conway's Life, you'll want src/edu.brook.life.ConwayLife. Right-click on the Java file and select "Execute". There are many models to explore! More information on running models can be found here: AMP/Running_Examples Running Examples. (It's not always obvious which Java files are for models, so you may have to poke around a bit. We need to put together a catalog here. Another nice opportunity for user contributions.)

Developing Models

The easiest way for Java developers to get started doing agent-based modeling in Eclipse is to begin to write programs using it.To develop new models, you can:

  1. Create a new Escape project. The Escape projects are actually configured for AMF code generation so there are dependencies and builders in there that you don't need; you can remove all of the escape builders and any of the kitchen sink items. We'll try to get a POJO Escape project wizard out there at some point.
  2. But it might be simpler to just create a new Plugin Project and add the necessary dependencies there. Have a look at the example escape project to see what you need. Note that you will likely need more dependencies then you need to simply build -- this is because the class loader uses the classes from the project path and so runtime classes have to be there as well. We may simply package an Eclipse runtime convenience plugin to gather these dependencies up a bit.

Then just create new Java classes for your root model scape and agents just as you would for an Ascape project.

Reference

Converting Existing Ascape models

There are only a few changes should have to make to existing Ascape models or to use existing Ascape documentation to develop Escape models.

Model

The core model is completely API compatible. No changes!

View

Because Escape uses SWT and Ascape uses Swing, there are a few unavoidable incompatibilities. Most of these we avoid by using higher level APIs but here are the key changes that you're likely to have to make:

Convert the low-level imports from AWT and Swing to SWT

The simplest way to accomplish this is to remove all of the imports and then organize imports. For example:

java.awt.Color => org.eclipse.swt.graphics.Color
java.awt.Graphics => org.eclipse.draw2d.Graphics

Then just do a global find for all of the imports and replace them with nothing. This is a great place for a regexp. Try:

find: import java\.awt\.(.*);
replace: [nothing]

You don't have to replace these with the SWT equivalents, just click on the project, right-click and choose "Source:Organize Imports.." By the way, a great way to avoid having to select the right entries in optimize imports and to alert you when you have missed anything is to prevent the awt and swing classes from being used at all. Right-click on project, choose "Build Path:Configure Build Path", go to Libraries tab, open JRE System Library, choose "Access Rules", edit, and then add entries for java/awt/** and javax/swing/**. The code will regenerate and you'll have error markers for all of the stuff that won't work with Escape and Eclipse.

Convert color features

You can't use AWT colors either so you'll need to replace any colors. AMP provides a convenience classes for Colors called ColorFeature and ColorFeatureConcrete. You can use these or any of the other ways to define SWT colors. For example:

Color.lightGray => ColorFeature.LIGHT_GRAY
new Color(Math.min(1.0f, (float) (redEnergy + orangeEnergy)), (float) orangeEnergy * .8f, (float) blueEnergy) => 
    ColorFeatureConcrete.create(Math.min(1.0f, (float) (redEnergy + orangeEnergy)), (float) orangeEnergy * .8f, (float) blueEnergy)
Change agent color getters

If you've defined colors through overriding Agents as in most models, you'll need to change the method signature. You could just do a global replace for this one.

public Color getColor( => public Object getPlatformColor(
Get rid of image features

Escape doesn't support them. In practice they haven't been used a lot. At some point perhaps we'll have nice sprite support instead. :)

public Image getImage() {**} => ""
Modify usages of DrawFeatures

If you've created any of your own draw features, you'll need to change them slightly to accommodate the differences between the AWT and SWT / Draw2D APIs. This should be pretty straightforwrd. For example:

g.setColor(...
g.fillOval(..
becomes:
g.setBackgroundColor(
g.fillOval(..

That's about it, though it's probable that we've missed something. Please post a message on the amp newsgroup if you run into any other conversion issues.

Configuration

Instead of using Ant, Escape has really nice support for parameterizing and testing models. See Experimenting and Testing (todo). If you do want to work with ant you will need to install the plugins from the Sourceforge download site. (These have dependencies that I didn't want to bother with going through the Eclipse IP process to get in. If for some reason you think these should be part of core Escape let Miles know and I'll take care of it.) Ant has not been tested for Escape so it's not even clear it will work.

Current Limitations

  1. Escape is pretty robust, and the APIs are solid and well-tested but the runtime is not going to be as stable for a while as Ascape which has been around for a long time.
  2. Escape graphics performance is generally slower especially for charts. But on the other hand you can run multiple models at once and the headless models should perform just as well as console launched Ascape programs. In practice this shouldn't affect your normal model exploration work.
  3. We don't have the speed slider working yet. See [1]
  4. Charts only support time series, not histograms and pie. See [2]

Back to the top