예제 #1
0
def pointsESLStudents(groupAssignments):
    global totalPES
    totalPES = 0

    pointWeight = load_csv.weightMaxESLStudents
    maxESL = load_csv.maxESLStudents
    groupESL = [0] * len(
        load_csv.projectIDs)  # Initializing an empty array to 0's
    groupSize = [0] * len(load_csv.projectIDs)

    prints.debug(
        f"\n\n========pointsESLStudents========\n{groupESL} gESL Before \n{groupSize} gSize Before"
    )
    # groupESL[i] is the number of ESL students on team i
    for i in range(len(load_csv.studentID)):
        if load_csv.studentESL[i]:
            groupESL[groupAssignments[i]] += 1  # ESL students per team
        groupSize[groupAssignments[i]] += 1  # Students per team

    prints.debug(f"{groupESL} gESL After \n{groupSize} gSize After")
    # Awarding points
    for i in range(len(groupESL)):
        if groupESL[i] <= maxESL and groupSize[i] >= load_csv.minTeamSize[i]:
            totalPES += pointWeight

    return totalPES
예제 #2
0
def pointsMaxLowGPAStudents(groupAssignments):
    global totalPML
    totalPML = 0

    weightPML = load_csv.weightMaxLowGPAStudents
    minGPA = load_csv.lowGPAThreshold
    maxLow = load_csv.maxLowGPAStudents
    # initialize maxLowGroup - counts how many per group do not meet minGPA constraint
    maxLowGroup = [0] * len(load_csv.projectIDs)
    # initialize groupSize - counts how many students there are in each group
    groupSize = [0] * len(load_csv.projectIDs)

    # loop for counting maxLowGPA students and group sizes
    for i in range(len(load_csv.studentID)):
        if load_csv.studentGPA[i] < minGPA:
            maxLowGroup[groupAssignments[i]] += 1
        groupSize[groupAssignments[i]] += 1

    prints.debug("========pointsMaxLowGPAStudents========")
    prints.debug(f"groups with lowGPA students: {maxLowGroup}")
    prints.debug(f"groups with # of studetns: {groupSize}")

    # iterates through maxLowGroup for points - also ignores empty groups
    for i in range(len(maxLowGroup)):
        if maxLowGroup[i] <= maxLow and groupSize[i] >= load_csv.minTeamSize[i]:
            prints.debug(
                f"group: {load_csv.projectIDs[i]} satisfies the condition!")
            totalPML += weightPML

    return totalPML
예제 #3
0
def outputCSV(studentFileData, outputFileName, optimalSolution):
    # optimalSolution is a numpy array
    # Matching projectID's to their indexed number in optimalSolution
    for i in range(len(optimalSolution)):
        optimalSolution[i] = load_csv.projectIDs[int(optimalSolution[i])]

    studentFileData[
        'assignment'] = ''  # If there's no 'Assignment' column, create its header
    assignments = pd.DataFrame({'assignment':
                                optimalSolution})  # Creating the dataframe
    studentFileData.update(
        assignments)  # Appending the dataframe assignments to studentFileData
    studentFileData = studentFileData.astype(
        {"assignment": int})  # Treats assignment outputs as ints

    prints.debug(f"\n========outputCSV========\n\n{studentFileData} After"
                 )  # After changes output
    # Writes/Overwrites to a csv named outputFileName
    studentFileData.to_csv(outputFileName, index=False, float_format="%.3f")
예제 #4
0
def pointsStudentChoice(groupAssignments):
    global totalPSC
    totalPSC = 0

    # maxNumChoices = load_csv.numStudentChoices
    maxScore = load_csv.weightStudentChoice1

    prints.debug(
        f"\n\n========pointsStudentChoice========\n{groupAssignments}")
    # This outputs the score for each student's choice's based on their actual assignment
    # Students = rows (y), ProjectChoices = columns (x)
    for y in range(len(load_csv.studentID)):
        for x in range(len(load_csv.studentChoiceN.columns)):
            # If NaN is detected gives score based on position x then breaks
            prints.debug(
                f"ID {load_csv.studentID.iat[y]}, Assignment {groupAssignments[y]}, Choice {load_csv.studentChoiceN.iat[y, x]}"
            )

            if pd.isna(load_csv.studentChoiceN.iat[y, x]):
                totalPSC += math.ceil(maxScore / (2**x))
                prints.debug(f"Score {totalPSC}")
                break

            # If an assignment match is detected gives score based on position x then breaks
            else:
                if load_csv.studentChoiceN.iat[y, x] == groupAssignments[y]:
                    if load_csv.studentChoiceN.iat[y,
                                                   0] == groupAssignments[y]:
                        totalPSC += maxScore
                        prints.debug(f"Score {totalPSC}")
                        break

                    totalPSC += math.ceil(maxScore / (2**x))
                    prints.debug(f"Score {totalPSC}")
                    break

    return totalPSC
예제 #5
0
def pointsAvoid(groupAssignments):
    global totalPSA
    totalPSA = 0

    weightPSA = load_csv.weightAvoid
    # initializes bad - counts how many studentAvoid matches are found
    bad = 0

    prints.debug("========pointsAvoid========")

    for i in range(load_csv.numStudents):
        # skips student with empty avoid value
        if pd.isna(load_csv.studentAvoid[i]) is False:
            # stores studentAvoid data to 'avoid'
            avoid = int(load_csv.studentAvoid[i])
            prints.debug("======student loop======")
            prints.debug(f"student: {[i]} avoid: {avoid}")
            prints.debug(f"student group: {groupAssignments[i]}")
            prints.debug(f"avoid group: {groupAssignments[avoid]}")
            # identifies studentAvoid match within in same group
            if groupAssignments[i] == groupAssignments[avoid]:
                prints.debug("studentAvoid match found")
                bad += 1

    prints.debug(f"bad: {bad}")
    totalPSA -= (weightPSA * bad)

    return totalPSA
예제 #6
0
def pointsTeamSize(groupAssignments):
    global totalPTS
    totalPTS = 0

    weightMinPTS = load_csv.weightMinTeamSize
    weightMaxPTS = load_csv.weightMaxTeamSize

    # initialize groupSize - counts how many students there are in each group
    groupSize = [0] * len(load_csv.projectIDs)

    # loop for counting group size
    for i in range(len(load_csv.studentID)):
        groupSize[groupAssignments[i]] += 1

    prints.debug("========pointsTeamSize========")
    prints.debug(f"group size: {groupSize}")
    prints.debug(f"min size: {load_csv.minTeamSize}")
    prints.debug(f"max size: {load_csv.maxTeamSize}")

    # iterates through groupSize to identify group meeting the size constraints
    for i in range(len(groupSize)):
        if load_csv.minTeamSize[i] - 1 > groupSize[i] and groupSize[i] > 0:
            totalPTS -= weightMinPTS
            prints.debug(
                f"group{[i]} teamSize:{groupSize[i]} points:{totalPTS}")
            continue
        if load_csv.minTeamSize[i] <= groupSize[i]:
            totalPTS += weightMinPTS
            if groupSize[i] > load_csv.maxTeamSize[i] + 2:
                x = groupSize[i] - load_csv.maxTeamSize[i] - 1
                totalPTS -= (weightMaxPTS * x)
                prints.debug(
                    f"group{[i]} teamSize:{groupSize[i]} points:{totalPTS}")
                continue
            if groupSize[i] > load_csv.maxTeamSize[i] + 1:
                totalPTS -= weightMaxPTS
                prints.debug(
                    f"group{[i]} teamSize:{groupSize[i]} points:{totalPTS}")
                continue
            if groupSize[i] <= load_csv.maxTeamSize[i]:
                totalPTS += weightMaxPTS
        prints.debug(f"group{[i]} teamSize:{groupSize[i]} points:{totalPTS}")

    return totalPTS