Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- *
- */
- package at.ac.wu.mzuba.ltcmicro2
- import repast.simphony.context.Context;
- import repast.simphony.engine.schedule.ScheduledMethod;
- import repast.simphony.random.RandomHelper;
- import repast.simphony.util.ContextUtils;
- /**
- * This class represents individuals in the microsimulation.
- *
- * @author Martin Zuba
- */
- public class Person {
- // <-- Basic data -->
- double age;
- Sex sex;
- /** Federal state of residence. */
- Bundesland wohnort;
- /** Number of Instrumental Activities of Daily Living the Person needs help with */
- int nrIADL;
- /** Number of Activities of Daily Living the Person needs help with */
- int nrADL;
- /** Number of chronic conditions the person suffers from */
- int nrCond;
- /** Level of care allowance granted to the Person <code>[0:7]</code> */
- int pfSt;
- // <-- Methods -->
- /**
- * Ages the person one year. This method is scheduled for every iteration of the simulation.
- *
- * @return <code>true </code> if the person survived, <br> <code>false</code> otherwise.
- */
- @ScheduledMethod(start = 1d, interval = 1d)
- public boolean age() {
- // age one year
- this.age++;
- // die with 20% probability after age 70 – will be replaced
- if (age > 70 && RandomHelper.nextDouble() < 0.1) {
- die();
- return false;
- }
- return true;
- }
- /**
- * Removes the Person from the context it inhabited.
- *
- * @return <code>true</code> if the person was found in a context, <br> <code>false</code> otherwise.
- */
- public boolean die() {
- Context<Object> context = ContextUtils.getContext(this);
- if (context != null) {
- context.remove(this);
- return true;
- } else {
- return true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement