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.
16package operations_research.math_opt;
18import "ortools/math_opt/callback.proto";
19import "ortools/math_opt/infeasible_subsystem.proto";
20import "ortools/math_opt/model.proto";
21import "ortools/math_opt/model_parameters.proto";
22import "ortools/math_opt/model_update.proto";
23import "ortools/math_opt/parameters.proto";
24import "ortools/math_opt/result.proto";
26option java_package = "com.google.ortools.mathopt";
27option java_multiple_files = true;
29// This message is used to specify some hints on the resources a remote solve is
30// expected to use. These parameters are hints and may be ignored by the remote
31// server (in particular in case of solve in a local subprocess, for example).
33// When using SolveService.Solve and SolveService.ComputeInfeasibleSubsystem,
34// these hints are mostly optional as some defaults will be computed based on
35// the other parameters.
37// When using SolveService.StreamSolve these hints are used to dimension the
38// resources available during the execution of every action; thus it is
39// recommended to set them.
40message SolverResourcesProto {
41 // The number of solver threads that are expected to actually execute in
42 // parallel. Must be finite and >0.0.
44 // For example a value of 3.0 means that if the solver has 5 threads that can
45 // execute we expect at least 3 of these threads to be scheduled in parallel
46 // for any given time slice of the operating system scheduler.
48 // A fractional value indicates that we don't expect the operating system to
49 // constantly schedule the solver's work. For example with 0.5 we would expect
50 // the solver's threads to be scheduled half the time.
52 // This parameter is usually used in conjunction with
53 // SolveParametersProto.threads. For some solvers like Gurobi it makes sense
54 // to use SolverResourcesProto.cpu = SolveParametersProto.threads. For other
55 // solvers like CP-SAT, it may makes sense to use a value lower than the
56 // number of threads as not all threads may be ready to be scheduled at the
57 // same time. It is better to consult each solver documentation to set this
60 // Note that if the SolveParametersProto.threads is not set then this
61 // parameter should also be left unset.
62 optional double cpu = 1;
64 // The limit of RAM for the solve in bytes. Must be finite and >=1.0 (even
65 // though it should in practice be much larger).
66 optional double ram = 2;
69// Request for a unary remote solve in MathOpt.
71 // Solver type to numerically solve the problem. Note that if a solver does
72 // not support a specific feautre in the model, the optimization procedure
73 // won't be successful.
74 SolverTypeProto solver_type = 1;
76 // A mathematical representation of the optimization problem to solve.
79 // Hints on resources requested for the solve.
80 SolverResourcesProto resources = 6;
82 SolverInitializerProto initializer = 3;
84 // Parameters to control a single solve. The enable_output parameter is
85 // handled specifically. For solvers that support messages callbacks, setting
86 // it to true will have the server register a message callback. The resulting
87 // messages will be returned in SolveResponse.messages. For other
88 // solvers, setting enable_output to true will result in an error.
89 SolveParametersProto parameters = 4;
91 // Parameters to control a single solve that are specific to the input model
92 // (see SolveParametersProto for model independent parameters).
93 ModelSolveParametersProto model_parameters = 5;
96// Response for a unary remote solve in MathOpt.
97message SolveResponse {
98 // Either `result` or `status` must be set. This is equivalent to C++
99 // StatusOr<SolveResult>.
101 // Description of the output of solving the model in the request.
102 SolveResultProto result = 1;
104 // The absl::Status returned by the solver. It should never be OK when set.
105 StatusProto status = 3;
108 // If SolveParametersProto.enable_output has been used, this will contain log
109 // messages for solvers that support message callbacks.
110 repeated string messages = 2;
113// The streamed version of absl::Status.
115 // The status code, one of the absl::StatusCode.
118 // The status message.