blob: 727a6b7b4bc47791198563803ec4f056024327f9 [file] [log] [blame]
mparkera6840922010-04-28 17:51:29 +00001<?xml version="1.0" encoding="UTF-8"?><book>
2 <title>Agent Modeling Guide</title>
3 <chapter id="Introduction">
4 <title>Introduction</title>
5 <para>In this manual we provide an in-depth understanding of what goes into an Agent Model, how you can use the Agent Modeling Framework and related tools to design one and present tutorials to get you started. But before going into details, let's take a quick overview at what agent-based modeling is is and how the Agent Modeling Framework can help you to develop models for ABM or other problem domains.</para>
6 <para>We hope you enjoy using the tool, and we look forward to your comments and feedback and most of all participation!</para>
mparker8c858af2010-04-29 03:11:32 +00007 <section id="Quick_Start">
8 <title>Quick Start</title>
9 <para>If you're the kind of person who likes to jump right in, here are the basics.</para>
10 <section id="Install">
11 <title>Install</title>
12 <para>If you're using a complete IDE, or have already installed AMP from the Eclipse update sites, you can ignore this step. Otherwise, refer to the Installation Guide at the end of this manual.</para>
13 </section>
14 <section id="Welcome.21">
15 <title>Welcome!</title>
16 <para>When you first run the tools, you will see a welcome screen. If the screen isn't showing, select the
17 <emphasis role="bold">Help &gt; Welcome</emphasis> menu. Click on the "Overview", "Samples" or "Tutorials" buttons to begin your exploration.
18 </para>
19 </section>
20 <section id="Cheat.21">
21 <title>Cheat!</title>
22 <para>The Agent Modeling tools come with a number of "Cheat Sheets" to help get you started. You can access them by selecting
23 <emphasis role="bold">Help &gt; Cheat Sheets...</emphasis>. Then under the "Agent Modeling" category, select a cheat sheet, such as "Load Sample Projects".
24 </para>
25 </section>
26 <section id="Follow_the_Tutorial">
27 <title>Follow the Tutorial</title>
28 <para>The tools also come with extensive tutorials. See the "Tutorials" section for more help on that.</para>
29 </section>
30 <section id="Follow_your_Interest">
31 <title>Follow your Interest</title>
32 <para>AMP has many potential facets and use cases. Check out the following sections of the manual for more information about..</para>
33 <section id="ABM_Researchers">
34 <title>ABM Researchers</title>
35 <para>Run an example model using the "Run an Example Model" cheat sheet.</para>
36 </section>
37 <section id="ABM_Modelers">
38 <title>ABM Modelers</title>
39 <para>Create Agent-Based models using simple visual tools and deploy them to a number of popular ABM platforms, including Escape. Follow the tutorial section of the Modeler's guide.</para>
40 </section>
41 <section id="ABM_Java_Developers">
42 <title>ABM Java Developers</title>
43 <para>Write "Plain Old Java" models within a full-featured agent-based modeling framework. Read Programmers Guide and then try the "Create an Escape Java Model" cheat sheet.</para>
44 </section>
45 <section id="Eclipse_Plugin_Developers">
46 <title>Eclipse Plugin Developers</title>
47 <para>AXF and AGF provide a number of features based around Eclipse technologies such as GEF, GEF3D, BIRT Charts and Zest. For example, AGF supports dynamic visualization of objects in space, and AXF supports managed UI and headless execution for models of any kind. There isn't currently any general documentation for these features, but we encourage you to look at the APIs and at Escape's implementation of them. They're straightforward and can be useful for a variety of general science platform needs.</para>
48 </section>
49 </section>
50 </section>
mparkera6840922010-04-28 17:51:29 +000051 <section id="Agent-Based_Modeling">
52 <title>Agent-Based Modeling</title>
53 <para>The primary focus of the Agent Modeling Platform tools is "Agent-Based Modeling" (ABM). ABM is an innovative technique used to explore complex phenomenon in many domains, including economics, social sciences, biomedicine, ecology and business operations. ABMs share characteristics with object models, but are:</para>
54 <variablelist>
55 <varlistentry>
56 <term>Spatial</term>
57 <listitem>
58 <para>Models have explicit environment(s) in which agents interact. (An environment need not be a physical landscape; other examples of spatial relationships include social networks or positions within a logic system.)</para>
59 </listitem>
60 </varlistentry>
61 <varlistentry>
62 <term>Temporal</term>
63 <listitem>
64 <para>Models change over discrete units of time.</para>
65 </listitem>
66 </varlistentry>
67 <varlistentry>
68 <term>Autonomous</term>
69 <listitem>
70 <para>Agent behaviors are activated independently from other object requests.</para>
71 </listitem>
72 </varlistentry>
73 <varlistentry>
74 <term>Heterogeneous</term>
75 <listitem>
76 <para>Agents may share behavior definitions but have apparent and distinct states and behaviors.</para>
77 </listitem>
78 </varlistentry>
79 <varlistentry>
80 <term>Collective</term>
81 <listitem>
82 <para>Models contain large communities of agents which exhibit collaborative and competitive behaviors.</para>
83 </listitem>
84 </varlistentry>
85 <varlistentry>
86 <term>Emergent</term>
87 <listitem>
88 <para>Agents have collective macro-behaviors that are non-obvious from agent micro-specifications.</para>
89 </listitem>
90 </varlistentry>
91 </variablelist>
92 <para>Existing scientific models are very good at representing relatively simple systems, but generally speaking aren't very good at representing complex systems. The world is full of complex systems, and our misunderstanding of these systems has prevented us from addressing many of the key challenges facing the world, including the global financial crisis and climate change -- in fact once could argue that our misunderstanding of these systems has strongly contributed to these crises.</para>
93 <para>Agent-Based Models (ABMs) seek to represent important real-world dynamics by designing communities of software agents that mimic real entities. Rather than make simplifying assumptions about such systems and then representing them in equation form or as off the shelf algorithmic constructs, the ABM researcher aims to identify key agent state, interaction spaces, and behaviors. Agents are then "let loose" on our computers and we explore what happens next. The computational horsepower exists today to simulate large numbers (e.g. &gt;&gt;10) of interacting, adaptive and autonomous agents but often desktop computers are all we need to explore significant domains. ABMs have been designed to represent all kinds of important natural systems, at scales reaching from cellular mechanics to international trade and are being used to solve truly hard problems in government, business, and academia. ABMs are not a solution to every problem, but they can help us to appreciate and gain unique insight into many systems, and often they can help us to come up with better practical decisions than we might using classic approaches.</para>
94 </section>
mparker8c858af2010-04-29 03:11:32 +000095 <section id="Other_Domains">
96 <title>Other Domains</title>
mparkera6840922010-04-28 17:51:29 +000097 <para>Many kinds of objects share characteristics of ABM agents -- after all, software agents are used in many other contexts. The Agent Modeling Framework meta-modeling support is potentially suitable (or extendible) for a number of approaches outside of ABM; for example business rules, object interactions, systems dynamics models and traditional discrete event models. Similarly, AMP execution and graphic support can be used for modeling natural systems but could also be used to manage other software agents -- for example independent reasoning tasks or dynamic visualization support.</para>
98 </section>
mparkera6840922010-04-28 17:51:29 +000099 <section id="The_Agent_Modeling_Platform_.28AMP.29">
100 <title>The Agent Modeling Platform (AMP)</title>
mparker8c858af2010-04-29 03:11:32 +0000101 <para>The Eclipse Agent Modeling Project (Incubation) or "AMP" provides the core support for both open source and commercial modeling tools. AMP in turn is built upon Elipse, the most powerful, well-supported and popular Integrated Development Platform (IDE) available anywhere.</para>
102 <para>AMP provides extensible frameworks and exemplary tools for representing, editing, generating, executing and visualizing ABMs and any other domain requiring spatial, behavioral and functional features. AMP has two main themes that complement but don't depend on one another, modeling of agent systems (AMF) and execution and exploration of those systems (AXF, AGF and Escape).</para>
mparkera6840922010-04-28 17:51:29 +0000103 <para>The overall AMP architecture and project dependencies are summarized in the architectural diagram below:</para>
104 <para>
105 <mediaobject>
106 <imageobject>
107 <imagedata fileref="images/AMPArchitectureDiagram.jpg" scale="50"/>
108 </imageobject>
109 </mediaobject>
110 </para>
111 <section id="Agent_Modeling_Framework_.28AMF.29">
112 <title>Agent Modeling Framework (AMF)</title>
113 <para>AMF provides an ABM meta-model representation, editor, generator and development environment. The AMF Acore meta-model is similar to EMF Ecore and defined in Ecore, but provides high-level support for complex agents.AMF generates complete executable models for Escape, Ascape and Repast Simphony, as well as Java Skeletons and Interfaces, JUnit test cases and documentation and is easily extensible to support additional targets. For more on AMF, see the Modeler Guide.</para>
114 </section>
115 <section id="Agent_Execution_Framework_.28AXF.29">
116 <title>Agent Execution Framework (AXF)</title>
117 <para>The execution framework provides services and UI for model management, execution, and views. Arbitrary toolkits can easily integrate with Eclipse and AXF by implementing pluggable providers like engines, agents and view parts. AXF is not just for ABM -- anyone who needs support for executing, managing and visualizing collections of objects may find it useful. AXF user tools are covered extensively in the User Guide, and the forthcoming Platform Developers Guide will provide information about integrating AXF in your own tools.</para>
118 </section>
119 <section id="Agent_Graphics_Framework_.28AGF.29">
120 <title>Agent Graphics Framework (AGF)</title>
121 <para>The graphics framework extends GEF, GEF3D, Zest, and the BIRT charting engine to support real-time visualization of and interaction with agent models. AGF currently provides support for 2D, 2 1/2 D. and graph structures, and will be extended to 3-D, GIS and others. As with other AMP components, the AGF design focus is to provide an extensible infrastructure so that platform adopters can easily create their own view and editor parts. AGF user tools are covered extensively in the User Guide, and the forthcoming Platform Developers Guide will provide information about integrating and extending AGF in your own tools.</para>
122 </section>
123 <section id="Escape">
124 <title>Escape</title>
125 <para>Escape is an exemplar ABM toolset. 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. Escape is the primary target for most of the models in this guide. Those users interested in writing code directly to the Escape API can refer to the Programmer Guide.</para>
126 </section>
127 </section>
mparker8c858af2010-04-29 03:11:32 +0000128 <section id="Credits">
129 <title>Credits</title>
130 <para>Miles Parker is a consultant and software developer with over ten years of experience in the agent-based modeling field and twenty years developing object-oriented tools and frameworks and is the architect and project lead for the Eclipse Agent Modeling Platform (Incubation).</para>
131 <para>Metascape, LLC is the primary contributor to AMP and provides Agent-Based Modeling tools, including sophisticated tools based on the AMF platform, and comprehensive consulting services. For more information on Metascape products and services visit
132 <ulink url=""></ulink>.
133 </para>
134 <para>The AMF meta-model started life as
135 <ulink url="/wiki/">"score"</ulink>, a component of the Repast Simphony environment. Argonne National Labs supported the initial development in 2007 and agreed to contribute the relevant IP to the Eclipse project in 2009. It wasn't fully utilized within Simphony, and migrated from there to the MetaABM project supported by Metascape. The MetaABM project defined a complete editor, code-generation and model execution suite that formed the initial AMP AMF contribution. Metascape has sponsored the development of AMF from 2007 through the present.
136 </para>
137 <para>The AMP logo was inspired by the
138 <ulink url="/wiki/http://swarm.org_Swarm_logo"> Swarm logo</ulink> with their kind permission.
139 </para>
mparkera6840922010-04-28 17:51:29 +0000140 </section>
141 </chapter>
142 <chapter id="Modeler_Guide">
143 <title>Modeler Guide</title>
144 <section id="Overview">
145 <title>Overview</title>
146 <para>In this section we present the design of the Agent Modeling Framework and explain how it can be used to create models that are transparent, composable and adaptable. Fundamentally, an agent-based model, or "ABM", is composed of five pieces: Agents and Context Agents, Attributes, Spaces, and Actions. The first three refer to structural components, whereas Actions define behavior. Agent models also have styles, which are a special kind of Action used to determine how to portray an agent in a visualization. Finally Actions make use of Functions. We'll describe of these components in a separate section.</para>
147 <section id="Agent_Modeling_Framework">
148 <title>Agent Modeling Framework</title>
149 <para>The Eclipse Platform provides many unique features that make it ideal for an ABM platform. AMF provides easy to use and powerful tools and techniques for designing Agent-Based Models, including a common representation, editors, generators and development environment.</para>
150 <para>The Agent Modeling Framework (AMF) provides high level representations for common ABM constructs, and introduces novel ways of representing agents and their behaviors. As detailed in other documentation sections, the Agent Modeling Framework and related tools have been designed to allow researchers to explore complex models in an intuitive way. One of our major design goals has been to create tools that non-programmers can use to create sophisticated models. It has been our experience that using Model-Driven Software Development (MDSD) techniques increase productivity for all developers regardless of skill level. </para>
151 <para>The foundation of the Agent Modeling Framework is "Acore". The current version uses an interim version of Acore called "MetaABM". We refer to the AMF models as "meta-models" because they are used to define
152 <emphasis role="italic">how</emphasis> Agent-Based Models are themselves modeled. For those familiar with Eclipse Model-Driven Development tools, AMF is analogous to EMF but is targeted toward the design and execution of models composed of agents. Acore and MetaABM are defined in Ecore but provide a more direct and high-level ABM representation of agents, including spatial, behavioral and functional features sufficient to generate complete executable models for the target platforms. AMF is fully integrated with the Eclipse IDE platform, but Acore models themselves need have no dependencies on any particular technology beyond XML/XSD.
153 </para>
154 <para>Models designed in AMF are transparently converted to Java code for leading Agent-Based Modeling tools, such as the Escape tools which are included in AMP and allow direct execution of models within the AMP environment, and Repast Simphony, another popular Java based ABM tool. These tools create Java code that can then be compiled, executed and event modified in these environments just as with any other Java program. AMF's generative capability is designed to be pluggable and modular so that other developers can create AMF generators for their own tools. In fact, targets can be designed that have no inherent dependencies on Eclipse or even on a traditional platform.</para>
155 <para>The Acore / MetaABM meta-model is made up of three main packages. This is all based on MetaABM, and while names and important details will change for Acore, the core design should be quite similar.</para>
156 </section>
157 </section>
158 <section id="Structure">
159 <title>Structure</title>
160 <section id="Overview_2">
161 <title>Overview</title>
162 <para>The basic structure of an agent-based model can be quite simple. While there are many subtle complexities -- beyond the scope of this manual -- we can construct most models following some straightforward and elegant design principles. And in fact, one of the main goals of the Agent Modeling Framework is to provide a consistent framework that can support using those principles to support the creation of models that can be easily understood, shared, and that can be used interchangeably as components in other models.</para>
163 <para>Unlike the approach of a traditional Object Oriented environment, the dominant organizing principal for agents within AMF follows a compositional hierarchical model, not an inheritance model. (Inheritance-like behavior will be supported in forthcoming versions of Acore, but in a more sophisticated, flexible and dynamic way than is supported by traditional programming languages such as Java.) Contexts -- also referred to as "Swarms" or "Scapes", are simply Agents that are capable of containing other agents. With this basic construct -- known as a Composition in design pattern language -- agents are able to contain other agents.</para>
164 </section>
165 <section id="Details">
166 <title>Details</title>
167 <section id="General">
168 <title>General</title>
169 <para>Everything represented in an Acore model needs to be referred to in some way. Just as software classes have names, Acore provides a way to label and describe every entity, but in a richer and more maintainable way. All entities in Acore -- including Actions and Functions which we describe in the next two sections -- have a number of shared values.</para>
170 <section id="Named_Entities">
171 <title>Named Entities</title>
172 <section id="Label">
173 <title>Label</title>
174 <para>A reasonably short, human readable name for the agent. For example, "Timber Wolf", "Exchange Trader" or "Movement Probability". These should be defined so that they fit in well with auto-generated documentation. Note that Labels must be unique throughout the model. (This may change in future releases for Action names.) If you try to provide an object with a name that is already in use, "Copy" will be appended to the end of the name. </para>
175 </section>
176 <section id="ID">
177 <title>ID</title>
178 <para>An ID is an identifier that can be used to represent the object in a software program. This means that it must follow certain rules such as no-spaces or non alpha-numeric characters. The editing tools will help make sure that this value is legal. Note that when you enter a label, a legal ID is automatically created for you! Usually you won't need to change this, but you might if for example you want the value to match up with some database or other external representation. So reasonable values here might be "timberWolf" or perhaps "MVMNT_PRB" if say you're trying to match up to some old statistics records you have. (Note that currently IDs by default use "camel case", i.e. "thisIsAnExampleOfCamelCase" to match with Java variable naming conventions, but this is likely to change.) Like labels, IDs need to be unique across the model, and the editing tools will assign a different id if you attempt to give two entities the same id.</para>
179 <para>And most entities also define:</para>
180 </section>
181 <section id="Description">
182 <title>Description</title>
183 <para>A complete textual description of the object. Don't overlook this -- it is the most important part of your model. The description will show up in your auto-generated html documentation, software documentation and even in your running model. You should include enough information that model users will understand what the entity is for and what it does without referring elsewhere. This is also where any attributions and references should go. You can put html tags in here -- such as href's to external papers, but keep those to a minimum as they won't be rendered as html in all contexts.</para>
184 </section>
185 <section id="Plural_Label">
186 <title>Plural Label</title>
187 <para>The plural representation of an entity. This can be a surprisingly useful thing to have in generated documentation and software code, so it's worth maintaining. The editor will automatically add an "s" at the end of the label you've entered above, but you change it to whatever is appropriate. For example "Person", or "Timber Wolves".</para>
188 </section>
189 </section>
190 </section>
191 <section id="Agents">
192 <title>Agents</title>
193 <section id="Simple_Agents">
194 <title>Simple Agents</title>
195 <para>An Agent is simply a software object that has autonomous behavior and (generally speaking) exists within some set of spaces. By autonomous, we mean that agents make the choice about when and how to execute a behavior, as opposed to have that controlled from "above", so to speak. Like any software objects, agents have attributes (fields) and actions (methods) associated with them.</para>
196 <section id="Attributes">
197 <title>Attributes</title>
198 <para>As described in the attribute sections above.</para>
199 </section>
200 <section id="Actions">
201 <title>Actions</title>
202 <para>Described in the "Actions" section.</para>
203 </section>
204 <section id="Styles">
205 <title>Styles</title>
206 <para>Special actions that are used to define how to draw an agent graphically as also described in the "Actions" section and detailed in the "Functions" section.</para>
207 </section>
208 </section>
209 <section id="Context_Agents_.28Contexts.29">
210 <title>Context Agents (Contexts)</title>
211 <para>As detailed above, agents also form the basic structural component of an agent-based model. To get an idea for how this works, have a look at the "EpidemicRegional.metaabm" model. Note that in future releases, we will probably refer to Contexts as "Scapes".</para>
212 <section id="Agents_2">
213 <title>Agents</title>
214 <para>The agents that are contained within this context. For example, a context representing a city might contain an Individual Agent for defining all individuals in the model, and a Vehicle agent defining all vehicles. Note that when we refer to an agent in this context, we mean a general type or class of agent, not the agent itself.</para>
215 </section>
216 <section id="Spaces">
217 <title>Spaces</title>
218 <para>The set of all spaces contained or subsumed by the agent. For example, a context representing a city might contain a geographical space and a transportation network space.</para>
219 </section>
220 </section>
221 </section>
222 <section id="Attributes_2">
223 <title>Attributes</title>
224 <para>Agents need some way to represent their internal state. For example, an agent in an economic model might have a wealth attribute, and an agent in an ecology model might have a quantity of food and a particular vision range. These states are represented as attributes just as all software objects do. In an agent model, we keep richer information about these attributes and generally represent them at a higher level. For example, rather than specify that a real value is a "double", a "float" or a "big number", we represent them as "Reals" so that they can be implemented and tested in different environments. This might allow us for instance to ensure that a model's behavior is not dependent on a particular machine implementation of floating point arithmetic. Also, note that attributes only represent so-called "primitive" values -- that is, actual measurable features of a particular agent but not an agent's relationship to other agents or objects. See the discussion about networks for more on this key topic.</para>
225 <para>Here are the basic types of attributes available in Acore models:</para>
226 <section id="Basic_Attributes">
227 <title>Basic Attributes</title>
228 <para>Attributes are single values that a given agent contains. For example, an agent might have an "Age" attribute. In this section we go over the values you can set for the attributes. For those with a tecnical bent, note that we are technically describing the meta-attributes for the meta-class "SAttribute". But it is far too confusing to refer to the attributes of attributes! So we'll just refer to the attributes that any of our model components as "values".</para>
229 <section id="Type">
230 <title>Type</title>
231 <para>These can be anyone of the following: </para>
mparker8c858af2010-04-29 03:11:32 +0000232 <variablelist>
233 <varlistentry>
234 <term>
235 <emphasis role="bold">Boolean</emphasis>
236 </term>
237 <listitem>
238 <para>A value that is simply true or false. Note that unless this value really is a simple binary value, you should consider using state instead. (See details below.) For example, rather than representing gender as a 'Female' boolean value, define a 'Gender' state with values 'Male' and "Female'. Generated artifacts and documentation will be much clearer, and you'll be able to easily modify the model later if for example you discover that there are more than two potential gender categories that are relevant to your model.</para>
239 </listitem>
240 </varlistentry>
241 <varlistentry>
242 <term>
243 <emphasis role="bold">Integer</emphasis>
244 </term>
245 <listitem>
246 <para>A discrete whole number value, such as "100", "-1", "10029920". It's generally a good idea to represent any value that can never have a decimal value as an integer.</para>
247 </listitem>
248 </varlistentry>
249 <varlistentry>
250 <term>
251 <emphasis role="bold">Real</emphasis>
252 </term>
253 <listitem>
254 <para>A continuous number value. While these are typically represented in software as floating point numbers, they can conceivably represent numbers at any arbitrary precision and in any scheme. Note that while technically speaking we should be representing irrational numbers, this is not currently supported for default values and users should simply use the closest decimal approximation.</para>
255 </listitem>
256 </varlistentry>
257 <varlistentry>
258 <term>
259 <emphasis role="bold">Symbol</emphasis>
260 </term>
261 <listitem>
262 <para>A string representing some state. More precisely, a computationally arbitrary value with contextual meaning. This could be any kind of identifier. For example, you might use it to store some kind of input coding from data that is then converted into an object state. Or it could simply be an agent's name. But theoretically (though this is not currently supported) one could imagine a symbol using an idiogram, an icon or even a sound that identifies or represents the agent in question.</para>
263 </listitem>
264 </varlistentry>
265 </variablelist>
mparkera6840922010-04-28 17:51:29 +0000266 <para>(Undefined and Numeric types should not be used within a well-defined model.)</para>
267 </section>
268 <section id="Default_Value">
269 <title>Default Value</title>
270 <para>The value that should be assigned to the attribute at the beginning of any model run. The attribute may of course be assigned a different value in an Initialize rule, but its a good idea to specify one here. It's OK to leave it blank, in which case a sensible 'empty' value will be assigned, i.e. false for Boolean, 0 for Integers and Reals, and an empty string for Symbol.</para>
271 </section>
272 <section id="Gather_Data">
273 <title>Gather Data</title>
274 <para>Here you can specify whether executing models should collect aggregate values for the data. For example, if you select this value as true for a 'Wealth' attribute, Escape will automatically keep track of minimum, maximum, average, sum and optionally standard deviation and variance across all agents for each model execution period. All of these statistics will then be selectable with a mouse click to appear in your model charts at runtime.</para>
275 </section>
276 <section id="Immutable">
277 <title>Immutable</title>
278 <para>This value indicates whether you expect the model value to change. If you know that it won't or shouldn't, this value should be true.</para>
279 </section>
280 <section id="Units">
281 <title>Units</title>
282 <para>Specifies what the attribute is actually measuring. For example, if you're defining an attribute for "Wealth" in the context of a model of the world economy, you might specify "USD". If you're defining "Age", you might specify "Years", for "Mass" "Kg". Like description, this value is often overlooked, but can be critically important to allowing yourself and others to understand and correctly calibrate a model. Note that this will also allow you to simplify variable names -- instead of using "Age in Years", you can simply specify "Age" and the appropriate unit. It may be obvious to you that your model is concerned with age in years, but a user who needs to specify a different granularity will be grateful for more clarity.</para>
283 </section>
284 </section>
285 <section id="Arrays">
286 <title>Arrays</title>
287 <para>Arrays are simply attributes with zero or more entries. For example, you might have an array of three Real numbers representing the Red Green and Blue color components for an object. Note that if you find yourself defining very complex sets of arrays, its likely that what you really want to define is a new agent with attributes for each array. In addition to what is defined above, arrays specify:</para>
288 <section id="Size">
289 <title>Size</title>
290 <para>The number of values that the array attribute will contain.</para>
291 </section>
292 </section>
293 <section id="States">
294 <title>States</title>
295 <para>States represent any agent quality that may take on one of a number of well defined values. For example, an "Ice Cream Consumer" Agent might contain a state of "Ice Cream Preference" with options of "Chocolate", "Vanilla" and "Ginger".</para>
296 <section id="State_Options">
297 <title>State Options</title>
298 <para>Create new options for states by adding them to the state node. States are simple described items. Don't forget to provide a description! States also have</para>
299 </section>
300 <section id="Default_Option">
301 <title>Default Option</title>
302 <para>unlike for regular attributes, this option is not optional! Simply pick a state option to be assigned that the agent will take if no other option has been assigned.</para>
303 </section>
304 </section>
305 </section>
306 <section id="Spaces_2">
307 <title>Spaces</title>
308 <para>All contexts can contain spaces. Spaces provide an environment in which agents can have a physical or notional location and upon which they can interact with one another and their environment. Agents can exist in more than one space at a time, and a given agent need not exist in every space. (Note that this is different from the Repast Simphony notion of projections, though the two representational approaches are generally compatible.) Agents need not represent explicit, "real" spatial structures such as a landscape, though this is of course the most common use. They can also represent relational and state information, such as a belief space or a social network. There are four kinds of space represented:</para>
309 <section id="Space_.28Continuous.29">
310 <title>Space (Continuous)</title>
311 <para>In the modeling tools, we simply refer to this as a "Space" as it is represents the general concept of a space. A space is simply something that contains objects with certain locations and extents and has a certain number of dimensions. The space is continuous, in the sense that objects can be placed anywhere with arbitrary position. Spaces hold attributes, which simply define their dimensions-- see below.</para>
312 <section id="Border_Rule">
313 <title>Border Rule</title>
314 <para>A value representing what happens to an agent when that agent is asked to move beyond its extent.</para>
315 <variablelist>
316 <varlistentry>
mparker8c858af2010-04-29 03:11:32 +0000317 <term>
318 <emphasis role="bold">Periodic</emphasis>
319 </term>
mparkera6840922010-04-28 17:51:29 +0000320 <listitem>
321 <para>When encountering an edge, the agent will treat the space as wrapping around to the other side of the space. For example, if the agent at location {1,2} (0-based) within a Moore space (see grid discussion below) of size {10,10} is asked to find some other agent within distance 3, the agent look in the square defined between {8,9} and {4,5}. An agent asked to move beyond the confines of the space will simply stop when it reaches the edge. You can imagine this as taking a piece of graph paper and connecting the opposite edges. You can't actually do that with paper, but if you could you would have a toroidal (donut) shape in three dimensions defining the shape in two.</para>
322 </listitem>
323 </varlistentry>
324 <varlistentry>
mparker8c858af2010-04-29 03:11:32 +0000325 <term>
326 <emphasis role="bold">APeriodic</emphasis>
327 </term>
mparkera6840922010-04-28 17:51:29 +0000328 <listitem>
329 <para>When encountering an edge, the agent treats it as the edge of the space. For example, if the agent at location {1,2} is asked to find some other agent within distance 3, the agent look between {0,0} and {4,5}. An agent asked to move beyond the confines of the space will simply stop when it reaches the edge.</para>
330 </listitem>
331 </varlistentry>
332 </variablelist>
333 <para>The "Strict" and "Bouncy" values are obsolete and should not be used.</para>
334 </section>
335 <section id="Dimensionality">
336 <title>Dimensionality</title>
337 <para>The number of dimensions that the space has. After selecting a dimensionality, attributes will be added to represent each dimension. For example, if you enter 3 here, you will have an attribute for X, Y, and Z. Be sure to enter default values here, as they will be used to specify the actual size of the space.</para>
338 </section>
339 </section>
340 <section id="Grid">
341 <title>Grid</title>
342 <para>A grid is technically a regular lattice structure. Currently, only rectilinear structures are supported, i.e. a One-dimensional vector, a two-dimensional grid, a three-dimensional cube and so on. (Though none of the current target platforms support n-d spaces yet.) </para>
343 <para>Like continuous spaces, a grid has a border rule and dimensionality. A grid has a couple of other important values:</para>
344 <section id="Multi-Occupant">
345 <title>Multi-Occupant</title>
346 <para>Does the grid allow more than one agent to occupy it at a time? This value may be replaced with another mechanism in future releases.</para>
347 </section>
348 <section id="Neighborhood">
349 <title>Neighborhood</title>
350 <para>This value determines what constitutes a region within a particular distance from the agent. The value for this is often critical in obtaining particular behavior from a model, and shouldn't be overlooked. There are three possible values:</para>
351 <variablelist>
352 <varlistentry>
mparker8c858af2010-04-29 03:11:32 +0000353 <term>
354 <emphasis role="bold">Euclidean</emphasis>
355 </term>
mparkera6840922010-04-28 17:51:29 +0000356 <listitem>
357 <para>The distance between any two cells is taken to be the "real" distance. For example, if an agent was within a chess board, and we wanted to find all agents within distance three of it, we could determine that by taking a string of length 3, tacking it to the center of the source square, and including all cells whose centers we can reach with the other string end. Note that although Euclidean space may seem the most reasonable neighborhood configuration to choose, this really isn't the case. Euclidean space is continuous whereas grid space is discrete, and mapping the two to each other can create unexpected issues. Still, this is a good choice for models representing notional real spaces.</para>
358 </listitem>
359 </varlistentry>
360 <varlistentry>
mparker8c858af2010-04-29 03:11:32 +0000361 <term>
362 <emphasis role="bold">Moore</emphasis>
363 </term>
mparkera6840922010-04-28 17:51:29 +0000364 <listitem>
365 <para>Here, the distance between any two cells is defined by the number of edge
366 <emphasis role="italic">or</emphasis> corner adjacent cells crossed to get between them. To continue the chess board analogy, this is the set of moves that a king can make. Note that this does not map well to real space at all, as a cell at distance 1 in a moore space is at distance sqrt(2) in "real" space.
367 </para>
368 </listitem>
369 </varlistentry>
370 <varlistentry>
mparker8c858af2010-04-29 03:11:32 +0000371 <term>
372 <emphasis role="bold">Von-Neumann</emphasis>
373 </term>
mparkera6840922010-04-28 17:51:29 +0000374 <listitem>
375 <para>Here, the distance between any two cells is defined by the number of edge adjacent cells crossed to get between them. This is the set of moves that a rook might make on a chess board -- if a rook could only move one square at a time. It is also often referred to as a Manhattan distance for the self-evident reason.</para>
376 </listitem>
377 </varlistentry>
378 </variablelist>
379 </section>
380 </section>
381 <section id="Network">
382 <title>Network</title>
383 <para>A network represents a set of relationships between agents, in a graph structure. The concept is pretty simple, but note that a network is actually a critical part of many AMF models. This is because we use networks to represent any kind of references between agents. You may have noticed in the discussion about attributes that there is no generic "object" type for an attribute. In fact, attributes only contain primitive values. So we will use networks to do the kinds of things that we would often use object references for in a traditional Object-Oriented model. For example, if an agent is a member of a family, rather than have that agent have a member attribute of "family" with a reference to the "Family" object, the modeler would create a "Family Members" network and connect agent's to their families as appropriate. This implies that network members can contain members of many different types.</para>
384 <para>A network has only one value to specify:</para>
385 <section id="Directed">
386 <title>Directed</title>
387 <para>This indicates whether connections between agents are one-way or two-way. If this value is false, then if a connection is made between an agent A and an agent B, and agent B searches within distance 1, agent B will find agent A. If this value is true, agent A can find agent B, but agent B can not find agent A. (Unless of course some other path leads B to A.)</para>
388 </section>
389 </section>
390 <section id="Geography">
391 <title>Geography</title>
392 <para>A geography represents a physical landscape. Here we assume that that landscape is going to be defined by an external data source and representational scheme -- typically a Geographical Information System. We'll describe how to work with GIS in more detail when we discuss builder actions.</para>
393 </section>
394 </section>
395 </section>
396 <section id="Reference">
397 <title>Reference</title>
398 <section id="Diagrams">
399 <title>Diagrams</title>
400 <para>For readers familiar with UML and meta-modeling, the following diagrams give more detail on the structural design.</para>
401 <section id="Meta-Classes">
402 <title>Meta-Classes</title>
403 <para>Our first diagram depicts the core structural design of the model. </para>
404 <para>
405 <mediaobject>
406 <imageobject>
407 <imagedata fileref="images/structure/StructureComplexDiagram.png" scale="50"/>
408 </imageobject>
409 </mediaobject>
410 </para>
411 <literallayout format="linespecific" class="normal">There seems to be a lot going on here, but the basic components are pretty straightforward as we can see in the next diagram.
413 </section>
414 <section id="Key_Collaborations">
415 <title>Key Collaborations</title>
416 <para>
417 <mediaobject>
418 <imageobject>
419 <imagedata fileref="images/structure/StructureSimpleDiagram.png" scale="50"/>
420 </imageobject>
421 </mediaobject>
422 </para>
423 <literallayout format="linespecific" class="normal">Core interactions are in Red. The meta-model structure is essentially a Composite pattern.
425 </section>
426 <section id="Details_2">
427 <title>Details</title>
428 <orderedlist inheritnum="ignore" continuation="restarts">
429 <listitem>
430 <para>Every model has at its root a Context (Scape). Contexts are Agents that are capable of containing other Agents (including other contexts, naturally). </para>
431 </listitem>
432 <listitem>
433 <para>(Meta-level) Contexts contain (meta-level) Agents at the model (design-time) level. At runtime, (model-level) Context instances defined in a (meta-level) SContext will contain (model-level) agent instances of the defined (meta-level) SAgent. This sounds more complicated than it is, so let's look at a simple example. Suppose we create a new Context, and give it a label of "Wiki Example". Within that Context, we create an Agent and give it a label of "Individual" and another Agent with the label "Block". At runtime when we are actually executing the model we will have one WikiExample model instance which contains a number of Individuals.</para>
434 </listitem>
435 <listitem>
436 <para>Agents contain Attributes, such as Vision and Age. Context attributes often represent input parameters for contained agents. For example, our Wiki Agent Context might contain an Individual Count as well as a Minimum Age and Maximum Age.</para>
437 </listitem>
438 <listitem>
439 <para>Contexts can contain Projections (Spaces), which represent some kind of spatial or structural interaction space for the agents; either a grid, a continuous (euclidean) space, or a network (graph) or geographic space of some kind. For example, we might want to have a City that contains Blocks and that an Individual can move around within.</para>
440 </listitem>
441 <listitem>
442 <para>Agents are Actable and thus can contain any number of behaviors called "Actions", described in detail in the next section. Actions can describe individual behavior, and at the Context (Scape) level can define how member Agents and Projections are created.</para>
443 </listitem>
444 <listitem>
445 <para>Styles provide a mechanism for defining generic visualization behavior for Agents and so are also Actable. For example, an Agent might have an Action that says effectively "draw a red circle shaded red for the wealth of the agent".</para>
446 </listitem>
447 </orderedlist>
448 </section>
449 </section>
450 </section>
451 </section>
452 <section id="Actions_2">
453 <title>Actions</title>
454 <para>Actions are the most important part of an agent model. While Agents, Attributes and Spaces define what we're modeling, it is Actions that give the models life.</para>
455 <section id="Overview_3">
456 <title>Overview</title>
457 <para>Actions allow the definition of behavior for agents at a very high level. You can think of actions as being analogous to methods in a traditional object-oriented model but that analogy only goes so far. In the same way that methods are defined as part of objects, actions belong to particular agents. (Though even more expressive ways of defining actions are contemplated in future releases.) In the next section we go into detail about what Actions are and how they can be used to define all agent behavior. They are also conceptually more challenging as unlike with structure they have no direct analogies to past agent representations.</para>
458 <para>An action provides simple, well-defined details that a model can use to determine what steps to take in model execution. That definition seems general enough to be almost useless, but its important to understand that an action is not equivalent to an instruction, a method or a query. In fact, actions can have aspects of all of these. But an action is not in itself an instruction specifying exactly
459 <emphasis role="italic">how</emphasis> the modeling engine should do something -- instead an action represents
460 <emphasis role="italic">what</emphasis> the modeler intends for the agents to do. (Technically, we might say that Actions takes a "declarative" approach instead of an 'imperative' approach, but that's not quite true, because actions do allow us to define behavior in a richer way than most declarative approaches, and many action constructs map directly to imperative approaches.)
461 </para>
462 <para>Actions are connected together in a series of sources and targets. (Technically, an acyclic directed graph.) In an abstract sense that is similar to the way any programming language is defined although that structure isn't usually obvious because of the constraints of textual representations. But unlike a typical programming language, in Actions it is not the execution thread (the processor) that moves from one instruction to the next, but the result of the previous action. In this way, action results "flow" from the output of one action into the next action.</para>
463 <para>Why are these distinctions between traditional Object-Oriented and the Action approaches important? They give us the advantages of simplicity, clarity and flexibility that
464 <ulink url="/wiki/">data-flow approaches</ulink> like spreadsheets and some query languages have, but with less restrictions. At the same time, they can bring us much of the power and expressiveness of
465 <ulink url="/wiki/">functional languages</ulink> like Lisp or
466 <ulink url="/wiki/">logical languages</ulink> like Prolog, but without the level of complexity and obscurity that such languages can have.
467 </para>
468 <para>We can get a better idea for how Actions work by thinking about how a spreadsheet works. In a spreadsheet, we might define a cell A that adds up a row of data, say "Income". We might define another cell C ("Profit") that takes A and adds it to another cell B that adds up another row of data ("Expenses"). Now, if we change a value in any of the rows, all of the other rows are added up and we get the results in A and B updated automatically. We never had to write code that said something like "for each cell in row X, where...". In fact, we don't really care
469 <emphasis role="italic">how</emphasis> our Spreadsheet program adds up the numbers -- it could have added them all up at once but in backward order, or stored a running total somewhere and updated just the difference in value for the cell we changed -- what we care about is
470 <emphasis role="italic">what</emphasis> the result is, and whether it is correct.
471 </para>
472 <para>But Actions are much more powerful than a spreadsheet, because what is flowing from Action A to Action B is not just a number, but any model component such as a space or a set of agents that we need to use in target actions.</para>
473 </section>
474 <section id="Concepts">
475 <title>Concepts</title>
476 <para>In this section, we'll describe how modelers can assemble actions into sets of behavior that accomplish complex tasks on interrelated agents and spaces over time.</para>
477 <section id="Kinds_of_Actions">
478 <title>Kinds of Actions</title>
479 <informaltable frame="none">
480 <tr>
481 <td rowspan="1" colspan="1">Before getting into the details of how each Actions work together, or the various kinds of Actions, it will be helpful to take a broad overview of how they all fit together. As discussed above, actions are strung together in a sequence or flow. They're always composed of two parts, though those parts can be assembled and intermixed in many different ways. First, we search for a collection of agents, and then we do something with that selection. We refer to these two parts as Selections and Commands. (For the technically minded, another useful way of looking at the Actions approach is as a Query Transformation language, as with SQL and Stored Procedures. Except again, the results of the queries along with the transformations flow through from one query to the next.) Selections find the agents we want to do something with, and the commands do it. We need some way to start the whole chain of actions off, and so we have a kind of Selection called a Root Selection, or simply a Root. Secondly, we need some way to actually make the agents exist in the model in the first place, so we have a Create Agents action. Finally, we have special commands called builders that allow us to create the spaces that the agents will occupy. The various actions are discussed in depth in the Details section.</td>
482 <td rowspan="1" colspan="1">
483 <mediaobject>
484 <imageobject>
485 <imagedata fileref="images/actions/ActionsBlocks.png" scale="50"/>
486 </imageobject>
487 </mediaobject>
488 </td>
489 </tr>
490 </informaltable>
491 </section>
492 <section id="Flow">
493 <title>Flow</title>
494 <para>First, let's look at how actions define the basic path that agents take during a model run. As with any programming language, the path we take through the program specification is what determines our state when we get there. In a pure object oriented program, the path just defines the control flow -- what we are doing. The actual state of our model is defined within the object itself. If we call a method B from another method A, we'll be relying on method A to set the values that we need into the object state itself. In a purely functional program the path defines how we are going to deal with whatever has been explicitly passed in to a function that has been called, that is the function parameters. In fact, most languages such as Java combine aspects of both approaches.</para>
495 <para>In Actions, the path itself implicitly carries all of the context of prior execution with it. This means that we don't have to worry about storing context in the object -- as we would in an object-oriented language -- or passing the correct values from one method call to the next as we would in a functional language. Instead, Actions can use the implicit context of the path of flow to determine what the current state of execution is.
496 An important aspect of the Actions design is that loop structures are not allowed -- that is, flows are acyclic. An action can never have an ancestor target (that is targets, targets of targets, etc..) that has as one of its ancestors that same action. As you'll see, actions don't typically
497 <emphasis role="italic">need</emphasis> loop structures. By far the most common use of loops in conventional programming langauges is to loop through collections of objects. As selections (see below) refer to the entire collection of agents, any actions on a selection apply to all members of that collection. Recursive structures are needed for some particular usages and will be supported in future releases, but not through an explicit looping construct.
498 </para>
499 <informaltable frame="none">
500 <tr>
501 <td rowspan="1" colspan="1">Again, behaviors in Actions are always defined by a set of
502 <emphasis role="italic">selections</emphasis> and
503 <emphasis role="italic">queries</emphasis>. In the diagram to the right, we can see the pattern. First, we define a Root Selection for a Rule, Schedule or other triggering event. Then, we might add a series of Query and Logic Actions to define the specific agents that we are interested in. These are all part of the Selection. Next, we might define a series of Commands to determine what to do with those agents. Or, we could use the result of that selection to immediately define another selection, for example if we are searching for an agent that is near another agent.
504 </td>
505 <td rowspan="1" colspan="1">
506 <mediaobject>
507 <imageobject>
508 <imagedata fileref="images/actions/ActionsSequence.png" scale="50"/>
509 </imageobject>
510 </mediaobject>
511 </td>
512 </tr>
513 </informaltable>
514 <informaltable frame="none">
515 <tr>
516 <td rowspan="1" colspan="1">The diagram to the right depicts a simple example. Here, we create a rule, and then check the results of two queries. For any agents that meet those criteria, we'll evaluate some function based on their state, and then set some value on them.</td>
517 <td rowspan="1" colspan="1">
518 <mediaobject>
519 <imageobject>
520 <imagedata fileref="images/actions/ActionsSimpleSequence.png" scale="50"/>
521 </imageobject>
522 </mediaobject>
523 </td>
524 </tr>
525 </informaltable>
526 <informaltable frame="none">
527 <tr>
528 <td rowspan="1" colspan="1">In this next example, we'll first create the rule, and then create a new selection with a set of criteria. Finally, we'll do a move based on those queries.</td>
529 <td rowspan="1" colspan="1">
530 <mediaobject>
531 <imageobject>
532 <imagedata fileref="images/actions/ActionsSimpleSequence2.png" scale="50"/>
533 </imageobject>
534 </mediaobject>
535 </td>
536 </tr>
537 </informaltable>
538 <para>In the following example, we've defined a set of actions and their relationships. We have a selection, a few queries and a couple of logic operators leading to a Set Action. We'll describe in detail below how Logic Actions are used in conjunction with other actions to assemble any kind of query structure needed. But for now, we'll focus on the control flow itself.</para>
539 <para>
540 <mediaobject>
541 <imageobject>
542 <imagedata fileref="images/actions/ActionsFlowSimple.png" scale="50"/>
543 </imageobject>
544 </mediaobject>
545 </para>
546 <para>As you have probably already guessed, the agents that have the Set Action applied to them could take one of two paths through the Action flow. Readers with experience with programming or formal logic will note that this looks just like a parse tree, and while that's basically what it is, there are important differences. For example, if we looked at the following structure as a definition of control flow for a single agent we'd take them to be equivalent. Both would evaluate the statement (Query 1 AND Query 2) OR Query 3 for each agent.</para>
547 <para>
548 <mediaobject>
549 <imageobject>
550 <imagedata fileref="images/actions/ActionsFlowUnion.png" scale="50"/>
551 </imageobject>
552 </mediaobject>
553 </para>
554 <para>Within Actions in many cases these two approaches will also act equivalently. If we are simply setting a value, it doesn't matter how an agent gets to that Set Action, as long as it gets there. All sources that flow into a given target Action act like a logical union since any of the paths might reach that target. But note that we have two flows moving in parallel in the flow on the right. What happens when the conditions for
555 <emphasis role="italic">both</emphasis> branches are true? As the set of agents flow through each branch the Set Action on the left will be evaluated once, while the one on the right will be evaluated twice. Again, this often ends up with the same behavior, but not always. If for example, the evaluate Action uses the value of the attribute that we are setting as input, we can get different results. Of course, you can write code in any language that accomplishes the same thing, but the code will look quite different. For example, if we wrote the same basic logic in Java, in the first case we'd have something like:
556 </para>
557 <literallayout format="linespecific" class="normal">if ((query1.evaluate() &amp;&amp; query2.evaluate()) || query3.evaluate()) {
558 doSomething();
561 <para>In the second we'd have:</para>
562 <literallayout format="linespecific" class="normal">if (query1.evaluate() &amp;&amp; query2.evaluate()) {
563 doSomething();
565if (query3.evaluate()) {
566 doSomething();
569 <para>This is a simple example, but with multiple branches such code design issues can quickly grow complex. The flow approach allows us to express things in a way that is often more natural and expressive. The important thing to keep in mind when desiging action flows is to see the flow as representing a selection of agents moving through streams independently. In the Actions example we expressed both approaches in nearly the same way, except in the case on the left we used a Union Action to bring the two branches of flow back together.</para>
570 </section>
571 <section id="Selections">
572 <title>Selections</title>
573 <para>Selections are a key concept in Actions. Put simply, selections define what we are searching for and where. They are defined by a combination of Select, Query and Logic Actions. Each time we create a new Select Action, we define a new selection. Queries can be used to further refine selections either immediately after or later in the Action flow, as described in the next section. Logic Actions are used to combine and organize the Action flow defined by Query Actions. In order to understand how these three pieces work together, we need to understand the idea of selection boundaries.</para>
574 <informaltable frame="none">
575 <tr>
576 <td rowspan="1" colspan="1">A selection boundary determines the set of selection actions that are used to determine what agents to apply target actions to. For example, in the following diagram, we can see the extent of the boundary for a straightforward selection.</td>
577 <td rowspan="1" colspan="1">
578 <mediaobject>
579 <imageobject>
580 <imagedata fileref="images/actions/ActionsSelBoundarySimple.png" scale="50"/>
581 </imageobject>
582 </mediaobject>
583 </td>
584 </tr>
585 </informaltable>
586 <informaltable frame="none">
587 <tr>
588 <td rowspan="1" colspan="1">Each time we create a new selection, we define a new set of boundaries. In the diagram to the right, Selection 1 and Selection 2 eaach start with a new Select Action. </td>
589 <td rowspan="1" colspan="1">
590 <mediaobject>
591 <imageobject>
592 <imagedata fileref="images/actions/ActionsSelBoundary2Parts.png" scale="50"/>
593 </imageobject>
594 </mediaobject>
595 </td>
596 </tr>
597 </informaltable>
598 <para>But boundaries can be defined for a group of actions by a Query Actions as well. This is because Query Actions can be directly part of a selection definition, but they can also refine selections. We'll see how that works below. So where does one selection boundary end and the next one begin? The simple rule is that the end of the boundary is defined for a given Action by the place where:</para>
599 <orderedlist inheritnum="ignore" continuation="restarts">
600 <listitem>
601 <para>A Query Action is not followed by a Logic Action, or</para>
602 </listitem>
603 <listitem>
604 <para>A Logic Action is not followed by another Logic Action</para>
605 </listitem>
606 </orderedlist>
607 <informaltable frame="none">
608 <tr>
609 <td rowspan="1" colspan="1">In other words, as soon as a Logic Action occurs in a path leading to an Action, any following Query will define a new boundary, as shown in the example to the right. </td>
610 <td rowspan="1" colspan="1">
611 <mediaobject>
612 <imageobject>
613 <imagedata fileref="images/actions/ActionsSelBoundary11A.png" scale="50"/>
614 </imageobject>
615 </mediaobject>
616 </td>
617 </tr>
618 </informaltable>
619 <para>Note that we refer to "Selection 1" and Selection 1A". This is because Selection 1A is a refinement of Selection 1 along its particular path of flow. When a query appears for the same selection but past a particular boundary, you can think of it as a sort of filter on the selection contents. We don't have a "Selection 2" here because any Actions that refer to "Selection 1" along the current path of flow will be acting on the selection defined by Selection 1 and Selection 1A.</para>
620 <para>These rules allow actions to be defined in the simplest possible way, but it is important to understand their implication as they result in behavior that can be different from what someone used to and imperative programming environment such as Java might expect. In a simple case the distinction might not matter. For example, if we are using a Query 1 to test whether an agent's attribute a == x and attribute b == y, we would get the same outcome if we placed intersected the queries as if we simply put them in sequence. Internally we would actually be searching for agents with a == x, and
621 <emphasis role="italic">then</emphasis> taking those agents and choosing those agents with b==y, but the outcome would be the same. But consider a more sophisticated case, where we are searching for neighboring available cells.
622 </para>
623 <para>
624 <mediaobject>
625 <imageobject>
626 <imagedata fileref="images/actions/ActionsSelBoundaryComplex.png" scale="50"/>
627 </imageobject>
628 </mediaobject>
629 </para>
630 <para>In the first case, we execute a search for all agents that meet the two criteria. This means that if there are
631 <emphasis role="italic">any</emphasis> neighboring cells which are available, we're guaranteed to find one (random) cell. In the second case, we first search for all cells that are neighbors. This will match any agents that include both available and non available agents. Now, at this point since our search returns one agent (in the current AMF design -- richer behavior will be supported in the future) the randomly selected agent could be either available or not. So in the second case, we might end up with no cell to move to, and thus make no move at all. This then becomes an important aspect of model design. For example, if one were defining a model where neighbors played a game with each other, one might want to instruct agents to play the game only with neighbors that have a certain wealth threshold. In the real-world situation that we are modeling, we might simply search for neighbors who are over a given wealth threshold and then play the game with them. This would imply that information about other agent's wealth is open knowledge. Or, we might simply select a random neighbor, and ask that neighbor to play a game with us. Upon discovering that our neighbor does not meet our wealth criteria, we would then choose not to play with them. Here we are modeling a cost in time to obtain information about another agent's wealth, because we might miss an opportunity to play the game with another agent on that round.
632 </para>
633 </section>
634 <section id="Weaving">
635 <title>Weaving</title>
636 <informaltable frame="none">
637 <tr>
638 <td rowspan="1" colspan="1">Now, let's put the concepts of Actions sequences and boundaries together to see how we can easily define complex interactions between multiple selections. When we define a Select, the state of its selection flows through and with any subsequent selections. So for example, if we have a Root Action rule, and then do a selection based on it, we'll have access to the agent from the original context as well as all of the subsequent selections. We can refer to any previous selection for any subsequent action. For example, instead of setting the value for the rule agent, we might instead set a value for an agent we've found in a target selection.</td>
639 <td rowspan="1" colspan="1">
640 <mediaobject>
641 <imageobject>
642 <imagedata fileref="images/actions/ActionsWeavingSetAnother.png" scale="50"/>
643 </imageobject>
644 </mediaobject>
645 </td>
646 </tr>
647 </informaltable>
648 <informaltable frame="none">
649 <tr>
650 <td rowspan="1" colspan="1">Inputs to functions also use selections. (We'll discuss more details in the functions section.) In the following example, we're adding the wealth of the Selection 1 agent to the wealth of the Selection 2 agent and using that value to set some other value. (Here, perhaps we are modeling an agent in a winner takes all game, in which case we'd also add a Set Action on Selection 2 and set the second agent's wealth to 0.)</td>
651 <td rowspan="1" colspan="1">
652 <mediaobject>
653 <imageobject>
654 <imagedata fileref="images/actions/ActionsWeavingEvaluate.png" scale="50"/>
655 </imageobject>
656 </mediaobject>
657 </td>
658 </tr>
659 </informaltable>
660 <informaltable frame="none">
661 <tr>
662 <td rowspan="1" colspan="1">But we can also use selections in defining Query Actions themselves. So in the following example, we select a neighbor agent and then compare the age of our Rule agent with the age of the Selection 2 agent. If and only if those ages are the same will we execute the target Set Action. This example also demonstrates why we refer to the data flow as weaving. Query Actions can be used to refine selections at any point in the data flow. Selections and their uses are interwoven throughout an action sequence.</td>
663 <td rowspan="1" colspan="1">
664 <mediaobject>
665 <imageobject>
666 <imagedata fileref="images/actions/ActionsWeaving1A.png" scale="50"/>
667 </imageobject>
668 </mediaobject>
669 </td>
670 </tr>
671 </informaltable>
672 <informaltable frame="none">
673 <tr>
674 <td rowspan="1" colspan="1">Finally, we can put all of these concepts together by weaving selections together with flows. As we discussed in the flow section, if we use multiple paths in the Query, the agents that flow through from any prior Query can follow multiple paths at once. And as we discussed in the selection section, the selection and its boundaries determine what agents we will be working with at any given evaluation point in the flow. Consider the example to the right. As we'll see in the detailed explanation of each Action below, Transformation Actions such as Move or Connect take multiple selections. The first selection defines the set of agents that will be performing the action. In the case of a Move agent, this refers to the mover. The second selection, which for Move we call "destination", refers to the selection that will be receiving the action. In the case of movement this is the agent or location that the Rule agent will be moving to. If we follow the flows through, we can note two important outcomes of our model design -- a Rule agent might move twice if it meets the criteria for both the blue path and the red path and that it might move to a different location each time.</td>
675 <td rowspan="1" colspan="1">
676 <mediaobject>
677 <imageobject>
678 <imagedata fileref="images/actions/ActionsWeaving2.png" scale="50"/>
679 </imageobject>
680 </mediaobject>
681 </td>
682 </tr>
683 </informaltable>
684 </section>
685 </section>
686 <section id="Details_3">
687 <title>Details</title>
688 <informaltable frame="none">
689 <tr>
690 <td rowspan="1" colspan="1">In this section, we'll dig into the specific role of each of the Actions. From the design discussion we hopefully have some sense of how these all fit together in general. Again, the block diagram to the right provides an overview of how the various actions are related. You might want to take a look at the meta-class diagrams in the referernce section as well.</td>
691 <td rowspan="1" colspan="1">
692 <mediaobject>
693 <imageobject>
694 <imagedata fileref="images/actions/ActionsBlocks.png" scale="50"/>
695 </imageobject>
696 </mediaobject>
697 </td>
698 </tr>
699 </informaltable>
700 <section id="Selections_2">
701 <title>Selections</title>
702 <para>A selection defines a particular set of agents that we want to do something with. Selections are made up of the Select action itself, along with Query and Logic actions. When we refer to a selection in any target command, we are referring to the selection in the context of where we have defined the behavior.</para>
703 <section id="Select">
704 <title>Select</title>
705 <para>As we discussed above, when we refer to a Select, we're actually referring to the selection as a whole leading up to the current action. The Select Action itself is used to define what we are searching for (Agent), where we are searching for it (Space), and from whose perspective we are doing it (Selection). Create Actions are a sepecial kind of Select Action that are used to create agents. See the decription in the Builders section below for more information.</para>
706 <section id="Selection">
707 <title>Selection</title>
708 <para>The selection that we are searching "from". This seems to be the concept that new users have the most difficulty with, but it is key to understanding how Actions works. Just as with any other Action -- a Move command for example -- a selection needs to know what set of agents that it is working with. For example, if we want to define a selection B that finds the cells neighboring a rule B's agent, we would set selection B's selection to A.</para>
709 </section>
710 <section id="Agent">
711 <title>Agent</title>
712 <para>Here we define what agent we will be looking for. In order for this to make sense, the agent has to be related in some meaningful way to the agent whose behavior we are defining. For example, it might be a partner agent or a location that we might want to move to. An agent must be specified unless we are searching within a continuous space, in which case this value should be empty, and the result of the selection will represent some location in that space. In the current version of the framework, we treat destination cell locations as agents, and require that location to be specified as a target agent, but in a future version we'll allow searches without defining an agent within grid spaces as well.</para>
713 </section>
714 <section id="Space">
715 <title>Space</title>
716 <para>The space that we want to search within. Of course, this must be specified if we use any spatial query terms (see below), but if we simply want to search across all agents it should not be specified.</para>
717 <para>Represent Queries (Controls) on agents and Transformations, or Commands, on the result of those queries. Queries, Transformations and other in which each child target carries the execution and data context for it's particular path.</para>
718 </section>
719 <section id="For">
720 <title>For</title>
721 <para>This value is obsolete and will be replaced with a different mechanism in the next version of the modeling environment.</para>
722 </section>
723 </section>
724 <section id="Query">
725 <title>Query</title>
726 <para>A Query represents a concrete criteria for our search. The name is a bit confusing because of potential for confusion with a generic query. Queries -- along with their cousin Evaluators -- define a function that is evaluated and that can take Agent attributes and the results of other Actions as input. Queries are combined with each other and with the logic actions to determine the results of a selection for their direct target actions. </para>
727 <section id="Selection_2">
728 <title>Selection</title>
729 <para>As with all other actions, evaluations specify a selection, and just as with the other actions, this determines the set of agents that the evaluation occurs for, but the input selections determine what agent is used for the calculation itself.</para>
730 </section>
731 <section id="Function">
732 <title>Function</title>
733 <para>A query function is evaluated to determine the results of a particular selection. Functions can represent very simple search criteria such as "My Age == Your Age", but they can also represent complex and inter-related concepts such as spatial relationships. They must return logical values. See the functions section for more information on specific functions.</para>
734 </section>
735 <section id="Inputs">
736 <title>Inputs</title>
737 <para>The set of values that will be used to determine the result, in the order specified by the function prototype. Inputs can specify any source evaluation and any agent state or agent parent context state. They can also be literal values -- see the section on literals below. The selection determines which agent's will be used to determine the value, and different inputs can specify different selections.</para>
738 </section>
739 </section>
740 <section id="Logic">
741 <title>Logic</title>
742 <para>These Actions provide us with the ability to combine queries with one another, and follow the basic rules of set logic. But as we've seen above, it is important to understand that there are important differences between Logic Actions and typical programming logic. Most importantly, they apply not to individual agents per se, but to the set of agents that move through them. Also, there is not neccesarily short circuit execution (it's not needed) and much richer criteria can be joined together because of the action flow design.</para>
743 </section>
744 <section id="Intersection">
745 <title>Intersection</title>
746 <para>An intersection contains only those agents that match all of its source actions. This is essentially equivalent to a logical AND statement and has similarities to an &amp;&amp; operator in a java "if" statement. An agent must be able to flow through all incoming actions in order to flow out of an Intersection Action.</para>
747 </section>
748 <section id="Union">
749 <title>Union</title>
750 <para>A union contains all agents that match any of its source actions. This shares similiarities to a logical OR statement and the || operator in a java "if" statement. It does mroe than that however, as it acts to join multiple flows of action. That is, as set logic implies, an agent will never appear in the result of a union more than once.</para>
751 </section>
752 <section id="Difference">
753 <title>Difference</title>
754 <para>A difference contains all agents that do not match any of its source actions. This essentially equivalent to a logical NOT statement, and has similarities to the Java else statement. Like the Union Action, difference implies that a given agent will only appear once in any subsequent targets. No agents that reach a Difference Action will flow through to the next action(s), and all agents (that meet the definition of the Select Action) that cannot reach that action will.</para>
755 </section>
756 </section>
757 <section id="Roots">
758 <title>Roots</title>
759 <para>Root actions are a special case of a selection. These represent behaviors that are defined for all members of agents; these are the highest granularity of an agent's behavior, such as "Find Partners" or "Eat" or "Reproduce". When you want to create a new set of Actions, you have the following choices.</para>
760 <section id="Build">
761 <title>Build</title>
762 <para>The Build Action is a specialized action that allow the construction of member agents and spaces within a parent context. A Build Action executes once for each context before any initialization actions occur for any children agents of that context. Currently it is undefined whether a context's own Initialize Action is executed before the Build Action occurs, so implementors should not rely on any initialized values being available at build time.</para>
763 </section>
764 <section id="Initialize">
765 <title>Initialize</title>
766 <para>An Initialize action is executed once and only once for every agent when the model is first started -- at time 0. Initialize Actions are guaranteed to execute before any other non-builder action occurs.</para>
767 </section>
768 <section id="Rule">
769 <title>Rule</title>
770 <para>A Rule executes once for every agent for every iteration of the model. An important note is that the actual sequence of rules is technically undefined. An implementor should not rely on the fact that a rule occurs before another rule in the list of agent actions though typically the order in which the rules were actually created is respected.</para>
771 </section>
772 <section id="Schedule">
773 <title>Schedule</title>
774 <para>A schedule is executed on a recurring basis, according to the values detailed below. Note that schedules are often overused. In most agent-based models it makes sense to have any behaviors occur at the same granularity using a Rule. Please note that Schedules are not currently supported in the Escap target, but that support should be available soon. In the following descriptions we refer to period as the current iteration of the model, that is where time == t.</para>
775 <section id="Start">
776 <title>Start</title>
777 <para>The period that the schedule will first be invoked. For example, if this value is 100, and interval is 1, the schedue will be executed at times 100,101,102..</para>
778 </section>
779 <section id="Interval">
780 <title>Interval</title>
781 <para>How often the schedule is invoked. For example, if this value is 3 and start is 1, the schedule will be executed at times 1,4,7..</para>
782 </section>
783 <section id="Priority">
784 <title>Priority</title>
785 <para>Where the rule will be placed in the execution queue for a given time period. For example, if Schedule A's priority is set to 3 and Schedule B's is set to 2, Schedule B will be executed for all agents before Schedule B is executed for any agents.</para>
786 </section>
787 <section id="Pick">
788 <title>Pick</title>
789 <para>Controls how many agents to execute the schedule against. While this value will have an effect on the Repast target, it is not recommended to be used for general models and is likely to be replaced by another approach.</para>
790 </section>
791 </section>
792 <section id="Watch">
793 <title>Watch</title>
794 <para>A Watch action is executed any time the watched value is set for any agent. Note that the Action will be triggerred even if the state is simply set back to the value that it already has. It is important to be careful about creating Watches that might set the values of other Watch actions which might in turn trigger this watch. To clarify, if a modeler creates a Watch A for attribute a, and creates a target Set for it for attribute b, and Watch B is watching attribute b, then if Watch B has a target Set for attribute A, a circular execution could occur. This would cause the model to get stuck in its current iteration. To help model developers avoid this case, a warning will be provided if such a set of circular watch dependencies is created.</para>
795 <section id="Attribute">
796 <title>Attribute</title>
797 <para>The attribute that will be monitored for change.</para>
798 </section>
799 </section>
800 </section>
801 <section id="Builders">
802 <title>Builders</title>
803 <para>Builders are a special category of actions that are used to create spaces. They should not be confused with the Build Action itself which is a root selection that defines the time at which builder actions should occur. Generally speaking, specific Builder Actions for spaces and Create Actions for agents are targets of Build Actions.</para>
804 <section id="Create_Agents">
805 <title>Create Agents</title>
806 <para>Agents are crete using the Create Agent action. The Create Agent Action is actually a special kind of Select Action that is used to actually create agents rather than simply search for them. Other than this capability, a Create Agent action can be used just like any other action except that Query and Logic actions aren't needed or genrally appropriate as this action defines a set number of agents to perform an action against. Create Agent actions have the special feature of being usable from the containing context, so that contexts can create initial agent populations before any agents exist within the context to perform actions against. But they can also be used directly within agent rules, for example to create a child agent as the result of a reproducation rule. Note that Initialize Actions are
807 <emphasis role="italic">not</emphasis> performed on agents that have been created within a model during regular (non-initialization time) execution. If the model creates actions during the regular model run, any state initialization should be handled by the targets of this action directly. (Naturally, if the enclosing context is used to create agents at the beginning of a model run, then the Initialize action is used as part of the normal model life-cycle.)
808 </para>
809 <section id="Agent_2">
810 <title>Agent</title>
811 <para>The kind of agent to create.</para>
812 </section>
813 <section id="Selection_3">
814 <title>Selection</title>
815 <para>The selection to use as the basic for this selection. This is generally not important except to define control flow.</para>
816 </section>
817 <section id="Space_2">
818 <title>Space</title>
819 <para>Not generally relevant for agent actions, as agents are not placed into a space unless explicitly moved to that space. Potential associations between agents and spaces are defined by the space building actions.</para>
820 </section>
821 <section id="Agent_Count">
822 <title>Agent Count</title>
823 <para>The number of agents to create. If used as part of an enclosing context's Initialize Action(s) an Attribute parameter will automatically be created. If not, then an evaluation or agent attribute should be used to define this number.</para>
824 </section>
825 <section id="For_2">
826 <title>For</title>
827 <para>Deprected. Should not be used.</para>
828 </section>
829 </section>
830 <section id="Create_Shaped_Agent">
831 <title>Create Shaped Agent</title>
832 <para>Creates an agent that has a particular shape extent within some continuous (i.e. vector as opposed to raster) space. This action performs just like a Create Action except for the following attribute:</para>
833 <section id="Shape">
834 <title>Shape</title>
835 <para>Determines how each agent's spatial extent will be defined. The actual form of that shape is implementation specific. For example, in a GIS space (the immediate rationale for this Action) a polygon represents a region on a map and the extent of that shape might be determined by a .shape file. The available shape types are:</para>
836 <variablelist>
837 <varlistentry>
838 <term>Point</term>
839 <listitem>
840 <para>A simple point in space, fully equivalent to a standard continuous space location.</para>
841 </listitem>
842 </varlistentry>
843 <varlistentry>
844 <term>Line</term>
845 <listitem>
846 <para>A single line within a continuous space. Technically this represents a line segment as it is expected to have a beginning and ending point. In the future, this might refer more generically to planes in three dimensional space and hypersurfaces in n-dimensional spaces, but this is currently not supported by any AMF target implementations.</para>
847 </listitem>
848 </varlistentry>
849 <varlistentry>
850 <term>Polygon</term>
851 <listitem>
852 <para>A region within a space defined by an arbitrarily large set of line segments. Potentially this could be used to refer to polyhedrons in three-dimeensional space, or even more genrally as polytopes, but this is currently not supported by any AMF target implementations.</para>
853 </listitem>
854 </varlistentry>
855 </variablelist>
856 </section>
857 </section>
858 <section id="Load_Agents">
859 <title>Load Agents</title>
860 <para>Imports and creates a set of agents from some input file. The actual form and manner of the import is implementation specific but should be inferrable from any source file based on the URL provided, assuming that the target platform or the AMF platform supports the appropriate imput type. For example, a Tab-CR delimited file might be used to populate a set of agents with various attributes. Additional meta-data could be provided by the URL, but we will likely add additional extensible meta-data to this action to better support the definition of expected input types and routines from within an AMF model itself. This action is equivalent to the Create Agents action except for:</para>
861 <section id="Source_URL">
862 <title>Source URL</title>
863 <para>The location of the input file or set of meta-data used to determine the location and type of the input file.</para>
864 </section>
865 </section>
866 <section id="Load_Shaped_Agents">
867 <title>Load Shaped Agents</title>
868 <para>Combines the properties of the Create Shaped Agent and Load Agent Actions. The source url should of course specify an input format that supports the shape type specified. See the descriptions of the related actions for more details.</para>
869 </section>
870 <section id="Build_Network">
871 <title>Build Network</title>
872 <para>Creates a network, i.e. a graph structure, supporting the establishment of edges between arbitrary nodes.</para>
873 <section id="Agents_3">
874 <title>Agents</title>
875 <para>Specifies the set of agents that can exist within this network. Agents must be included here in order for them to make connections within the network but agents included here are not required to have connections within the network, nor are such connections created for them. (See important note regarding network types below.)</para>
876 </section>
877 <section id="Attributes_3">
878 <title>Attributes</title>
879 <para>Not currently used for networks.</para>
880 </section>
881 <section id="Network_Type">
882 <title>Network Type</title>
883 <para>Deprecated. This feature is only currently supported for Repast targets and is likely to be removed from future versions of the AMF meta-model. Future AMF implementations are likely will provide a different mechanism for instantiating and importing network structures either within the network defintion or through other Action definitions. Instead of using this feature, modelers should create specific networks by building them up with Connect Actions for indivdual agents. For example to create a small world netowrk, a modeler might create random links between agents and then replace or augment those connections.</para>
884 </section>
885 <section id="Selection_4">
886 <title>Selection</title>
887 <para>Not relevant for network builders except as part of normal control flow.</para>
888 </section>
889 </section>
890 <section id="Build_Grid">
891 <title>Build Grid</title>
892 <para>Creates a grid space.</para>
893 <section id="Agents_4">
894 <title>Agents</title>
895 <para>The set of agents that might exist as occupants of this grid; that is, members of individual cells within a given grid. Agents must be included here in order for instances to exist within the space, but agents included here do not actually have to exist within the space. (In the Repast implementation, all agents technically are memebers of the spatial projection, but are not required to have valid coordinates within that space.) For example, in an agriculture model these might represent agents moving about and harvesting plots of land.</para>
896 </section>
897 <section id="Fill_Agent">
898 <title>Fill Agent</title>
899 <para>The agent that will be used to populate the grid itself. A gird is guranteed to contain one and only one fill agent within each grid locaiton. The grid will be populated with instances of the specified agent and these agents cannot move, leave or die within this space. This value need not be specified -- if left blank a default cell without any state will be used. For example, in an agriculture model, this agent might represent a single plot of land.</para>
900 </section>
901 <section id="Space_Type">
902 <title>Space Type</title>
903 <para>Deprecated. Should not be used.</para>
904 </section>
905 <section id="Selection_5">
906 <title>Selection</title>
907 <para>Not relevant for builders except as part of normal control flow.</para>
908 </section>
909 <section id="Attributes_4">
910 <title>Attributes</title>
911 <para>Not currently used for spaces.</para>
912 </section>
913 </section>
914 <section id="Build_Space">
915 <title>Build Space</title>
916 <para>Creates a continous space. The actual dimensionality and other qualities of the space are currently defined in the space itself though this might change in future versions. All other values are used in the same way as for the gird and other builder actions.</para>
917 <section id="Agents_5">
918 <title>Agents</title>
919 <para>The set of agents that might be a part of this space. Agents must be included here in order for instances to exist within the space, but agents included here do not actually have to exist within the space. (In the Repast implementation, all agents technically are memebers of the spatial projection, but are not required to have valid coordinates within that space.)</para>
920 </section>
921 </section>
922 <section id="Build_Geography">
923 <title>Build Geography</title>
924 <para>Constructs a geographical space. All details of this space are specfied by the implementation, i.e. a specific geographical imported space. Generally these would be defined by a Create Agents action; that is a set of imported agents representing US states would also represent the overall space of interest.</para>
925 </section>
926 </section>
927 <section id="Commands">
928 <title>Commands</title>
929 <section id="Evaluate">
930 <title>Evaluate</title>
931 <para>Evaluate Actions define some calculation on a function based on the model state and a set of input(s). The inputs that an Evaluate Action can take is determined by its functions and can be either agent attributes, prior evaluations or literals. The result is then determined based on those inputs. In some cases Evaluate functions can be used to determine some action indirectly, such as with a graphics fill, but they can never be used to directly change model state.</para>
932 <section id="Selection_6">
933 <title>Selection</title>
934 <para>As with all other actions, evaluations specify a selection, and just as with the other actions, this determines the set of agents that the evaluation occurs for, but the input selections determine what agent is used for the calculation itself.</para>
935 </section>
936 <section id="Function_2">
937 <title>Function</title>
938 <para>A with queries, a function is evaluated against its input set. Functions can represent simple operators as well as complex functions. See the functions section for more information on specific functions.</para>
939 </section>
940 <section id="Inputs_2">
941 <title>Inputs</title>
942 <para>The set of values that will be used to determine the result, in the order of the function prototype. Inputs can specify any source evaluation and any agent state or agent parent context state. They can also be literal values -- see the discussion in the Tools section. The selection determines which agent's will be used to determine the value, and different inputs can specify different selections.</para>
943 </section>
944 </section>
945 <section id="Set">
946 <title>Set</title>
947 <para>The Set Action assigns some value to another value.</para>
948 <section id="Selection_7">
949 <title>Selection</title>
950 <para>Here the selection refers to the agent that we want to change. This does not have to be the immediatily preceeding selection but can be any accessible selection.</para>
951 </section>
952 <section id="Attribute_2">
953 <title>Attribute</title>
954 <para>The attribute to modify. It must be a member of this action's agent or of that agent's parent context.</para>
955 </section>
956 <section id="Parameter">
957 <title>Parameter</title>
958 <para>The value to assign to the attribute. Here, we can use either another agent attribute, or the results of a source evaluation. </para>
959 </section>
960 </section>
961 <section id="Move">
962 <title>Move</title>
963 <para>The Move Action causes an agent to change its location in some space or network. The agent will leave whatever location it was in before within the selection space, and move to its new destination.</para>
964 <section id="Selection_8">
965 <title>Selection</title>
966 <para>As in any other action, the selection determines what agent is affected -- in this case the agent that is being moved.</para>
967 </section>
968 <section id="Destination">
969 <title>Destination</title>
970 <para>Specifies the target agent or location for the movement.</para>
971 </section>
972 </section>
973 <section id="Leave">
974 <title>Leave</title>
975 <para>Causes the agent to leave a particular space.</para>
976 <section id="Selection_9">
977 <title>Selection</title>
978 <para>The selection determines what agent will be leaving and what space the agent will be leaving. If the agent doesn't exist in that space nothing will happen.</para>
979 </section>
980 <section id="Destination_2">
981 <title>Destination</title>
982 <para>The destination is irrelevant for a leave action and should not be specified.</para>
983 </section>
984 </section>
985 <section id="Die">
986 <title>Die</title>
987 <para>Causes the agent to cease to exist within the model as a whole.</para>
988 <section id="Selection_10">
989 <title>Selection</title>
990 <para>The selection determines what space the agent to remove.</para>
991 </section>
992 <section id=".3DDestination">
993 <title>=Destination</title>
994 <para>The destination is irrelevant in this case and will probably be removed.</para>
995 </section>
996 </section>
997 <section id="Connect">
998 <title>Connect</title>
999 <para>Connects two agents within a network space. This Action is not applicable for any other kinds of spaces. Note that unlike with other transformational commands, we do not use the destination space to determine the space that will be impacted by the Action. This provides a more efficient representation without any loss in generality, because it allows us to search for a source and target agent within other spaces and then create a connection without creating a separate selection. As the important structural feature of networks are the relationships themselves, not the nodes this provides a more direct way to specify these relationships.</para>
1000 <section id="Selection_11">
1001 <title>Selection</title>
1002 <para>The selection determines the agent that will be connected to another agent. In the case of a directed graph, this is the source node.</para>
1003 </section>
1004 <section id=".3DDestination_2">
1005 <title>=Destination</title>
1006 <para>The destination determines the agent that the selection agent will be connected to. In the case of a directed graph, this is the target node.</para>
1007 </section>
1008 <section id="Within">
1009 <title>Within</title>
1010 <para>Specifies the network that the connection will be created within.</para>
1011 </section>
1012 </section>
1013 <section id="Directed_2">
1014 <title>Directed</title>
1015 <para>Determines whether the connection made is directed or not. If true, selections from source agents will include the target, but target agent selections will not include the source agents (unless they are connected through some other path).</para>
1016 </section>
1017 <section id="Disconnect">
1018 <title>Disconnect</title>
1019 <para>Removes the connection between agents within a network space. See the description of the Connect Action for important details.</para>
1020 <section id="Selection_12">
1021 <title>Selection</title>
1022 <para>The selection determines one side of the agent relationship that will be disconnected.</para>
1023 </section>
1024 <section id="Destination_3">
1025 <title>Destination</title>
1026 <para>The selection determines one other side of the agent relationship that will be disconnected.</para>
1027 </section>
1028 <section id="Within_2">
1029 <title>Within</title>
1030 <para>Specifies the network that the connection will be created within.</para>
1031 </section>
1032 </section>
1033 <section id="Replace">
1034 <title>Replace</title>
1035 <para>Functions in the same way as a Connect Action excepth that all other connections to other agents will first be removed.</para>
1036 <section id="Selection_13">
1037 <title>Selection</title>
1038 <para>The selection determines the agent that will be connected to another agent. In the case of a directed graph, this is the source node.</para>
1039 </section>
1040 <section id="Destination_4">
1041 <title>Destination</title>
1042 <para>The destination determines the agent that the selection agent will be connected to. In the case of a directed graph, this is the target node.</para>
1043 </section>
1044 <section id="Within_3">
1045 <title>Within</title>
1046 <para>Specifies the network that the connection will be created within.</para>
1047 </section>
1048 </section>
1049 <section id="Directed_3">
1050 <title>Directed</title>
1051 <para>Determines whether the connection made is directed or not. See the Connect description for more details.</para>
1052 </section>
1053 </section>
1054 <section id="Other">
1055 <title>Other</title>
1056 <section id="Method">
1057 <title>Method</title>
1058 <para>The Method action supports inclusion of arbitrary code within a generated method. Generally, this will be Java code as all of the current target platforms are Java-based but there is no technical requirement that it must be. For example, if a target has been developed to produce code for Swarm running on an iPad (and no, there are no current plans to support such a thing, though it would certainly be cool!) then the modeler could define Objective C code for the method.</para>
1059 <para>Please note that the Method Action should be avoided whenever possible. You should consider using it only in the case where there doesn't appear to be a way to construct equivalent functionality using the native Actions framework, such as when interfacing with third party APIs. The aim of Actions is to provide the most general support for Agent Modeling possible without compromising the core design. Any use of native Java code strongly limits the set of platforms that your model will be able to generate code for and prevents you from using the AMF edit tools to explore the model behavior. In the case where you wish to construct a model feature and believe that it isn't possible or practical to do it with Actions, please contact us (see support section) so that we can suggest how you can accomplish what you want within Actions. If that is not possible, we'll consider developing new features that will support what you want to do.</para>
1060 <para>On the other hand, you may simply wish to use the Agent Modeling Framework to build a scaffolding for your model -- perhaps using your own custom Java framework for example -- and Method would be a good way to accomplish that. Also, note there are a number of other approaches to mixing hand-crafted Java together with AMF generated code. Please see the Programmer's Guide section "Integrating Java and AMF Models" for more on that.</para>
1061 <para>If you do decide to use the Method Action, keep in mind the following design practice recommendations:</para>
1062 <orderedlist inheritnum="ignore" continuation="restarts">
1063 <listitem>
1064 <para>Keep your usage of external API references to a minimum. If you can use only code provied by the core Java classes as well as the Apache Collections library, your code should work on every current Java target. On the other hand, if you make use of a specific ABM platform APIs your code will obviously only compile and run against that target.</para>
1065 </listitem>
1066 <listitem>
1067 <para>Code should be in the form of a method body, excluding the signature. A single Java method is created using this code body. There is no support for input parameters -- if you need access to evaluated values from source actions, create agent attributes for them, set their values for the selected agents, and use them as sources for your Method Action.</para>
1068 </listitem>
1069 <listitem>
1070 <para>All Java class references should be fully qualified. For example, if you wish to use the eclipse Draw2D Graphics class, you should refer to "org.eclipse.draw2d.Graphics", not simply "Graphics". If classes are not fully qualified, you will recieve compile errors. You can usually easily fix these by selecting your source code directory and choosing
1071 <emphasis role="bold">Source &gt; Organize Imports..</emphasis> but it prevents automatic code generation.
1072 </para>
1073 </listitem>
1074 <listitem>
1075 <para>The method interface has no support for code completion, syntax checking or other common Java development environment features. You can avoid code maintenance and even support targetting multiple APIs by using the following technique. From your method body, call a helper method in a seperate class. The referred class could use a static method call, or you could instantiate the class and call a method against it, passing in the agent class so that the helper class can reference the agent's state. For example, if you wanted to use some custom java code to import agents from a specialized input file, you could put the following code in the Method Action body for the root Context:</para>
1076 </listitem>
1077 </orderedlist>
1078 <literallayout format="linespecific" class="normal">(new;
1080 <para>Then create a new source directory in your project called "src" (
1081 <emphasis role="bold">New &gt; Source Folder...</emphasis>) and create the class for the specialized file loader including the following method:
1082 </para>
1083 <literallayout format="linespecific" class="normal">public void load(MyRootModel model) {...}
1085 <para>This approach allows you to a) maintain the working code using the Java Development Environment, b) avoid changes to the Method Action within the model, and most importantly, c) allow other implementations of the code using multiple APIs. For example, if you need to create a specialized graphics routine, you could create seperate implementations for your Escape (Eclipse Draw 2D), Ascape (Java Swing), and Repast (Simphony API) and place them in the appropriate projects. As long as the different Java source files have the same names and signatures, they will all compile correctly and execute the appropriate behavior.</para>
1086 <section id="Selection_14">
1087 <title>Selection</title>
1088 <para>The selection determines what Agent class the code will be created within and the set of agents the method will be called upon.</para>
1089 </section>
1090 <section id="Body">
1091 <title>Body</title>
1092 <para>The actual code to insert in the method body. See the detailed recommendations for code use above.</para>
1093 </section>
1094 <section id="Generate">
1095 <title>Generate</title>
1096 <para>Determines wether the code is actually inserted. If this is false, a bare method body will be constructed instead. This can be useful if you wish to turn off method generation in certain model implementaitons without removing the actual code.</para>
1097 </section>
1098 </section>
1099 </section>
1100 <section id="Query_and_Evaluation_Inputs">
1101 <title>Query and Evaluation Inputs</title>
1102 <para>Query and Evaluation Actions are both "Sinks" which means that they are capable of containing inputs. When you select a function, the appropriate number of inputs will be created. After selecting a function, you can view and select the inputs. The choices for the inputs will be constrained by the type of the function and the other operands you've selected.</para>
1103 <section id="Input_Literals">
1104 <section>
1105 <title>Input Literals</title>
1106 <para>Inputs can take literal values; that is values that you specify simply by entering them directly into the query. In general it is useful to think of literals as similar to local variables in a conventional programming language, whereas attributes are analogous to member variables. (And this is how they are represented in the generated Java code.) As with local variables in model code, literals are not recommended for any values that can change model behavior. The value cannot be easily accessed or changed by other model users. For greater transparency, you should instead create an Attribute with an appropriate default value, setting the "immutable" value to true. Still, literals can be useful for values that are special cases related to the evaluation or query, such as an input code, and for quickly prototyping functionality.</para>
1107 </section>
1108 </section>
1109 </section>
1110 </section>
1111 <section id="Example">
1112 <title>Example</title>
1113 <para>In this section, we'll look at an example that should make clear how the basic Actions approach works in a model. Say we want to define a behavior like:</para>
1114 <literallayout format="linespecific" class="normal">"Search for a random agent within my vision that is the same age as I am. Find a location next to that agent that is not already occupied and move to it."
1116 <para>Here, we create a sequence of actions like so:</para>
1117 <orderedlist inheritnum="ignore" continuation="restarts">
1118 <listitem>
1119 <para>Select every agent for every period of the model. ("Find Partner" Rule)</para>
1120 </listitem>
1121 <listitem>
1122 <para>For every member of that selection, search for other agents of the same age within vision distance. ("Partner" selection.)</para>
1123 </listitem>
1124 <listitem>
1125 <para>From "Partners" find a random member and search for a neighboring locations. ("Partner Neighbor" selection.)</para>
1126 </listitem>
1127 <listitem>
1128 <para>Finally, move the agent in "Find Partner" to the "Partner Neighbor" location.</para>
1129 </listitem>
1130 </orderedlist>
1131 <para>Now, notice that although it's convenient to speak as if there is only one "Find Partner" and one "Partner Neighbor" in step 4 above, in fact selections are flowing through for each of the results of each of the previous action sequences, and we can refer to each of the directly. We could represent these behaviors in many different ways. For example, we might want to specify the model in a (hand-drawn) graphical language or in a (made-up) textual language:</para>
1132 <para>
1133 <mediaobject>
1134 <imageobject>
1135 <imagedata fileref="images/actions/ActionsExample.png" scale="50"/>
1136 </imageobject>
1137 </mediaobject>
1138 </para>
1139 <para>This is how it looks in an actual model:</para>
1140 <para>
1141 <mediaobject>
1142 <imageobject>
1143 <imagedata fileref="images/actions/ActionsExampleNew.png" scale="50"/>
1144 </imageobject>
1145 </mediaobject>
1146 </para>
1147 <para>And here is how this works in detail:</para>
1148 <orderedlist inheritnum="ignore" continuation="restarts">
1149 <listitem>
1150 <para>Create a Rule that will trigger the behavior. In this case, we want this rule to apply to all "Individual" agents within the model. (Space isn't relevant in this case.</para>
1151 </listitem>
1152 <listitem>
1153 <para>Create a child Select Action that will find our partner. Two important things to note here:</para>
1154 <orderedlist inheritnum="ignore" continuation="restarts">
1155 <listitem>
1156 <para>The selection occurs based on the "Find Partner" selection. This means that for each Individual in the model, we'll be searching from the point of view of that agent to some other selection of agents.</para>
1157 </listitem>
1158 <listitem>
1159 <para>We also need to define what type of agent we want and in this case the space does matter. We want to find an agent that is nearby within the City space. If instead we wanted to find a partner in a social network, we'd specify that instead.</para>
1160 </listitem>
1161 </orderedlist>
1162 </listitem>
1163 <listitem>
1164 <para>Create two child Query Actions:</para>
1165 <orderedlist inheritnum="ignore" continuation="restarts">
1166 <listitem>
1167 <para>We want to search for someone who is the same age as us. This highlights the importance of the idea of the Selection in the Actions design. We're qualifying Age by the rule agent's partner for the first input and by the rule agent for the second. The selection carries throughout the flow of execution and this context is an explicit part of the entire structure. Note that this is very different from the way control flow works in a traditional imperative language such as Java.</para>
1168 </listitem>
1169 <listitem>
1170 <para>We also want to search using a function for nearness, "within", which takes a parameter of vision. Note that the spatial functions are all polymorphic -- if we decided later on that we would rather search within say "Kevin Bacon space", that is a graph structure representation of space, we would only need to change the space we've defined in Select Partner.</para>
1171 </listitem>
1172 </orderedlist>
1173 </listitem>
1174 <listitem>
1175 <para>Intersect the results of these two query components. This delineates the end of the selection definition for any target Actions.</para>
1176 </listitem>
1177 <listitem>
1178 <para>Select a neighbor. Again, we can see the importance of Selections. Here, we are selecting from the point of view of the partner, not the initial agent that the current Rule is being executed for. Note that this time our target agent is a "Block", that is, a location within the city.</para>
1179 </listitem>
1180 <listitem>
1181 <para>As above, define some queries. This time we want only those agents that are:</para>
1182 <orderedlist inheritnum="ignore" continuation="restarts">
1183 <listitem>
1184 <para>available, and</para>
1185 </listitem>
1186 <listitem>
1187 <para>neighbors of our partner.</para>
1188 </listitem>
1189 </orderedlist>
1190 </listitem>
1191 <listitem>
1192 <para>And another intersection..</para>
1193 </listitem>
1194 <listitem>
1195 <para>Finally, we move to the location we've found. All that's required at this point is to specify:</para>
1196 <orderedlist inheritnum="ignore" continuation="restarts">
1197 <listitem>
1198 <para>The movement selection, or those agents that are moving, which in this case is the original agent we're executing the rule for, and</para>
1199 </listitem>
1200 <listitem>
1201 <para>The destination, which is the cell that we've found. Note that the framework infers from the space definition that the Block agent is capable of hosting the Individual.</para>
1202 </listitem>
1203 </orderedlist>
1204 </listitem>
1205 </orderedlist>
1206 </section>
1207 <section id="Reference_2">
1208 <title>Reference</title>
1209 <section id="Diagrams_2">
1210 <title>Diagrams</title>
1211 <para>The following diagram may be helpful to readers familiar with UML and Meta-modeling:</para>
1212 <section id="Meta-Classes_2">
1213 <title>Meta-Classes</title>
1214 <para>
1215 <mediaobject>
1216 <imageobject>
1217 <imagedata fileref="images/actions/ActionsDiagram.png" scale="50"/>
1218 </imageobject>
1219 </mediaobject>
1220 </para>
1221 </section>
1222 <section id="Details_4">
1223 <title>Details</title>
1224 <para>In the diagram above, all meta-objects except for Input, Literal, and the enumerators (lists of options) are Actions. Blue meta-classes are concrete (you can create and use them directly). Red meta-classes are key collaborations.</para>
1225 <orderedlist inheritnum="ignore" continuation="restarts">
1226 <listitem>
1227 <para>An Act is anything that might happen during the execution of an Agent-Based Model.</para>
1228 </listitem>
1229 <listitem>
1230 <para>All Actions have as their root-most source action a Root. These are added first to any agent behavior and act as triggers for all target behavior. For example, a Watch will execute any time the watched attribute is modified. (As the diagrams do not refer to elements outside of the current package, we cannot see here that Accessor includes a reference to some Attribute, but it does. To see these kinds of relationships you will want to refer to the metaabm.ecore file itself.)#Actions are targets and sources of one another, but an Act can never have itself as a source. (That is, Actions are acyclic, but branches can re-converge. When we refer to an Act source or target, we typically mean to include all ancestors or descendants, not just the immediately connected Act.)</para>
1231 </listitem>
1232 <listitem>
1233 <para>All Actions (except for root Actions) reference a Select, referred to as the "selected" relation. An ASelect represents the model aspects that the Act is working within; that is, the spatial, temporal and type (agent) "world" that is currently being selected.</para>
1234 </listitem>
1235 <listitem>
1236 <para>Commands trigger some model state change (Set) or spatial transformation (Transform).</para>
1237 </listitem>
1238 <listitem>
1239 <para>Controls determine whether target Actions are executed and against what agents. They are in some sense query terms and include Query actions and Logic Actions.</para>
1240 </listitem>
1241 <listitem>
1242 <para>Transforms also specify a "destination" Select. This represents aspects that the selected agent(s) will transform to. For example, a Move may use a Rule to select all SugarAgents (type) in the SugarGrid (space) every period (time) and move them to a destination of a neighboring SugarCell (type) in the SugarGrid (space, with time implicit).</para>
1243 </listitem>
1244 <listitem>
1245 <para>Sinks are Actions which use some Function (see next section) to interpret state in the form of Inputs. Inputs can come from selected agent attributes, other Actions, or literal values.</para>
1246 </listitem>
1247 </orderedlist>
1248 </section>
1249 </section>
1250 </section>
1251 </section>
1252 <section id="Functions">
1253 <title>Functions</title>
1254 <section id="Overview_4">
1255 <title>Overview</title>
1256 <para>Functions are relatively simple in terms of model design, but we need to understand how particular functions work in order to develop models. Functions are divided in two ways. By type:</para>
1257 <orderedlist inheritnum="ignore" continuation="restarts">
1258 <listitem>
1259 <para>Operators are simple calculations sharing the same type.</para>
1260 </listitem>
1261 <listitem>
1262 <para>Functions that can represent any general function that takes some well-defined input(s) and returns some well-defined output(s).</para>
1263 </listitem>
1264 </orderedlist>
1265 <para>And by usage:</para>
1266 <orderedlist inheritnum="ignore" continuation="restarts">
1267 <listitem>
1268 <para>Generics can return any value and are used in Evaluate actions.</para>
1269 </listitem>
1270 <listitem>
1271 <para>Logicals return some boolean result and are used by Query actions to decide whether target Actions apply to a particular selection, and by Evaluate actions just as with any other functions. Input types should be defined as generally as possible.</para>
1272 </listitem>
1273 </orderedlist>
1274 <para>These overlap, so we have operators, logical operators, functions and logical functions. Functions are also divided into categories. We'll go through each of these in depth below.</para>
1275 <para>The most important thing to point out about functions is that - as we've seen with other Acore concepts -- they provide richer sets of functionality than traditional approaches. Many functions are designed to collaborate with one another as we'll see when looking at Spatial and Graphical functions. Functions can also trigger the creation of related model artifacts as we'll see with the Distribution functions.</para>
1276 <para>A technical note: conceptually, functions can return multi-values, but that is not currently implemented in the reference targets because of limitations of the target language Java.</para>
1277 </section>
1278 <section id="Details_5">
1279 <title>Details</title>
1280 <section id="General_Functions">
1281 <title>General Functions</title>
1282 <para>Naturally, the Modeling tools provide general functions for performing calculations, comparisons and more complex mathematical expressions. The function library can be easily extended, and we'll be adding additional capabilities over time. As always, we welcome feedback and we'd like to hear what functions you need that aren't covered here.</para>
1283 <section id="Logical_Operators">
1284 <title>Logical Operators</title>
1285 <section id="Not">
1286 <title>Not</title>
1287 <para>The result of the expression !X.</para>
1288 </section>
1289 <section id="Equal">
1290 <title>Equal</title>
1291 <para>The result of the expression X==Y.</para>
1292 </section>
1293 <section id="Identical">
1294 <title>Identical</title>
1295 <para>The result of the expression X==Y.</para>
1296 </section>
1297 <section id="Greater">
1298 <title>Greater</title>
1299 <para>The result of the expression X&gt;Y.</para>
1300 </section>
1301 <section id="Lesser">
1302 <title>Lesser</title>
1303 <para>The result of the expression X&lt;Y.</para>
1304 </section>
1305 <section id="Greater_or_Equal">
1306 <title>Greater or Equal</title>
1307 <para>The result of the expression X&gt;=Y.</para>
1308 </section>
1309 <section id="Lesser_or_Equal">
1310 <title>Lesser or Equal</title>
1311 <para>The result of the expression X&lt;=Y.</para>
1312 </section>
1313 <section id="True">
1314 <title>True</title>
1315 <para>The result of the expression true.</para>
1316 </section>
1317 <section id="False">
1318 <title>False</title>
1319 <para>The result of the expression false.</para>
1320 </section>
1321 <section id="Identity">
1322 <title>Identity</title>
1323 <para>The result of the expression X.</para>
1324 </section>
1325 <section id="Different">
1326 <title>Different</title>
1327 <para>The result of the expression X!=Y.</para>
1328 </section>
1329 </section>
1330 <section id="Numeric_Operators">
1331 <title>Numeric Operators</title>
1332 <section id="Negative_Value">
1333 <title>Negative Value</title>
1334 <para>The result of the expression -X.</para>
1335 </section>
1336 <section id="Add">
1337 <title>Add</title>
1338 <para>The result of the expression X+Y.</para>
1339 </section>
1340 <section id="Subtract">
1341 <title>Subtract</title>
1342 <para>The result of the expression X-Y.</para>
1343 </section>
1344 <section id="Multiply">
1345 <title>Multiply</title>
1346 <para>The result of the expression X*Y.</para>
1347 </section>
1348 <section id="Divide">
1349 <title>Divide</title>
1350 <para>The result of the expression X/Y.</para>
1351 </section>
1352 <section id="Power">
1353 <title>Power</title>
1354 <para>The result of the expression X^Y.</para>
1355 </section>
1356 <section id="Modulo">
1357 <title>Modulo</title>
1358 <para>The result of the expression X%Y.</para>
1359 </section>
1360 <section id="Increment">
1361 <title>Increment</title>
1362 <para>The result of the expression ++X.</para>
1363 </section>
1364 <section id="Decrement">
1365 <title>Decrement</title>
1366 <para>The result of the expression --X.</para>
1367 </section>
1368 <section id="Unit_Value">
1369 <title>Unit Value</title>
1370 <para>The result of the expression 1.</para>
1371 </section>
1372 <section id="Zero_Value">
1373 <title>Zero Value</title>
1374 <para>The result of the expression 0.</para>
1375 </section>
1376 <section id="Original_Value">
1377 <title>Original Value</title>
1378 <para>The result of the expression o.</para>
1379 </section>
1380 </section>
1381 <section id="Math">
1382 <title>Math</title>
1383 <para>The math functions use the extremely well specified and tested routines form the Java Math library. (Because of copyright restrictions, we aren't able to include the exact definitions here. Click on the links to get more details on each function.)</para>
1384 <section id="Sine">
1385 <title>Sine</title>
1386 <para>See JavaDoc:
1387 <ulink url=""></ulink>
1388 </para>
1389 </section>
1390 <section id="Cosine">
1391 <title>Cosine</title>
1392 <para>See JavaDoc:
1393 <ulink url=""></ulink>
1394 </para>
1395 </section>
1396 <section id="Tangent">
1397 <title>Tangent</title>
1398 <para>See JavaDoc:
1399 <ulink url=""></ulink>
1400 </para>
1401 </section>
1402 <section id="Arc_Sine">
1403 <title>Arc Sine</title>
1404 <para>See JavaDoc:
1405 <ulink url=""></ulink>
1406 </para>
1407 </section>
1408 <section id="Arc_Cosine">
1409 <title>Arc Cosine</title>
1410 <para>See JavaDoc:
1411 <ulink url=""></ulink>
1412 </para>
1413 </section>
1414 <section id="Arc_Tangent">
1415 <title>Arc Tangent</title>
1416 <para>See JavaDoc:
1417 <ulink url=""></ulink>
1418 </para>
1419 </section>
1420 <section id="Convert_Degree_to_Radians">
1421 <title>Convert Degree to Radians</title>
1422 <para>See JavaDoc:
1423 <ulink url=""></ulink>
1424 </para>
1425 </section>
1426 <section id="Convert_Radians_to_Degrees">
1427 <title>Convert Radians to Degrees</title>
1428 <para>See JavaDoc:
1429 <ulink url=""></ulink>
1430 </para>
1431 </section>
1432 <section id="Exp">
1433 <title>Exp</title>
1434 <para>See JavaDoc:
1435 <ulink url=""></ulink>
1436 </para>
1437 </section>
1438 <section id="Log">
1439 <title>Log</title>
1440 <para>See JavaDoc:
1441 <ulink url=""></ulink>
1442 </para>
1443 </section>
1444 <section id="Log_b10">
1445 <title>Log b10</title>
1446 <para>See JavaDoc:
1447 <ulink url=""></ulink>
1448 </para>
1449 </section>
1450 <section id="Square_Root">
1451 <title>Square Root</title>
1452 <para>See JavaDoc:
1453 <ulink url=""></ulink>
1454 </para>
1455 </section>
1456 <section id="Cube_Root">
1457 <title>Cube Root</title>
1458 <para>See JavaDoc:
1459 <ulink url=""></ulink>
1460 </para>
1461 </section>
1462 <section id="Remainder">
1463 <title>Remainder</title>
1464 <para>See JavaDoc:
1465 <ulink url=",%20double)">,%20double)</ulink>
1466 </para>
1467 </section>
1468 <section id="Ceiling">
1469 <title>Ceiling</title>
1470 <para>See JavaDoc:
1471 <ulink url=""></ulink>
1472 </para>
1473 </section>
1474 <section id="Floor">
1475 <title>Floor</title>
1476 <para>See JavaDoc:
1477 <ulink url=""></ulink>
1478 </para>
1479 </section>
1480 <section id="Rount">
1481 <title>Rount</title>
1482 <para>See JavaDoc:
1483 <ulink url=""></ulink>
1484 </para>
1485 </section>
1486 <section id="Arc_Tangent_Rectangular">
1487 <title>Arc Tangent Rectangular</title>
1488 <para>See JavaDoc:
1489 <ulink url=",%20double)">,%20double)</ulink>
1490 </para>
1491 </section>
1492 <section id="Power_2">
1493 <title>Power</title>
1494 <para>See JavaDoc:
1495 <ulink url=",%20double)">,%20double)</ulink>
1496 </para>
1497 </section>
1498 <section id="Absolute_Value">
1499 <title>Absolute Value</title>
1500 <para>See JavaDoc:
1501 <ulink url=""></ulink>
1502 </para>
1503 </section>
1504 <section id="Maximum">
1505 <title>Maximum</title>
1506 <para>See JavaDoc:
1507 <ulink url=",%20double)">,%20double)</ulink>
1508 </para>
1509 </section>
1510 <section id="Minimum">
1511 <title>Minimum</title>
1512 <para>See JavaDoc:
1513 <ulink url=",%20double)">,%20double)</ulink>
1514 </para>
1515 </section>
1516 <section id="ULP">
1517 <title>ULP</title>
1518 <para>See JavaDoc:
1519 <ulink url=""></ulink>
1520 </para>
1521 </section>
1522 <section id="Sign">
1523 <title>Sign</title>
1524 <para>See JavaDoc:
1525 <ulink url=""></ulink>
1526 </para>
1527 </section>
1528 <section id="Hyperbolic_Sine">
1529 <title>Hyperbolic Sine</title>
1530 <para>See JavaDoc:
1531 <ulink url=""></ulink>
1532 </para>
1533 </section>
1534 <section id="Hyperbolic_Cosine">
1535 <title>Hyperbolic Cosine</title>
1536 <para>See JavaDoc:
1537 <ulink url=""></ulink>
1538 </para>
1539 </section>
1540 <section id="Hyperbolic_Tan">
1541 <title>Hyperbolic Tan</title>
1542 <para>See JavaDoc:
1543 <ulink url=""></ulink>
1544 </para>
1545 </section>
1546 <section id="Hypotuneuse">
1547 <title>Hypotuneuse</title>
1548 <para>See JavaDoc:
1549 <ulink url=",%20double)">,%20double)</ulink>
1550 </para>
1551 </section>
1552 <section id="Expm1">
1553 <title>Expm1</title>
1554 <para>See JavaDoc:
1555 <ulink url=""></ulink>
1556 </para>
1557 </section>
1558 <section id="Log1p">
1559 <title>Log1p</title>
1560 <para>See JavaDoc:
1561 <ulink url=""></ulink>
1562 </para>
1563 </section>
1564 </section>
1565 </section>
1566 <section id="Random">
1567 <title>Random</title>
1568 <section id="Design">
1569 <title>Design</title>
1570 <para>Random functions are especially significant for agent models. Of particular interest are the weighted membership and random state and boolean value functions. You should be familiar with these functions so that you don't have to create more complex Action flows to accomplish the same thing.</para>
1571 <para>Note that we only have support for uniform distributions as of this release. We're working on a collaborative design for evaluations that allow easy mixing and matching of random functions and distributions.</para>
1572 </section>
1573 <section id="Details_6">
1574 <title>Details</title>
1575 <section id="Random_In_Range">
1576 <title>Random In Range</title>
1577 <para>A pseudo-random value within that numeric range specified as drawn from a uniform distribution. The minimum values are inclusive. The maximum values are inclusive for integer inputs and exclusive for Real inputs.</para>
1578 <literallayout format="linespecific" class="normal">Inputs:
1579[Numeral] The minimum value (inclusive).
1580[Numeral] The maximum value (inclusive).
1582[Numeral] The random number.
1584 </section>
1585 <section id="Random_To_Limit">
1586 <title>Random To Limit</title>
1587 <para>A pseudo-random value between zero and the value specified by the (non-zero) input and drawn from a uniform range. That value is inclusive for Integers and exclusive for Reals. (Note that as with the random in range function in the context of real numbers the distinction between an exclusive and inclusive limit is essentially meaningless.)</para>
1588 <literallayout format="linespecific" class="normal">Inputs:
1589[Numeral] The maximum value (inclusive).
1591[Numeral] The result.
1593 </section>
1594 <section id="Random_Unit">
1595 <title>Random Unit</title>
1596 <para>A pseudo-random Real value between 0 and 1 drawn from a uniform distribution. (The distinction between inclusive and exclusive range is essentially meaningless in this context and we can assume that the result will never be greater or equal to 1.)</para>
1597 <literallayout format="linespecific" class="normal">Outputs:
1600 </section>
1601 <section id="Random_Boolean">
1602 <title>Random Boolean</title>
1603 <para>A value that is randomly true or false, i.e. a fair coin toss.</para>
1604 </section>
1605 <section id="Random_Weighted">
1606 <title>Random Weighted</title>
1607 <para>An indexed value weighted against a probability distribution. The total probability must sum to 1.0. For example, an input of {.1,.2,.7} under a uniform distribution would would have 10% probability of producing "0" , 20% for "1" and 70% for "2". This function can then be used with Item to return a biased result from another list.</para>
1608 <literallayout format="linespecific" class="normal">Inputs:
1609[Real] A list of values that will determine the resulting weighted index.
1611[Integer] A resulting indexed value bounded by 0 and the length of the input list - 1.
1613 </section>
1614 <section id="Random_Member">
1615 <title>Random Member</title>
1616 <para>Represents a random value drawn from the set of Real values specified.</para>
1617 <literallayout format="linespecific" class="normal">Inputs:
1618[Real] Returns a random member of the supplied list of numbers.
1620[Generic] The value of the item at a random index.
1622 </section>
1623 <section id="Random_State">
1624 <title>Random State</title>
1625 <para>A random specified value (option) from the specified state.</para>
1626 <literallayout format="linespecific" class="normal">Inputs:
1627[Generic] The state to select items from. All items are included.
1629[Boolean] The resulting option.
1631 </section>
1632 </section>
1633 </section>
1634 <section id="Space_3">
1635 <title>Space</title>
1636 <section id="Design_2">
1637 <title>Design</title>
1638 <para>Spatial functions provide the core functionality for Agent Models. Spatial functions are polymorphic, which basically means that they don't care what space they are operating on as long as that space is suitable for them. Spatial functions are designed to collaborate with one another. For example, by intersecting the "Neighbor", "Available" and "Toward" functions, we can design a rule that causes the agent to move to the next neighboring cell that get's it closer to some target agent. See the function details for more information.</para>
1639 </section>
1640 <section id="Details_7">
1641 <title>Details</title>
1642 <section id="Nearest">
1643 <title>Nearest</title>
1644 <para>Represents the nearest agents (including gird cells) or locations to this agent. If more than one agent or location is the same distance away they will all be considered. Note that while this function is defined for the selection of an agent, the result of this function is defined by the context within which it is used. If the selection specifies another agent within a space, this function will represent the nearest agent in that space. If the selection specifies a Cell within a grid space, this function will represent that cell.</para>
1645 </section>
1646 <section id="Toward">
1647 <title>Toward</title>
1648 <para>Represents a location that is on the shortest path to a particular agent or location from the source agent (that is, the selection's selection's agent). This function collaborates with the within and neighbor functions to allow the agent to move in a particular direction towards some objective.</para>
1649 </section>
1650 <section id="Within_4">
1651 <title>Within</title>
1652 <para>Represents a limit to the distance of a spatial search. When used in combination with other spatial functions such as "nearest" requires that all agents or locations must be within the distance specified by the input value.</para>
1653 <literallayout format="linespecific" class="normal">Inputs:
1656 </section>
1657 <section id="Neighbor">
1658 <title>Neighbor</title>
1659 <para>Represents any agents that are nearest neighbors to the agent, that is nominally of distance 1. This function is only relevant in discrete spaces -- grids and networks -- where there are immediate neighboring cells as defined by the geometry of the selection's space.</para>
1660 </section>
1661 <section id="Include_Self">
1662 <title>Include Self</title>
1663 <para>Specifies whether the agent that we are searching from -- that is, the agent of the selection for this Query Action's selection -- is included in the results of the search.</para>
1664 </section>
1665 <section id="Within_2D_Boundary">
1666 <title>Within 2D Boundary</title>
1667 <para>Represents agents or locations that exist within the boundary specified by the inputs.</para>
1668 <literallayout format="linespecific" class="normal">Inputs:
1671 </section>
1672 <section id="Here">
1673 <title>Here</title>
1674 <para>Represents the location of the searching agent. For example, if a selection is defined for an agent cell, and that selection's selection's agent is an occupant of a cell, the cell that the agent is occupying will be used. </para>
1675 </section>
1676 <section id="Available">
1677 <title>Available</title>
1678 <para>Represents cells which are not currently occupied. This function is only relevant for grids which are not multi-occupant.</para>
1679 </section>
1680 <section id="Distance">
1681 <title>Distance</title>
1682 <para>The distance between the source agent and an agent represented by this selection. If more than one agent is represented by the other functions in the selection, this function will the distance to an arbitrary (randomly selected) agent as defined by those other functions.</para>
1683 <literallayout format="linespecific" class="normal">Outputs:
1686 </section>
1687 <section id="Away">
1688 <title>Away</title>
1689 <para>Represents a location that is on the path that will take the source agent (that is, the selection's selection's agent) the farthest distance from the agent(s) represented by the search. This function collaborates with the within and neighbor functions to allow the agent to move in a particular direction away from some location or agent.</para>
1690 </section>
1691 <section id="Minimize">
1692 <title>Minimize</title>
1693 <para>This function is not currently supported.</para>
1694 </section>
1695 <section id="Maximize">
1696 <title>Maximize</title>
1697 <para>This function is not currently supported.</para>
1698 </section>
1699 <section id="Location_2D">
1700 <title>Location 2D</title>
1701 <para>Represents the location of the current agent for use in subsequent selections.</para>
1702 <literallayout format="linespecific" class="normal">Inputs:
1706 </section>
1707 <section id="Boundary_2D">
1708 <title>Boundary 2D</title>
1709 <para>Represents a two-dimensional boundary within a space. (Not currently relevant for any general usages.)</para>
1710 <literallayout format="linespecific" class="normal">Outputs:
1714 </section>
1715 </section>
1716 <section id="Example_2">
1717 <title>Example</title>
1718 <para>For examples of how spatial functions can be used within action flows to provide agents with complex movement behaviors, see the Modelers Guide actions examples. In the following example from that section, we define an action that causes a partner agent to move to an available neighboring space.</para>
1719 <para>
1720 <mediaobject>
1721 <imageobject>
1722 <imagedata fileref="images/actions/ActionsExampleNew.png" scale="50"/>
1723 </imageobject>
1724 </mediaobject>
1725 </para>
1726 </section>
1727 </section>
1728 <section id="Time">
1729 <title>Time</title>
1730 <section id="Details_8">
1731 <title>Details</title>
1732 <section id="Now">
1733 <title>Now</title>
1734 <para>The current simulation period, that is the number of iterations that the model has gone through, or in the case of models with callibrarted time, the number of iterations added to the model's nominal start time.</para>
1735 <literallayout format="linespecific" class="normal">Outputs:
1736[Integer] The current period.
1738 </section>
1739 </section>
1740 </section>
1741 <section id="Graphics">
1742 <title>Graphics</title>
1743 <section id="Design_3">
1744 <title>Design</title>
1745 <para>Graphic functions are combined within Style Evaluate Actions to determine how to draw an agent within a visualization. One nice aspect of this approach is that the same style definition can be used in multiple places without changing any code. For example, the same style could be used to draw an agent on a two-dimensional grid within Escape, a three-dimensional shape within Escape, a Java Swing based visualization in Ascape, and an XML configured visualizaiton in Repast Simphony.</para>
1746 <para>To define a graphic style for an agent, design a flow in which you create Evaluate Actions for color and shape, and then create an Evaluate Action with the graphic fill or outline function as a target of these.</para>
1747 </section>
1748 <section id="Details_9">
1749 <title>Details</title>
1750 <section id="Shape_Oval">
1751 <title>Shape Oval</title>
1752 <para>Draw a generic oval.</para>
1753 </section>
1754 <section id="Shape_Rectangle">
1755 <title>Shape Rectangle</title>
1756 <para>Draws a rectangular shape.</para>
1757 </section>
1758 <section id="Shape_Inset">
1759 <title>Shape Inset</title>
1760 <para>Shrinks the current shape by the input amount. (The overall scale is currently unspecified, but in most implementations should be 20.)</para>
1761 <literallayout format="linespecific" class="normal">Inputs:
1762[Integer] Number of nominal pixels to inset.
1764 </section>
1765 <section id="Shape_Marker">
1766 <title>Shape Marker</title>
1767 <para>Draw a marker, that is a graphical indicator that can be used to add an additional cue about the object state. For example, in a two-dimensional graphics representation this might be a small shape drawn inset at the corner of the larger shape. </para>
1768 </section>
1769 <section id="Shape_Marker_2">
1770 <title>Shape Marker 2</title>
1771 <para>Represents a marker placed in a different location from the other shape markers.</para>
1772 </section>
1773 <section id="Shape_Marker_3">
1774 <title>Shape Marker 3</title>
1775 <para>Represents a marker placed in a different location from the other shape markers.</para>
1776 </section>
1777 <section id="Color_RGB">
1778 <title>Color RGB</title>
1779 <para>A color specified by the three inputs for Red, Green and Blue color components. Those inputs are expected to be in the range 0..1.</para>
1780 <literallayout format="linespecific" class="normal">Inputs:
1781[Real] A value from 0.0 to 1.0.
1782[Real] A value from 0.0 to 1.0.
1783[Real] A value from 0.0 to 1.0.
1785 </section>
1786 <section id="Color_Red">
1787 <title>Color Red</title>
1788 <para>The color red.</para>
1789 </section>
1790 <section id="Color_Yellow">
1791 <title>Color Yellow</title>
1792 <para>The color yellow.</para>
1793 </section>
1794 <section id="Color_Blue">
1795 <title>Color Blue</title>
1796 <para>The color blue.</para>
1797 </section>
1798 <section id="Color_Orange">
1799 <title>Color Orange</title>
1800 <para>The color orange.</para>
1801 </section>
1802 <section id="Color_Green">
1803 <title>Color Green</title>
1804 <para>The color green.</para>
1805 </section>
1806 <section id="Color_Purple">
1807 <title>Color Purple</title>
1808 <para>The color purple.</para>
1809 </section>
1810 <section id="Color_Black">
1811 <title>Color Black</title>
1812 <para>The color black.</para>
1813 </section>
1814 <section id="Color_White">
1815 <title>Color White</title>
1816 <para>The color white.</para>
1817 </section>
1818 <section id="Color_Gray">
1819 <title>Color Gray</title>
1820 <para>The color gray.</para>
1821 </section>
1822 <section id="Graphic_Outline">
1823 <title>Graphic Outline</title>
1824 <para>Draws an outline of the last evaluated shape, using the last specified color or the default color (usually black) if none has been specified.</para>
1825 </section>
1826 <section id="Graphic_Fill">
1827 <title>Graphic Fill</title>
1828 <para>Fills the last evaluated shape with the last specified color or the default color (usually black) if none has been specified.</para>
1829 </section>
1830 </section>
1831 <section id="Example_3">
1832 <title>Example</title>
1833 <para>In the following action flow for the epidemic style, we've create Query Actions to determine each agent's current state, picked a color based on that, and then used a shared target to select a shape for the agent style and fill it:</para>
1834 <para>
1835 <mediaobject>
1836 <imageobject>
1837 <imagedata fileref="images/functions/GraphicsFunctionExampleDesign.png" scale="50"/>
1838 </imageobject>
1839 </mediaobject>
1840 </para>
1841 <para>After saving the model we can execute the two and three dimensional visualizations. Note something really nice -- even the charts have used the colors we've defined!</para>
1842 <para>
1843 <mediaobject>
1844 <imageobject>
1845 <imagedata fileref="images/functions/GraphicsFunctionExampleRun.png" scale="50"/>
1846 </imageobject>
1847 </mediaobject>
1848 </para>
1849 </section>
1850 </section>
1851 <section id="Lists">
1852 <title>Lists</title>
1853 <section id="Details_10">
1854 <title>Details</title>
1855 <section id="Item">
1856 <title>Item</title>
1857 <para>Returns the item at the specified index from the list of items provided. Those items will typically be input primitives such as Integer or Real values.</para>
1858 <literallayout format="linespecific" class="normal">Inputs:
1864 </section>
1865 <section id="Length">
1866 <title>Length</title>
1867 <para>The number of items in the provided list of items.</para>
1868 <literallayout format="linespecific" class="normal">Inputs:
1873 </section>
1874 </section>
1875 </section>
1876 <section id="Attribute_Distributions">
1877 <title>Attribute Distributions</title>
1878 <para>One of the most common tasks in the Agent Modeling process is the creation of agents with particular states drawn from a distribution. For example, you might want to create a number of agents with wealth randomly distributed between some minimum and maximum values. The distribution functions greatly ease the process of setting up those initializations and their associated parameters.</para>
1879 <section id="Distribution">
1880 <title>Distribution</title>
1881 <section id="Uniform_Cross_Distribution">
1882 <title>Uniform Cross Distribution</title>
1883 <para>A random number taken from a distribution of values as defined by a cross of all values. (See Cross Distribution.) This funciton then returns a value drawn from the minimum and maximum values as determined by the current agent state. In the cross distribution, each of the values is treated independently so that an input attribute is created for every potential combination of states.</para>
1884 <literallayout format="linespecific" class="normal">Inputs:
1885[Generic] The list of states to factor into the distribution. This is a multi-argument, which means that you can specify any number of attributes as arguments.
1886[Real] The set of attributes that will determine the minimum value of the function result based on the current state of the agent. Note that this list is automatically created and maintained. These values don't need to be and should not be manually edited.
1887[Real] The set of attributes that will determine the maximum value of the function result based on the current state of the agent. Note that this list is automatically created and maintained. These values don't need to be and should not be manually edited.
1889[Real] The resulting random number based on the current agent state and the input parameters.
1891 </section>
1892 <section id="Uniform_Additive_Distribution">
1893 <title>Uniform Additive Distribution</title>
1894 <para>A random number taken from a distribution of values in which each of the minimum and maximum values are added to determine a total minimum and maximum value. (See Additive Distribution.) In the additive distribution, each of the values is treated as dependent on the others so that an input attribute is only created for each seperate state.</para>
1895 <literallayout format="linespecific" class="normal">Inputs:
1896[Generic] The list of states to factor into the distribution. This is a multi-argument, which means that you can specify any number of attributes as arguments.
1897[Real] The set of attributes that will determine the minimum value of the function result based on the current state of the agent. Note that this list is automatically created and maintained. These values don't need to be and should not be manually edited.
1898[Real] The set of attributes that will determine the maximum value of the function result based on the current state of the agent. Note that this list is automatically created and maintained. These values don't need to be and should not be manually edited.
1900[Real] The resulting random number based on the current agent state and the input parameters.
1902 </section>
1903 <section id="Cross_Distribution">
1904 <title>Cross Distribution</title>
1905 <para>A value taken from a set of (auto-generated) attributes based on the value of each state included. For example, if the multi-values included a state X with values A and B and a state Y with values I and II, this distribution would create separate input attributes for AI, AII, BI and BII. Then for an agent with States A and II this function would return the value specified by the AII input attribute.</para>
1906 <literallayout format="linespecific" class="normal">Inputs:
1907[Generic] The list of states to factor into the distribution. This is a multi-argument, which means that you can specify any number of attributes as arguments.
1908[Real] The set of attributes that when multiplied against each other will determine the value of the function result based on the current state of the agent. Note that this list is automatically created and maintained. These values don't need to be and should not be manually edited.
1910[Real] The resulting value based on the current agent state and the input parameters.
1912 </section>
1913 <section id="Additive_Distribution">
1914 <title>Additive Distribution</title>
1915 <para>A value taken from a set of (auto-generated) attributes based on the combined values of the states provided. For example, if the multi-values included a state X with values A and B and a state Y with values I and II, this distribution would create input attributes for A, B, I and II. Those values would then be added together, so that for an Agent with state A and II this function would return A + II.</para>
1916 <literallayout format="linespecific" class="normal">Inputs:
1917[Generic] The states to include in the distribution. This is a multi-argument, which means that you can specify any number of attributes as arguments.
1918[Real] The set of attributes that when combined with each other determine the value of the function result based on the current state of the agent. Note that this list is automatically created and maintained. These values don't need to be and should not be manually edited.
1920[Real] The resulting value based on the current agent state and the input parameters.
1922 </section>
1923 </section>
1924 <section id="Example_4">
1925 <title>Example</title>
1926 <para>In the following example, we walk through the process of using a distribution functions, demonstrating how we can easily modify the Epidemic model so that instead of simply setting an initial exposed population, we can define factors that take together will determine an individuals initial exposure state. We simply:</para>
1927 <orderedlist inheritnum="ignore" continuation="restarts">
1928 <listitem>
1929 <para>Create an Evaluate Action called "Initial Status". </para>
1930 </listitem>
1931 <listitem>
1932 <para>Set the function to "Cross Distribution"</para>
1933 </listitem>
1934 <listitem>
1935 <para>Opened the "Multiple Value" node in the editor, and clicked the "Multiple Values" item within it.</para>
1936 </listitem>
1937 <listitem>
1938 <para>Selected the "Status" attribute.</para>
1939 </listitem>
1940 </orderedlist>
1941 <para>
1942 <mediaobject>
1943 <imageobject>
1944 <imagedata fileref="images/functions/DistributionDesignChoice.png" scale="50"/>
1945 </imageobject>
1946 </mediaobject>
1947 </para>
1948 <para>The appropriate attributes are automatically added to the model, as you can see below.</para>
1949 <para>
1950 <mediaobject>
1951 <imageobject>
1952 <imagedata fileref="images/functions/DistributionDesign.png" scale="50"/>
1953 </imageobject>
1954 </mediaobject>
1955 </para>
1956 <para>In order to assign these values to the agent, we'd simply need to assign the results of this Evaluate Action to the agent.</para>
1957 </section>
1958 </section>
1959 </section>
1960 <section id="Reference_3">
1961 <title>Reference</title>
1962 <section id="Diagrams_3">
1963 <title>Diagrams</title>
1964 <para>The following diagram may be helpful to readers familiar with UML and Meta-modeling:</para>
1965 <section id="Meta-Classes_3">
1966 <title>Meta-Classes</title>
1967 <para>
1968 <mediaobject>
1969 <imageobject>
1970 <imagedata fileref="images/functions/FunctionsDiagram.png" scale="50"/>
1971 </imageobject>
1972 </mediaobject>
1973 </para>
1974 </section>
1975 </section>
1976 </section>
1977 </section>
1978 </chapter>
1979 <chapter id="User_Guide">
1980 <title>User Guide</title>
1981 <para>In this section of the guide, we'll discuss specific aspects of the Agent Modeling tools and show you how to use them in your day to day agent development activities. We discuss only tools specific to Agent Modeling itself. For more general information about the tools, such as how to customize editors, views, and perspectives, see the
1982 <emphasis role="bold">Workbench User Guide</emphasis>.
1983 </para>
1984 <section id="Overview_5">
1985 <title>Overview</title>
1986 <para>The Agent Modeling Platform provides two general modes or "perspectives" for working with Agent Models.</para>
1987 <para>
1988 <mediaobject>
1989 <imageobject>
1990 <imagedata fileref="images/tools/Perspectives.png" scale="50"/>
1991 </imageobject>
1992 </mediaobject>
1993 </para>
1994 <para>
1995 <emphasis role="bold">Agent Modeling</emphasis> supports all aspects of working with models, including editing models and automatically generating all the of your code and documentation.
1996 <emphasis role="bold">Agent Execution</emphasis> supports running and exploring those models. A key feature of the Agent Modeling Platform is the ability to execute models within the same environment that they are developed within -- you don't need to launch a separate environment in order to run a model. Agent Execution automatically activates when you launch a model. We'll discuss the agent modeling tools first, and then turn to agent execution.
1997 </para>
1998 </section>
1999 <section id="Modeling">
2000 <title>Modeling</title>
2001 <section id="Perspective">
2002 <title>Perspective</title>
2003 <para>The Provides a custom layout menus and tools specific to working with agent models. Because the agent modeling process also often involves Java and Eclipse Plugin development we include easy access to many of those tools here as well.</para>
2004 </section>
2005 <section id="Creating_Projects_and_Models">
2006 <title>Creating Projects and Models</title>
2007 <para>You can create projects and project components using the Popup menu. Just click in a blank space within the Package Explorer. Any installed project targets are displayed in this menu. For example, if you've installed the Simphony target, you'd see that displayed in this menu as well.</para>
2008 <para>
2009 <mediaobject>
2010 <imageobject>
2011 <imagedata fileref="images/edit_tutorial/SimpleTutorial3CreateModel.png" scale="50"/>
2012 </imageobject>
2013 </mediaobject>
2014 </para>
2015 </section>
2016 <section id="Menus.2C_Popups_and_Toolbar">
2017 <title>Menus, Popups and Toolbar</title>
2018 <para>The popup menus and application menus provide access to various model features and are context sensitive. Throughout these screenshots, we've customized the toolbar in order to only show the agent Modeling specific features.</para>
2019 </section>
2020 <section id="Views">
2021 <title>Views</title>
2022 <para>By default the workbench includes a number of views. See the Workbench documentation for more details on how they can be customized accessed and used.</para>
2023 <para>
2024 <mediaobject>
2025 <imageobject>
2026 <imagedata fileref="images/tools/Workbench.png" scale="50"/>
2027 </imageobject>
2028 </mediaobject>
2029 </para>
2030 <section id="Editor">
2031 <title>Editor</title>
2032 <para>This is not technically a view in itself. It is the major focus of the workbench and contains any edit models or other files such as Java source or parameters.</para>
2033 </section>
2034 <section id="Default_Views">
2035 <title>Default Views</title>
2036 <para>The default modeling views are visible by default.</para>
2037 <section id="Package_Explorer">
2038 <title>Package Explorer</title>
2039 <para>Supports navigation within projects.</para>
2040 </section>
2041 <section id="Properties">
2042 <title>Properties</title>
2043 <para>The properties allows you to view and edit specific details for the currently selected object. For example, if you select a model context, you'll be able to edit its attributes here.</para>
2044 </section>
2045 <section id="Outline">
2046 <title>Outline</title>
2047 <para>The outline view supports easy navigation within the edited files. See the model editing sections for more on how the outline can be used to assist exploration of Agent Models.</para>
2048 </section>
2049 </section>
2050 <section id="Diagnostic_Views">
2051 <title>Diagnostic Views</title>
2052 <para>There are a number of views that can be used to explore issues that might come up during the modeling process. You can see them on the lower left-hand corner of the screenshot above. Click on one of the icons to view their contents.</para>
2053 <section id="Problems">
2054 <title>Problems</title>
2055 <para>This view is one that you'll become very familiar with. It is used to display specific about problems with any of the artifacts (files) in your modeling project. If you see a red or yellow marker on a file, opening the view will present a list of the issues that are currently being reported. For a usage example, please see the Tutorial.</para>
2056 </section>
2057 <section id="Console">
2058 <title>Console</title>
2059 <para>This view displays text (console) output for appropriate processes. For example, if you launch an Ascape project, this will display any output that would go to the Java console.</para>
2060 </section>
2061 <section id="Errors">
2062 <title>Errors</title>
2063 <para>This is another view that you will find valuable in your day to day modeling activities. The error log lists everything important that happens during model execution. It's the first place to look if something mysterious goes wrong, and when you report problems it's always helpful to include anything that could be relevant in the log. Despite its name, the Errors view is not just for reporting errors -- it is also used to report progress on normal operations. For example, when models are automatically generated that is reported to the log, as we can see in the following example:</para>
2064 </section>
2065 </section>
2066 </section>
2067 <section id="Modeling_Tree_Editor">
2068 <title>Modeling Tree Editor</title>
2069 <para>The Eclipse Agent Modeling Framework includes a full-featured model editor based on the Eclipse Modeling Framework's Edit tools. All aspects of an AMF model can be managed from within this tool. Note that the tree editor is only one of many ways of editing a model. Other editors of AMF models include textual languages and custom editors that are part of commercial offerings.</para>
2070 <section id="Opening_the_Editor">
2071 <title>Opening the Editor</title>
2072 <para>To open a model in the editor, simply double-click on it. If the model doesn't open in the model editor (if for example it had been previously opened using another editor), you can always access the editor using
2073 <emphasis role="bold">Open With &gt; Other...</emphasis> and selecting "MetaABM Editor". The editor has two pages, an Editor page that we'll focus on first and a "description" page that we'll discuss at the end of this section.
2074 </para>
2075 </section>
2076 <section id="Structure_2">
2077 <title>Structure</title>
2078 <para>The model is composed of nodes representing specific model entities such as agents, actions and spaces. For details about any of these entities, see the Concepts section.</para>
2079 <section id="Opening_Components">
2080 <title>Opening Components</title>
2081 <para>After opening a model, you can see the contents by clicking the Triangle symbol to the left of an item. For example, opening the root context node, we see:</para>
2082 <para>
2083 <mediaobject>
2084 <imageobject>
2085 <imagedata fileref="images/tools/Editor.png" scale="50"/>
2086 </imageobject>
2087 </mediaobject>
2088 </para>
2089 </section>
2090 <section id="Creating_Components">
2091 <title>Creating Components</title>
2092 <para>You add nodes by right-clicking on a node, like so:</para>
2093 <para>
2094 <mediaobject>
2095 <imageobject>
2096 <imagedata fileref="images/tools/EditorAdd.png" scale="50"/>
2097 </imageobject>
2098 </mediaobject>
2099 </para>
2100 </section>
2101 <section id="Editing_Components">
2102 <title>Editing Components</title>
2103 <para>To edit components, select the node you want to modify. The
2104 <emphasis role="bold">Properties View</emphasis> will be updated with the agent details. Use the properties view to modify the values. In the screenshot below, we're editing the values for the City space.
2105 </para>
2106 <para>
2107 <mediaobject>
2108 <imageobject>
2109 <imagedata fileref="images/tools/EditorEditing.png" scale="50"/>
2110 </imageobject>
2111 </mediaobject>
2112 </para>
2113 </section>
2114 <section id="Moving_Components">
2115 <title>Moving Components</title>
2116 <para>You can often rearrange model components by dragging them from one place to another. In the following example, we're creating a model of a regional epidemic by creating a City sub-context and moving the agent into it: </para>
2117 <para>
2118 <mediaobject>
2119 <imageobject>
2120 <imagedata fileref="images/tools/EditorMoving.png" scale="50"/>
2121 </imageobject>
2122 </mediaobject>
2123 </para>
2124 </section>
2125 <section id="Removing_Components">
2126 <title>Removing Components</title>
2127 <para>You can remove actions by deleting or cutting them using the popup menu. When you delete an entity, all of its children are deleted as well, except in some special cases (such as with actions) where other paths to that entity still exist.</para>
2128 </section>
2129 <section id="Copying_Components">
2130 <title>Copying Components</title>
2131 <para>To make a copy of an entity and place it in a new location, option-drag the entity to the destination. You can make a copy in the existing location by dragging it into the same parent. The name will automatically be updated with "copy" appended to it.</para>
2132 </section>
2133 <section id="Editing_Attributes">
2134 <title>Editing Attributes</title>
2135 <para>The attributes node -- along with the actions and styles nodes -- represents a group of components rather than an entity itself. It contains all of the attributes for the parent agent or context. In the examples below, we can see the attributes for the Epidemic route model. Note that the top level attributes in a root context act as the parameters for the model itself.</para>
2136 <para>
2137 <mediaobject>
2138 <imageobject>
2139 <imagedata fileref="images/tools/EditorAttributes.png" scale="50"/>
2140 </imageobject>
2141 </mediaobject>
2142 </para>
2143 </section>
2144 <section id="Editing_Styles">
2145 <title>Editing Styles</title>
2146 <para>The Styles node is another group node, in this case representing a set of styles that can be used to visualize the agents. When creating a style, you will need to create a Rule for each style as well, like so:</para>
2147 <para>
2148 <mediaobject>
2149 <imageobject>
2150 <imagedata fileref="images/tools/EditorStyles.png" scale="50"/>
2151 </imageobject>
2152 </mediaobject>
2153 </para>
2154 </section>
2155 </section>
2156 <section id="Actions_3">
2157 <title>Actions</title>
2158 <para>Actions are a key and relatively complex aspect of the model editor. Because actions are actually related in a graph structure, a tree-based editor will not be able to represent a the underlying structure of action relationships directly. (This is actually no different from most development environments -- for example, Java code is edited in a text based editor, but the call structure represents a complex graph. Advance tools developed by AMP contributors do support more sophisticated methods for action browsing and we'll have simple versions of them available in future releases of the AMF edit tools.) Therefore, it's helpful to take time to understand how action relationships appear in the editor.</para>
2159 <para>Like attributes and styles, every agent has a single Actions nodes which contains its Root Action(s).</para>
2160 <section id="Creating_Actions">
2161 <title>Creating Actions</title>
2162 <para>You create actions as with any other component, by right-clicking on the source action and choosing the new action. The menu is organized by usage.</para>
2163 <para>
2164 <mediaobject>
2165 <imageobject>
2166 <imagedata fileref="images/tools/EditorActionMenu.png" scale="50"/>
2167 </imageobject>
2168 </mediaobject>
2169 </para>
2170 </section>
2171 <section id="Editing_Actions">
2172 <title>Editing Actions</title>
2173 <para>Actions and their inputs are edited just like any other model component. Click on the action or input you want to edit and then make changes to it in the properties editor.</para>
2174 </section>
2175 <section id="Order">
2176 <title>Order</title>
2177 <para>Generally, action sources will appear above their targets. In the case where there is only one source for a given target, and that target has no other sources, they will appear directly above one another. Its important to note however that
2178 <emphasis role="italic">the order of the nodes does not indicate a specific source and target relationship</emphasis>. For example, in the case where there are multiple targets for a source, they will typically follow that source immediately. To make the relationships clear, every action lists its source actions as part of the action label. Agent selections also appear as part of the label.
2179 </para>
2180 <para>
2181 <mediaobject>
2182 <imageobject>
2183 <imagedata fileref="images/tools/ActionsExample.png" scale="50"/>
2184 </imageobject>
2185 </mediaobject>
2186 </para>
2187 <para>In the above example, the Initialize Location "Initialize Action" is straightforward. We simply define a Select Action, a Query Action target for that selection, and then a Move Action target for the query. The "Transmission" Rule is more complicated. Note for example that the "Infectious" Union Action is the target of both the "Asymptomatic Infectious" and "Symptomatic Infectious" Query Actions. The "Vulnerable Neighbor" action has the label "Vulnerable Neighbor [Potential Exposure] &lt;- [Potential Exposure]" indicating that the "Potential Exposure" action serves as its selection as well as its source.</para>
2188 </section>
2189 <section id="Initial_Order">
2190 <title>Initial Order</title>
2191 <para>A new action's initial target will be the action that you clicked on when creating it. For an action that should always act within a given root action (i.e. Rule, Schedule, etc..), add it to the root action. A root action can have more than one target.</para>
2192 </section>
2193 <section id="Changing_Sources_and_Targets_.28Reordering.29">
2194 <title>Changing Sources and Targets (Reordering)</title>
2195 <para>An action's target can be changed by dragging it over the new target action. Note that this is a different behavior from that of standard entity movement. You cannot make an action a target of an action that is itself a source of the modified action! (See the concepts section for why.) Using the default tree editor you cannot change an action's targets directly; instead select the action's target and move that. </para>
2196 </section>
2197 <section id="Adding_Sources_and_Targets">
2198 <title>Adding Sources and Targets</title>
2199 <para>As discussed earlier, actions often have multiple sources and targets. To make an action the target of an additional action, click on target action, hold down the control key, and drag the action to its new destination. See the tutorial for a complete example.</para>
2200 </section>
2201 <section id="Removing_Sources_and_Targets">
2202 <title>Removing Sources and Targets</title>
2203 <para>You cannot remove single sources from targets directly using the tree editor. Instead, first drag the agent to a source nodes that will be part of its changed set of sources. That will remove all existing actions sources but for the one you have just dragged it to. Then add back any of the other source and target nodes you wish to retain.</para>
2204 </section>
2205 <section id="Removing_Actions">
2206 <title>Removing Actions</title>
2207 <para>You can remove actions in the same way as with structural model components. Note that just as when you delete an agent, all of that agent's attributes, actions and styles are also deleted form the model, when you delete an Action, any of its targets will also be removed, unless there is some other source action path that connects it to the root action. And of course, any targets of such targets will be affected in the same way and so on. If you remove a node from high in the action tree a lot of nodes could disappear at once! If you have actions that you want to retain as part of the flow, you should first make them targets of a new action before deleting their parent action.</para>
2208 </section>
2209 <section id="Copying_Actions">
2210 <title>Copying Actions</title>
2211 <para>Copying actions works just as with other entities, and copies will become targets of their option-drag destination. </para>
2212 </section>
2213 <section id="Query_and_Evaluation_Inputs_2">
2214 <title>Query and Evaluation Inputs</title>
2215 <para>The number of inputs is determined by the selected functions. (In rare cases where a function can take an arbitrary number of arguments you may need to create additional values or delete existing ones.) In the following example, we're picking the Symptom Infectious status for a query that will affect the potentially exposed agents. Note that is instead you wanted to compare another kind of value -- for example an Integer value -- you would need to change the first input listed before changing the second input so that you will be able to get the appropriate options for the second.</para>
2216 <para>
2217 <mediaobject>
2218 <imageobject>
2219 <imagedata fileref="images/tools/Inputs.png" scale="50"/>
2220 </imageobject>
2221 </mediaobject>
2222 </para>
2223 </section>
2224 <section id="Input_Literals_2">
2225 <title>Input Literals</title>
2226 <para>To create an input value, right click on the input and select
2227 <emphasis role="bold">Create Member &gt; Literal</emphasis>. Then specify the actual value in the Value property in the
2228 <emphasis role="bold">Properties View</emphasis>.
2229 </para>
2230 </section>
2231 </section>
2232 </section>
2233 </section>
2234 <section id="Building">
2235 <title>Building</title>
2236 <section id="Building_Models">
2237 <title>Building Models</title>
2238 <para>If you've used other development environments, you're probably used to a separate build step. For example, if you edit a set of Java files, you might invoke a compile command. Eclipse and the Agent Modeling Platform support automatic building. This means that in order to build your code, you simply save the model and the environment takes care of the rest. What gets built is defined by the project. For example, if you save a model that is contained within an Agent Modeling Escape Project, the following steps occur automatically:</para>
2239 <orderedlist inheritnum="ignore" continuation="restarts">
2240 <listitem>
2241 <para>The Escape builder generates Java code for the Escape API, including support for specialized graphics and (if enabled) 3D visualization.</para>
2242 </listitem>
2243 <listitem>
2244 <para>The Documentation builder generates custom html documentation for the model.</para>
2245 </listitem>
2246 <listitem>
2247 <para>The Java builder takes the Java code generated above and compiles it.</para>
2248 </listitem>
2249 <listitem>
2250 <para>The Manifest and Schema builders package the project for use as part of the Eclipse plugin environment.</para>
2251 </listitem>
2252 </orderedlist>
2253 <para>So what do you do if you want to generate code for a different target, such as Repast? Here, you simply create another project and drag the model into it. You can also edit the builders for a given project (see the Workbench Documentation) but you'll only want to do that if you're making permanent changes to the project itself.</para>
2254 </section>
2255 <section id="Generating_Specialized_Model_Artifacts">
2256 <title>Generating Specialized Model Artifacts</title>
2257 <para>You can also manually generate code for models. This is useful if you want to create code for a model in a non target project and don't want the automatic build capabilities. There are also specialized targets that can be generated manually that are bundled with the tools -- AMP plugin developers can easily add custom generation targets for this menu. To generate custom artifacts, right-click on a model and select
2258 <emphasis role="bold">Generate</emphasis>.
2259 </para>
2260 <para>
2261 <mediaobject>
2262 <imageobject>
2263 <imagedata fileref="images/tools/GenerateMenu.png" scale="50"/>
2264 </imageobject>
2265 </mediaobject>
2266 </para>
2267 <para>Targets include:</para>
2268 <section id="Platform_Targets">
2269 <title>Platform Targets</title>
2270 <para>Creates code for one of the installed targets, such as Ascape, Escape, and Simphony. (Again, these generators are unnecessary for projects that already have target specific builders configured.)</para>
2271 </section>
2272 <section id="Interfaces">
2273 <title>Interfaces</title>
2274 <para>Creates a complete set of interfaces for the model classes. These can be very useful for development and integration in enterprise environments. Generated classes are placed in the src directory with "I" added to the name. For example, if you generate interfaces for a model with an "Individual" agent, this target will create an "IIndividual" interface that includes getters, setters and methods for all of the agent's attributes and actions.</para>
2275 </section>
2276 <section id="Skeleton">
2277 <title>Skeleton</title>
2278 <para>Creates a base class for the model. This is essentially a complete implementation, but without the action implementations. Again, these classes can be useful when generating code for use in enterprise and other specialized environments.</para>
2279 </section>
2280 <section id="Test_Cases">
2281 <title>Test Cases</title>
2282 <para>Generates base support (needing customization) test cases for use in JUnit tests.</para>
2283 </section>
2284 <section id="Text_Documents">
2285 <title>Text Documents</title>
2286 <para>Creates simple text documentation for use in other documents.</para>
2287 </section>
2288 <section id="Generate_Key_Graphics">
2289 <title>Generate Key Graphics</title>
2290 <para>This specialized target supports the creation of graphic keys for the model. To use this target:</para>
2291 <orderedlist inheritnum="ignore" continuation="restarts">
2292 <listitem>
2293 <para>Generate the code.</para>
2294 </listitem>
2295 <listitem>
2296 <para>Add a dependency to the Manifest for "org.eclipse.amp.amf.gen.extras".</para>
2297 </listitem>
2298 <listitem>
2299 <para>In the srcutil directory find the Java source code for the calss {RootContext}GraphicsWriter. For example, for the Epidemic model, this would be srcutil/name.milesparker.epi/</para>
2300 </listitem>
2301 <listitem>
2302 <para>Right-click, and select
2303 <emphasis role="bold">Run As &gt; Java Application</emphasis>.
2304 </para>
2305 </listitem>
2306 <listitem>
2307 <para>Refresh the project by right-clicking on it and selecting
2308 <emphasis role="bold">Refresh</emphasis>.
2309 </para>
2310 </listitem>
2311 <listitem>
2312 <para>The Doc directory will now contain a number of new files, including</para>
2313 <orderedlist inheritnum="ignore" continuation="restarts">
2314 <listitem>
2315 <para>{RootContext}Key.png</para>
2316 </listitem>
2317 <listitem>
2318 <para>{RootContext}GraphicsKey.html</para>
2319 </listitem>
2320 </orderedlist>
2321 </listitem>
2322 </orderedlist>
2323 <para>Both files contain graphic representations of the model using the definitions defined by the model styles, very useful artifacts for inclusion in papers and web pages describing your model. For example, here is the EpidemicKey.png:</para>
2324 <para>
2325 <mediaobject>
2326 <imageobject>
2327 <imagedata fileref="images/tools/EpidemicKey.png" scale="50"/>
2328 </imageobject>
2329 </mediaobject>
2330 </para>
2331 </section>
2332 <section id="Function_Docs">
2333 <title>Function Docs</title>
2334 <para>Generates WikiText documentation for function libraries. We use it to create the function documentation in this guide!</para>
2335 </section>
2336 </section>
2337 </section>
2338 <section id="Exploring">
2339 <title>Exploring</title>
2340 <section id="Launching_a_Model_.28AMF.29">
2341 <title>Launching a Model (AMF)</title>
2342 <informaltable frame="none">
2343 <tr>
2344 <td rowspan="1" colspan="1">Launching AMF and Escape models is easy. When an AMF file is selected -- in any of the perspectives -- the toolbar and Application menus are updated to reflect the file you've selected and provide convenient access to other functions. For example, when we click on a metaabm file in the package explorer, model execution buttons appear in the toolbar. If you right-click on a file a pop-up menu appears like the one to the far right -- in this case we're selecting the "Execute Headless" option. To launch a model, just select one of the options. (Note that the execution framework doesn't know whether your code exists in an Escape project or another target project. If you attempt to execute a .metaabm model in an Ascape project for example, you will get an error.)</td>
2345 <td rowspan="1" colspan="1">
2346 <mediaobject>
2347 <imageobject>
2348 <imagedata fileref="images/tools/EditorToolbar.png" scale="50"/>
2349 </imageobject>
2350 </mediaobject>
2351 </td>
2352 <td rowspan="1" colspan="1">
2353 <mediaobject>
2354 <imageobject>
2355 <imagedata fileref="images/tools/EditorMenu.png" scale="50"/>
2356 </imageobject>
2357 </mediaobject>
2358 </td>
2359 </tr>
2360 </informaltable>
2361 <para>One a model has been launched, the Agent Execution Perspective automatically becomes active. The Provides a custom layout menus and tools specific to executing agent models.</para>
2362 <para>
2363 <mediaobject>
2364 <imageobject>
2365 <imagedata fileref="images/execution/EpidemicExecNew.png" scale="50"/>
2366 </imageobject>
2367 </mediaobject>
2368 </para>
2369 <para>The execution options are:</para>
2370 <section id="Execute">
2371 <title>Execute</title>
2372 <para>Launches the model using default graphics, opening the Agent Execution perspective.</para>
2373 </section>
2374 <section id="Execute_Headless">
2375 <title>Execute Headless</title>
2376 <para>Launches the model without graphics, opening the Agent Execution perspective.</para>
2377 </section>
2378 <section id="Execute_Headless_.28Data.29">
2379 <title>Execute Headless (Data)</title>
2380 <para>Launches the model with an observer that collects data into the AMF adata model representation.</para>
2381 </section>
2382 </section>
2383 <section id="Executing_a_Model_.28Java_.2F_3D.29">
2384 <title>Executing a Model (Java / 3D)</title>
2385 <para>You can execute any Escape model directly from its Java file by right-clicking on it. This is used for models that have been written directly in Java, or that you have created or that have been automatically generated, such as the 3D versions of AMF models. In order for the model to launch correctly, it must have as a superclass the Escape "Scape" class. In the following screenshot, we've launched a 3D version of the Epidemic model. The 3D models are automatically generated for all .metaabm models.</para>
2386 <para>
2387 <mediaobject>
2388 <imageobject>
2389 <imagedata fileref="images/execution/Epidemic3D.png" scale="50"/>
2390 </imageobject>
2391 </mediaobject>
2392 </para>
2393 </section>
2394 <section id="Controlling_Model_Execution">
2395 <title>Controlling Model Execution</title>
2396 <para>Once a model has been launched, the toolbar buttons allow you to control model execution.</para>
2397 <para>
2398 <mediaobject>
2399 <imageobject>
2400 <imagedata fileref="images/execution/EpidemicModelControls.png" scale="50"/>
2401 </imageobject>
2402 </mediaobject>
2403 </para>
2404 <para>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.</para>
2405 <para>
2406 <mediaobject>
2407 <imageobject>
2408 <imagedata fileref="images/execution/EpidemicModelComparison.png" scale="50"/>
2409 </imageobject>
2410 </mediaobject>
2411 </para>
2412 <section id="The_Active_Model">
2413 <title>The Active Model</title>
2414 <para>An important concept in the execution workbench is the "active model". The active model is the model that is controlled by the toolbar buttons. As discussed, the Escape environment supports more than one running model at any given time. The active model is the current "focused" or front-most model, there can be only one active model at any given time and whenever any models are running one of them will be active. To make a model become the active model, you simply select a view of that model or select the model in the model manager (see below). When a model is closed, another model is automatically activated.</para>
2415 </section>
2416 </section>
2417 <section id="Views_2">
2418 <title>Views</title>
2419 <para>There are many views specific to the Agent Execution environment that will enable you to explore and control running models.</para>
2420 <section id="Properties_2">
2421 <title>Properties</title>
2422 <para>If you want to find out more about an agent, show the properties view, and click on agent in the 2D view or any other views that support agent selection such as the tree view.</para>
2423 <para>
2424 <mediaobject>
2425 <imageobject>
2426 <imagedata fileref="images/execution/EpidemicModelAgentProperties.png" scale="50"/>
2427 </imageobject>
2428 </mediaobject>
2429 </para>
2430 <para>You can experiment with different parameters (settings) for models by then clicking on the model in the Model Manager or by selecting a general mode area such as the gray area enclosing the 2D view.</para>
2431 <para>
2432 <mediaobject>
2433 <imageobject>
2434 <imagedata fileref="images/execution/EpidemicModelProperties.png" scale="50"/>
2435 </imageobject>
2436 </mediaobject>
2437 </para>
2438 </section>
2439 <section id="Agent_Navigator">
2440 <title>Agent Navigator</title>
2441 <para>The
2442 <emphasis role="bold">Agent Navigator</emphasis> allows you to select agents from a tree view. The agent selection is coordinated across views so that for example when you select an agent in the navigator it is also selected in the 2D view. In the following screenshot you can see an agent selected in both views as well as the properties editor.
2443 </para>
2444 <para>
2445 <mediaobject>
2446 <imageobject>
2447 <imagedata fileref="images/execution/AgentNavigator.png" scale="50"/>
2448 </imageobject>
2449 </mediaobject>
2450 </para>
2451 </section>
2452 <section id="Model_Manager">
2453 <title>Model Manager</title>
2454 <para>The
2455 <emphasis role="bold">'Model Manager</emphasis>' allows you to examine and control the status of all running models. In the following screenshot, we've launched four separate models so that we can compare the typical model state at different periods.
2456 </para>
2457 <para>
2458 <mediaobject>
2459 <imageobject>
2460 <imagedata fileref="images/execution/ModelManager.png" scale="50"/>
2461 </imageobject>
2462 </mediaobject>
2463 </para>
2464 <para>The manager shows that two of the models are running and two are paused. By opening the model node, we can see the views that are currently being displayed. Note that we mean something different by "Views" in this context. Here "Views" are any thing that is monitoring the state of a running model. A view may not have a graphical component at all.</para>
2465 <para>You can make any model the current active model by clicking on its node in this view.</para>
2466 <section id=".22About_this_Model.22">
2467 <title>"About this Model"</title>
2468 <para>The
2469 <emphasis role="bold">'About this Model</emphasis>' view displays information about a (AMF or Java based) model if it has been provided by the developer. In order to appear in this dialog, create a file named "About[MyModel].html" where "MyModel" is the model's Scape Class Name (not the AMF model file name). The file should be placed in a "res" source folder in the model project directory in a parallel directory path to the root scape's Java class package. For example, an about file for a model defined by the scape "edu.brook.norms.Norms" should be placed at "res/edu/brook/norms/AboutNorms.html". The file should be an html fragment -- that is, without body and head tags -- and can include any valid html tags, including links.
2470 </para>
2471 <para>
2472 <mediaobject>
2473 <imageobject>
2474 <imagedata fileref="images/execution/AboutView.png" scale="50"/>
2475 </imageobject>
2476 </mediaobject>
2477 </para>
2478 </section>
2479 </section>
2480 </section>
2481 <section id="Visualization">
2482 <title>Visualization</title>
2483 <para>The Agent Modeling Environment is designed to support many kinds of 2D or 3D visualization. AMP includes the following views for generated models. The Escape API supports a number of additional visualization to support Ascape models that aren't shown here. Look at the example org.ascape.escape.models.examples and org.ascape.escape.models.brook for examples of those.</para>
2484 <section id="2D_Views">
2485 <title>2D Views</title>
2486 <para>The
2487 <emphasis role="bold">Graphic 2D</emphasis> view is the most common view way to work with an Agent Model and is automatically generated and displayed for executing models.
2488 </para>
2489 <para>
2490 <mediaobject>
2491 <imageobject>
2492 <imagedata fileref="images/execution/Epidemic2DView.png" scale="50"/>
2493 </imageobject>
2494 </mediaobject>
2495 </para>
2496 <para>There are a number of view widgets in the upper-right hand corner that you can use to modify the view. You can:</para>
2497 <section id="Scaling">
2498 <title>Scaling</title>
2499 <orderedlist inheritnum="ignore" continuation="restarts">
2500 <listitem>
2501 <para>Enter or select a specific scale in the combo menu.</para>
2502 </listitem>
2503 <listitem>
2504 <para>Select a button to have the model scale either:</para>
2505 <orderedlist inheritnum="ignore" continuation="restarts">
2506 <listitem>
2507 <para>Freely</para>
2508 </listitem>
2509 <listitem>
2510 <para>Within the bounds of the view</para>
2511 </listitem>
2512 <listitem>
2513 <para>Within the vertical bounds of the view</para>
2514 </listitem>
2515 <listitem>
2516 <para>Within the horizontal bounds of the view</para>
2517 </listitem>
2518 </orderedlist>
2519 </listitem>
2520 <listitem>
2521 <para>Zoom In</para>
2522 </listitem>
2523 <listitem>
2524 <para>Zoom Out</para>
2525 </listitem>
2526 </orderedlist>
2527 </section>
2528 </section>
2529 <section id="Charts">
2530 <title>Charts</title>
2531 <para>A
2532 <emphasis role="bold">Chart</emphasis> view is automatically created and displayed for executing models. It can display aggregate values for any of the agent attributes you have set the "gather data" value to true for. Charts can be easily modified. While the built-in view is not meant to be the sole tool for Escape model data analysis, it provides an easy to use and powerful way to explore models interactively. The Chart view widgets allow you to modify the chart with the click of a button.
2533 </para>
2534 <para>
2535 <mediaobject>
2536 <imageobject>
2537 <imagedata fileref="images/execution/EpidemicChartOptions.png" scale="50"/>
2538 </imageobject>
2539 </mediaobject>
2540 </para>
2541 <section id="Chart_Type">
2542 <title>Chart Type</title>
2543 <para>Several chart types are supported: The line, area, bar and pie chart. Click on one of the icons to select that type.</para>
2544 <para>
2545 <mediaobject>
2546 <imageobject>
2547 <imagedata fileref="images/execution/LineChart.png" scale="50"/>
2548 </imageobject>
2549 </mediaobject>
2551 <mediaobject>