math_opt: Add solve_arguments.cc
This commit is contained in:
@@ -313,6 +313,7 @@ cc_library(
|
||||
|
||||
cc_library(
|
||||
name = "solve_arguments",
|
||||
srcs = ["solve_arguments.cc"],
|
||||
hdrs = [
|
||||
"solve_arguments.h",
|
||||
],
|
||||
|
||||
41
ortools/math_opt/cpp/solve_arguments.cc
Normal file
41
ortools/math_opt/cpp/solve_arguments.cc
Normal file
@@ -0,0 +1,41 @@
|
||||
// Copyright 2010-2022 Google LLC
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "ortools/math_opt/cpp/solve_arguments.h"
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include "absl/container/flat_hash_set.h"
|
||||
#include "absl/status/status.h"
|
||||
#include "ortools/base/status_macros.h"
|
||||
#include "ortools/math_opt/cpp/callback.h"
|
||||
#include "ortools/math_opt/cpp/model_solve_parameters.h"
|
||||
#include "ortools/math_opt/storage/model_storage.h"
|
||||
|
||||
namespace operations_research::math_opt {
|
||||
|
||||
absl::Status SolveArguments::CheckModelStorageAndCallback(
|
||||
const ModelStorage* const expected_storage) const {
|
||||
RETURN_IF_ERROR(model_parameters.CheckModelStorage(expected_storage))
|
||||
<< "invalid model_parameters";
|
||||
RETURN_IF_ERROR(callback_registration.CheckModelStorage(expected_storage))
|
||||
<< "invalid callback_registration";
|
||||
|
||||
if (callback == nullptr && !callback_registration.events.empty()) {
|
||||
return absl::InvalidArgumentError(
|
||||
"no callback was provided to run, but callback events were registered");
|
||||
}
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
} // namespace operations_research::math_opt
|
||||
Reference in New Issue
Block a user