1// Copyright 2010-2025 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// Enums used to define routing parameters.
18option java_package = "com.google.ortools.constraintsolver";
19option java_multiple_files = true;
20option csharp_namespace = "Google.OrTools.ConstraintSolver";
22package operations_research;
24// First solution strategies, used as starting point of local search.
25message FirstSolutionStrategy {
27 // See the homonymous value in LocalSearchMetaheuristic.
30 // Lets the solver detect which strategy to use according to the model being
34 // --- Path addition heuristics ---
35 // Starting from a route "start" node, connect it to the node which produces
36 // the cheapest route segment, then extend the route by iterating on the
37 // last node added to the route.
38 PATH_CHEAPEST_ARC = 3;
39 // Same as PATH_CHEAPEST_ARC, but arcs are evaluated with a comparison-based
40 // selector which will favor the most constrained arc first. To assign a
41 // selector to the routing model, see
42 // RoutingModel::ArcIsMoreConstrainedThanArc() in routing.h for details.
43 PATH_MOST_CONSTRAINED_ARC = 4;
44 // Same as PATH_CHEAPEST_ARC, except that arc costs are evaluated using the
45 // function passed to RoutingModel::SetFirstSolutionEvaluator()
47 EVALUATOR_STRATEGY = 5;
48 // Savings algorithm (Clarke & Wright).
49 // Reference: Clarke, G. & Wright, J.W.:
50 // "Scheduling of Vehicles from a Central Depot to a Number of Delivery
51 // Points", Operations Research, Vol. 12, 1964, pp. 568-581
53 // Parallel version of the Savings algorithm.
54 // Instead of extending a single route until it is no longer possible,
55 // the parallel version iteratively considers the next most improving
56 // feasible saving and possibly builds several routes in parallel.
57 PARALLEL_SAVINGS = 17;
58 // Sweep algorithm (Wren & Holliday).
59 // Reference: Anthony Wren & Alan Holliday: Computer Scheduling of Vehicles
60 // from One or More Depots to a Number of Delivery Points Operational
61 // Research Quarterly (1970-1977),
62 // Vol. 23, No. 3 (Sep., 1972), pp. 333-344
64 // Christofides algorithm (actually a variant of the Christofides algorithm
65 // using a maximal matching instead of a maximum matching, which does
66 // not guarantee the 3/2 factor of the approximation on a metric travelling
67 // salesman). Works on generic vehicle routing models by extending a route
68 // until no nodes can be inserted on it.
69 // Reference: Nicos Christofides, Worst-case analysis of a new heuristic for
70 // the travelling salesman problem, Report 388, Graduate School of
71 // Industrial Administration, CMU, 1976.
74 // --- Path insertion heuristics ---
75 // Make all nodes inactive. Only finds a solution if nodes are optional (are
76 // element of a disjunction constraint with a finite penalty cost).
78 // Iteratively build a solution by inserting the cheapest node at its
79 // cheapest position; the cost of insertion is based on the global cost
80 // function of the routing model. As of 2/2012, only works on models with
81 // optional nodes (with finite penalty costs).
83 // Iteratively build a solution by inserting the cheapest node at its
84 // cheapest position; the cost of insertion is based on the arc cost
85 // function. Is faster than BEST_INSERTION.
86 PARALLEL_CHEAPEST_INSERTION = 8;
87 // Iteratively build a solution by constructing routes sequentially, for
88 // each route inserting the cheapest node at its cheapest position until the
89 // route is completed; the cost of insertion is based on the arc cost
90 // function. Is faster than PARALLEL_CHEAPEST_INSERTION.
91 SEQUENTIAL_CHEAPEST_INSERTION = 14;
92 // Iteratively build a solution by inserting each node at its cheapest
93 // position; the cost of insertion is based on the arc cost function.
94 // Differs from PARALLEL_CHEAPEST_INSERTION by the node selected for
95 // insertion; here nodes are considered in decreasing order of distance to
96 // the start/ends of the routes, i.e. farthest nodes are inserted first.
97 // Is faster than SEQUENTIAL_CHEAPEST_INSERTION.
98 LOCAL_CHEAPEST_INSERTION = 9;
99 // Same as LOCAL_CHEAPEST_INSERTION except that the cost of insertion is
100 // based on the routing model cost function instead of arc costs only.
101 LOCAL_CHEAPEST_COST_INSERTION = 16;
103 // --- Variable-based heuristics ---
104 // Iteratively connect two nodes which produce the cheapest route segment.
105 GLOBAL_CHEAPEST_ARC = 1;
106 // Select the first node with an unbound successor and connect it to the
107 // node which produces the cheapest route segment.
108 LOCAL_CHEAPEST_ARC = 2;
109 // Select the first node with an unbound successor and connect it to the
110 // first available node.
111 // This is equivalent to the CHOOSE_FIRST_UNBOUND strategy combined with
112 // ASSIGN_MIN_VALUE (cf. constraint_solver.h).
113 FIRST_UNBOUND_MIN_VALUE = 12;
117// Local search metaheuristics used to guide the search. Apart from greedy
118// descent, they will try to escape local minima.
119message LocalSearchMetaheuristic {
121 // Means "not set". If the solver sees that, it'll behave like for
122 // AUTOMATIC. But this value won't override others upon a proto MergeFrom(),
123 // whereas "AUTOMATIC" will.
126 // Lets the solver select the metaheuristic.
129 // Accepts improving (cost-reducing) local search neighbors until a local
130 // minimum is reached.
132 // Uses guided local search to escape local minima
133 // (cf. http://en.wikipedia.org/wiki/Guided_Local_Search); this is generally
134 // the most efficient metaheuristic for vehicle routing.
135 GUIDED_LOCAL_SEARCH = 2;
136 // Uses simulated annealing to escape local minima
137 // (cf. http://en.wikipedia.org/wiki/Simulated_annealing).
138 SIMULATED_ANNEALING = 3;
139 // Uses tabu search to escape local minima
140 // (cf. http://en.wikipedia.org/wiki/Tabu_search).
142 // Uses tabu search on a list of variables to escape local minima. The list
143 // of variables to use must be provided via the SetTabuVarsCallback
145 GENERIC_TABU_SEARCH = 5;
149// Used by `RoutingModel` to report the status of the search for a solution.
150message RoutingSearchStatus {
152 // Problem not solved yet (before calling RoutingModel::Solve()).
153 ROUTING_NOT_SOLVED = 0;
154 // Problem solved successfully after calling RoutingModel::Solve().
156 // Problem solved successfully after calling RoutingModel::Solve(), except
157 // that a local optimum has not been reached. Leaving more time would allow
158 // improving the solution.
159 ROUTING_PARTIAL_SUCCESS_LOCAL_OPTIMUM_NOT_REACHED = 2;
160 // No solution found to the problem after calling RoutingModel::Solve().
162 // Time limit reached before finding a solution with RoutingModel::Solve().
163 ROUTING_FAIL_TIMEOUT = 4;
164 // Model, model parameters or flags are not valid.
166 // Problem proven to be infeasible.
167 ROUTING_INFEASIBLE = 6;
168 // Problem has been solved to optimality.