mparker | 7c6347a | 2010-04-14 02:36:22 +0000 | [diff] [blame] | 1 | <html> |
| 2 | <head> |
| 3 | <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> |
| 4 | <title>Actions</title> |
Miles Parker | c3cd081 | 2010-11-09 17:46:09 -0800 | [diff] [blame^] | 5 | <link href="book.css" type="text/css" rel="stylesheet"> |
| 6 | <meta content="DocBook XSL Stylesheets V1.76.0" name="generator"> |
mparker | 7c6347a | 2010-04-14 02:36:22 +0000 | [diff] [blame] | 7 | <link rel="home" href="index.html" title="Agent Modeling Guide"> |
Miles Parker | c3cd081 | 2010-11-09 17:46:09 -0800 | [diff] [blame^] | 8 | <link rel="up" href="Modeler_Guide.html" title="Chapter . Modeler Guide"> |
mparker | 7c6347a | 2010-04-14 02:36:22 +0000 | [diff] [blame] | 9 | <link rel="prev" href="Structure.html" title="Structure"> |
| 10 | <link rel="next" href="Functions.html" title="Functions"> |
| 11 | </head> |
| 12 | <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> |
| 13 | <h1 xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0">Actions</h1> |
mparker | 53e32b2 | 2010-04-24 04:17:28 +0000 | [diff] [blame] | 14 | <div class="section" title="Actions"> |
| 15 | <div class="titlepage"> |
| 16 | <div> |
| 17 | <div> |
| 18 | <h2 class="title" style="clear: both"> |
| 19 | <a name="Actions_2"></a>Actions</h2> |
| 20 | </div> |
| 21 | </div> |
| 22 | </div> |
mparker | 7c6347a | 2010-04-14 02:36:22 +0000 | [diff] [blame] | 23 | <p>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.</p> |
| 24 | <div class="section" title="Overview"> |
| 25 | <div class="titlepage"> |
| 26 | <div> |
| 27 | <div> |
| 28 | <h3 class="title"> |
| 29 | <a name="Overview_3"></a>Overview</h3> |
| 30 | </div> |
| 31 | </div> |
| 32 | </div> |
| 33 | <p>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.</p> |
| 34 | <p>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 |
| 35 | <span class="italic">how</span> the modeling engine should do something -- instead an action represents |
| 36 | <span class="italic">what</span> 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.) |
| 37 | </p> |
| 38 | <p>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.</p> |
| 39 | <p>Why are these distinctions between traditional Object-Oriented and the Action approaches important? They give us the advantages of simplicity, clarity and flexibility that |
| 40 | <a class="ulink" href="/wiki/http://en.wikipedia.org/wiki/Dataflow_programming" target="_new">data-flow approaches</a> 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 |
| 41 | <a class="ulink" href="/wiki/http://en.wikipedia.org/wiki/Functional_programming" target="_new">functional languages</a> like Lisp or |
| 42 | <a class="ulink" href="/wiki/http://en.wikipedia.org/wiki/Logical_programming" target="_new">logical languages</a> like Prolog, but without the level of complexity and obscurity that such languages can have. |
| 43 | </p> |
| 44 | <p>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 |
| 45 | <span class="italic">how</span> 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 |
| 46 | <span class="italic">what</span> the result is, and whether it is correct. |
| 47 | </p> |
| 48 | <p>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.</p> |
| 49 | </div> |
mparker | 53e32b2 | 2010-04-24 04:17:28 +0000 | [diff] [blame] | 50 | <div class="section" title="Concepts"> |
mparker | 7c6347a | 2010-04-14 02:36:22 +0000 | [diff] [blame] | 51 | <div class="titlepage"> |
| 52 | <div> |
| 53 | <div> |
| 54 | <h3 class="title"> |
mparker | 53e32b2 | 2010-04-24 04:17:28 +0000 | [diff] [blame] | 55 | <a name="Concepts"></a>Concepts</h3> |
mparker | 7c6347a | 2010-04-14 02:36:22 +0000 | [diff] [blame] | 56 | </div> |
| 57 | </div> |
| 58 | </div> |
| 59 | <p>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.</p> |
| 60 | <div class="section" title="Kinds of Actions"> |
| 61 | <div class="titlepage"> |
| 62 | <div> |
| 63 | <div> |
| 64 | <h4 class="title"> |
| 65 | <a name="Kinds_of_Actions"></a>Kinds of Actions</h4> |
| 66 | </div> |
| 67 | </div> |
| 68 | </div> |
mparker | 8b5614b | 2010-06-17 23:18:38 +0000 | [diff] [blame] | 69 | <table id="N102B9"> |
mparker | a684092 | 2010-04-28 17:51:29 +0000 | [diff] [blame] | 70 | <tr> |
| 71 | |
mparker | 8b5614b | 2010-06-17 23:18:38 +0000 | [diff] [blame] | 72 | <td>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. The diagram at the right depicts how actions relate to one another -- it does not include some actions that have been added more recently.</td> |
mparker | a684092 | 2010-04-28 17:51:29 +0000 | [diff] [blame] | 73 | <td> |
| 74 | |
mparker | 7c6347a | 2010-04-14 02:36:22 +0000 | [diff] [blame] | 75 | <div class="mediaobject"> |
mparker | a684092 | 2010-04-28 17:51:29 +0000 | [diff] [blame] | 76 | <img src="images/actions/ActionsBlocks.png"></div> |
| 77 | |
| 78 | </td> |
| 79 | |
| 80 | </tr> |
| 81 | </table> |
mparker | 7c6347a | 2010-04-14 02:36:22 +0000 | [diff] [blame] | 82 | </div> |
| 83 | <div class="section" title="Flow"> |
| 84 | <div class="titlepage"> |
| 85 | <div> |
| 86 | <div> |
| 87 | <h4 class="title"> |
| 88 | <a name="Flow"></a>Flow</h4> |
| 89 | </div> |
| 90 | </div> |
| 91 | </div> |
| 92 | <p>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.</p> |
mparker | a684092 | 2010-04-28 17:51:29 +0000 | [diff] [blame] | 93 | <p>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. |
| 94 | 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 |
mparker | 668331c | 2010-04-23 05:22:03 +0000 | [diff] [blame] | 95 | <span class="italic">need</span> 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. |
| 96 | </p> |
mparker | 8b5614b | 2010-06-17 23:18:38 +0000 | [diff] [blame] | 97 | <table id="N102D7"> |
mparker | a684092 | 2010-04-28 17:51:29 +0000 | [diff] [blame] | 98 | <tr> |
| 99 | |
| 100 | <td>Again, behaviors in Actions are always defined by a set of |
| 101 | <span class="italic">selections</span> and |
| 102 | <span class="italic">queries</span>. 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. |
| 103 | </td> |
| 104 | <td> |
| 105 | |
mparker | 7c6347a | 2010-04-14 02:36:22 +0000 | [diff] [blame] | 106 | <div class="mediaobject"> |
mparker | 668331c | 2010-04-23 05:22:03 +0000 | [diff] [blame] | 107 | <img src="images/actions/ActionsSequence.png"></div> |
mparker | a684092 | 2010-04-28 17:51:29 +0000 | [diff] [blame] | 108 | |
| 109 | </td> |
mparker | 7c6347a | 2010-04-14 02:36:22 +0000 | [diff] [blame] | 110 | |
mparker | a684092 | 2010-04-28 17:51:29 +0000 | [diff] [blame] | 111 | </tr> |
| 112 | </table> |
mparker | 8b5614b | 2010-06-17 23:18:38 +0000 | [diff] [blame] | 113 | <table id="N102F1"> |
mparker | a684092 | 2010-04-28 17:51:29 +0000 | [diff] [blame] | 114 | <tr> |
| 115 | |
| 116 | <td>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> |
| 117 | <td> |
| 118 | |
mparker | 7c6347a | 2010-04-14 02:36:22 +0000 | [diff] [blame] | 119 | <div class="mediaobject"> |
mparker | 668331c | 2010-04-23 05:22:03 +0000 | [diff] [blame] | 120 | <img src="images/actions/ActionsSimpleSequence.png"></div> |
mparker | a684092 | 2010-04-28 17:51:29 +0000 | [diff] [blame] | 121 | |
| 122 | </td> |
mparker | 7c6347a | 2010-04-14 02:36:22 +0000 | [diff] [blame] | 123 | |
mparker | a684092 | 2010-04-28 17:51:29 +0000 | [diff] [blame] | 124 | </tr> |
| 125 | </table> |
mparker | 8b5614b | 2010-06-17 23:18:38 +0000 | [diff] [blame] | 126 | <table id="N10303"> |
mparker | a684092 | 2010-04-28 17:51:29 +0000 | [diff] [blame] | 127 | <tr> |
| 128 | |
| 129 | <td>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> |
| 130 | <td> |
| 131 | |
mparker | 7c6347a | 2010-04-14 02:36:22 +0000 | [diff] [blame] | 132 | <div class="mediaobject"> |
mparker | 668331c | 2010-04-23 05:22:03 +0000 | [diff] [blame] | 133 | <img src="images/actions/ActionsSimpleSequence2.png"></div> |
mparker | a684092 | 2010-04-28 17:51:29 +0000 | [diff] [blame] | 134 | |
| 135 | </td> |
| 136 | |
| 137 | </tr> |
| 138 | </table> |
mparker | 7c6347a | 2010-04-14 02:36:22 +0000 | [diff] [blame] | 139 | <p>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.</p> |
| 140 | <p> |
| 141 | |
| 142 | </p> |
| 143 | <div class="mediaobject"> |
mparker | 668331c | 2010-04-23 05:22:03 +0000 | [diff] [blame] | 144 | <img src="images/actions/ActionsFlowSimple.png"></div> |
mparker | 7c6347a | 2010-04-14 02:36:22 +0000 | [diff] [blame] | 145 | <p> |
| 146 | |
| 147 | </p> |
| 148 | <p>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.</p> |
| 149 | <p> |
| 150 | |
| 151 | </p> |
| 152 | <div class="mediaobject"> |
mparker | 668331c | 2010-04-23 05:22:03 +0000 | [diff] [blame] | 153 | <img src="images/actions/ActionsFlowUnion.png"></div> |
mparker | 7c6347a | 2010-04-14 02:36:22 +0000 | [diff] [blame] | 154 | <p> |
| 155 | |
| 156 | </p> |
| 157 | <p>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 |
| 158 | <span class="italic">both</span> 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: |
| 159 | </p> |
| 160 | <div class="literallayout"> |
| 161 | <p>if ((query1.evaluate() && query2.evaluate()) || query3.evaluate()) {<br> |
| 162 | doSomething();<br> |
| 163 | }<br> |
| 164 | |
| 165 | </p> |
| 166 | </div> |
| 167 | <p>In the second we'd have:</p> |
| 168 | <div class="literallayout"> |
| 169 | <p>if (query1.evaluate() && query2.evaluate()) {<br> |
| 170 | doSomething();<br> |
| 171 | }<br> |
| 172 | if (query3.evaluate()) {<br> |
| 173 | doSomething();<br> |
| 174 | }<br> |
| 175 | |
| 176 | </p> |
| 177 | </div> |
| 178 | <p>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.</p> |
| 179 | </div> |
| 180 | <div class="section" title="Selections"> |
| 181 | <div class="titlepage"> |
| 182 | <div> |
| 183 | <div> |
| 184 | <h4 class="title"> |
| 185 | <a name="Selections"></a>Selections</h4> |
| 186 | </div> |
| 187 | </div> |
| 188 | </div> |
| 189 | <p>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.</p> |
mparker | 8b5614b | 2010-06-17 23:18:38 +0000 | [diff] [blame] | 190 | <table id="N1033F"> |
mparker | a684092 | 2010-04-28 17:51:29 +0000 | [diff] [blame] | 191 | <tr> |
| 192 | |
| 193 | <td>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> |
| 194 | <td> |
| 195 | |
mparker | 7c6347a | 2010-04-14 02:36:22 +0000 | [diff] [blame] | 196 | <div class="mediaobject"> |
mparker | 668331c | 2010-04-23 05:22:03 +0000 | [diff] [blame] | 197 | <img src="images/actions/ActionsSelBoundarySimple.png"></div> |
mparker | a684092 | 2010-04-28 17:51:29 +0000 | [diff] [blame] | 198 | |
| 199 | </td> |
mparker | 7c6347a | 2010-04-14 02:36:22 +0000 | [diff] [blame] | 200 | |
mparker | a684092 | 2010-04-28 17:51:29 +0000 | [diff] [blame] | 201 | </tr> |
| 202 | </table> |
mparker | 8b5614b | 2010-06-17 23:18:38 +0000 | [diff] [blame] | 203 | <table id="N10351"> |
mparker | a684092 | 2010-04-28 17:51:29 +0000 | [diff] [blame] | 204 | <tr> |
| 205 | |
| 206 | <td>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> |
| 207 | <td> |
| 208 | |
mparker | 7c6347a | 2010-04-14 02:36:22 +0000 | [diff] [blame] | 209 | <div class="mediaobject"> |
mparker | a684092 | 2010-04-28 17:51:29 +0000 | [diff] [blame] | 210 | <img src="images/actions/ActionsSelBoundary2Parts.png"></div> |
| 211 | |
| 212 | </td> |
| 213 | |
| 214 | </tr> |
| 215 | </table> |
| 216 | <p>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:</p> |
mparker | 7c6347a | 2010-04-14 02:36:22 +0000 | [diff] [blame] | 217 | <div class="orderedlist"> |
| 218 | <ol class="orderedlist" type="1"> |
| 219 | <li class="listitem"> |
| 220 | <p>A Query Action is not followed by a Logic Action, or</p> |
| 221 | </li> |
| 222 | <li class="listitem"> |
| 223 | <p>A Logic Action is not followed by another Logic Action</p> |
| 224 | </li> |
| 225 | </ol> |
| 226 | </div> |
mparker | 8b5614b | 2010-06-17 23:18:38 +0000 | [diff] [blame] | 227 | <table id="N1036E"> |
mparker | a684092 | 2010-04-28 17:51:29 +0000 | [diff] [blame] | 228 | <tr> |
| 229 | |
| 230 | <td>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> |
| 231 | <td> |
| 232 | |
mparker | 7c6347a | 2010-04-14 02:36:22 +0000 | [diff] [blame] | 233 | <div class="mediaobject"> |
mparker | 668331c | 2010-04-23 05:22:03 +0000 | [diff] [blame] | 234 | <img src="images/actions/ActionsSelBoundary11A.png"></div> |
mparker | a684092 | 2010-04-28 17:51:29 +0000 | [diff] [blame] | 235 | |
| 236 | </td> |
| 237 | |
| 238 | </tr> |
| 239 | </table> |
mparker | 7c6347a | 2010-04-14 02:36:22 +0000 | [diff] [blame] | 240 | <p>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.</p> |
| 241 | <p>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 |
| 242 | <span class="italic">then</span> 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. |
| 243 | </p> |
| 244 | <p> |
| 245 | |
| 246 | </p> |
| 247 | <div class="mediaobject"> |
mparker | 668331c | 2010-04-23 05:22:03 +0000 | [diff] [blame] | 248 | <img src="images/actions/ActionsSelBoundaryComplex.png"></div> |
mparker | 7c6347a | 2010-04-14 02:36:22 +0000 | [diff] [blame] | 249 | <p> |
| 250 | |
| 251 | </p> |
| 252 | <p>In the first case, we execute a search for all agents that meet the two criteria. This means that if there are |
| 253 | <span class="italic">any</span> 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. |
| 254 | </p> |
| 255 | </div> |
| 256 | <div class="section" title="Weaving"> |
| 257 | <div class="titlepage"> |
| 258 | <div> |
| 259 | <div> |
| 260 | <h4 class="title"> |
| 261 | <a name="Weaving"></a>Weaving</h4> |
| 262 | </div> |
| 263 | </div> |
| 264 | </div> |
mparker | 8b5614b | 2010-06-17 23:18:38 +0000 | [diff] [blame] | 265 | <table id="N10399"> |
mparker | a684092 | 2010-04-28 17:51:29 +0000 | [diff] [blame] | 266 | <tr> |
| 267 | |
| 268 | <td>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> |
| 269 | <td> |
| 270 | |
mparker | 7c6347a | 2010-04-14 02:36:22 +0000 | [diff] [blame] | 271 | <div class="mediaobject"> |
mparker | 668331c | 2010-04-23 05:22:03 +0000 | [diff] [blame] | 272 | <img src="images/actions/ActionsWeavingSetAnother.png"></div> |
mparker | a684092 | 2010-04-28 17:51:29 +0000 | [diff] [blame] | 273 | |
| 274 | </td> |
mparker | 7c6347a | 2010-04-14 02:36:22 +0000 | [diff] [blame] | 275 | |
mparker | a684092 | 2010-04-28 17:51:29 +0000 | [diff] [blame] | 276 | </tr> |
| 277 | </table> |
mparker | 8b5614b | 2010-06-17 23:18:38 +0000 | [diff] [blame] | 278 | <table id="N103AB"> |
mparker | a684092 | 2010-04-28 17:51:29 +0000 | [diff] [blame] | 279 | <tr> |
| 280 | |
| 281 | <td>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> |
| 282 | <td> |
| 283 | |
mparker | 7c6347a | 2010-04-14 02:36:22 +0000 | [diff] [blame] | 284 | <div class="mediaobject"> |
mparker | 668331c | 2010-04-23 05:22:03 +0000 | [diff] [blame] | 285 | <img src="images/actions/ActionsWeavingEvaluate.png"></div> |
mparker | a684092 | 2010-04-28 17:51:29 +0000 | [diff] [blame] | 286 | |
| 287 | </td> |
mparker | 7c6347a | 2010-04-14 02:36:22 +0000 | [diff] [blame] | 288 | |
mparker | a684092 | 2010-04-28 17:51:29 +0000 | [diff] [blame] | 289 | </tr> |
| 290 | </table> |
mparker | 8b5614b | 2010-06-17 23:18:38 +0000 | [diff] [blame] | 291 | <table id="N103BD"> |
mparker | a684092 | 2010-04-28 17:51:29 +0000 | [diff] [blame] | 292 | <tr> |
| 293 | |
| 294 | <td>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> |
| 295 | <td> |
| 296 | |
mparker | 7c6347a | 2010-04-14 02:36:22 +0000 | [diff] [blame] | 297 | <div class="mediaobject"> |
mparker | 668331c | 2010-04-23 05:22:03 +0000 | [diff] [blame] | 298 | <img src="images/actions/ActionsWeaving1A.png"></div> |
mparker | a684092 | 2010-04-28 17:51:29 +0000 | [diff] [blame] | 299 | |
| 300 | </td> |
mparker | 7c6347a | 2010-04-14 02:36:22 +0000 | [diff] [blame] | 301 | |
mparker | a684092 | 2010-04-28 17:51:29 +0000 | [diff] [blame] | 302 | </tr> |
| 303 | </table> |
mparker | 8b5614b | 2010-06-17 23:18:38 +0000 | [diff] [blame] | 304 | <table id="N103CF"> |
mparker | a684092 | 2010-04-28 17:51:29 +0000 | [diff] [blame] | 305 | <tr> |
| 306 | |
| 307 | <td>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> |
| 308 | <td> |
| 309 | |
mparker | 7c6347a | 2010-04-14 02:36:22 +0000 | [diff] [blame] | 310 | <div class="mediaobject"> |
mparker | 668331c | 2010-04-23 05:22:03 +0000 | [diff] [blame] | 311 | <img src="images/actions/ActionsWeaving2.png"></div> |
mparker | a684092 | 2010-04-28 17:51:29 +0000 | [diff] [blame] | 312 | |
| 313 | </td> |
| 314 | |
| 315 | </tr> |
| 316 | </table> |
mparker | 7c6347a | 2010-04-14 02:36:22 +0000 | [diff] [blame] | 317 | </div> |
| 318 | </div> |
mparker | 53e32b2 | 2010-04-24 04:17:28 +0000 | [diff] [blame] | 319 | <div class="section" title="Details"> |
mparker | 7c6347a | 2010-04-14 02:36:22 +0000 | [diff] [blame] | 320 | <div class="titlepage"> |
| 321 | <div> |
| 322 | <div> |
| 323 | <h3 class="title"> |
mparker | 53e32b2 | 2010-04-24 04:17:28 +0000 | [diff] [blame] | 324 | <a name="Details_3"></a>Details</h3> |
mparker | 7c6347a | 2010-04-14 02:36:22 +0000 | [diff] [blame] | 325 | </div> |
| 326 | </div> |
| 327 | </div> |
mparker | 8b5614b | 2010-06-17 23:18:38 +0000 | [diff] [blame] | 328 | <table id="N103E5"> |
mparker | a684092 | 2010-04-28 17:51:29 +0000 | [diff] [blame] | 329 | <tr> |
| 330 | |
mparker | 8b5614b | 2010-06-17 23:18:38 +0000 | [diff] [blame] | 331 | <td>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, but it is missing some of the more recent actions such as Diffusion, Perform, Derive and Cause. You might want to take a look at the meta-class diagrams in the reference section as well.</td> |
mparker | a684092 | 2010-04-28 17:51:29 +0000 | [diff] [blame] | 332 | <td> |
| 333 | |
mparker | 7c6347a | 2010-04-14 02:36:22 +0000 | [diff] [blame] | 334 | <div class="mediaobject"> |
mparker | a684092 | 2010-04-28 17:51:29 +0000 | [diff] [blame] | 335 | <img src="images/actions/ActionsBlocks.png"></div> |
| 336 | |
| 337 | </td> |
| 338 | |
| 339 | </tr> |
| 340 | </table> |
mparker | 7c6347a | 2010-04-14 02:36:22 +0000 | [diff] [blame] | 341 | <div class="section" title="Selections"> |
| 342 | <div class="titlepage"> |
| 343 | <div> |
| 344 | <div> |
| 345 | <h4 class="title"> |
| 346 | <a name="Selections_2"></a>Selections</h4> |
| 347 | </div> |
| 348 | </div> |
| 349 | </div> |
| 350 | <p>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.</p> |
| 351 | <div class="section" title="Select"> |
| 352 | <div class="titlepage"> |
| 353 | <div> |
| 354 | <div> |
| 355 | <h5 class="title"> |
| 356 | <a name="Select"></a>Select</h5> |
| 357 | </div> |
| 358 | </div> |
| 359 | </div> |
mparker | 8b5614b | 2010-06-17 23:18:38 +0000 | [diff] [blame] | 360 | <p>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 special kind of Select Action that are used to create agents. See the description in the Builders section below for more information.</p> |
mparker | 7c6347a | 2010-04-14 02:36:22 +0000 | [diff] [blame] | 361 | <div class="section" title="Selection"> |
| 362 | <div class="titlepage"> |
| 363 | <div> |
| 364 | <div> |
| 365 | <h6 class="title"> |
| 366 | <a name="Selection"></a>Selection</h6> |
| 367 | </div> |
| 368 | </div> |
| 369 | </div> |
| 370 | <p>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.</p> |
| 371 | </div> |
| 372 | <div class="section" title="Agent"> |
| 373 | <div class="titlepage"> |
| 374 | <div> |
| 375 | <div> |
| 376 | <h6 class="title"> |
| 377 | <a name="Agent"></a>Agent</h6> |
| 378 | </div> |
| 379 | </div> |
| 380 | </div> |
| 381 | <p>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.</p> |
| 382 | </div> |
| 383 | <div class="section" title="Space"> |
| 384 | <div class="titlepage"> |
| 385 | <div> |
| 386 | <div> |
| 387 | <h6 class="title"> |
| 388 | <a name="Space"></a>Space</h6> |
| 389 | </div> |
| 390 | </div> |
| 391 | </div> |
| 392 | <p>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.</p> |
| 393 | <p>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.</p> |
| 394 | </div> |
| 395 | <div class="section" title="For"> |
| 396 | <div class="titlepage"> |
| 397 | <div> |
| 398 | <div> |
| 399 | <h6 class="title"> |
| 400 | <a name="For"></a>For</h6> |
| 401 | </div> |
| 402 | </div> |
| 403 | </div> |
| 404 | <p>This value is obsolete and will be replaced with a different mechanism in the next version of the modeling environment.</p> |
| 405 | </div> |
| 406 | </div> |
| 407 | <div class="section" title="Query"> |
| 408 | <div class="titlepage"> |
| 409 | <div> |
| 410 | <div> |
| 411 | <h5 class="title"> |
| 412 | <a name="Query"></a>Query</h5> |
| 413 | </div> |
| 414 | </div> |
| 415 | </div> |
| 416 | <p>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. </p> |
mparker | 668331c | 2010-04-23 05:22:03 +0000 | [diff] [blame] | 417 | <div class="section" title="Selection"> |
| 418 | <div class="titlepage"> |
| 419 | <div> |
| 420 | <div> |
| 421 | <h6 class="title"> |
| 422 | <a name="Selection_2"></a>Selection</h6> |
| 423 | </div> |
| 424 | </div> |
| 425 | </div> |
| 426 | <p>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.</p> |
| 427 | </div> |
mparker | 7c6347a | 2010-04-14 02:36:22 +0000 | [diff] [blame] | 428 | <div class="section" title="Function"> |
| 429 | <div class="titlepage"> |
| 430 | <div> |
| 431 | <div> |
| 432 | <h6 class="title"> |
| 433 | <a name="Function"></a>Function</h6> |
| 434 | </div> |
| 435 | </div> |
| 436 | </div> |
mparker | 668331c | 2010-04-23 05:22:03 +0000 | [diff] [blame] | 437 | <p>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.</p> |
| 438 | </div> |
| 439 | <div class="section" title="Inputs"> |
| 440 | <div class="titlepage"> |
| 441 | <div> |
| 442 | <div> |
| 443 | <h6 class="title"> |
| 444 | <a name="Inputs"></a>Inputs</h6> |
| 445 | </div> |
| 446 | </div> |
| 447 | </div> |
| 448 | <p>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.</p> |
mparker | 7c6347a | 2010-04-14 02:36:22 +0000 | [diff] [blame] | 449 | </div> |
| 450 | </div> |
| 451 | <div class="section" title="Logic"> |
| 452 | <div class="titlepage"> |
| 453 | <div> |
| 454 | <div> |
| 455 | <h5 class="title"> |
| 456 | <a name="Logic"></a>Logic</h5> |
| 457 | </div> |
| 458 | </div> |
| 459 | </div> |
| 460 | <p>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.</p> |
| 461 | </div> |
| 462 | <div class="section" title="Intersection"> |
| 463 | <div class="titlepage"> |
| 464 | <div> |
| 465 | <div> |
| 466 | <h5 class="title"> |
| 467 | <a name="Intersection"></a>Intersection</h5> |
| 468 | </div> |
| 469 | </div> |
| 470 | </div> |
| 471 | <p>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 && 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.</p> |
| 472 | </div> |
| 473 | <div class="section" title="Union"> |
| 474 | <div class="titlepage"> |
| 475 | <div> |
| 476 | <div> |
| 477 | <h5 class="title"> |
| 478 | <a name="Union"></a>Union</h5> |
| 479 | </div> |
| 480 | </div> |
| 481 | </div> |
| 482 | <p>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.</p> |
| 483 | </div> |
| 484 | <div class="section" title="Difference"> |
| 485 | <div class="titlepage"> |
| 486 | <div> |
| 487 | <div> |
| 488 | <h5 class="title"> |
| 489 | <a name="Difference"></a>Difference</h5> |
| 490 | </div> |
| 491 | </div> |
| 492 | </div> |
| 493 | <p>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.</p> |
| 494 | </div> |
mparker | 8f20bf1 | 2010-04-17 23:58:19 +0000 | [diff] [blame] | 495 | </div> |
mparker | 8b5614b | 2010-06-17 23:18:38 +0000 | [diff] [blame] | 496 | <div class="section" title="Root Actions"> |
mparker | 7c6347a | 2010-04-14 02:36:22 +0000 | [diff] [blame] | 497 | <div class="titlepage"> |
| 498 | <div> |
| 499 | <div> |
mparker | 8f20bf1 | 2010-04-17 23:58:19 +0000 | [diff] [blame] | 500 | <h4 class="title"> |
mparker | 8b5614b | 2010-06-17 23:18:38 +0000 | [diff] [blame] | 501 | <a name="Root_Actions"></a>Root Actions</h4> |
mparker | 7c6347a | 2010-04-14 02:36:22 +0000 | [diff] [blame] | 502 | </div> |
| 503 | </div> |
| 504 | </div> |
| 505 | <p>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.</p> |
mparker | 7c6347a | 2010-04-14 02:36:22 +0000 | [diff] [blame] | 506 | <div class="section" title="Build"> |
| 507 | <div class="titlepage"> |
| 508 | <div> |
| 509 | <div> |
| 510 | <h5 class="title"> |
| 511 | <a name="Build"></a>Build</h5> |
| 512 | </div> |
| 513 | </div> |
| 514 | </div> |
| 515 | <p>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.</p> |
| 516 | </div> |
| 517 | <div class="section" title="Initialize"> |
| 518 | <div class="titlepage"> |
| 519 | <div> |
| 520 | <div> |
| 521 | <h5 class="title"> |
| 522 | <a name="Initialize"></a>Initialize</h5> |
| 523 | </div> |
| 524 | </div> |
| 525 | </div> |
| 526 | <p>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.</p> |
| 527 | </div> |
| 528 | <div class="section" title="Rule"> |
| 529 | <div class="titlepage"> |
| 530 | <div> |
| 531 | <div> |
| 532 | <h5 class="title"> |
| 533 | <a name="Rule"></a>Rule</h5> |
| 534 | </div> |
| 535 | </div> |
| 536 | </div> |
| 537 | <p>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.</p> |
| 538 | </div> |
| 539 | <div class="section" title="Schedule"> |
| 540 | <div class="titlepage"> |
| 541 | <div> |
| 542 | <div> |
| 543 | <h5 class="title"> |
| 544 | <a name="Schedule"></a>Schedule</h5> |
| 545 | </div> |
| 546 | </div> |
| 547 | </div> |
| 548 | <p>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.</p> |
| 549 | <div class="section" title="Start"> |
| 550 | <div class="titlepage"> |
| 551 | <div> |
| 552 | <div> |
| 553 | <h6 class="title"> |
| 554 | <a name="Start"></a>Start</h6> |
| 555 | </div> |
| 556 | </div> |
| 557 | </div> |
| 558 | <p>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..</p> |
| 559 | </div> |
| 560 | <div class="section" title="Interval"> |
| 561 | <div class="titlepage"> |
| 562 | <div> |
| 563 | <div> |
| 564 | <h6 class="title"> |
| 565 | <a name="Interval"></a>Interval</h6> |
| 566 | </div> |
| 567 | </div> |
| 568 | </div> |
| 569 | <p>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..</p> |
| 570 | </div> |
| 571 | <div class="section" title="Priority"> |
| 572 | <div class="titlepage"> |
| 573 | <div> |
| 574 | <div> |
| 575 | <h6 class="title"> |
| 576 | <a name="Priority"></a>Priority</h6> |
| 577 | </div> |
| 578 | </div> |
| 579 | </div> |
| 580 | <p>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.</p> |
| 581 | </div> |
| 582 | <div class="section" title="Pick"> |
| 583 | <div class="titlepage"> |
| 584 | <div> |
| 585 | <div> |
| 586 | <h6 class="title"> |
| 587 | <a name="Pick"></a>Pick</h6> |
| 588 | </div> |
| 589 | </div> |
| 590 | </div> |
| 591 | <p>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.</p> |
| 592 | </div> |
| 593 | </div> |
| 594 | <div class="section" title="Watch"> |
| 595 | <div class="titlepage"> |
| 596 | <div> |
| 597 | <div> |
| 598 | <h5 class="title"> |
| 599 | <a name="Watch"></a>Watch</h5> |
| 600 | </div> |
| 601 | </div> |
| 602 | </div> |
mparker | 8b5614b | 2010-06-17 23:18:38 +0000 | [diff] [blame] | 603 | <p>A Watch 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.</p> |
mparker | 7c6347a | 2010-04-14 02:36:22 +0000 | [diff] [blame] | 604 | <div class="section" title="Attribute"> |
| 605 | <div class="titlepage"> |
| 606 | <div> |
| 607 | <div> |
| 608 | <h6 class="title"> |
| 609 | <a name="Attribute"></a>Attribute</h6> |
| 610 | </div> |
| 611 | </div> |
| 612 | </div> |
| 613 | <p>The attribute that will be monitored for change.</p> |
| 614 | </div> |
| 615 | </div> |
mparker | 8b5614b | 2010-06-17 23:18:38 +0000 | [diff] [blame] | 616 | <div class="section" title="Derive"> |
| 617 | <div class="titlepage"> |
| 618 | <div> |
| 619 | <div> |
| 620 | <h5 class="title"> |
| 621 | <a name="Derive"></a>Derive</h5> |
| 622 | </div> |
| 623 | </div> |
| 624 | </div> |
| 625 | <p>A Derive action is a unique kind of root that is used to determine that value of a derived attribute. There can be one and only one Derive action for each such attribute. One of the benefits of a derived action is that unlike a standard attribute, it only needs to be calculated when the value is actually needed and its inputs have also been changes -- allowing signifcant performance optimizations to be made. Derived actions can also make model behavior much more clear. Derive actions are especially useful for calculating dependent measures for model agents. These in turn can be used directly in charting and data output tools -- leaving no need to configure your chart view calculations seperatly. Developers need not worry about overhead and should feel free to create as many derived attributes as might be neccessary. The "gather data" value of the derived attribute can always be set to false to prevent data collection overhead when they aren't needed.</p> |
| 626 | <p>The derived value will always simply be the value of the last evaluation in a particular flow. You can mix queries and even selections on seperate agents into a derived value. The only restriction is that the type of the last Evaluate actions(s) must match the type of the value. If there is no path leading to an Evalutate action for a particular agent state, the attributes default value will be used.</p> |
| 627 | <div class="section" title="Attribute"> |
| 628 | <div class="titlepage"> |
| 629 | <div> |
| 630 | <div> |
| 631 | <h6 class="title"> |
| 632 | <a name="Attribute_2"></a>Attribute</h6> |
| 633 | </div> |
| 634 | </div> |
| 635 | </div> |
| 636 | <p>The attribute that will be derived.</p> |
| 637 | </div> |
| 638 | </div> |
| 639 | <div class="section" title="Diffuse"> |
| 640 | <div class="titlepage"> |
| 641 | <div> |
| 642 | <div> |
| 643 | <h5 class="title"> |
| 644 | <a name="Diffuse"></a>Diffuse</h5> |
| 645 | </div> |
| 646 | </div> |
| 647 | </div> |
| 648 | <p>The diffuse action provides high level support for the common behavior of diffusing some value across some lattice space. For example, heat may spread over time from one grid cell to the next. (There are actually significant issues involved in implementing this through lower level actions.) To specify that a value should diffuse through a space you simply need to provide the following values. This action does not need and shouldn't include target actions. The "Heatbugs" model in the org.eclipse.amp.amf.examples.escape project provides a good example for how diffusion can be easily implemented into any grid model.</p> |
| 649 | <div class="section" title="Diffused"> |
| 650 | <div class="titlepage"> |
| 651 | <div> |
| 652 | <div> |
| 653 | <h6 class="title"> |
| 654 | <a name="Diffused"></a>Diffused</h6> |
| 655 | </div> |
| 656 | </div> |
| 657 | </div> |
| 658 | <p>The attribute whose value is to be diffused.</p> |
| 659 | </div> |
| 660 | <div class="section" title="Diiffusion Rate="> |
| 661 | <div class="titlepage"> |
| 662 | <div> |
| 663 | <div> |
| 664 | <h6 class="title"> |
| 665 | <a name="Diiffusion_Rate.3D"></a>Diiffusion Rate=</h6> |
| 666 | </div> |
| 667 | </div> |
| 668 | </div> |
| 669 | <p>The rate at which any given cell's attribute value is transferred to surrounding cells.</p> |
| 670 | </div> |
| 671 | <div class="section" title="Evaporation Rate"> |
| 672 | <div class="titlepage"> |
| 673 | <div> |
| 674 | <div> |
| 675 | <h6 class="title"> |
| 676 | <a name="Evaporation_Rate"></a>Evaporation Rate</h6> |
| 677 | </div> |
| 678 | </div> |
| 679 | </div> |
| 680 | <p>An optional rate by which each cells value is reduced for each period. This is useful for a model where agents are creating energy within the environment.</p> |
| 681 | </div> |
| 682 | </div> |
| 683 | <div class="section" title="Perform"> |
| 684 | <div class="titlepage"> |
| 685 | <div> |
| 686 | <div> |
| 687 | <h5 class="title"> |
| 688 | <a name="Perform"></a>Perform</h5> |
| 689 | </div> |
| 690 | </div> |
| 691 | </div> |
| 692 | <p>A Perform root action simply defines a set of actions that have no independent trigger. The only way Perform actions can occur is if a Cause action specifes one as a result. Performs then are similar to sub-calls or helper methods within a traditonal procedural or OO language, and can be very helpful in organizing and simlplifying code. Note that whenever you use a Perform instead of directly specifying a set of targets you lose the context of the selection. You couldn't use a Perform to directly trigger a move as the selection source for the move would not be available.</p> |
| 693 | </div> |
mparker | 7c6347a | 2010-04-14 02:36:22 +0000 | [diff] [blame] | 694 | </div> |
mparker | 8f20bf1 | 2010-04-17 23:58:19 +0000 | [diff] [blame] | 695 | <div class="section" title="Builders"> |
| 696 | <div class="titlepage"> |
| 697 | <div> |
| 698 | <div> |
| 699 | <h4 class="title"> |
| 700 | <a name="Builders"></a>Builders</h4> |
| 701 | </div> |
| 702 | </div> |
| 703 | </div> |
| 704 | <p>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.</p> |
| 705 | <div class="section" title="Create Agents"> |
| 706 | <div class="titlepage"> |
| 707 | <div> |
| 708 | <div> |
| 709 | <h5 class="title"> |
| 710 | <a name="Create_Agents"></a>Create Agents</h5> |
| 711 | </div> |
| 712 | </div> |
| 713 | </div> |
| 714 | <p>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 |
| 715 | <span class="italic">not</span> 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.) |
| 716 | </p> |
| 717 | <div class="section" title="Agent"> |
| 718 | <div class="titlepage"> |
| 719 | <div> |
| 720 | <div> |
| 721 | <h6 class="title"> |
| 722 | <a name="Agent_2"></a>Agent</h6> |
| 723 | </div> |
| 724 | </div> |
| 725 | </div> |
| 726 | <p>The kind of agent to create.</p> |
| 727 | </div> |
| 728 | <div class="section" title="Selection"> |
| 729 | <div class="titlepage"> |
| 730 | <div> |
| 731 | <div> |
| 732 | <h6 class="title"> |
mparker | 668331c | 2010-04-23 05:22:03 +0000 | [diff] [blame] | 733 | <a name="Selection_3"></a>Selection</h6> |
mparker | 8f20bf1 | 2010-04-17 23:58:19 +0000 | [diff] [blame] | 734 | </div> |
| 735 | </div> |
| 736 | </div> |
| 737 | <p>The selection to use as the basic for this selection. This is generally not important except to define control flow.</p> |
| 738 | </div> |
| 739 | <div class="section" title="Space"> |
| 740 | <div class="titlepage"> |
| 741 | <div> |
| 742 | <div> |
| 743 | <h6 class="title"> |
| 744 | <a name="Space_2"></a>Space</h6> |
| 745 | </div> |
| 746 | </div> |
| 747 | </div> |
| 748 | <p>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.</p> |
| 749 | </div> |
mparker | 668331c | 2010-04-23 05:22:03 +0000 | [diff] [blame] | 750 | <div class="section" title="Agent Count"> |
mparker | 8f20bf1 | 2010-04-17 23:58:19 +0000 | [diff] [blame] | 751 | <div class="titlepage"> |
| 752 | <div> |
| 753 | <div> |
| 754 | <h6 class="title"> |
mparker | 668331c | 2010-04-23 05:22:03 +0000 | [diff] [blame] | 755 | <a name="Agent_Count"></a>Agent Count</h6> |
mparker | 8f20bf1 | 2010-04-17 23:58:19 +0000 | [diff] [blame] | 756 | </div> |
| 757 | </div> |
| 758 | </div> |
| 759 | <p>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.</p> |
| 760 | </div> |
| 761 | <div class="section" title="For"> |
| 762 | <div class="titlepage"> |
| 763 | <div> |
| 764 | <div> |
| 765 | <h6 class="title"> |
| 766 | <a name="For_2"></a>For</h6> |
| 767 | </div> |
| 768 | </div> |
| 769 | </div> |
| 770 | <p>Deprected. Should not be used.</p> |
| 771 | </div> |
| 772 | </div> |
| 773 | <div class="section" title="Create Shaped Agent"> |
| 774 | <div class="titlepage"> |
| 775 | <div> |
| 776 | <div> |
| 777 | <h5 class="title"> |
| 778 | <a name="Create_Shaped_Agent"></a>Create Shaped Agent</h5> |
| 779 | </div> |
| 780 | </div> |
| 781 | </div> |
| 782 | <p>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:</p> |
| 783 | <div class="section" title="Shape"> |
| 784 | <div class="titlepage"> |
| 785 | <div> |
| 786 | <div> |
| 787 | <h6 class="title"> |
| 788 | <a name="Shape"></a>Shape</h6> |
| 789 | </div> |
| 790 | </div> |
| 791 | </div> |
| 792 | <p>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:</p> |
| 793 | <div class="variablelist"> |
| 794 | <dl> |
| 795 | <dt> |
| 796 | <span class="term">Point</span> |
| 797 | </dt> |
| 798 | <dd> |
| 799 | <p>A simple point in space, fully equivalent to a standard continuous space location.</p> |
| 800 | </dd> |
| 801 | <dt> |
| 802 | <span class="term">Line</span> |
| 803 | </dt> |
| 804 | <dd> |
| 805 | <p>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.</p> |
| 806 | </dd> |
| 807 | <dt> |
| 808 | <span class="term">Polygon</span> |
| 809 | </dt> |
| 810 | <dd> |
| 811 | <p>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.</p> |
| 812 | </dd> |
| 813 | </dl> |
| 814 | </div> |
| 815 | </div> |
| 816 | </div> |
| 817 | <div class="section" title="Load Agents"> |
| 818 | <div class="titlepage"> |
| 819 | <div> |
| 820 | <div> |
| 821 | <h5 class="title"> |
| 822 | <a name="Load_Agents"></a>Load Agents</h5> |
| 823 | </div> |
| 824 | </div> |
| 825 | </div> |
| 826 | <p>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:</p> |
| 827 | <div class="section" title="Source URL"> |
| 828 | <div class="titlepage"> |
| 829 | <div> |
| 830 | <div> |
| 831 | <h6 class="title"> |
| 832 | <a name="Source_URL"></a>Source URL</h6> |
| 833 | </div> |
| 834 | </div> |
| 835 | </div> |
| 836 | <p>The location of the input file or set of meta-data used to determine the location and type of the input file.</p> |
| 837 | </div> |
| 838 | </div> |
| 839 | <div class="section" title="Load Shaped Agents"> |
| 840 | <div class="titlepage"> |
| 841 | <div> |
| 842 | <div> |
| 843 | <h5 class="title"> |
| 844 | <a name="Load_Shaped_Agents"></a>Load Shaped Agents</h5> |
| 845 | </div> |
| 846 | </div> |
| 847 | </div> |
| 848 | <p>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.</p> |
| 849 | </div> |
| 850 | <div class="section" title="Build Network"> |
| 851 | <div class="titlepage"> |
| 852 | <div> |
| 853 | <div> |
| 854 | <h5 class="title"> |
| 855 | <a name="Build_Network"></a>Build Network</h5> |
| 856 | </div> |
| 857 | </div> |
| 858 | </div> |
| 859 | <p>Creates a network, i.e. a graph structure, supporting the establishment of edges between arbitrary nodes.</p> |
| 860 | <div class="section" title="Agents"> |
| 861 | <div class="titlepage"> |
| 862 | <div> |
| 863 | <div> |
| 864 | <h6 class="title"> |
| 865 | <a name="Agents_3"></a>Agents</h6> |
| 866 | </div> |
| 867 | </div> |
| 868 | </div> |
| 869 | <p>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.)</p> |
| 870 | </div> |
| 871 | <div class="section" title="Attributes"> |
| 872 | <div class="titlepage"> |
| 873 | <div> |
| 874 | <div> |
| 875 | <h6 class="title"> |
| 876 | <a name="Attributes_3"></a>Attributes</h6> |
| 877 | </div> |
| 878 | </div> |
| 879 | </div> |
| 880 | <p>Not currently used for networks.</p> |
| 881 | </div> |
| 882 | <div class="section" title="Network Type"> |
| 883 | <div class="titlepage"> |
| 884 | <div> |
| 885 | <div> |
| 886 | <h6 class="title"> |
| 887 | <a name="Network_Type"></a>Network Type</h6> |
| 888 | </div> |
| 889 | </div> |
| 890 | </div> |
| 891 | <p>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.</p> |
| 892 | </div> |
| 893 | <div class="section" title="Selection"> |
| 894 | <div class="titlepage"> |
| 895 | <div> |
| 896 | <div> |
| 897 | <h6 class="title"> |
mparker | 668331c | 2010-04-23 05:22:03 +0000 | [diff] [blame] | 898 | <a name="Selection_4"></a>Selection</h6> |
mparker | 8f20bf1 | 2010-04-17 23:58:19 +0000 | [diff] [blame] | 899 | </div> |
| 900 | </div> |
| 901 | </div> |
| 902 | <p>Not relevant for network builders except as part of normal control flow.</p> |
| 903 | </div> |
| 904 | </div> |
| 905 | <div class="section" title="Build Grid"> |
| 906 | <div class="titlepage"> |
| 907 | <div> |
| 908 | <div> |
| 909 | <h5 class="title"> |
| 910 | <a name="Build_Grid"></a>Build Grid</h5> |
| 911 | </div> |
| 912 | </div> |
| 913 | </div> |
| 914 | <p>Creates a grid space.</p> |
| 915 | <div class="section" title="Agents"> |
| 916 | <div class="titlepage"> |
| 917 | <div> |
| 918 | <div> |
| 919 | <h6 class="title"> |
| 920 | <a name="Agents_4"></a>Agents</h6> |
| 921 | </div> |
| 922 | </div> |
| 923 | </div> |
| 924 | <p>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.</p> |
| 925 | </div> |
| 926 | <div class="section" title="Fill Agent"> |
| 927 | <div class="titlepage"> |
| 928 | <div> |
| 929 | <div> |
| 930 | <h6 class="title"> |
| 931 | <a name="Fill_Agent"></a>Fill Agent</h6> |
| 932 | </div> |
| 933 | </div> |
| 934 | </div> |
| 935 | <p>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.</p> |
| 936 | </div> |
| 937 | <div class="section" title="Space Type"> |
| 938 | <div class="titlepage"> |
| 939 | <div> |
| 940 | <div> |
| 941 | <h6 class="title"> |
| 942 | <a name="Space_Type"></a>Space Type</h6> |
| 943 | </div> |
| 944 | </div> |
| 945 | </div> |
| 946 | <p>Deprecated. Should not be used.</p> |
| 947 | </div> |
| 948 | <div class="section" title="Selection"> |
| 949 | <div class="titlepage"> |
| 950 | <div> |
| 951 | <div> |
| 952 | <h6 class="title"> |
mparker | 668331c | 2010-04-23 05:22:03 +0000 | [diff] [blame] | 953 | <a name="Selection_5"></a>Selection</h6> |
mparker | 8f20bf1 | 2010-04-17 23:58:19 +0000 | [diff] [blame] | 954 | </div> |
| 955 | </div> |
| 956 | </div> |
| 957 | <p>Not relevant for builders except as part of normal control flow.</p> |
| 958 | </div> |
| 959 | <div class="section" title="Attributes"> |
| 960 | <div class="titlepage"> |
| 961 | <div> |
| 962 | <div> |
| 963 | <h6 class="title"> |
| 964 | <a name="Attributes_4"></a>Attributes</h6> |
| 965 | </div> |
| 966 | </div> |
| 967 | </div> |
| 968 | <p>Not currently used for spaces.</p> |
| 969 | </div> |
| 970 | </div> |
| 971 | <div class="section" title="Build Space"> |
| 972 | <div class="titlepage"> |
| 973 | <div> |
| 974 | <div> |
| 975 | <h5 class="title"> |
| 976 | <a name="Build_Space"></a>Build Space</h5> |
| 977 | </div> |
| 978 | </div> |
| 979 | </div> |
| 980 | <p>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.</p> |
| 981 | <div class="section" title="Agents"> |
| 982 | <div class="titlepage"> |
| 983 | <div> |
| 984 | <div> |
| 985 | <h6 class="title"> |
| 986 | <a name="Agents_5"></a>Agents</h6> |
| 987 | </div> |
| 988 | </div> |
| 989 | </div> |
| 990 | <p>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.)</p> |
| 991 | </div> |
| 992 | </div> |
| 993 | <div class="section" title="Build Geography"> |
| 994 | <div class="titlepage"> |
| 995 | <div> |
| 996 | <div> |
| 997 | <h5 class="title"> |
| 998 | <a name="Build_Geography"></a>Build Geography</h5> |
| 999 | </div> |
| 1000 | </div> |
| 1001 | </div> |
| 1002 | <p>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.</p> |
mparker | 7c6347a | 2010-04-14 02:36:22 +0000 | [diff] [blame] | 1003 | </div> |
| 1004 | </div> |
mparker | 668331c | 2010-04-23 05:22:03 +0000 | [diff] [blame] | 1005 | <div class="section" title="Commands"> |
| 1006 | <div class="titlepage"> |
| 1007 | <div> |
| 1008 | <div> |
| 1009 | <h4 class="title"> |
| 1010 | <a name="Commands"></a>Commands</h4> |
| 1011 | </div> |
| 1012 | </div> |
| 1013 | </div> |
| 1014 | <div class="section" title="Evaluate"> |
| 1015 | <div class="titlepage"> |
| 1016 | <div> |
| 1017 | <div> |
| 1018 | <h5 class="title"> |
| 1019 | <a name="Evaluate"></a>Evaluate</h5> |
| 1020 | </div> |
| 1021 | </div> |
| 1022 | </div> |
| 1023 | <p>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.</p> |
| 1024 | <div class="section" title="Selection"> |
| 1025 | <div class="titlepage"> |
| 1026 | <div> |
| 1027 | <div> |
| 1028 | <h6 class="title"> |
| 1029 | <a name="Selection_6"></a>Selection</h6> |
| 1030 | </div> |
| 1031 | </div> |
| 1032 | </div> |
| 1033 | <p>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.</p> |
| 1034 | </div> |
| 1035 | <div class="section" title="Function"> |
| 1036 | <div class="titlepage"> |
| 1037 | <div> |
| 1038 | <div> |
| 1039 | <h6 class="title"> |
| 1040 | <a name="Function_2"></a>Function</h6> |
| 1041 | </div> |
| 1042 | </div> |
| 1043 | </div> |
| 1044 | <p>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.</p> |
| 1045 | </div> |
| 1046 | <div class="section" title="Inputs"> |
| 1047 | <div class="titlepage"> |
| 1048 | <div> |
| 1049 | <div> |
| 1050 | <h6 class="title"> |
| 1051 | <a name="Inputs_2"></a>Inputs</h6> |
| 1052 | </div> |
| 1053 | </div> |
| 1054 | </div> |
| 1055 | <p>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.</p> |
| 1056 | </div> |
| 1057 | </div> |
| 1058 | <div class="section" title="Set"> |
| 1059 | <div class="titlepage"> |
| 1060 | <div> |
| 1061 | <div> |
| 1062 | <h5 class="title"> |
| 1063 | <a name="Set"></a>Set</h5> |
| 1064 | </div> |
| 1065 | </div> |
| 1066 | </div> |
| 1067 | <p>The Set Action assigns some value to another value.</p> |
| 1068 | <div class="section" title="Selection"> |
| 1069 | <div class="titlepage"> |
| 1070 | <div> |
| 1071 | <div> |
| 1072 | <h6 class="title"> |
| 1073 | <a name="Selection_7"></a>Selection</h6> |
| 1074 | </div> |
| 1075 | </div> |
| 1076 | </div> |
mparker | 8b5614b | 2010-06-17 23:18:38 +0000 | [diff] [blame] | 1077 | <p>Here the selection refers to the agent that we want to change. This does not have to be the immediatly preceeding selection but can be any accessible selection.</p> |
mparker | 668331c | 2010-04-23 05:22:03 +0000 | [diff] [blame] | 1078 | </div> |
| 1079 | <div class="section" title="Attribute"> |
| 1080 | <div class="titlepage"> |
| 1081 | <div> |
| 1082 | <div> |
| 1083 | <h6 class="title"> |
mparker | 8b5614b | 2010-06-17 23:18:38 +0000 | [diff] [blame] | 1084 | <a name="Attribute_3"></a>Attribute</h6> |
mparker | 668331c | 2010-04-23 05:22:03 +0000 | [diff] [blame] | 1085 | </div> |
| 1086 | </div> |
| 1087 | </div> |
| 1088 | <p>The attribute to modify. It must be a member of this action's agent or of that agent's parent context.</p> |
| 1089 | </div> |
| 1090 | <div class="section" title="Parameter"> |
| 1091 | <div class="titlepage"> |
| 1092 | <div> |
| 1093 | <div> |
| 1094 | <h6 class="title"> |
| 1095 | <a name="Parameter"></a>Parameter</h6> |
| 1096 | </div> |
| 1097 | </div> |
| 1098 | </div> |
| 1099 | <p>The value to assign to the attribute. Here, we can use either another agent attribute, or the results of a source evaluation. </p> |
| 1100 | </div> |
| 1101 | </div> |
mparker | 8b5614b | 2010-06-17 23:18:38 +0000 | [diff] [blame] | 1102 | <div class="section" title="Cause"> |
| 1103 | <div class="titlepage"> |
| 1104 | <div> |
| 1105 | <div> |
| 1106 | <h5 class="title"> |
| 1107 | <a name="Cause"></a>Cause</h5> |
| 1108 | </div> |
| 1109 | </div> |
| 1110 | </div> |
| 1111 | <p>A Cause Action "causes" some Root Action to occur upon the specified selection. This action can be extremely useful for organizing model behavior and preventing the need for creating duplicate action definitions.</p> |
| 1112 | <p>Cause actions also support recursive functionality and "WHILE" behavior. These can be used to mimic loop strucutres. For example, you might want an agent to execute some behavior as long as that agent has energy remaining. To accomplish this, you could create a query for "energy > 0" and then create a Cause target with the root action as its results.</p> |
| 1113 | <p>Note that you should be cautious and thoughtful when using the Cause action. Remember that selections represent sets of agents and thus get rid of the need for collection loop strucutures -- such as Java "for each" -- common in traditional programming languages. You should be able to do almost anything that might require a loop strucutre using the selection mechanism itself. Also, just as with a traditional language, you should be careful about defining cause actions that trigger their own root actions or that cause other actions to in turn trigger the orginal root action. You can easily end up defining infinite loops in this way. (In the current implementation this will eventually trigger a stack overflow error as cause invocations are recursive, but future implementations will be able to infer target language loop strcutures to prevent stack depth issues.)</p> |
| 1114 | <div class="section" title="Result"> |
| 1115 | <div class="titlepage"> |
| 1116 | <div> |
| 1117 | <div> |
| 1118 | <h6 class="title"> |
| 1119 | <a name="Result"></a>Result</h6> |
| 1120 | </div> |
| 1121 | </div> |
| 1122 | </div> |
| 1123 | <p>The root aciton that should be trigerred for every memeber of the current selection. This is typically a Perform action but it can be any kind of root action except for "Derived". (Which doesn't make any sense to do.)</p> |
| 1124 | </div> |
| 1125 | </div> |
mparker | 668331c | 2010-04-23 05:22:03 +0000 | [diff] [blame] | 1126 | <div class="section" title="Move"> |
| 1127 | <div class="titlepage"> |
| 1128 | <div> |
| 1129 | <div> |
| 1130 | <h5 class="title"> |
| 1131 | <a name="Move"></a>Move</h5> |
| 1132 | </div> |
| 1133 | </div> |
| 1134 | </div> |
| 1135 | <p>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.</p> |
| 1136 | <div class="section" title="Selection"> |
| 1137 | <div class="titlepage"> |
| 1138 | <div> |
| 1139 | <div> |
| 1140 | <h6 class="title"> |
| 1141 | <a name="Selection_8"></a>Selection</h6> |
| 1142 | </div> |
| 1143 | </div> |
| 1144 | </div> |
| 1145 | <p>As in any other action, the selection determines what agent is affected -- in this case the agent that is being moved.</p> |
| 1146 | </div> |
| 1147 | <div class="section" title="Destination"> |
| 1148 | <div class="titlepage"> |
| 1149 | <div> |
| 1150 | <div> |
| 1151 | <h6 class="title"> |
| 1152 | <a name="Destination"></a>Destination</h6> |
| 1153 | </div> |
| 1154 | </div> |
| 1155 | </div> |
| 1156 | <p>Specifies the target agent or location for the movement.</p> |
| 1157 | </div> |
| 1158 | </div> |
| 1159 | <div class="section" title="Leave"> |
| 1160 | <div class="titlepage"> |
| 1161 | <div> |
| 1162 | <div> |
| 1163 | <h5 class="title"> |
| 1164 | <a name="Leave"></a>Leave</h5> |
| 1165 | </div> |
| 1166 | </div> |
| 1167 | </div> |
| 1168 | <p>Causes the agent to leave a particular space.</p> |
| 1169 | <div class="section" title="Selection"> |
| 1170 | <div class="titlepage"> |
| 1171 | <div> |
| 1172 | <div> |
| 1173 | <h6 class="title"> |
| 1174 | <a name="Selection_9"></a>Selection</h6> |
| 1175 | </div> |
| 1176 | </div> |
| 1177 | </div> |
| 1178 | <p>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.</p> |
| 1179 | </div> |
| 1180 | <div class="section" title="Destination"> |
| 1181 | <div class="titlepage"> |
| 1182 | <div> |
| 1183 | <div> |
| 1184 | <h6 class="title"> |
| 1185 | <a name="Destination_2"></a>Destination</h6> |
| 1186 | </div> |
| 1187 | </div> |
| 1188 | </div> |
| 1189 | <p>The destination is irrelevant for a leave action and should not be specified.</p> |
| 1190 | </div> |
| 1191 | </div> |
| 1192 | <div class="section" title="Die"> |
| 1193 | <div class="titlepage"> |
| 1194 | <div> |
| 1195 | <div> |
| 1196 | <h5 class="title"> |
| 1197 | <a name="Die"></a>Die</h5> |
| 1198 | </div> |
| 1199 | </div> |
| 1200 | </div> |
| 1201 | <p>Causes the agent to cease to exist within the model as a whole.</p> |
| 1202 | <div class="section" title="Selection"> |
| 1203 | <div class="titlepage"> |
| 1204 | <div> |
| 1205 | <div> |
| 1206 | <h6 class="title"> |
| 1207 | <a name="Selection_10"></a>Selection</h6> |
| 1208 | </div> |
| 1209 | </div> |
| 1210 | </div> |
| 1211 | <p>The selection determines what space the agent to remove.</p> |
| 1212 | </div> |
mparker | 8b5614b | 2010-06-17 23:18:38 +0000 | [diff] [blame] | 1213 | <div class="section" title="Destination"> |
mparker | 668331c | 2010-04-23 05:22:03 +0000 | [diff] [blame] | 1214 | <div class="titlepage"> |
| 1215 | <div> |
| 1216 | <div> |
| 1217 | <h6 class="title"> |
mparker | 8b5614b | 2010-06-17 23:18:38 +0000 | [diff] [blame] | 1218 | <a name="Destination_3"></a>Destination</h6> |
mparker | 668331c | 2010-04-23 05:22:03 +0000 | [diff] [blame] | 1219 | </div> |
| 1220 | </div> |
| 1221 | </div> |
| 1222 | <p>The destination is irrelevant in this case and will probably be removed.</p> |
| 1223 | </div> |
| 1224 | </div> |
| 1225 | <div class="section" title="Connect"> |
| 1226 | <div class="titlepage"> |
| 1227 | <div> |
| 1228 | <div> |
| 1229 | <h5 class="title"> |
| 1230 | <a name="Connect"></a>Connect</h5> |
| 1231 | </div> |
| 1232 | </div> |
| 1233 | </div> |
| 1234 | <p>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.</p> |
| 1235 | <div class="section" title="Selection"> |
| 1236 | <div class="titlepage"> |
| 1237 | <div> |
| 1238 | <div> |
| 1239 | <h6 class="title"> |
| 1240 | <a name="Selection_11"></a>Selection</h6> |
| 1241 | </div> |
| 1242 | </div> |
| 1243 | </div> |
| 1244 | <p>The selection determines the agent that will be connected to another agent. In the case of a directed graph, this is the source node.</p> |
| 1245 | </div> |
| 1246 | <div class="section" title="=Destination"> |
| 1247 | <div class="titlepage"> |
| 1248 | <div> |
| 1249 | <div> |
| 1250 | <h6 class="title"> |
mparker | 8b5614b | 2010-06-17 23:18:38 +0000 | [diff] [blame] | 1251 | <a name=".3DDestination"></a>=Destination</h6> |
mparker | 668331c | 2010-04-23 05:22:03 +0000 | [diff] [blame] | 1252 | </div> |
| 1253 | </div> |
| 1254 | </div> |
| 1255 | <p>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.</p> |
| 1256 | </div> |
| 1257 | <div class="section" title="Within"> |
| 1258 | <div class="titlepage"> |
| 1259 | <div> |
| 1260 | <div> |
| 1261 | <h6 class="title"> |
| 1262 | <a name="Within"></a>Within</h6> |
| 1263 | </div> |
| 1264 | </div> |
| 1265 | </div> |
| 1266 | <p>Specifies the network that the connection will be created within.</p> |
| 1267 | </div> |
| 1268 | </div> |
| 1269 | <div class="section" title="Directed"> |
| 1270 | <div class="titlepage"> |
| 1271 | <div> |
| 1272 | <div> |
| 1273 | <h5 class="title"> |
| 1274 | <a name="Directed_2"></a>Directed</h5> |
| 1275 | </div> |
| 1276 | </div> |
| 1277 | </div> |
| 1278 | <p>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).</p> |
| 1279 | </div> |
| 1280 | <div class="section" title="Disconnect"> |
| 1281 | <div class="titlepage"> |
| 1282 | <div> |
| 1283 | <div> |
| 1284 | <h5 class="title"> |
| 1285 | <a name="Disconnect"></a>Disconnect</h5> |
| 1286 | </div> |
| 1287 | </div> |
| 1288 | </div> |
| 1289 | <p>Removes the connection between agents within a network space. See the description of the Connect Action for important details.</p> |
| 1290 | <div class="section" title="Selection"> |
| 1291 | <div class="titlepage"> |
| 1292 | <div> |
| 1293 | <div> |
| 1294 | <h6 class="title"> |
| 1295 | <a name="Selection_12"></a>Selection</h6> |
| 1296 | </div> |
| 1297 | </div> |
| 1298 | </div> |
| 1299 | <p>The selection determines one side of the agent relationship that will be disconnected.</p> |
| 1300 | </div> |
| 1301 | <div class="section" title="Destination"> |
| 1302 | <div class="titlepage"> |
| 1303 | <div> |
| 1304 | <div> |
| 1305 | <h6 class="title"> |
mparker | 8b5614b | 2010-06-17 23:18:38 +0000 | [diff] [blame] | 1306 | <a name="Destination_4"></a>Destination</h6> |
mparker | 668331c | 2010-04-23 05:22:03 +0000 | [diff] [blame] | 1307 | </div> |
| 1308 | </div> |
| 1309 | </div> |
| 1310 | <p>The selection determines one other side of the agent relationship that will be disconnected.</p> |
| 1311 | </div> |
| 1312 | <div class="section" title="Within"> |
| 1313 | <div class="titlepage"> |
| 1314 | <div> |
| 1315 | <div> |
| 1316 | <h6 class="title"> |
| 1317 | <a name="Within_2"></a>Within</h6> |
| 1318 | </div> |
| 1319 | </div> |
| 1320 | </div> |
| 1321 | <p>Specifies the network that the connection will be created within.</p> |
| 1322 | </div> |
| 1323 | </div> |
| 1324 | <div class="section" title="Replace"> |
| 1325 | <div class="titlepage"> |
| 1326 | <div> |
| 1327 | <div> |
| 1328 | <h5 class="title"> |
| 1329 | <a name="Replace"></a>Replace</h5> |
| 1330 | </div> |
| 1331 | </div> |
| 1332 | </div> |
| 1333 | <p>Functions in the same way as a Connect Action excepth that all other connections to other agents will first be removed.</p> |
| 1334 | <div class="section" title="Selection"> |
| 1335 | <div class="titlepage"> |
| 1336 | <div> |
| 1337 | <div> |
| 1338 | <h6 class="title"> |
| 1339 | <a name="Selection_13"></a>Selection</h6> |
| 1340 | </div> |
| 1341 | </div> |
| 1342 | </div> |
| 1343 | <p>The selection determines the agent that will be connected to another agent. In the case of a directed graph, this is the source node.</p> |
| 1344 | </div> |
| 1345 | <div class="section" title="Destination"> |
| 1346 | <div class="titlepage"> |
| 1347 | <div> |
| 1348 | <div> |
| 1349 | <h6 class="title"> |
mparker | 8b5614b | 2010-06-17 23:18:38 +0000 | [diff] [blame] | 1350 | <a name="Destination_5"></a>Destination</h6> |
mparker | 668331c | 2010-04-23 05:22:03 +0000 | [diff] [blame] | 1351 | </div> |
| 1352 | </div> |
| 1353 | </div> |
| 1354 | <p>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.</p> |
| 1355 | </div> |
| 1356 | <div class="section" title="Within"> |
| 1357 | <div class="titlepage"> |
| 1358 | <div> |
| 1359 | <div> |
| 1360 | <h6 class="title"> |
| 1361 | <a name="Within_3"></a>Within</h6> |
| 1362 | </div> |
| 1363 | </div> |
| 1364 | </div> |
| 1365 | <p>Specifies the network that the connection will be created within.</p> |
| 1366 | </div> |
| 1367 | </div> |
| 1368 | <div class="section" title="Directed"> |
| 1369 | <div class="titlepage"> |
| 1370 | <div> |
| 1371 | <div> |
| 1372 | <h5 class="title"> |
| 1373 | <a name="Directed_3"></a>Directed</h5> |
| 1374 | </div> |
| 1375 | </div> |
| 1376 | </div> |
| 1377 | <p>Determines whether the connection made is directed or not. See the Connect description for more details.</p> |
| 1378 | </div> |
| 1379 | </div> |
| 1380 | <div class="section" title="Other"> |
| 1381 | <div class="titlepage"> |
| 1382 | <div> |
| 1383 | <div> |
| 1384 | <h4 class="title"> |
| 1385 | <a name="Other"></a>Other</h4> |
| 1386 | </div> |
| 1387 | </div> |
| 1388 | </div> |
| 1389 | <div class="section" title="Method"> |
| 1390 | <div class="titlepage"> |
| 1391 | <div> |
| 1392 | <div> |
| 1393 | <h5 class="title"> |
| 1394 | <a name="Method"></a>Method</h5> |
| 1395 | </div> |
| 1396 | </div> |
| 1397 | </div> |
| 1398 | <p>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.</p> |
| 1399 | <p>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.</p> |
| 1400 | <p>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.</p> |
| 1401 | <p>If you do decide to use the Method Action, keep in mind the following design practice recommendations:</p> |
| 1402 | <div class="orderedlist"> |
| 1403 | <ol class="orderedlist" type="1"> |
| 1404 | <li class="listitem"> |
| 1405 | <p>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.</p> |
| 1406 | </li> |
| 1407 | <li class="listitem"> |
| 1408 | <p>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.</p> |
| 1409 | </li> |
| 1410 | <li class="listitem"> |
| 1411 | <p>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 |
| 1412 | <span class="bold"><strong>Source > Organize Imports..</strong></span> but it prevents automatic code generation. |
| 1413 | </p> |
| 1414 | </li> |
| 1415 | <li class="listitem"> |
mparker | a684092 | 2010-04-28 17:51:29 +0000 | [diff] [blame] | 1416 | <p>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:</p> |
mparker | 668331c | 2010-04-23 05:22:03 +0000 | [diff] [blame] | 1417 | </li> |
| 1418 | </ol> |
| 1419 | </div> |
mparker | a684092 | 2010-04-28 17:51:29 +0000 | [diff] [blame] | 1420 | <div class="literallayout"> |
| 1421 | <p>(new org.me.SpecialFileLoader()).load(this);<br> |
| 1422 | |
| 1423 | </p> |
| 1424 | </div> |
| 1425 | <p>Then create a new source directory in your project called "src" ( |
| 1426 | <span class="bold"><strong>New > Source Folder...</strong></span>) and create the class for the specialized file loader including the following method: |
| 1427 | </p> |
| 1428 | <div class="literallayout"> |
| 1429 | <p>public void load(MyRootModel model) {...}<br> |
| 1430 | |
| 1431 | </p> |
| 1432 | </div> |
| 1433 | <p>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.</p> |
mparker | 668331c | 2010-04-23 05:22:03 +0000 | [diff] [blame] | 1434 | <div class="section" title="Selection"> |
| 1435 | <div class="titlepage"> |
| 1436 | <div> |
| 1437 | <div> |
| 1438 | <h6 class="title"> |
| 1439 | <a name="Selection_14"></a>Selection</h6> |
| 1440 | </div> |
| 1441 | </div> |
| 1442 | </div> |
| 1443 | <p>The selection determines what Agent class the code will be created within and the set of agents the method will be called upon.</p> |
| 1444 | </div> |
| 1445 | <div class="section" title="Body"> |
| 1446 | <div class="titlepage"> |
| 1447 | <div> |
| 1448 | <div> |
| 1449 | <h6 class="title"> |
| 1450 | <a name="Body"></a>Body</h6> |
| 1451 | </div> |
| 1452 | </div> |
| 1453 | </div> |
| 1454 | <p>The actual code to insert in the method body. See the detailed recommendations for code use above.</p> |
| 1455 | </div> |
| 1456 | <div class="section" title="Generate"> |
| 1457 | <div class="titlepage"> |
| 1458 | <div> |
| 1459 | <div> |
| 1460 | <h6 class="title"> |
| 1461 | <a name="Generate"></a>Generate</h6> |
| 1462 | </div> |
| 1463 | </div> |
| 1464 | </div> |
| 1465 | <p>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.</p> |
| 1466 | </div> |
| 1467 | </div> |
| 1468 | </div> |
| 1469 | <div class="section" title="Query and Evaluation Inputs"> |
| 1470 | <div class="titlepage"> |
| 1471 | <div> |
| 1472 | <div> |
| 1473 | <h4 class="title"> |
| 1474 | <a name="Query_and_Evaluation_Inputs"></a>Query and Evaluation Inputs</h4> |
| 1475 | </div> |
| 1476 | </div> |
| 1477 | </div> |
| 1478 | <p>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.</p> |
| 1479 | <div class="section"> |
| 1480 | <div class="titlepage"></div> |
| 1481 | <div class="section" title="Input Literals"> |
| 1482 | <div class="titlepage"> |
| 1483 | <div> |
| 1484 | <div> |
| 1485 | <h6 class="title"> |
mparker | 8b5614b | 2010-06-17 23:18:38 +0000 | [diff] [blame] | 1486 | <a name="N10689"></a>Input Literals</h6> |
mparker | 668331c | 2010-04-23 05:22:03 +0000 | [diff] [blame] | 1487 | </div> |
| 1488 | </div> |
| 1489 | </div> |
| 1490 | <p>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.</p> |
| 1491 | </div> |
| 1492 | </div> |
| 1493 | </div> |
mparker | 7c6347a | 2010-04-14 02:36:22 +0000 | [diff] [blame] | 1494 | </div> |
mparker | 49c2bdd | 2010-07-01 01:44:25 +0000 | [diff] [blame] | 1495 | <div class="section" title="Reference"> |
| 1496 | <div class="titlepage"> |
| 1497 | <div> |
| 1498 | <div> |
| 1499 | <h3 class="title"> |
| 1500 | <a name="Reference_2"></a>Reference</h3> |
| 1501 | </div> |
| 1502 | </div> |
| 1503 | </div> |
| 1504 | <div class="section" title="Diagrams"> |
| 1505 | <div class="titlepage"> |
| 1506 | <div> |
| 1507 | <div> |
| 1508 | <h4 class="title"> |
| 1509 | <a name="Diagrams_2"></a>Diagrams</h4> |
| 1510 | </div> |
| 1511 | </div> |
| 1512 | </div> |
| 1513 | <p>The following diagram may be helpful to readers familiar with UML and Meta-modeling:</p> |
| 1514 | <div class="section" title="Meta-Classes"> |
| 1515 | <div class="titlepage"> |
| 1516 | <div> |
| 1517 | <div> |
| 1518 | <h5 class="title"> |
| 1519 | <a name="Meta-Classes_2"></a>Meta-Classes</h5> |
| 1520 | </div> |
| 1521 | </div> |
| 1522 | </div> |
| 1523 | <p> |
| 1524 | |
| 1525 | </p> |
| 1526 | <div class="mediaobject"> |
| 1527 | <img src="images/actions/ActionsDiagram.png"></div> |
| 1528 | <p> |
| 1529 | |
| 1530 | </p> |
| 1531 | </div> |
| 1532 | <div class="section" title="Details"> |
| 1533 | <div class="titlepage"> |
| 1534 | <div> |
| 1535 | <div> |
| 1536 | <h5 class="title"> |
| 1537 | <a name="Details_4"></a>Details</h5> |
| 1538 | </div> |
| 1539 | </div> |
| 1540 | </div> |
| 1541 | <p>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.</p> |
| 1542 | <div class="orderedlist"> |
| 1543 | <ol class="orderedlist" type="1"> |
| 1544 | <li class="listitem"> |
| 1545 | <p>An Act is anything that might happen during the execution of an Agent-Based Model.</p> |
| 1546 | </li> |
| 1547 | <li class="listitem"> |
| 1548 | <p>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.)</p> |
| 1549 | </li> |
| 1550 | <li class="listitem"> |
| 1551 | <p>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.</p> |
| 1552 | </li> |
| 1553 | <li class="listitem"> |
| 1554 | <p>Commands trigger some model state change (Set) or spatial transformation (Transform).</p> |
| 1555 | </li> |
| 1556 | <li class="listitem"> |
| 1557 | <p>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.</p> |
| 1558 | </li> |
| 1559 | <li class="listitem"> |
| 1560 | <p>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).</p> |
| 1561 | </li> |
| 1562 | <li class="listitem"> |
| 1563 | <p>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.</p> |
| 1564 | </li> |
| 1565 | </ol> |
| 1566 | </div> |
| 1567 | </div> |
| 1568 | </div> |
| 1569 | </div> |
mparker | 7c6347a | 2010-04-14 02:36:22 +0000 | [diff] [blame] | 1570 | <div class="section" title="Example"> |
| 1571 | <div class="titlepage"> |
| 1572 | <div> |
| 1573 | <div> |
| 1574 | <h3 class="title"> |
| 1575 | <a name="Example"></a>Example</h3> |
| 1576 | </div> |
| 1577 | </div> |
| 1578 | </div> |
| 1579 | <p>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:</p> |
| 1580 | <div class="literallayout"> |
| 1581 | <p>"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."<br> |
| 1582 | |
| 1583 | </p> |
| 1584 | </div> |
| 1585 | <p>Here, we create a sequence of actions like so:</p> |
| 1586 | <div class="orderedlist"> |
| 1587 | <ol class="orderedlist" type="1"> |
| 1588 | <li class="listitem"> |
| 1589 | <p>Select every agent for every period of the model. ("Find Partner" Rule)</p> |
| 1590 | </li> |
| 1591 | <li class="listitem"> |
| 1592 | <p>For every member of that selection, search for other agents of the same age within vision distance. ("Partner" selection.)</p> |
| 1593 | </li> |
| 1594 | <li class="listitem"> |
| 1595 | <p>From "Partners" find a random member and search for a neighboring locations. ("Partner Neighbor" selection.)</p> |
| 1596 | </li> |
| 1597 | <li class="listitem"> |
| 1598 | <p>Finally, move the agent in "Find Partner" to the "Partner Neighbor" location.</p> |
| 1599 | </li> |
| 1600 | </ol> |
| 1601 | </div> |
| 1602 | <p>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:</p> |
| 1603 | <p> |
| 1604 | |
| 1605 | </p> |
| 1606 | <div class="mediaobject"> |
mparker | 668331c | 2010-04-23 05:22:03 +0000 | [diff] [blame] | 1607 | <img src="images/actions/ActionsExample.png"></div> |
mparker | 7c6347a | 2010-04-14 02:36:22 +0000 | [diff] [blame] | 1608 | <p> |
| 1609 | |
| 1610 | </p> |
| 1611 | <p>This is how it looks in an actual model:</p> |
| 1612 | <p> |
| 1613 | |
| 1614 | </p> |
| 1615 | <div class="mediaobject"> |
mparker | 668331c | 2010-04-23 05:22:03 +0000 | [diff] [blame] | 1616 | <img src="images/actions/ActionsExampleNew.png"></div> |
mparker | 7c6347a | 2010-04-14 02:36:22 +0000 | [diff] [blame] | 1617 | <p> |
| 1618 | |
| 1619 | </p> |
| 1620 | <p>And here is how this works in detail:</p> |
| 1621 | <div class="orderedlist"> |
| 1622 | <ol class="orderedlist" type="1"> |
| 1623 | <li class="listitem"> |
| 1624 | <p>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.</p> |
| 1625 | </li> |
| 1626 | <li class="listitem"> |
| 1627 | <p>Create a child Select Action that will find our partner. Two important things to note here:</p> |
| 1628 | <div class="orderedlist"> |
| 1629 | <ol class="orderedlist" type="a"> |
| 1630 | <li class="listitem"> |
| 1631 | <p>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.</p> |
| 1632 | </li> |
| 1633 | <li class="listitem"> |
| 1634 | <p>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.</p> |
| 1635 | </li> |
| 1636 | </ol> |
| 1637 | </div> |
| 1638 | </li> |
| 1639 | <li class="listitem"> |
| 1640 | <p>Create two child Query Actions:</p> |
| 1641 | <div class="orderedlist"> |
| 1642 | <ol class="orderedlist" type="a"> |
| 1643 | <li class="listitem"> |
| 1644 | <p>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.</p> |
| 1645 | </li> |
| 1646 | <li class="listitem"> |
| 1647 | <p>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.</p> |
| 1648 | </li> |
| 1649 | </ol> |
| 1650 | </div> |
| 1651 | </li> |
| 1652 | <li class="listitem"> |
| 1653 | <p>Intersect the results of these two query components. This delineates the end of the selection definition for any target Actions.</p> |
| 1654 | </li> |
| 1655 | <li class="listitem"> |
| 1656 | <p>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.</p> |
| 1657 | </li> |
| 1658 | <li class="listitem"> |
| 1659 | <p>As above, define some queries. This time we want only those agents that are:</p> |
| 1660 | <div class="orderedlist"> |
| 1661 | <ol class="orderedlist" type="a"> |
| 1662 | <li class="listitem"> |
| 1663 | <p>available, and</p> |
| 1664 | </li> |
| 1665 | <li class="listitem"> |
| 1666 | <p>neighbors of our partner.</p> |
| 1667 | </li> |
| 1668 | </ol> |
| 1669 | </div> |
| 1670 | </li> |
| 1671 | <li class="listitem"> |
| 1672 | <p>And another intersection..</p> |
| 1673 | </li> |
| 1674 | <li class="listitem"> |
| 1675 | <p>Finally, we move to the location we've found. All that's required at this point is to specify:</p> |
| 1676 | <div class="orderedlist"> |
| 1677 | <ol class="orderedlist" type="a"> |
| 1678 | <li class="listitem"> |
| 1679 | <p>The movement selection, or those agents that are moving, which in this case is the original agent we're executing the rule for, and</p> |
| 1680 | </li> |
| 1681 | <li class="listitem"> |
| 1682 | <p>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.</p> |
| 1683 | </li> |
| 1684 | </ol> |
| 1685 | </div> |
| 1686 | </li> |
| 1687 | </ol> |
| 1688 | </div> |
| 1689 | </div> |
mparker | 53e32b2 | 2010-04-24 04:17:28 +0000 | [diff] [blame] | 1690 | </div> |
mparker | 7c6347a | 2010-04-14 02:36:22 +0000 | [diff] [blame] | 1691 | </body> |
| 1692 | </html> |