KH-Model with Replacement
Winter 2016
Psychology 120
We now have a working KH-model that does everything in the original model and, in addition, we can change various parameter values. Before we investigate it systematically, let’s add one more feature that was not in the original KH-model: replacement.
One way in which the KH-model is unrealistic is that there is only a finite population of male and female agents, which all start out with the same dating experience. As they pair off, the population empties out, but is this like real life? No. New people are always entering or re-entering the dating pool, so it would be a step towards a more realistic model to include replacement.
One way we could do this is that for every male-female pair that leaves the dating pool, a new pair with random levels of attractiveness is added. How can we do this? I will lay out steps that will give you hints along the way. Once you have successfully added the replacement feature, then there will be questions at the end that you will discuss with us to finish the lab.
How to Extend the KH Model to Include Replacement
Step 1
Download and install the file:
particle_to_agents_MC_C_lab.zip
Step 2
Next create a method that makes a male or a female agent that correspond to each agent removed from the dating population. Your new method should be:
public void addAgent(SimState state, int sex){ MateChoiceEnvironment e = (MateChoiceEnvironment)state; if(sex == e.FEMALE) e.placeAgent(sex, e.femalePop, PC ); else e.placeAgent(sex, e.malePop, PC ); }
Step 3
There is one more thing to do. You need to add as many male and female agents back into the population as was removed. To do this, look at kh_model(SimState state) and khm_model(SimState state) methods in Agent. Add an “if” where a pair of agents are removed.
That looks like this:
if(replacement){ //add your code here //Line #1 for females //Line #2 for males }
Hint 1: There are two lines of code: one for males and one for females using the “addAgent” method above. The above code then must be inserted in the right place (where paired agents are removed) in both the kh_model(SimState state) and khm_model(SimState state) methods.
Step 4
A set method in Agent for the boolean variable replacement, add set and get method for the boolean variable replacement in the MateChoiceEnvironment, and in the placeAgent method in the MateChoiceEnvironment, set replacement for each newly created agent as we have done for all other variables.
Analysis of the Model
Step 1
Try out different parameters values, run at least 2 simulations for each parameter value, and record the average results (i.e., The number of steps, the number of pairs in the case of replacement), and the correlation. For both rules do the following:
1. Try at least the following choosiness (r) values: 1, 2, and 3.
2. Try at least the following dMax (maxDates) values: 10, 50, 100, 10,000
3. Try at least the following maxAttractiveness (maxAttractiveness) values: 2, 5, 10, 100
4. Try at least the following population sizes (each for males and females) values: 100, 500, 1000, 2000
5. Try at least the following sex skewed population values: <500, 600>, <500, 1000>, where one value is the number of males and the other value is the number of females.
Step 2
1. With replacement turned on, try the five options in step 1. Do you get the same results?
2. Now, try random movement. Try probabilityOfChange =1 and probabilityOfChange = 0.01. Is there a difference?
3. You can try coordination (coordinate) and aggregation (aggregate) to see if that makes a difference.
4. Finally, show us something interesting that you discovered and send us a one or two page writeup (you can use snapshots to illustrate your points) by next Tuesday.