1// Copyright 2010-2024 Google LLC
2// Licensed under the Apache License, Version 2.0 (the "License");
3// you may not use this file except in compliance with the License.
4// You may obtain a copy of the License at
6// http://www.apache.org/licenses/LICENSE-2.0
8// Unless required by applicable law or agreed to in writing, software
9// distributed under the License is distributed on an "AS IS" BASIS,
10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11// See the License for the specific language governing permissions and
12// limitations under the License.
16package operations_research;
18// Information required to create a schedule for a school system.
19message CourseSchedulingModel {
20 // Schedule name, used only for logging purposes.
21 string display_name = 1;
23 // The number of days in a schedule rotation. If the school system uses a
24 // block schedule, this value should be 1.
27 // The number of time slots each day in a schedule rotation. If the school
28 // system uses a block schedule, this value is the number of blocks.
29 int32 daily_time_slot_count = 3;
31 // List of courses that need to be scheduled.
32 repeated Course courses = 4;
35 repeated Teacher teachers = 5;
37 // List of students that need to be assigned to these courses.
38 repeated Student students = 6;
40 // List of rooms that the courses can be assigned to.
41 repeated Room rooms = 7;
44// Holds the solution to the course scheduling problem.
45message CourseSchedulingResult {
46 // Human readable message about the solver or given model.
49 // Status of the solver.
50 CourseSchedulingResultStatus solver_status = 2;
52 // List of the time slot and room assignments for each section of a course.
53 repeated ClassAssignment class_assignments = 3;
55 // List of course and section assignments for each student.
56 repeated StudentAssignment student_assignments = 4;
59message ClassAssignment {
60 // Index of the course in the CourseSchedulingModel.
61 int32 course_index = 1;
63 // Specific section of the course in the CourseSchedulingModel.
64 int32 section_number = 2;
66 // Time slots that this class has been assigned to in the
67 // CourseSchedulingModel.
68 repeated int32 time_slots = 3;
70 // Indices of the rooms that the class is assigned to in the
71 // CourseSchedulingModel. If this is not empty, then the number of indices
72 // must match the number of time slots.
73 repeated int32 room_indices = 4;
76message StudentAssignment {
77 // Index of the student in the CourseSchedulingModel.
78 int32 student_index = 1;
80 // Course indices in the CourseSchedulingModel that this student has been
81 // assigned to. The number of indices must match the number of section
83 repeated int32 course_indices = 2;
85 // Section indices for each Course in the CourseSchedulingModel this this
86 // student has been assigned to. The number of indices must match the number
88 repeated int32 section_indices = 3;
92 // Course name, used only for logging purposes.
93 string display_name = 1;
95 // The number of times each section of this course needs to meet during a
96 // schedule rotation. Each section of the course meets no more than once a
97 // day. If the school system uses a block schedule, then this value should
99 int32 meetings_count = 2;
101 // The maximum number of students for this course. This value can be equal to
102 // +Infinity to encode a course has no maximum capacity.
103 int32 max_capacity = 3;
105 // The minimum number of students for this course.
106 int32 min_capacity = 4;
108 // The number of consecutive time slots that each section of this course needs
109 // to be scheduled for. This value can only be 1 or 2. If the value is 2, then
110 // 2 consecutive time slots in a day counts as 1 meeting time for the section.
111 int32 consecutive_slots_count = 5;
113 // List of indices for the teachers of this course. We are assuming that each
114 // teacher teaches separately. Must have the same number of elements as the
115 // number of sections list.
116 repeated int32 teacher_indices = 6;
118 // The number of sections each teacher teaches of this course. Must have the
119 // same number of elements as the teacher index list.
120 repeated int32 teacher_section_counts = 7;
122 // List of the possible rooms that this course can be assigned to. This can
124 repeated int32 room_indices = 8;
128 // Teacher name, used only for logging purposes.
129 string display_name = 1;
131 // List of time slots that the teacher cannot be scheduled for. These time
132 // slot values index to the accumulative number of time slots starting at 0.
133 // For example, if a schedule rotation has 5 days and 8 time slots per day,
134 // and a teacher cannot be scheduled for the last time slot of the fourth
135 // day, the number here would be 31.
136 repeated int32 restricted_time_slots = 2;
140 // Student name, used only for logging purposes.
141 string display_name = 1;
143 // List of course indices that the student needs to be enrolled in.
144 repeated int32 course_indices = 2;
148 // Room name, used only for logging purposes.
149 string display_name = 1;
151 // Maximum number of students that can fit into this room.
155// Status returned by the solver.
156enum CourseSchedulingResultStatus {
157 COURSE_SCHEDULING_RESULT_STATUS_UNSPECIFIED = 0;
159 // The solver had enough time to find some solution that satisfies all
160 // constraints, but it did not prove optimality (which means it may or may
161 // not have reached the optimal).
163 // This can happen for large LP models (linear programming), and is a frequent
164 // response for time-limited MIPs (mixed integer programming). This is also
165 // what the CP (constraint programming) solver will return if there is no
166 // objective specified.
169 // The solver found the proven optimal solution.
172 // The model does not have any solution, according to the solver (which
173 // "proved" it, with the caveat that numerical proofs aren't actual proofs),
174 // or based on trivial considerations (eg. a variable whose lower bound is
175 // strictly greater than its upper bound).
176 SOLVER_INFEASIBLE = 3;
178 // Model errors. These are always deterministic and repeatable.
179 // They should be accompanied with a string description of the error.
180 SOLVER_MODEL_INVALID = 4;
182 // The model has not been solved in the given time or the solver was not able
183 // to solve the model given.
184 SOLVER_NOT_SOLVED = 5;
186 // An error (either numerical or from a bug in the code) occurred.