LABSS/PyPROTON-OC

Social proximity must be normalized

Closed this issue · 0 comments

def social_proximity(self, target: Person) -> int:
"""
This function calculates the social proximity between self and another agent based on age,
gender, wealth level, education level and friendship
:param target: Person
:return: int, social proximity
"""
#todo: add weight? we could create a global model attribute(a dict) with weights
total = 0
total += 0 if abs(target.age - self.age) > 18 else 1 - abs(target.age - self.age)/18
total += 1 if self.gender_is_male == target.gender_is_male else 0
total += 1 if self.wealth_level == target.wealth_level else 0
total += 1 if self.education_level == target.education_level else 0
total += 1 if self.neighbors.get("friendship").intersection(
target.neighbors.get("friendship")) else 0
return total

Line 666 should be:
return total/5