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// RCPSP: Resource-Constrained Project Scheduling Problem.
16// The problem description is as follows:
18// You have a set of resources. They all have a maximum capacity, and
19// can be renewable or not.
21// You have a set of tasks. Each task has a list of successors, and a
22// list of recipes. Each recipe consists of a duration, and a list of
23// demands, one per resource.
24// The problem is always built with 2 sentinels. The first task is the source
25// with a set of successors. The last task is the sink, with no successors and a
27// All tasks are reachable from the source task. And the sink task is reachable
28// from all tasks. Furthermore, the graph has no cycles.
30// The tasks dependencies form a DAG with a single source and a single end.
31// Both source and end tasks have a zero duration, and no resource consumption.
33// In case the problem is of type RCPSP/Max. The data contains an additional
34// 3D array of delays per task. This structure contains the following
35// information for task i with recipe ri and successor j with recipe rj, then
36// start(i) + delay(i, ri, j, rj) <= start(j). This subsumes the normal
37// successor predecence of the non RCPSP/Max variation, i.e.:
38// start(i) + duration(i, mi) <= start(j).
40// In the normal case, the objective is to minimize the makespan of the problem.
42// In the resource investment problem, there is no makespan. It is
43// replaced by a strict deadline, and each task must finish before
44// this deadline. In that case, resources have a unit cost, and the
45// objective is to minimize the sum of resource cost.
47// In the consumer/producer case, tasks have a zero duration, and demands can be
48// negative. The constraint states that at each time point, the sum of demands
49// happening before or during this time must be between the min and max
50// capacity. Note that in that case, both min and max capacity can be negative.
51// Furthermore, if 0 is not in [min_capacity, max_capacity], then a sufficient
52// set of events must happen at time 0 such that the sum of their demands must
53// fall inside the capacity interval.
55// The supported file formats are:
56// - standard psplib (.sm and .mm):
57// http://www.om-db.wi.tum.de/psplib/data.html
58// - rcpsp problem in the patterson format (.rcp):
59// http://www.om-db.wi.tum.de/psplib/dataob.html
61// https://www.wiwi.tu-clausthal.de/de/abteilungen/produktion/forschung/
62// schwerpunkte/project-generator/rcpspmax/
63// https://www.wiwi.tu-clausthal.de/de/abteilungen/produktion/forschung/
64// schwerpunkte/project-generator/mrcpspmax/
65// - resource investment problem with max delay (.sch):
66// https://www.wiwi.tu-clausthal.de/de/abteilungen/produktion/forschung/
67// schwerpunkte/project-generator/ripmax/
71option java_package = "com.google.ortools.scheduling.rcpsp";
72option java_multiple_files = true;
73option csharp_namespace = "Google.OrTools.Scheduling.Rcpsp";
75package operations_research.scheduling.rcpsp;
78 // The max capacity of the cumulative.
79 int32 max_capacity = 1;
81 // This field is used only in the consumer/producer case. It states the
82 // minimum capacity that must be valid at each time point.
83 int32 min_capacity = 2;
85 // Indicates if the resource is renewable, that is if a task demands
86 // d from this resource, then the available capacity decreases by d at the
87 // start of the task and increases by d at the end of the task.
90 // If non zero, then each unit of capacity will incur a cost of unit_cost.
95 // The duration of the task when this recipe is selected.
98 // In the general case, demand must be >= 0. In the consumer/producer case,
99 // it can be < 0. Note that in this case, the tasks always have a duration
100 // of zero. Thus the effect of the demand (increase or decrease of the
101 // current usage) happens at the start of the task.
102 repeated int32 demands = 2;
104 // This parallel list indicates which resource index (in the main problem)
105 // the above demand corresponds to.
106 repeated int32 resources = 3;
109message PerRecipeDelays {
110 repeated int32 min_delays = 1;
113message PerSuccessorDelays {
114 repeated PerRecipeDelays recipe_delays = 1;
118 // The indices of the successors tasks in the main problem.
119 repeated int32 successors = 1;
121 // The list of possible ways to execute the task.
122 repeated Recipe recipes = 2;
124 // If the current task has n successors and m recipes then this is
125 // an n x m matrix where each entry at line i is a vector with the
126 // same length as the number of recipes for the task successor[i]. If
127 // recipe m1 is chosen for the current task, and recipe m2 is chosen
128 // for its successor i, we have:
129 // start(current_task) + delay[i][m1][m2] <= start(successor_task).
130 repeated PerSuccessorDelays successor_delays = 3;
133message RcpspProblem {
135 repeated Resource resources = 1;
136 repeated Task tasks = 2;
138 bool is_consumer_producer = 3;
139 bool is_resource_investment = 4;
140 bool is_rcpsp_max = 5;
141 // If set, it defines a strict date, and each task must finish before this.
143 // Additional info stored in the source file.
144 // The horizon is a date where we are sure that all tasks can fit before it.
146 // The release date is defined in the rcpsp base format, but is not used.
147 int32 release_date = 8;
148 // The tardiness cost is defined in the rcpsp base format, but is not used.
149 int32 tardiness_cost = 9;
150 // The mpm_time is defined in the rcpsp base format, but is not used.
151 // It is defined as the minimum makespan in case of interruptible tasks.
153 // Data used by the problem generator.
155 string basedata = 12;
156 // The due date is defined in the rcpsp base format, but is not used.
161message RcpspAssignment {
162 repeated int64 start_of_task = 1;
163 repeated int32 selected_recipe_of_task = 2;