Google OR-Tools v9.12
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
model_parameters.proto
Go to the documentation of this file.
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
5//
6// http://www.apache.org/licenses/LICENSE-2.0
7//
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.
13
14// Solve parameters that are specific to the model.
15
16syntax = "proto3";
17
18package operations_research.math_opt;
19
20import "google/protobuf/duration.proto";
21import "ortools/math_opt/solution.proto";
22import "ortools/math_opt/sparse_containers.proto";
23
24option java_package = "com.google.ortools.mathopt";
25option java_multiple_files = true;
26
27// A suggested starting solution for the solver.
28//
29// MIP solvers generally only want primal information (`variable_values`), while
30// LP solvers want both primal and dual information (`dual_values`).
31//
32// Many MIP solvers can work with: (1) partial solutions that do not specify all
33// variables or (2) infeasible solutions. In these cases, solvers typically
34// solve a sub-MIP to complete/correct the hint.
35//
36// How the hint is used by the solver, if at all, is highly dependent on the
37// solver, the problem type, and the algorithm used. The most reliable way to
38// ensure your hint has an effect is to read the underlying solvers logs with
39// and without the hint.
40//
41// Simplex-based LP solvers typically prefer an initial basis to a solution hint
42// (they need to crossover to convert the hint to a basic feasible solution
43// otherwise).
44//
45// TODO(b/183616124): Add hint-priorities to variable_values.
46message SolutionHintProto {
47 // A possibly partial assignment of values to the primal variables of the
48 // problem. The solver-independent requirements for this sub-message are:
49 // * variable_values.ids are elements of VariablesProto.ids.
50 // * variable_values.values must all be finite.
51 SparseDoubleVectorProto variable_values = 1;
52
53 // A (potentially partial) assignment of values to the linear constraints of
54 // the problem.
55 //
56 // Requirements:
57 // * dual_values.ids are elements of LinearConstraintsProto.ids.
58 // * dual_values.values must all be finite.
59 SparseDoubleVectorProto dual_values = 2;
60}
61
62// Parameters for an individual objective in a multi-objective model.
63message ObjectiveParametersProto {
64 // Optional objective degradation absolute tolerance. For a hierarchical
65 // multi-objective solver, each objective fⁱ is processed in priority order:
66 // the solver determines the optimal objective value Γⁱ, if it exists, subject
67 // to all constraints in the model and the additional constraints that
68 // fᵏ(x) = Γᵏ (within tolerances) for each k < i. If set, a solution is
69 // considered to be "within tolerances" for this objective fᵏ if
70 // |fᵏ(x) - Γᵏ| ≤ `objective_degradation_absolute_tolerance`.
71 //
72 // See also `objective_degradation_relative_tolerance`; if both parameters are
73 // set for a given objective, the solver need only satisfy one to be
74 // considered "within tolerances".
75 //
76 // If set, must be nonnegative.
77 optional double objective_degradation_absolute_tolerance = 7;
78
79 // Optional objective degradation relative tolerance. For a hierarchical
80 // multi-objective solver, each objective fⁱ is processed in priority order:
81 // the solver determines the optimal objective value Γⁱ, if it exists, subject
82 // to all constraints in the model and the additional constraints that
83 // fᵏ(x) = Γᵏ (within tolerances) for each k < i. If set, a solution is
84 // considered to be "within tolerances" for this objective fᵏ if
85 // |fᵏ(x) - Γᵏ| ≤ `objective_degradation_relative_tolerance` * |Γᵏ|.
86 //
87 // See also `objective_degradation_absolute_tolerance`; if both parameters are
88 // set for a given objective, the solver need only satisfy one to be
89 // considered "within tolerances".
90 //
91 // If set, must be nonnegative.
92 optional double objective_degradation_relative_tolerance = 8;
93
94 // Maximum time a solver should spend on optimizing this particular objective
95 // (or infinite if not set).
96 //
97 // Note that this does not supersede the global time limit in
98 // SolveParametersProto.time_limit; both will be enforced when set.
99 //
100 // This value is not a hard limit, solve time may slightly exceed this value.
101 google.protobuf.Duration time_limit = 9;
102}
103
104// TODO(b/183628247): follow naming convention in fields below.
105// Parameters to control a single solve that are specific to the input model
106// (see SolveParametersProto for model independent parameters).
107message ModelSolveParametersProto {
108 // Filter that is applied to all returned sparse containers keyed by variables
109 // in PrimalSolutionProto and PrimalRayProto
110 // (PrimalSolutionProto.variable_values, PrimalRayProto.variable_values).
111 //
112 // Requirements:
113 // * filtered_ids are elements of VariablesProto.ids.
114 SparseVectorFilterProto variable_values_filter = 1;
115
116 // Filter that is applied to all returned sparse containers keyed by linear
117 // constraints in DualSolutionProto and DualRay
118 // (DualSolutionProto.dual_values, DualRay.dual_values).
119 //
120 // Requirements:
121 // * filtered_ids are elements of LinearConstraints.ids.
122 SparseVectorFilterProto dual_values_filter = 2;
123
124 // Filter that is applied to all returned sparse containers keyed by quadratic
125 // constraints in DualSolutionProto and DualRay
126 // (DualSolutionProto.quadratic_dual_values, DualRay.quadratic_dual_values).
127 //
128 // Requirements:
129 // * filtered_ids are keys of ModelProto.quadratic_constraints.
130 SparseVectorFilterProto quadratic_dual_values_filter = 10;
131
132 // Filter that is applied to all returned sparse containers keyed by variables
133 // in DualSolutionProto and DualRay (DualSolutionProto.reduced_costs,
134 // DualRay.reduced_costs).
135 //
136 // Requirements:
137 // * filtered_ids are elements of VariablesProto.ids.
138 SparseVectorFilterProto reduced_costs_filter = 3;
139
140 // Optional initial basis for warm starting simplex LP solvers. If set, it is
141 // expected to be valid according to `ValidateBasis` in
142 // `validators/solution_validator.h` for the current `ModelSummary`.
143 BasisProto initial_basis = 4;
144
145 // Optional solution hints. If the underlying solver only accepts a single
146 // hint, the first hint is used.
147 repeated SolutionHintProto solution_hints = 5;
148
149 // Optional branching priorities. Variables with higher values will be
150 // branched on first. Variables for which priorities are not set get the
151 // solver's default priority (usually zero).
152 //
153 // Requirements:
154 // * branching_priorities.values must be finite.
155 // * branching_priorities.ids must be elements of VariablesProto.ids.
156 SparseInt32VectorProto branching_priorities = 6;
157
158 // Optional parameters for the primary objective in a multi-objective model.
159 ObjectiveParametersProto primary_objective_parameters = 7;
160
161 // Optional parameters for the auxiliary objectives in a multi-objective
162 // model.
163 //
164 // Requirements:
165 // * Map keys must also be map keys of ModelProto.auxiliary_objectives.
166 map<int64, ObjectiveParametersProto> auxiliary_objective_parameters = 8;
167
168 // Optional lazy constraint annotations. Included linear constraints will be
169 // marked as "lazy" with supporting solvers, meaning that they will only be
170 // added to the working model as-needed as the solver runs.
171 //
172 // Note that this an algorithmic hint that does not affect the model's
173 // feasible region; solvers not supporting these annotations will simply
174 // ignore it.
175 //
176 // Requirements:
177 // * Each entry must be an element of VariablesProto.ids.
178 // * Entries must be in strictly increasing order (i.e., sorted, no repeats).
179 repeated int64 lazy_linear_constraint_ids = 9;
180}