def quadHasPartner(quad: list):
    flag = False
    for student1 in quad:
        for student2 in quad:
            if matchPartner(student1, student2) or matchPartner(student2, student1):
                flag = True
    return flag
Esempio n. 2
0
def scoreTwoByTwo(studentPair1: list, studentPair2: list, matchBefore):
    #Default to a score of 0
    score = 0

    #If anybody has asked for anybody else, score high
    for student1 in studentPair1:
        for student2 in studentPair2:
            if matchPartner(student1, student2) or matchPartner(
                    student2, student1):
                score += 40000

    #Measure each student in the second pair by the first two's preferences
    for student1 in studentPair1:
        for student2 in studentPair2:
            score = score + scoreOneByOne(student1, student2, matchBefore)

    #Put them all in a list in order to make the rest of the code smoother
    studentList = [
        studentPair1[0], studentPair1[1], studentPair2[0], studentPair2[1]
    ]

    #Reward extra a group where 4 people speak the same language
    #Assume that they do until you prove they don't
    language = True
    for i in range(3):
        if studentList[i].language != studentList[(i + 1)].language:
            language = False

    #If the language flag is still true, reward the group
    if language:
        score = score + 800

    #Reward a group with at least one leader
    flagLeader = False
    for i in range(3):
        if studentList[i].preferLeader:
            flagLeader = True
            break

    if flagLeader:
        score = score + 50

    #Reward a group with a mix of people from multiple confidence levels
    score = score + scoreAtLeastOneConfidenceLevel(studentList)

    #Return the total calculated score
    return score
Esempio n. 3
0
def scoreOneByOne(student1: Student, student2: Student, matchDict: dict):

    #Assign weights to the priorty list
    scoreWeights = [50, 30, 15, 5, 0]
    score = 0

    if matchPartner(student1, student2) > 0 and matchPartner(
            student2, student1) > 0:
        score += 40000

    for i in range(4):
        #IF the priority list hits default, score no further
        if student1.priorityList[i] == "default":
            break
        #If the student priority is matched, add its weight to the score
        elif student1.priorityList[i] == "International":
            if matchInternational(student1, student2):
                score = score + scoreWeights[i]
        elif student1.priorityList[i] == "Language":
            if matchLanguage(student1, student2):
                score = score + scoreWeights[i]
        elif student1.priorityList[i] == "Matching Time to Meet":
            if matchTime(student1, student2):
                score = score + scoreWeights[i]
        elif student1.priorityList[i] == "What They Want to Do":
            if matchActivity(student1, student2):
                score = score + scoreWeights[i]
        elif student1.priorityList[i] == "Gender":
            if matchGender(student1, student2):
                score = score + scoreWeights[i]
        else:
            print(
                "Error, this index of the priority list does not meet any acceptable criteria",
                student1.name, i)

    #If the two students have matched before, punish it harshly in score
    #The punishment needs to be high enough to make groups with only one match still poor
    tempList = [student1, student2]
    score = score - 2000 * isValidGroup(matchDict, tempList)

    return score
Esempio n. 4
0
def scoreOneByGroup(student: Student, group: list, matchedBefore: dict):
    score = 0

    for student1 in group:
        if matchPartner(student1, student) > 0 or matchPartner(
                student, student1) > 0:
            score += 40000

    for student1 in group:
        score = score + scoreOneByOne(student1, student, matchedBefore)

    #Reward extra a group that all speaks that same langauge
    groupSameLanguage = True
    for i in range(len(group) - 1):
        if group[i].language != group[(i + 1)].language:
            groupSameLanguage = False

    if groupSameLanguage and student.language == group[0].language:
        score = score + 800

    #Punish harshly if the student is alone without another speaker of their language
    matchStudentLanguage = False
    for student2 in group:
        if student.language == student2.language:
            matchStudentLanguage = True
            break

    if not matchStudentLanguage:
        score = score - 800

    #Reward a group with at least one person of each confidence level
    tempList = []
    for student2 in group:
        tempList.append(student2)

    tempList.append(student)
    score = score + scoreAtLeastOneConfidenceLevel(tempList)

    return score