Example #1
0
    def parseUniformity(self):
        sh = self.wb.sheet_by_name(UNIF)
        unifL = []
        for i in range(1,sh.nrows):
            restr = Restriction(False, 1, None, None)
            key, pen, maxCount, timeMin, timeMax, stadium, field = self.getRow(sh, i, True)
            if stadium is not None : restr.stadiumS = set([stadium])
            if field is not None : restr.fNameS = set([field])
            restr.timeMin = parseTime(timeMin)
            restr.timeMax = parseTime(timeMax)
            unifL.append( (key, float(pen) / 2**maxCount, restr) )

        keySet = set(list(zip( *unifL))[0])
        for team in self.league.getTeamL():
            if hasattr( team, 'unifCountD'):
                for id_ in team.unifCountD.keys():
                    if id_ not in keySet:
                        print("Warning : %s not in [%s]" % (id_, ', '.join(list(keySet))))

        self.unifL = unifL
Example #2
0
    def getRestriction(self):
        sh = self.wb.sheet_by_name(RESTR)

        typeL, type2idx = self.getType( sh )

        restrD = {}

        self.teamSrv.lock = True
        self.dateSrv.lock = True

        for i in range(1,sh.nrows):
            valL = self.getRow( sh, i, True )
            include = signD[ str(valL[0]).strip() ]
            value = valL[1]

            teamL, dateL = self.expandAll( valL,type2idx,(TEAM,DATE) )
            timeMinL, timeMaxL, stadiumL, fNameL = self.expandAll( valL,type2idx,(TIME_MIN,TIME_MAX,STADIUM,FNAME) )



            if dateL is None:
                dateL = self.dateSrv.objD.values()

            for team in teamL:
                for date in dateL:
                    restr = Restriction( include, value, team, date )
                    if timeMinL is not None: restr.timeMin  = parseTime(timeMinL[0])
                    if timeMaxL is not None: restr.timeMax  = parseTime(timeMaxL[0])
                    if stadiumL is not None: restr.stadiumS = set( stadiumL )
                    if fNameL   is not None: restr.fNameS   = set( fNameL )
                    try:                restrD[ (team,date) ].append( restr )
                    except KeyError :   restrD[ (team,date) ] = [restr]



        self.restrD = restrD
Example #3
0
def add_restriction(dimension_list, hierarchy_list, index_worst_dimension,
                    index_worst_hierarchy, restrictions):

    peor_dimension = dimension_list[index_worst_dimension]
    jerarquia_elegida = hierarchy_list[index_worst_dimension][
        index_worst_hierarchy]
    peor_instancia = jerarquia_elegida.get_worst_instance()
    restriccion = Restriction(peor_dimension.name, jerarquia_elegida.name,
                              peor_instancia.name)
    restrictions.append(restriccion)

    il = peor_instancia.current_value / (jerarquia_elegida.target_value /
                                         len(jerarquia_elegida.instances))

    return il
Example #4
0
    def parseUniformity(self):
        sh = self.wb.sheet_by_name(UNIF)
        unifL = []
        for i in range(1, sh.nrows):
            restr = Restriction(False, 1, None, None)
            key, pen, maxCount, timeMin, timeMax, stadium, field = self.getRow(
                sh, i, True)
            if stadium is not None: restr.stadiumS = set([stadium])
            if field is not None: restr.fNameS = set([field])
            restr.timeMin = parseTime(timeMin)
            restr.timeMax = parseTime(timeMax)
            unifL.append((key, float(pen) / 2**maxCount, restr))

        keySet = set(list(zip(*unifL))[0])
        for team in self.league.getTeamL():
            if hasattr(team, 'unifCountD'):
                for id_ in team.unifCountD.keys():
                    if id_ not in keySet:
                        print("Warning : %s not in [%s]" %
                              (id_, ', '.join(list(keySet))))

        self.unifL = unifL
Example #5
0
    def getRestriction(self):
        sh = self.wb.sheet_by_name(RESTR)

        typeL, type2idx = self.getType(sh)

        restrD = {}

        self.teamSrv.lock = True
        self.dateSrv.lock = True

        for i in range(1, sh.nrows):
            valL = self.getRow(sh, i, True)
            include = signD[str(valL[0]).strip()]
            value = valL[1]

            teamL, dateL = self.expandAll(valL, type2idx, (TEAM, DATE))
            timeMinL, timeMaxL, stadiumL, fNameL = self.expandAll(
                valL, type2idx, (TIME_MIN, TIME_MAX, STADIUM, FNAME))

            if dateL is None:
                dateL = self.dateSrv.objD.values()

            for team in teamL:
                for date in dateL:
                    restr = Restriction(include, value, team, date)
                    if timeMinL is not None:
                        restr.timeMin = parseTime(timeMinL[0])
                    if timeMaxL is not None:
                        restr.timeMax = parseTime(timeMaxL[0])
                    if stadiumL is not None: restr.stadiumS = set(stadiumL)
                    if fNameL is not None: restr.fNameS = set(fNameL)
                    try:
                        restrD[(team, date)].append(restr)
                    except KeyError:
                        restrD[(team, date)] = [restr]

        self.restrD = restrD