OR-Tools  9.1
solver_parameters_validator.cc
Go to the documentation of this file.
1 // Copyright 2010-2021 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 
15 
16 #include <string>
17 
18 #include "absl/memory/memory.h"
19 #include "absl/status/status.h"
20 #include "absl/status/statusor.h"
21 #include "absl/strings/str_cat.h"
22 #include "ortools/math_opt/parameters.pb.h"
24 #include "ortools/base/protoutil.h"
25 
26 namespace operations_research {
27 namespace math_opt {
28 
29 absl::Status ValidateSolverParameters(const SolveParametersProto& parameters) {
31  parameters.common_parameters().time_limit())
32  .status())
33  << "invalid parameters.common_parameters.time_limit";
34 
35  if (parameters.common_parameters().has_threads()) {
36  if (parameters.common_parameters().threads() <= 0) {
37  return absl::InvalidArgumentError(
38  absl::StrCat("parameters.common_parameters.threads = ",
39  parameters.common_parameters().threads(), " <= 0"));
40  }
41  }
42 
43  return absl::OkStatus();
44 }
45 
46 } // namespace math_opt
47 } // namespace operations_research
inline ::absl::StatusOr< absl::Duration > DecodeGoogleApiProto(const google::protobuf::Duration &proto)
Definition: protoutil.h:42
absl::Status ValidateSolverParameters(const SolveParametersProto &parameters)
Collection of objects used to extend the Constraint Solver library.
SatParameters parameters
#define RETURN_IF_ERROR(expr)
Definition: status_macros.h:29