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

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

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 NullableModelStorageCPtr storage, const ModelStorageCPtr 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 ConstraintData>
ConstraintData::IdType AddAtomicConstraint (const ConstraintData &data, Elemental &elemental)
template<ElementType e>
AtomicConstraintTraits< ElementId< e > >::ConstraintData GetAtomicConstraint (ElementId< e > id, const Elemental &elemental)
template<>
QuadraticConstraintId AddAtomicConstraint (const QuadraticConstraintData &data, Elemental &elemental)
template<>
QuadraticConstraintData GetAtomicConstraint (QuadraticConstraintId id, const Elemental &elemental)
template<>
IndicatorConstraintId AddAtomicConstraint (const IndicatorConstraintData &data, Elemental &elemental)
template<>
IndicatorConstraintData GetAtomicConstraint (IndicatorConstraintId id, const Elemental &elemental)
void FormatModelStorageElement (std::ostream &ostr, ElementType element_type, absl::string_view name, int64_t id)
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

Typedef Documentation

◆ BaseSolverFactory

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

A factory of solver.

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

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

◆ AddAtomicConstraint() [1/3]

template<typename ConstraintData>
ConstraintData::IdType operations_research::math_opt::internal::AddAtomicConstraint ( const ConstraintData & data,
Elemental & elemental )

◆ AddAtomicConstraint() [2/3]

template<>
IndicatorConstraintId operations_research::math_opt::internal::AddAtomicConstraint ( const IndicatorConstraintData & data,
Elemental & elemental )
inline

Indicator constraints

Definition at line 101 of file atomic_constraints_v2.h.

◆ AddAtomicConstraint() [3/3]

template<>
QuadraticConstraintId operations_research::math_opt::internal::AddAtomicConstraint ( const QuadraticConstraintData & data,
Elemental & elemental )
inline

Quadratic constraints

Definition at line 47 of file atomic_constraints_v2.h.

◆ 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 1609 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 NullableModelStorageCPtr storage,
const ModelStorageCPtr expected_storage )
inline

Returns a failure when the input pointer is not nullptr and points to a different model storage than expected_storage.

Failure message is kInputFromInvalidModelStorage.

This is not allowed by the contract, but let's be safe.

Definition at line 169 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 138 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.

◆ FormatModelStorageElement()

void operations_research::math_opt::internal::FormatModelStorageElement ( std::ostream & ostr,
ElementType element_type,
absl::string_view name,
int64_t id )
Todo
(b/170992529): handle quoting of invalid characters in the name.

Definition at line 25 of file model_storage_item.cc.

◆ GetAtomicConstraint() [1/3]

template<ElementType e>
AtomicConstraintTraits< ElementId< e > >::ConstraintData operations_research::math_opt::internal::GetAtomicConstraint ( ElementId< e > id,
const Elemental & elemental )

◆ GetAtomicConstraint() [2/3]

template<>
IndicatorConstraintData operations_research::math_opt::internal::GetAtomicConstraint ( IndicatorConstraintId id,
const Elemental & elemental )
inline

Definition at line 122 of file atomic_constraints_v2.h.

◆ GetAtomicConstraint() [3/3]

template<>
QuadraticConstraintData operations_research::math_opt::internal::GetAtomicConstraint ( QuadraticConstraintId id,
const Elemental & elemental )
inline

Definition at line 67 of file atomic_constraints_v2.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 124 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

OR_DLL 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 162 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 152 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 157 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.