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// Solve parameters that are specific to the model.
18package operations_research.service.v1.mathopt;
20import "ortools/service/v1/mathopt/solution.proto";
21import "ortools/service/v1/mathopt/sparse_containers.proto";
23option java_multiple_files = true;
24option java_package = "com.google.ortools.service.v1.mathopt";
25option csharp_namespace = "Google.OrTools.Service";
27// A suggested starting solution for the solver.
29// MIP solvers generally only want primal information (`variable_values`), while
30// LP solvers want both primal and dual information (`dual_values`).
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.
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.
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
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;
53 // A (potentially partial) assignment of values to the linear constraints of
57 // * dual_values.ids are elements of LinearConstraintsProto.ids.
58 // * dual_values.values must all be finite.
59 SparseDoubleVectorProto dual_values = 2;
62// TODO(b/183628247): follow naming convention in fields below.
63// Parameters to control a single solve that that are specific to the input
64// model (see SolveParametersProto for model independent parameters).
65message ModelSolveParametersProto {
66 // Filter that is applied to all returned sparse containers keyed by variables
67 // in PrimalSolutionProto and PrimalRayProto
68 // (PrimalSolutionProto.variable_values, PrimalRayProto.variable_values).
71 // * filtered_ids are elements of VariablesProto.ids.
72 SparseVectorFilterProto variable_values_filter = 1;
74 // Filter that is applied to all returned sparse containers keyed by linear
75 // constraints in DualSolutionProto and DualRay
76 // (DualSolutionProto.dual_values, DualRay.dual_values).
79 // * filtered_ids are elements of LinearConstraints.ids.
80 SparseVectorFilterProto dual_values_filter = 2;
82 // Filter that is applied to all returned sparse containers keyed by variables
83 // in DualSolutionProto and DualRay (DualSolutionProto.reduced_costs,
84 // DualRay.reduced_costs).
87 // * filtered_ids are elements of VariablesProto.ids.
88 SparseVectorFilterProto reduced_costs_filter = 3;
90 // Optional initial basis for warm starting simplex LP solvers. If set, it is
91 // expected to be valid according to `ValidateBasis` in
92 // `validators/solution_validator.h` for the current `ModelSummary`.
93 BasisProto initial_basis = 4;
95 // Optional solution hints. If the underlying solver only accepts a single
96 // hint, the first hint is used.
97 repeated SolutionHintProto solution_hints = 5;
99 // Optional branching priorities. Variables with higher values will be
100 // branched on first. Variables for which priorities are not set get the
101 // solver's default priority (usually zero).
104 // * branching_priorities.values must be finite.
105 // * branching_priorities.ids must be elements of VariablesProto.ids.
106 SparseInt32VectorProto branching_priorities = 6;