Example #1
0
    def take_action(self, simulator, end_time: Time):
        """Start the action that the commands is designed for.

        Args:
            simulator (Simulator): The main simulator object which is passed to
            this command.



            end_time (Time): The final time of the simulation.
        """
        if self.condition.is_satisfied(simulator, end_time):
            logger.info(f'Command executed: {self.__class__.__name__}')

            for family in simulator.families:
                if family.id_number == self.id:
                    logger.debug(f'Family quarantined: {family.id_number}')
                    family.quarantine(simulator.people)
Example #2
0
    def take_action(self, simulator, end_time: Time):
        """Start the action that the commands is designed for.

        Args:
            simulator (Simulator): The main simulator object which is passed to
            this command.



            end_time (Time): The final time of the simulation.
        """
        if self.condition.is_satisfied(simulator, end_time):
            logger.info(f'Command executed: {self.__class__.__name__}')

            for person in simulator.people:
                if person.id_number in self.ids:
                    logger.debug(f'Person unquarantined: {person.id_number}')
                    person.unquarantine()
Example #3
0
    def take_action(self, simulator, end_time: Time):
        """Start the action that the commands is designed for.

        Args:
            simulator (Simulator): The main simulator object which is passed to
            this command.



            end_time (Time): The final time of the simulation.
        """
        if self.condition.is_satisfied(simulator, end_time):
            logger.info(f'Command executed: {self.__class__.__name__}')

            for person in simulator.people:
                if person.infection_status is Infection_Status.CONTAGIOUS or \
                        person.infection_status is Infection_Status.INCUBATION:
                    if Random.flip_coin(self.probability):
                        logger.debug(f'Person quarantined: {person.id_number}')
                        person.quarantine()
Example #4
0
    def take_action(self, simulator, end_time: Time):
        """Start the action that the commands is designed for.

        Args:
            simulator (Simulator): The main simulator object which is passed to
            this command.

            end_time (Time): The final time of the simulation.
        """
        if self.condition.is_satisfied(simulator, end_time):
            logger.info(
                f'Command executed: {self.__class__.__name__}, target: {self.community_type_name}'
            )

            for community_type_id in simulator.communities:
                if simulator.communities[community_type_id][
                        0].community_type.name == self.community_type_name:
                    logger.debug(
                        f'Community quarantined: {self.community_type_name}, {self.community_index}'
                    )
                    simulator.communities[community_type_id][
                        self.community_index].unquarantine()