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.
14// This protocol buffer is used to represent jobshop scheduling problems.
15// https://en.wikipedia.org/wiki/Job_shop_scheduling
17// In a jobshop, a job is a sequence of tasks. A task must be performed by a
18// machine for a given duration. A task cannot be interrupted.
21// Each task in a job must be performed in sequence. That is the second task
22// cannot start before the first one has finished.
24// One machine can only execute one task at a time.
26// Tasks can have alternative ways of being executed. Each way specifies the
27// machine that can perform it, the duration, and an optional cost.
29// Each job can specify hard constraints on its start and end date, as well as
30// soft constraints on its end date. In the case of soft constraints, both
31// earliness and tardiness penalties can be specified.
33// A makespan cost specifies a penalty based on the max ending time of all jobs.
35// The objective to minimize is:
36// the sum of task costs +
37// the earliness-tardiness cost for all jobs +
38// the weighted makespan.
42option java_package = "com.google.ortools.scheduling.jssp";
43option java_multiple_files = true;
44option csharp_namespace = "Google.OrTools.scheduling.Jssp";
46package operations_research.scheduling.jssp;
48import "google/protobuf/wrappers.proto";
50// This message specifies a task inside a job.
52 // The alternative machines that can perform that task. Only one must
53 // be selected. We store the index of the machine in the main
55 repeated int32 machine = 1;
56 // The corresponding duration for the alternative ways of performing this
57 // task. This list must have the same size as the machine_id list.
58 repeated int64 duration = 2;
59 // An optional cost for selecting one alternative way of performing the task
60 // against another. This list must either be empty, or has the same size as
61 // the above two lists.
62 repeated int64 cost = 3;
65// A job is an ordered sequence of tasks, plus hard constraints on its earliest
66// start time, and its latest completion time. As well as optional
67// earliness-tardiness penalties on its end date. The job starts with the first
68// task in the list, and ends with the last.
70 // The ordered sequence of tasks.
71 repeated Task tasks = 1;
72 // This date, if set, specifies a hard constraint on when the job can start.
73 google.protobuf.Int64Value earliest_start = 2;
74 // This date specifies the earliest time the job should end. If
75 // this is set, then the earliness_cost_per_time_unit should be set
76 // too with a positive value.
77 int64 early_due_date = 3;
78 // This date specifies the latest time the job should end. If this
79 // is set, then the lateness_cost_per_time_unit should be set too
80 // with a positive value. If both early_due_date and late_due_date
81 // are set, then early_due_date <= late_due_date must hold.
82 int64 late_due_date = 4;
83 // The cost model is a convex function
87 // The slopes of this shape are specified on the left by the earliness cost,
88 // and on the right by the lateness cost. These penalty parts start at the
89 // early and late due dates. For one penalty part to be active, both
90 // the date and a positive cost must be defined. All costs must be positive.
91 int64 earliness_cost_per_time_unit = 5;
92 int64 lateness_cost_per_time_unit = 6;
93 // This date, if set, specifies a hard constraint on when the job
94 // can end. If both earliest_start and latest_end are specified,
95 // then earliest_start <= latest_end must hold.
96 google.protobuf.Int64Value latest_end = 7;
97 // Optional. A name for the job. This will only be used for logging purposes.
101// Stores the transition time matrix between jobs on a given machine.
102// If the initial job has n jobs, then time[i * n + j] will indicate the
103// minimum delay between the end of a task of a job i performed on this machine
104// and the start of a task of job j performed on the same machine.
105// Nothing can be executed on that machine during this delay.
106message TransitionTimeMatrix {
107 repeated int64 transition_time = 1;
111 // Optional transition time matrix for this machine.
112 TransitionTimeMatrix transition_time_matrix = 1;
113 // Optional. A name for a machine. This will only be used for logging
118// Specifies a precedence relation between jobs.
119// It states: start(second_job) >= end(first_job) + min_delay.
120message JobPrecedence {
121 int32 first_job_index = 1;
122 int32 second_job_index = 2;
126// The input of a problem.
127message JsspInputProblem {
128 repeated Job jobs = 1;
129 repeated Machine machines = 2;
130 repeated JobPrecedence precedences = 3;
131 int64 makespan_cost_per_time_unit = 4;
132 // If set, the cost coefficients are multiplied by this factor.
133 // It is set to 1000 by the parser when reading early tardy taillard problems
134 // where the weight of a job is a floating point value.
135 google.protobuf.DoubleValue scaling_factor = 5;
136 // Sometimes, the academic data files contain extra information. We store it
137 // in the input problem message.
139 // Optional: Name of the problem.
143// Stores how a task is executed.
144message AssignedTask {
145 // Indicates which alternative was selected. It corresponds to the
146 // alternative_index-th machine in the 'machine' field in Tasks
147 int32 alternative_index = 1;
148 // The start time of that task.
149 int64 start_time = 2;
152// Stores how a job is executed.
154 // How each task is executed.
155 repeated AssignedTask tasks = 1;
156 // Earliness-Tardiness cost of that job.
157 int64 due_date_cost = 2;
158 // Sum of all tasks costs for that job.
159 int64 sum_of_task_costs = 3;
162// The output of solving a jobshop problem.
163message JsspOutputSolution {
164 // The solution for all jobs.
165 repeated AssignedJob jobs = 1;
166 // The makespan cost of that solution.
167 int64 makespan_cost = 2;
168 // The total cost of that solution.
169 int64 total_cost = 3;