family_camp/schedule/deep.py
def goodness(self, campers, debug=False):
        """Measure how many of the other activities we have met.

        The higher the value the better."""

        # What percentage of the other activities have been met?

        # Total number of other activities requested.
        other_total = sum([len(c.others) for c in self.campers])
        met = 0
        for c in self.campers:
            activities = [s.session.activity for s in self.session_inst
                          if c in s.campers]
            # The intersection is the list of activities that have been met.
            # we divide this by the number that have been asked for. This
            # give 1 if they have all been met and 0 if none have been met.
            # It gives a weighted score depending on how many have been
            # requested. The more requested the less the effect on the overall
            # goodness. This should favour those that have only request a
            # small number of activites.
            num_others = len(c.others)
            set_others = set(c.others)
            set_acts = set(activities)

            met += (1 if num_others == 0 else
                    len(set_others & set_acts) / num_others)

            if (len(set_others) > len(set_others & set_acts)):
                if debug:
                    self.summary_file.write("Others not met: {} missing - {}\n".format(
                        str(c), " ".join(str(_) for _ in
                                         set_others - set_acts)))

        # If all campers have all activitites met == len(campers)
        # so met / len(campers) is the fraction of activities not met
        # wieghted by the greediness of each camper.
        percentage_met = ((met / len(campers)) * 100)

        if debug and percentage_met != 100:
            self.summary_file.write("Percentation met: {} {} {}\n".format(
                percentage_met, other_total, met))

        return percentage_met if percentage_met != 0 else 1
Measure how many of the other activities we have met.

        The higher the value the better.
Measure how many of the other activities we have met.
The higher the value the better.
Measure how many of the other activities we have met . The higher the value the better .
def goodness(self, campers, debug=False):
        other_total = sum([len(c.others) for c in self.campers])
        met = 0
        for c in self.campers:
            activities = [s.session.activity for s in self.session_inst
                          if c in s.campers]
            num_others = len(c.others)
            set_others = set(c.others)
            set_acts = set(activities)
            met += (1 if num_others == 0 else
                    len(set_others & set_acts) / num_others)
            if (len(set_others) > len(set_others & set_acts)):
                if debug:
                    self.summary_file.write("Others not met: {} missing - {}\n".format(
                        str(c), " ".join(str(_) for _ in
                                         set_others - set_acts)))
        percentage_met = ((met / len(campers)) * 100)
        if debug and percentage_met != 100:
            self.summary_file.write("Percentation met: {} {} {}\n".format(
                percentage_met, other_total, met))
        return percentage_met if percentage_met != 0 else 1
def goodness ( self , campers , debug = False ) : other_total = sum ( [ len ( c . others ) for c in self . campers ] ) met = 0 for c in self . campers : activities = [ s . session . activity for s in self . session_inst if c in s . campers ] num_others = len ( c . others ) set_others = set ( c . others ) set_acts = set ( activities ) met += ( 1 if num_others == 0 else len ( set_others & set_acts ) / num_others ) if ( len ( set_others ) > len ( set_others & set_acts ) ) : if debug : self . summary_file . write ( "Others not met: {} missing - {}\n" . format ( str ( c ) , " " . join ( str ( _ ) for _ in set_others - set_acts ) ) ) percentage_met = ( ( met / len ( campers ) ) * 100 ) if debug and percentage_met != 100 : self . summary_file . write ( "Percentation met: {} {} {}\n" . format ( percentage_met , other_total , met ) ) return percentage_met if percentage_met != 0 else 1
Measure how many of the other activities we have met.
Measure how many of the other activities we have met .
"""Measure how many of the other activities we have met.

        The higher the value the better.""" # What percentage of the other activities have been met? # Total number of other activities requested. # The intersection is the list of activities that have been met. # we divide this by the number that have been asked for. This # give 1 if they have all been met and 0 if none have been met. # It gives a weighted score depending on how many have been # requested. The more requested the less the effect on the overall # goodness. This should favour those that have only request a # small number of activites. # If all campers have all activitites met == len(campers) # so met / len(campers) is the fraction of activities not met # wieghted by the greediness of each camper.
self
campers
debug