@ncollier: There is still one thing I didn't understand pertaining to our discussion of how to record the time of incarceration. The decision for whether a person is incarcerated happens in the simulate_incarceration() method on the Person class. That's where I record the change in the person's incarceration status, and I believe should be where I record the *time* of their incarceration too. But, the time variable is defined in the run method on the Model class. I am not sure how I access this variable in a method on Person() because the variable is defined in a method inside a whole other class. I'd be grateful for any tips.
class Person():
def __init__(self,
...
current_incarceration_status = None,
last_incarceration_time = None):
....
def simulate_incarceration(self):
PROBABILITY_DAILY_INCARCERATION = 1/100
prob = random.uniform(0, 1)
if self.current_incarceration_status == 0:
if prob < PROBABILITY_DAILY_INCARCERATION:
self.current_incarceration_status = 1
self.last_incarceration_time = #how should I call the time attribute which appears in the run method in the Model class?
...
class Model:
def __init__(self, n, verbose=True):
....
def run(self, MAXTIME=10):
for time in range(MAXTIME):
... #time is defined here, but I want to call it above in the simulate_incarceration method on the Person class
@ncollier: There is still one thing I didn't understand pertaining to our discussion of how to record the time of incarceration. The decision for whether a person is incarcerated happens in the simulate_incarceration() method on the Person class. That's where I record the change in the person's incarceration status, and I believe should be where I record the *time* of their incarceration too. But, the time variable is defined in the
run
method on theModel
class. I am not sure how I access this variable in a method onPerson()
because the variable is defined in a method inside a whole other class. I'd be grateful for any tips.