Skip to main content

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

Jump to: navigation, search

AMP/Creating Distributions

< AMP
Revision as of 18:59, 22 September 2009 by Milesparker.gmail.com (Talk | contribs) (New page: =Creating distributions of values for an agent.= Let's say you want to create a distribution of happiness across a set of Individuals. If you want to assign a simple random value for happ...)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Creating distributions of values for an agent.

Let's say you want to create a distribution of happiness across a set of Individuals. If you want to assign a simple random value for happiness you could simply:

  1. Create an Individual "Happiness" attribute an give it type Real. Set the "Gather Data" property to true.
  2. Create an Individual Initialize Rule.
  3. Create an Evaluate Action, name it "Initial Happiness" and a random function such as "Random Unit" which gives a uniformly distributed random number between 0.0 and 1.0.
  4. Create a child Set Action with Happiness as the Attribute and "Initial Happiness" as the To value.

But typically you will want to parameterize the value, and you may even want to have the value depend on other agent attributes. You could do all of that manually, but AMF has built in support for creating more elaborate distributions easily. This looks more complicated than it is!

  1. Add Agent States for factors that might affect happiness. Perhaps Relative Income (Low, Average,Maximum) and Philosophy (Optimist, Realist, Stoic).
  2. Create an Evaluate Action with function "Random State" and a corresponding Set Action for Relative Income.
  3. Do the same for Philosophy. These should be children Actions for the above actions.
  4. Drag the "Initial Happiness" Action to become a child node of the Set Action for Philosophy.
  5. Change the function to "Distribution: Uniform Add Distribution".
  6. Open the first "Multiple Values" entry in the Evaluate Action, select "Initial Happiness State and select the ... button next to the Multiple State properties. (You might have to open the "Misc" category.)
  7. In the dialog, select the Relative Income and Philosophy states and add them. Click OK.
  8. You'll see that a bunch of Attributes have been created in the enclosing context. Assign some ranges for them. (Though it's generally good practice to assign a default value for everything, 0 will be assumed if you don't specify anything else.
  9. The factor values will be added to one another so add an Evaluate Action with function: "Minimum", input 1 value "Initial Happiness" and input 2 value of "Unit".
  10. Drag the Set Action is a child of the new Evaluate, and change it's to attribute to the new Minimum evaluation you've just created.

Your model should look something like this:

DistributionDesign.jpg

You can download the model here: http://download.eclipse.org/amp/examples/models/Happiness.metaabm. When you run the model, you can see that the agents have been assigned values according to the distributions.

DistributionRun.jpg

TODO: There is an issue with code generation for the other distribution functions. https://bugs.eclipse.org/bugs/show_bug.cgi?id=290191. Unfortunately, there is only support for uniform distributions now. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=290195. We need to add functions for creating gaussian and other distributions from normal.

Back to the top