Simulation with AnyLogic/Agent-Based Modeling/Step 3. Adding Adoption from Advertisement< Simulation with AnyLogic | Agent-Based Modeling
Step 3. Adding Adoption from Advertisement
In this model the volume of advertising and the probability that a potential adopter will adopt as the result of exposure to a given amount of advertising are assumed to be constant each period. So, we will use a parameter to model the advertising effectiveness — the fractional adoption rate from advertising.
We will create this parameter in the Person class. Since all agents are represented by objects of this active object class, they have the same characteristics we define here. Optionally, you can define characteristics individually for each agent by altering values of parameters for some agents.
- Open the Person class diagram
- Drag the Parameter element from the General page of the Palette view onto the diagram.
- On the General page of the Properties view, set up the parameter properties.
- Change the name of the parameter. Type
AdEffectivenessin the Name edit box.
- In the Default Value edit box, type
Now we will define the behavior of our agent using a statechart.
- Draw the following statechart:
- First, draw a state. Drag the State element from the Statechart page of the Palette view onto the diagram.
- Resize it by dragging the state borders. Change its Name to PotentialAdopter.
- Add statechart entry pointer pointing to this state as shown on the figure below. Drag the Statechart Entry Point element from the Statechart page of the Palette view into the graphical editor, so that its ending point got connected to the upper border of the state:
- Now PotentialAdopter is an initial state of the statechart, since the atatechart entry pointer points to it. The person remains a potential adopter until this state is active.
- Add one more state below the created one. You can simply drag the PotentialAdopter state with Ctrl button pressed. This will create a copy of the state. Name this state Adopter. The person becomes an adopter, when this state becomes active.
- Add a transition going from the PotentialAdopter state to the Adopter state. Drag the Transition element from the Statechart page of the Palette view onto the diagram of active object class, so that the starting point of the transition got connected to the lower border of PotentialAdopter state.
- Drag the ending point of the transition onto a border of Adopter state. The transition should look like in the figure below:
- This transition models the product purchase by this person. The time needed to come to a conclusion to buy the product depends on the person’s advertising suggestibility exponentially. So, set up that this transition will be taken with AdEffectiveness rate. Go to the General page of the transition's Properties view and choose Rate from the Triggered by drop-down list. Type
AdEffectivenessin the Rate field below. You can use the code completion assistant when typing the parameter name. Type only the first letters of the name and then press Ctrl+space. This will open the assistant dialog listing parameters, variables and functions of your model. Scroll to the AdEffectiveness parameter and insert its name by double-clicking on it.