<< Click to Display Table of Contents >> 4. Relate Entities |
|
Show/Hide Hidden Text |
In this run we will use an attribute to assign a discrete property to an entity, namely, a relationship to another entity. In concrete terms, we will assign to each cow a property called "pasture" whose value is the ID of a pasture entity. This will represent the relationship between each cow entity and the pasture entity where that cow will graze.
This exercise and the next two are featured in this video:
Stages of Ventity™ Modeling |
In this run, we will ... |
Stage 1 - Define entity types
|
Define a "cow" entity type and give each cow an attribute to represent a relationship to another entity: in this case, an assignment to a particular pasture entity.
|
Stage 2 - Initialize the model
|
Specify that there will be fourteen cows in this run of the model, and specify for each cow its grass consumption rate and which pasture it is in.
|
Stage 3 - Run the model Configure time settings and perform calculations
|
Just push the green button.
|
Stage 4 - Examine results See model behavior in graphs and tables
|
See how we can use attributes to partition entities into groups. In this case, including or excluding from output graphs different subgroups of cows, according to which pasture they are in. |
Create the Model by Copying an Existing Model |
We will build this model by continuing from where we left off in the previous model. 1. Open Ventity. Navigate to the Open Model button and open either your version of the Pasture model from the previous run, or the Exercise 3 Complete model located [here].
2. Choose File > Save As to save a copy of the model using the model name "Cows".
Click OK, and you now have a new model called Cows which is just a copy of the Pasture model.
|
The new entity type we are going to design is a cow.
1. Right-click Entity Types in the Model Overview, or choose Model > New Entity Type... and create type "cow".
The new entity type is indicated in three places: in the model overview (1), as a new diagram (2), and in a new inspector (3):
If our purpose is simply grass control, all we need to know about each cow is, how much grass does she eat, and which pasture is she in.
2. In the cow diagram, create an auxiliary variable called "consumption rate" (either drag a variable off the palette, or right-click the diagram and "add auxiliary"), then edit the variable (by right-clicking) to give it a default value of 70 pounds/day.* Check the "Constant" box to indicate that this value can be overwritten for each cow during initialization, but will not change during the run.
To specify the pasture for each cow, we will introduce an attribute. An attribute is a property or characteristic of an entity. In this case, we want each cow to have a pasture that she is in, so we will create a pasture attribute.
3. Drag an attribute symbol from the palette onto the cow diagram, and rename it "pasture". Right-click to edit the attribute. Set "refers to" to type "pasture". This indicates to Ventity that this attribute describes the relationship between each cow entity and a specific pasture entity. Leave the default value blank, and enter a description of the relationship represented by the attribute.
Every cow can now be associated with a single pasture. This association will be used in two ways: •In the next run of this model, we will use the pasture attribute as a label for organizing cows. To be specific, we will be grouping cows according to their pasture and calculating total grass consumption for each group. The "pasture" attribute is now a property of cows: each cow has a pasture. •In the third run of this model, we will be using information from each cow's pasture to inform calculations about the cow. To be specific, each cow entity will need to know the available grass per cow for the pasture entity it is related to. Getting information from another entity or set of entities is called a reference. You can easily review the attributes and references that have been defined for an entity type, by toggling the attribute and reference grids. In any diagram, click the show/hide grids button
to reveal or hide the attribute in reference grids. For this model, the grids now show an attribute called "pasture" which refers to an entity of type "pasture". The grid also shows that this can be used as a reference: the reference "pasture" will refer to the pasture entity whose pastureID matches the value of this cow's pasture attribute.
We will link specific cows to specific pastures during initialization.
_________________ * There are people at Ventana who actually know how to raise cows. None of them were involved in the writing of this manual.
|
Our model now has designs for pastures and cows. We will initialize the run with some of each, and use the input file to indicate which cow is in which pasture.
4. Double-click the built-in file "many pastures" that we created for the Pasture model. When it opens, you will see three tabs: the pasture tab we created previously, the innate Model tab, and a new tab, called "cow". On the cow tab, each row you complete will add a cow to the model. •The cowID column gives a unique name to each cow. If you leave it blank, the cows will automatically be named cow_1, cow_2, cow_3,.... Or you can provide your own names (Abigail, Bessie, Clara, ... or whatever you'd like, as long as no cows share the same name). The consumption rate column gives you an opportunity to use a specific value for each cow, rather than the default value of 70 we input above. •The pasture column holds the name of the pasture where each cow grazes. In the example below, we've assigned twelve cows to the pastures defined earlier. We've also assigned two cows to a pasture entity ("thistle hill") which will not exist in the simulation, because it is not listed on the pasture input tab. For the moment, this will not create any difficulties, because the cow-entity calculations do not require any inputs from the pasture entities.
|
No changes are needed to the time configuration, so we can run the model. We'll use Run #001 for the run name. 5. Push run or choose Run Model from the Model menu.
|
All the same results we got in the Pasture model are still available, and now we also have results for our fourteen cows.
6. In the cow diagram, right-click on consumption rate and choose "Line Chart". In the Scenario Entity Overview, you can now choose which cows to display in the cow > cowID section. In this figure, we are showing only cows 1, 4, 5, 10 and 11.
7. Now, however, our cows are labeled with the "pasture" attribute. So we can include (or exclude) cows on the chart in the cow > pasture section. In the figure below, we are showing values only for cows in the green gables, dairy home companion, and thistle hill pastures.
We've seen in this run how to assign cows a property as an attribute, and specifically, how to create a relationship to another entity (a pasture entity) using an attribute. This allows us to consider cows grouped by pasture. In the next two runs we will see how to take advantage of this in computations, not just in graph output.
|