def fuzzy_fitness(fitness): r = redis rate_by_fuzzy=[] fuzzy=[] activity = Activity_stream() print "FITNESS" print fitness for u in fitness: if u != "DefaultContext": usr, usr_date = u.split(":") #exp = int(r.get(usr)) exp = int(activity.experience(usr)) print ":P:P:P:P:P:P:P:P:" print exp rate = int(fitness[u]) n = Person() participation = n.get_participation(usr) participation = participation[0][0] ranking=get_level(participation) print str(rate) +" , " + str(exp) +" , " + str(ranking) print "PPPPPPPFUZZYPPPPP" print ranking print fisuser(rate, exp, ranking) rate_by_fuzzy.append(rate * fisuser(rate, exp, ranking)) fuzzy.append(fisuser(rate,exp,ranking)) print rate_by_fuzzy print sum(rate_by_fuzzy) print fuzzy print sum(fuzzy) fuzzy_ponderation = sum(rate_by_fuzzy)/sum(fuzzy) print fuzzy_ponderation return fuzzy_ponderation
def fuzzy_fitness(fitness): #r = redis.StrictRedis(host='localhost', port=6379, db=0) rate_by_fuzzy=[] fuzzy=[] print "FITNESS" print fitness for u in fitness: if u != "DefaultContext": usr, usr_date = u.split(":") exp = int(r.get(usr)) rate = int(fitness[u]) print "&&&&&&&&&&&&&&&&&" print exp print "*****************" print rate n = Person() participation = n.get_participation(usr) participation = participation[0][0] ranking=get_level(participation) print str(rate) +" , " + str(exp) print fisuser(rate,exp, participation) rate_by_fuzzy.append(rate * fisuser(rate, exp, ranking)) fuzzy.append(fisuser(rate,exp, ranking)) print "@@@@@@@@@@@@@@@@@@@@@" print rate_by_fuzzy print sum(rate_by_fuzzy) print fuzzy print sum(fuzzy) fuzzy_ponderation = sum(rate_by_fuzzy)/sum(fuzzy) return fuzzy_ponderation