Skip to content

Commit

Permalink
math_opt: add solvers info
Browse files Browse the repository at this point in the history
  • Loading branch information
Mizux committed Sep 11, 2023
1 parent 9572c95 commit bab8c0c
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions ortools/math_opt/samples/mathopt_info.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// 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.

// Check MathOpt available solvers.
#include <iostream>

#include "absl/strings/str_cat.h"
#include "absl/strings/str_join.h"
#include "ortools/base/init_google.h"

#include "ortools/math_opt/cpp/math_opt.h"
#include "ortools/math_opt/parameters.pb.h"
#include "ortools/math_opt/core/solver_interface.h"
//#include "ortools/math_opt/cpp/enums.h"

namespace {

struct SolverTypeProtoFormatter {
void operator()(
std::string* const out,
const operations_research::math_opt::SolverTypeProto solver_type) {
out->append(EnumToString(EnumFromProto(solver_type).value()));
}
};

} // namespace

int main(int argc, char* argv[]) {
InitGoogle(argv[0], &argc, &argv, /*remove_flags=*/true);

std::cout <<
absl::StrCat(
"the solver to use, possible values: ",
absl::StrJoin(
operations_research::math_opt::AllSolversRegistry::Instance()->RegisteredSolvers(),
", ",
SolverTypeProtoFormatter())) << std::endl;

return 0;
}

0 comments on commit bab8c0c

Please sign in to comment.