Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
operations_research::math_opt::internal Namespace Reference

Classes

class  ArrowOperatorProxy
 
class  IncrementalSolverImpl
 Incremental solve of a model. More...
 
class  SosConstraintData
 
struct  VariablesEquality
 

Typedefs

using BaseSolverFactory
 

Functions

template<typename SosConstraint >
std::string SosConstraintToString (SosConstraint constraint, absl::string_view sos_type_name)
 
absl::Status CheckIdsRangeAndStrictlyIncreasing2 (absl::Span< const int64_t > ids)
 
template<typename DataProto >
absl::Status UpdateBiMapFromMappedData (const absl::Span< const int64_t > deleted_ids, const google::protobuf::Map< int64_t, DataProto > &proto_map, IdNameBiMap &bimap)
 
absl::Status ValidateInitArgs (const Solver::InitArgs &init_args, const SolverTypeProto solver_type)
 
absl::Status CheckModelStorage (const ModelStorage *const storage, const ModelStorage *const expected_storage)
 
absl::StatusOr< SolveResult > SolveImpl (const BaseSolverFactory solver_factory, const Model &model, const SolverType solver_type, const SolveArguments &solve_args, const SolveInterrupter *const user_canceller, const bool remove_names)
 
absl::StatusOr< ComputeInfeasibleSubsystemResultComputeInfeasibleSubsystemImpl (const BaseSolverFactory solver_factory, const Model &model, const SolverType solver_type, const ComputeInfeasibleSubsystemArguments &compute_args, const SolveInterrupter *const user_canceller, const bool remove_names)
 
template<typename LeftIterable , typename RightIterable , typename Expression >
void AddInnerProduct (const LeftIterable &left, const RightIterable &right, Expression &expr)
 
template<typename RowId , typename ColumnId >
SparseDoubleMatrixProto EntriesToMatrixProto (std::vector< std::tuple< RowId, ColumnId, double > > entries)
 entries must have unique (row, column) values but can be in any order.
 

Variables

std::atomic< int64_t > debug_num_solver = 0
 
constexpr absl::string_view kKeyHasNullModelStorage
 The CHECK message to use when a KeyType::storage() is nullptr.
 
constexpr absl::string_view kObjectsFromOtherModelStorage
 
constexpr absl::string_view kInputFromInvalidModelStorage
 
constexpr absl::string_view kModelIsDestroyed
 
constexpr double kZerosCleanup = 1.0 / 3.0
 

Detailed Description

Inline implementations

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.

VariablesEquality

Inlined functions

Typedef Documentation

◆ BaseSolverFactory

Initial value:
absl::AnyInvocable<absl::StatusOr<std::unique_ptr<BaseSolver>>(
SolverTypeProto solver_type, ModelProto model,
SolveInterrupter* local_canceller) const>
GRBmodel * model

A factory of solver.

The local_canceller is a local interrupter that exists in the scope of SolveImpl(), ComputeInfeasibleSubsystemImpl() or IncrementalSolverImpl. It is triggered:

  • either when the user_canceller is triggered
  • or when the BaseSolver::Callback returns an invalid CallbackResultProto; in that case a new CallbackResultProto with its terminate set to true is also returned instead.

Solvers that don't support cancellation (i.e. in-process solving) should ignore the local_canceller: this use case won't have a user_canceller and the CallbackResultProto.terminate will terminate the solve as soon as possible if the CallbackResultProto is invalid.

Definition at line 50 of file solve_impl.h.

Function Documentation

◆ AddInnerProduct()

template<typename LeftIterable , typename RightIterable , typename Expression >
void operations_research::math_opt::internal::AddInnerProduct ( const LeftIterable & left,
const RightIterable & right,
Expression & expr )

Definition at line 1683 of file variable_and_expressions.h.

◆ CheckIdsRangeAndStrictlyIncreasing2()

absl::Status operations_research::math_opt::internal::CheckIdsRangeAndStrictlyIncreasing2 ( absl::Span< const int64_t > ids)
Todo
(b/232526223): this is an exact copy of CheckIdsRangeAndStrictlyIncreasing from ids_validator.h, find a way to share the code.
Note
This function is only exposed in the header because we need UpdateBiMapFromMappedData here for testing purposes.

Definition at line 40 of file model_summary.cc.

◆ CheckModelStorage()

absl::Status operations_research::math_opt::internal::CheckModelStorage ( const ModelStorage *const storage,
const ModelStorage *const expected_storage )
inline

Returns a failure when the input pointer is not nullptr and points to a different model storage than expected_storage (which must not be nullptr).

Failure message is kInputFromInvalidModelStorage.

Definition at line 168 of file key_types.h.

◆ ComputeInfeasibleSubsystemImpl()

absl::StatusOr< ComputeInfeasibleSubsystemResult > operations_research::math_opt::internal::ComputeInfeasibleSubsystemImpl ( BaseSolverFactory solver_factory,
const Model & model,
SolverType solver_type,
const ComputeInfeasibleSubsystemArguments & compute_args,
const SolveInterrupter * user_canceller,
bool remove_names )

ComputeInfeasibleSubsystems the input model in a subprocess.

The user_canceller parameter is optional.

Definition at line 135 of file solve_impl.cc.

◆ EntriesToMatrixProto()

template<typename RowId , typename ColumnId >
SparseDoubleMatrixProto operations_research::math_opt::internal::EntriesToMatrixProto ( std::vector< std::tuple< RowId, ColumnId, double > > entries)

entries must have unique (row, column) values but can be in any order.

Definition at line 279 of file sparse_matrix.h.

◆ SolveImpl()

absl::StatusOr< SolveResult > operations_research::math_opt::internal::SolveImpl ( BaseSolverFactory solver_factory,
const Model & model,
SolverType solver_type,
const SolveArguments & solve_args,
const SolveInterrupter * user_canceller,
bool remove_names )

Solves the input model.

The user_canceller parameter is optional.

Definition at line 121 of file solve_impl.cc.

◆ SosConstraintToString()

template<typename SosConstraint >
std::string operations_research::math_opt::internal::SosConstraintToString ( SosConstraint constraint,
absl::string_view sos_type_name )

This method can only be called with a parameter of either Sos1Constraint or Sos2Constraint.

Tested in sos1_constraint_test and sos2_constraint_test, as the ToString() member functions are thin wrappers around this function.

Inline function implementations

Definition at line 44 of file util.h.

◆ UpdateBiMapFromMappedData()

template<typename DataProto >
absl::Status operations_research::math_opt::internal::UpdateBiMapFromMappedData ( const absl::Span< const int64_t > deleted_ids,
const google::protobuf::Map< int64_t, DataProto > & proto_map,
IdNameBiMap & bimap )
Note
This is only exposed in the header for testing purposes.

Definition at line 245 of file model_summary.h.

◆ ValidateInitArgs()

absl::Status operations_research::math_opt::internal::ValidateInitArgs ( const Solver::InitArgs & init_args,
SolverTypeProto solver_type )

Validates that the input streamable and non_streamable init arguments are either not set or are the one of solver_type.

Definition at line 231 of file solver.cc.

Variable Documentation

◆ debug_num_solver

std::atomic< int64_t > operations_research::math_opt::internal::debug_num_solver = 0

The number of Solver instances that currently exist.

This variable is intended to be used by MathOpt unit tests in other languages to test the proper garbage collection. It should never be used in any other context.

Definition at line 23 of file solver_debug.cc.

◆ kInputFromInvalidModelStorage

absl::string_view operations_research::math_opt::internal::kInputFromInvalidModelStorage
inlineconstexpr
Initial value:
=
"the input does not belong to the same model"

The Status message to use when an input KeyType is from an unexpected storage().

Definition at line 161 of file key_types.h.

◆ kKeyHasNullModelStorage

absl::string_view operations_research::math_opt::internal::kKeyHasNullModelStorage
inlineconstexpr
Initial value:
=
"The input key has null .storage()."

The CHECK message to use when a KeyType::storage() is nullptr.

Definition at line 151 of file key_types.h.

◆ kModelIsDestroyed

absl::string_view operations_research::math_opt::internal::kModelIsDestroyed
constexpr
Initial value:
=
"can't call this function after the associated model has been destroyed"

The failure message used when a function of UpdateTracker is called after the destruction of the model..

Definition at line 110 of file update_tracker.h.

◆ kObjectsFromOtherModelStorage

absl::string_view operations_research::math_opt::internal::kObjectsFromOtherModelStorage
inlineconstexpr
Initial value:
=
"The input objects belongs to another model."

The CHECK message to use when two KeyType with different storage() are used in the same collection.

Definition at line 156 of file key_types.h.

◆ kZerosCleanup

double operations_research::math_opt::internal::kZerosCleanup = 1.0 / 3.0
constexpr

When the fraction of entries in values_ with value 0.0 is larger than kZerosCleanup, we compact the data structure and remove all zero entries.

Definition at line 257 of file sparse_matrix.h.