File size: 1,746 Bytes
8e7d8ae
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from .Constant import Constant


# Reads configuration file and stores parsed objects
class Criteria:
    weights = [0, 0.5, 0.5, 0, 0]

    # check for room overlapping of classes
    @staticmethod
    def isRoomOverlapped(slots, reservation, dur):
        reservation_index = hash(reservation)
        cls = slots[reservation_index: reservation_index + dur]
        return any(True for slot in cls if len(slot) > 1)

    # does current room have enough seats
    @staticmethod
    def isSeatEnough(r, cc):
        return r.NumberOfSeats >= cc.NumberOfSeats

    # does current room have computers if they are required
    @staticmethod
    def isComputerEnough(r, cc):
        # return (not cc.LabRequired) or (cc.LabRequired and r.Lab)
        return cc.LabRequired == r.Lab

    # check overlapping of classes for professors and student groups (size of course)
    @staticmethod
    def isOverlappedProfStudentGrp(slots, cc, numberOfRooms, timeId):
        po = go = False

        dur = cc.Duration
        for i in range(numberOfRooms, 0, -1):
            # for each hour of class
            for j in range(timeId, timeId + dur):
                cl = slots[j]
                for cc1 in cl:
                    if cc != cc1:
                        # professor overlaps?
                        if not po and cc.professorOverlaps(cc1):
                            po = True
                        # student group enough?
                        if not go and cc.groupsOverlap(cc1):
                            go = True
                        # both type of overlapping? no need to check more
                        if po and go:
                            return po, go

            timeId += Constant.DAY_HOURS
        return po, go