File size: 8,372 Bytes
f823a82
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
custom_branches = [
    {
        'name': 'CS',
        'subjects': 
            [
                {'name':'OOPS','duration': 1, 'frequency': 3, 'teachers': ['rks'], 'type': 'theory'}, 
                {'name':'OS','duration': 1, 'frequency': 3, 'teachers': ['hsp'], 'type': 'theory',  }, 
                {'name':'Networks','duration': 1, 'frequency': 3, 'teachers': ['ak'], 'type': 'theory',  }, 
                {'name':'Database','duration': 1, 'frequency': 3, 'teachers': ['msa'], 'type': 'theory',  }, 
                {'name':'Language','duration': 1, 'frequency': 2, 'teachers': ['nj'], 'type': 'theory',  }, 
                {'name':'TestOnline','duration': 1, 'frequency': 1, 'teachers': ['msa'], 'type': 'online'}
            ]
    },
    
    {
        'name':'EE',
        'subjects': 
        [
                    {'name':'Robotics','duration': 1, 'frequency': 3, 'teachers': ['rks'], 'type': 'theory',  }, 
                    {'name':'BEEE','duration': 1, 'frequency': 3, 'teachers': ['hsp'], 'type': 'theory',  }, 
                    {'name':'EmbeddedSystem','duration': 1, 'frequency': 3, 'teachers': ['ak'], 'type': 'theory',  }, 
                    {'name':'Microcontrollers','duration': 1, 'frequency': 3, 'teachers': ['msa'], 'type': 'theory',  }, 
                    {'name':'DLD','duration': 1, 'frequency': 2, 'teachers': ['nj'], 'type': 'theory',  }, 
                    {'name':'Calculus','duration': 2, 'frequency': 1, 'teachers': ['ns'], 'type': 'theory',  }, 
                    {'name':'TestOnline2','duration': 1, 'frequency': 1, 'teachers': ['hsp'], 'type': 'online'}
        ]

                    
    
    },
    {
        'name':'BS',
        'subjects':[
                    {'name':'LinearAlgebra','duration': 1, 'frequency': 3, 'teachers': ['na'], 'type': 'theory',  }, 
                    {'name':'Buisness','duration': 1, 'frequency': 3, 'teachers': ['mc'], 'type': 'theory',  }, 
                    {'name':'Economics','duration': 1, 'frequency': 3, 'teachers': ['pd'], 'type': 'theory',  }, 
                    {'name':'PoliticalScience','duration': 1, 'frequency': 3, 'teachers': ['rrs'], 'type': 'theory',  }, 
                    {'name':'Geometry','duration': 1, 'frequency': 2, 'teachers': ['nm'], 'type': 'theory',  }, 
                    {'name':'Idiocracy','duration': 2, 'frequency': 1, 'teachers': ['na'], 'type': 'theory',  }, 
                    {'name':'TestOnline3','duration': 1, 'frequency': 1, 'teachers': ['pt'], 'type': 'online', }
                 
        ] 

    }

  
]
    


custom_teachers = ['rks', 'hsp', 'ak', 'msa', 'nj', 'ab', 'na', 'vt', 'rs', 'mc', 'nm', 'aa', 
                'ns', 'pd', 'rrs', 'bsr', 'gh', 'sks', 'ast', 'pt', 'sd', 'sm', 'kt', 'res', 'jkm', 'dkm', 'pm', 'so', 'ts']


batches = 2
day_names = ["Mon", "Tue", "Wed", "Thr", "Fri", "Sat"]


slot_names = [
    "9:00", "10:00", "11:00", "12:00",
    "BREAK",
    "2:00", "3:00", "4:00", "5:00"
]

days = range(len(day_names))            
slots = range(len(slot_names))

ast_json = [

            {
                "type": "hard",
                "name": "no_classes_on_saturday",
                "forall": [
                    {"b": "branches"},
                    {"sub": {"subjects": "b"}},
                    {"d": "days"},
                    {"s": "slots"}
                ],
                "where": {
                    "operator": "AND",
                    "left":
                        {
                            "operator": "==",
                            "left": "d",
                            "right": 5
                        },
                    "right":
                        {
                            "operator": "!=",
                            "left": {"type": "sub"},
                            "right": "online"
                        }
                    
                },
                "assert": {
                    "operator": "==",
                    "left": {
                        "target": "schedule",
                        "args": [{"name": "b"}, {"name":"sub" }, "d", "s"]
                    },
                    "right": 0
                }
        }
        ,
        {
                    "type": "hard",
                    "name": "teacher_no_double_booking",
                    "forall": [
                        {"teacher": "teachers"},
                        {"d": "days"},
                        {"t": "slots"}
                    ],
                    "assert": {
                        "operator": "<=",
                        "left": {
                            "operator": "sum",
                            "over": [
                                {"b": "branches"},
                                {"sub": {"subjects": "b"}}
                            ],
                            "expression": {
                                "target": "occupies_teacher",
                                "args": ["b", "sub", "teacher", "d", "t"]
                            }
                        },
                        "right": 1
                    }
            },

            {
                    "type": "hard",
                    "name": "subject_weekly_frequency",
                    "forall": [
                        {"b": "branches"},
                        {"sub": {"subjects": "b"}}
                    ],
                    "assert": {
                        "operator": "==",
                        "left": {
                            "operator": "sum",
                            "over": [
                                {"d": "days"}, 
                                {"s": "slots"}
                            ],
                            "expression": {
                                "target": "schedule",
                                "args": [{"name": "b"}, {"name":"sub" }, "d", "s"]
                            }
                        },
                        "right": {"frequency": "sub"}
                    }
            },

        {
                "type": "hard",
                "name": "cs_department_meeting",
                "forall": [
                    {"b": "branches"},
                    {"sub": {"subjects": "b"}},
                    {"d": "days"},
                    {"s": "slots"}
                ],
                "where": {
                    "operator": "AND",
                    "left": {
                        "operator": "==",
                        "left": {"name":"b"},
                        "right": "CS"
                    },
                    "right": {
                        "operator": "AND",
                        "left": {
                            "operator": "==",
                            "left": "d",
                            "right": 2
                        },
                        "right": {
                            "operator": "==",
                            "left": "s",
                            "right": 3
                        }
                    }
                },
                "assert": {
                    "operator": "==",
                    "left": {
                        "target": "schedule",
                        "args": [{"name": "b"}, {"name":"sub" }, "d", "s"]
                    },
                    "right": 0
                }
            },

            {
                "type": "hard",
                "name": "one_class_per_slot_per_branch",
                "forall": [
                    {"b": "branches"},
                    {"d": "days"},
                    {"s": "slots"}
                ],
                "assert": {
                    "operator": "<=",
                    "left": {
                        "operator": "sum",
                        "over": [
                            {"sub": {"subjects": "b"}}
                        ],
                        "expression": {
                            "target": "schedule",
                            "args": [{"name": "b"}, {"name": "sub"}, "d", "s"]
                        }
                    },
                    "right": 1
                }
            }
     
]