Example #1
0
    def _calculateGreed(self, advisor, slot, numSlotsPrev):
        A = 15
        B = 1.2
        C = 3.0
        D = 1.0
        E = 1.5
        F = 1

        nSameMajors = len([
            adv for adv in slot.getScheduledAdvisors()
            if adv.major == advisor.major
        ])
        needsReturning = not any(
            map((lambda adv: str(adv.returning.asBool())),
                slot.getScheduledAdvisors()))
        satisfiesReturning = int(needsReturning and advisor.returning.asBool())

        personalGreed = A*tools.pos(advisor.minSlotsPerWeek-advisor.nAvailSlotsRem) + B*tools.pos(slot.getDensity()-nSameMajors) + \
            C*satisfiesReturning + D*tools.pos(advisor.reqSlotsPerWeek-advisor.nSchedSlots) + \
            E*tools.pos(advisor.reqSlotsPerWeek-advisor.nAvailSlotsRem)

        slotGreed = 0
        if numSlotsPrev > 0 and numSlotsPrev < advisor.reqSlotsPerWeek:
            slotGreed = F
        elif numSlotsPrev > advisor.reqSlotsPerWeek:
            slotGreed = -F

        advisor.greed = personalGreed + slotGreed
Example #2
0
	def _calculateGreed(self, advisor, slot, numSlotsPrev):
		A = 15;	B = 1.2;	C = 1.0;	D = 1.0;	E = 1.5;	F=3;	

		nSameMajors = len([adv for adv in slot.getScheduledAdvisors() if adv.major == advisor.major])
		avgExp = tools.getAverage([adv.year for adv in slot.getScheduledAdvisors()] + [advisor.year])

		personalGreed = A*tools.pos(advisor.minSlotsPerWeek-advisor.nAvailSlots) + B*tools.pos(slot.getDensity()-nSameMajors) + \
						C*(-math.fabs(2.5 - avgExp)) + D*tools.pos(advisor.reqSlotsPerWeek-advisor.nSchedSlots) + \
						E*tools.pos(advisor.reqSlotsPerWeek-advisor.nAvailSlots)

		slotGreed = 0
		if numSlotsPrev > 0 and numSlotsPrev < advisor.reqSlotsPerWeek:
			slotGreed = F
		elif numSlotsPrev > advisor.reqSlotsPerWeek:
			slotGreed = -F

		advisor.greed = personalGreed + slotGreed
Example #3
0
	def _calculateGreed(self, advisor, slot, numSlotsPrev):
		A = 15;	B = 1.2;	C = 3.0;	D = 1.0;	E = 1.5;	F=1;	

		nSameMajors = len([adv for adv in slot.getScheduledAdvisors() if adv.major == advisor.major])
		needsReturning = not any( map( (lambda adv: str(adv.returning.asBool())), slot.getScheduledAdvisors()))
		satisfiesReturning = int(needsReturning and advisor.returning.asBool())

		personalGreed = A*tools.pos(advisor.minSlotsPerWeek-advisor.nAvailSlotsRem) + B*tools.pos(slot.getDensity()-nSameMajors) + \
						C*satisfiesReturning + D*tools.pos(advisor.reqSlotsPerWeek-advisor.nSchedSlots) + \
						E*tools.pos(advisor.reqSlotsPerWeek-advisor.nAvailSlotsRem)

		slotGreed = 0
		if numSlotsPrev > 0 and numSlotsPrev < advisor.reqSlotsPerWeek:
			slotGreed = F
		elif numSlotsPrev > advisor.reqSlotsPerWeek:
			slotGreed = -F

		advisor.greed = personalGreed + slotGreed
Example #4
0
	def _calculateNeed(self, advisor, slot, numSlotsPrev, numSlotsAfter, breakSize):
		personalNeed = tools.pos(advisor.minSlotsPerWeek-advisor.nSchedSlots)/advisor.nAvailSlots
		
		possibleConsecSize = numSlotsPrev+1+numSlotsAfter
		if breakSize and breakSize < self._minBreakSlots:	
			advisor.need = -1
		elif possibleConsecSize < self._minBlockSlots:
			advisor.need = -1
		elif numSlotsPrev+1 > self._maxBlockSlots:
			advisor.need = -1
		elif advisor.nSchedSlots+1 > advisor.maxSlotsPerWeek:
			advisor.need = -1
		elif numSlotsPrev > 0 and numSlotsPrev < self._minBlockSlots:
			advisor.need = 999
		else:
			advisor.need = personalNeed
Example #5
0
    def _calculateNeed(self, advisor, slot, numSlotsPrev, numSlotsAfter,
                       breakSize):
        personalNeed = tools.pos(advisor.minSlotsPerWeek -
                                 advisor.nSchedSlots) / advisor.nAvailSlots

        possibleConsecSize = numSlotsPrev + 1 + numSlotsAfter
        if breakSize and breakSize < self._minBreakSlots:
            advisor.need = -1
        elif possibleConsecSize < self._minBlockSlots:
            advisor.need = -1
        elif numSlotsPrev + 1 > self._maxBlockSlots:
            advisor.need = -1
        elif advisor.nSchedSlots + 1 > advisor.maxSlotsPerWeek:
            advisor.need = -1
        elif numSlotsPrev > 0 and numSlotsPrev < self._minBlockSlots:
            advisor.need = 999
        else:
            advisor.need = personalNeed