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

In SWIG mode, we don't want anything besides these top-level includes. More...

Namespaces

namespace  base
 
namespace  bop
 
namespace  cap_prod_util
 
namespace  fz
 
namespace  glop
 
namespace  gtl
 
namespace  internal
 End of the interface. Below is the implementation.
 
namespace  lp_format
 
namespace  math_opt
 An object oriented wrapper for quadratic constraints in ModelStorage.
 
namespace  or_internal
 
namespace  packing
 
namespace  pdlp
 Validation utilities for solvers.proto.
 
namespace  sat
 
namespace  scheduling
 
namespace  Source
 
namespace  sysinfo
 
namespace  use_only_in_tests
 
namespace  utf8
 

Classes

class  AccurateSum
 
class  AdaptiveParameterValue
 
class  AffineRelation
 
class  AnnotatedGraphBuildManager
 
class  Arc
 
class  ArcFunctorOrderingByTailAndHead
 
class  ArcIndexOrderingByTailNode
 
struct  ArcWithLength
 
struct  ArcWithLengthAndResources
 
class  ArgumentHolder
 Argument Holder: useful when visiting a model. More...
 
class  ArrayIndexCycleHandler
 
class  ArrayWithOffset
 
class  Assignment
 
class  AssignmentContainer
 
class  AssignmentElement
 
class  BaseInactiveNodeToPathOperator
 
class  BaseIntExpr
 
class  BaseKnapsackSolver
 
class  BaseLns
 
class  BaseObject
 
class  BasePathFilter
 Generic path-based filter class. More...
 
class  BidirectionalDijkstra
 
class  BinaryIndexedTree
 
class  BinCapacities
 
class  Bitmap
 
class  BitQueue64
 
class  Bitset64
 
class  BlossomGraph
 
class  BooleanVar
 
class  BopInterface
 
class  BoundedDijkstraWrapper
 
class  BronKerboschAlgorithm
 
class  CachedLog
 
struct  CallbackRangeConstraint
 
struct  CallbackSetup
 
class  CallMethod0
 Demon proxy to a method on the constraint with no arguments. More...
 
class  CallMethod1
 Demon proxy to a method on the constraint with one argument. More...
 
class  CallMethod2
 Demon proxy to a method on the constraint with two arguments. More...
 
class  CallMethod3
 Demon proxy to a method on the constraint with three arguments. More...
 
class  CarpParser
 
class  CastConstraint
 
class  CBCInterface
 
class  ChangeValue
 
class  CheapestAdditionFilteredHeuristic
 
class  CheapestInsertionFilteredHeuristic
 
class  ChristofidesFilteredHeuristic
 
class  ChristofidesPathSolver
 
struct  ClosedInterval
 
class  CloseRoutesRemovalRuinProcedure
 Remove a number of routes that are spatially close together. More...
 
class  CLPInterface
 
class  ComparatorCheapestAdditionFilteredHeuristic
 
class  ConstrainedShortestPathsOnDagWrapper
 
class  Constraint
 
struct  Coordinates2
 Real-world coordinates. More...
 
struct  Coordinates3
 
class  CostValueCycleHandler
 
class  CplexInterface
 
class  CppBridge
 
struct  CppFlags
 
class  Cross
 --— Cross --— More...
 
class  CumulBoundsPropagator
 
class  CVRPToursParser
 Class parsing tours (solution) data in CVRPlib format. More...
 
struct  DebugStringFormatter
 Helper to display a object with a DebugString method in a absl::StrJoin. More...
 
class  Decision
 
class  DecisionBuilder
 
class  DecisionVisitor
 
struct  DefaultPhaseParameters
 
class  DefaultSolutionPool
 
class  DelayedCallMethod0
 Low-priority demon proxy to a method on the constraint with no arguments. More...
 
class  DelayedCallMethod1
 Low-priority demon proxy to a method on the constraint with one argument. More...
 
class  DelayedCallMethod2
 Low-priority demon proxy to a method on the constraint with two arguments. More...
 
class  Demon
 
class  DemonProfiler
 
class  DenseDoublyLinkedList
 
class  DenseIntDuplicateRemover
 
class  DenseSet
 
class  Dimension
 -------— Dimension -------— More...
 
class  DimensionChecker
 
class  DimensionCumulOptimizerCore
 
class  DisabledScopedInstructionCounter
 
class  DisabledScopedTimeDistributionUpdater
 
class  DisjunctiveConstraint
 
struct  DistanceAndParentArc
 
class  DistributionStat
 
class  Domain
 
class  DoubleDistribution
 Statistic on the distribution of a sequence of doubles. More...
 
class  DynamicPartition
 
class  DynamicPermutation
 
class  EbertGraph
 Forward declarations. More...
 
class  EbertGraphBase
 
class  Edge
 
class  ElementDegreeSolutionGenerator
 
class  ElementGetter
 
class  ElementIterator
 
class  EnabledScopedTimeDistributionUpdater
 
class  EvaluatorCheapestAdditionFilteredHeuristic
 
class  Exchange
 --— Exchange --— More...
 
class  ExchangeSubtrip
 
class  ExtendedSwapActiveOperator
 --— ExtendedSwapActiveOperator --— More...
 
class  FilteredHeuristicCloseNodesLNSOperator
 
class  FilteredHeuristicExpensiveChainLNSOperator
 
class  FilteredHeuristicLocalSearchOperator
 
class  FilteredHeuristicPathLNSOperator
 
class  FinalizerVariables
 
class  FindOneNeighbor
 --— Finds a neighbor of the assignment passed --— More...
 
class  FlatMatrix
 NOTE(user): T=bool is not yet supported (the [] operator doesn't work). More...
 
class  ForwardEbertGraph
 
class  ForwardStaticGraph
 
class  GenericMaxFlow
 Forward declaration. More...
 
class  GenericMinCostFlow
 Forward declaration. More...
 
class  GlobalCheapestInsertionFilteredHeuristic
 
class  GlobalDimensionCumulOptimizer
 
class  GLOPInterface
 
class  GLPKInformation
 Class to store information gathered in the callback. More...
 
class  GLPKInterface
 
struct  graph_traits
 
struct  graph_traits< ForwardEbertGraph< NodeIndexType, ArcIndexType > >
 
struct  graph_traits< ForwardStaticGraph< NodeIndexType, ArcIndexType > >
 
struct  Graphs
 
struct  Graphs< operations_research::StarGraph >
 
class  GraphSymmetryFinder
 
class  GreedySolutionGenerator
 
class  GroupPairAndRelocateOperator
 
struct  GScipCallbackStats
 
class  GScipConstraintHandler
 
class  GScipConstraintHandlerContext
 
struct  GScipConstraintHandlerProperties
 
struct  GScipCutOptions
 Options passed to SCIP when adding a cut. More...
 
class  GScipEventHandler
 
class  GScipEventHandlerContext
 
struct  GScipEventHandlerDescription
 
struct  GScipIndicatorRangeConstraint
 
struct  GScipLazyConstraintOptions
 Options passed to SCIP when adding a lazy constraint. More...
 
struct  GScipLinearExpr
 
class  GuidedLocalSearch
 
class  GuidedTabuSearch
 
class  GurobiInterface
 
class  HamiltonianPathSolver
 
class  HighsInterface
 
class  HungarianOptimizer
 
class  IfThenElseCt
 -------— Generalized element -------— More...
 
class  ImprovementSearchLimit
 
class  IndexPairSwapActiveOperator
 
class  InitAndGetValues
 
class  InsertionSequenceContainer
 
class  InsertionSequenceGenerator
 Generates insertion positions respecting structural constraints. More...
 
class  IntegerDistribution
 Statistic on the distribution of a sequence of integers. More...
 
class  IntegerPriorityQueue
 
class  IntersectingSubsetsIterator
 
class  IntervalVar
 
class  IntervalVarElement
 
class  IntExpr
 
class  IntTupleSet
 --— Main IntTupleSet class --— More...
 
class  IntVar
 
class  IntVarElement
 
class  IntVarFilteredDecisionBuilder
 
class  IntVarFilteredHeuristic
 Generic filter-based heuristic applied to IntVars. More...
 
class  IntVarIterator
 
class  IntVarLocalSearchFilter
 
class  IntVarLocalSearchOperator
 
class  Knapsack64ItemsSolver
 
struct  KnapsackAssignment
 
class  KnapsackBruteForceSolver
 
class  KnapsackCapacityPropagator
 
class  KnapsackCpSat
 --— KnapsackCpSat --— More...
 
class  KnapsackDivideAndConquerSolver
 
class  KnapsackDynamicProgrammingSolver
 
class  KnapsackGenericSolver
 
class  KnapsackInterface
 
struct  KnapsackItem
 
struct  KnapsackItemWithEfficiency
 
class  KnapsackMIPSolver
 --— KnapsackMIPSolver --— More...
 
class  KnapsackPropagator
 
class  KnapsackSearchNode
 
class  KnapsackSearchPath
 
class  KnapsackSolver
 
class  KnapsackState
 
struct  KShortestPaths
 
class  KShortestPathsOnDagWrapper
 
class  LatticeMemoryManager
 
class  LazyMutableCopy
 
class  LightIntFunctionElementCt
 --— LightIntFunctionElementCt --— More...
 
class  LightIntIntFunctionElementCt
 --— LightIntIntFunctionElementCt --— More...
 
class  LightPairRelocateOperator
 
class  LiLimParser
 Li&Lim parser class. More...
 
class  LinearExpr
 
class  LinearRange
 
class  LinearSumAssignment
 This class does not take ownership of its underlying graph. More...
 
class  LinKernighan
 
class  LocalCheapestInsertionFilteredHeuristic
 
class  LocalDimensionCumulOptimizer
 
class  LocalSearch
 --— Local search decision builder --— More...
 
class  LocalSearchFilter
 
class  LocalSearchFilterManager
 
class  LocalSearchMonitor
 
class  LocalSearchMonitorPrimary
 -------— Local Search Monitor Primary -------— More...
 
class  LocalSearchOperator
 
class  LocalSearchOperatorState
 
class  LocalSearchPhaseParameters
 -------— Local Search Phase Parameters -------— More...
 
class  LocalSearchProfiler
 --— LocalSearchProfiler --— More...
 
class  LocalSearchState
 
class  LocationContainer
 
class  MakeActiveAndRelocate
 --— MakeActiveAndRelocate --— More...
 
class  MakeActiveOperator
 --— MakeActiveOperator --— More...
 
class  MakeChainInactiveOperator
 --— MakeChainInactiveOperator --— More...
 
class  MakeInactiveOperator
 --— MakeInactiveOperator --— More...
 
class  MakePairActiveOperator
 
class  MakePairInactiveOperator
 Operator which makes pairs of active nodes inactive. More...
 
class  MakeRelocateNeighborsOperator
 
class  MathUtil
 
class  MatrixOrFunction
 
class  MatrixOrFunction< ScalarType, std::vector< std::vector< ScalarType > >, square >
 Specialization for vector-based matrices. More...
 
class  MaxFlow
 
class  MaxFlowStatusClass
 
class  MbLogCallback
 Simple director class for C#. More...
 
class  MergingPartition
 
class  MinCostFlow
 
class  MinCostFlowBase
 
class  MinCostPerfectMatching
 
class  ModelBuilderHelper
 
class  ModelCache
 
class  ModelParser
 Model Parser. More...
 
class  ModelSolverHelper
 
class  ModelVisitor
 Model visitor. More...
 
class  MonoidOperationTree
 
class  MPCallback
 
class  MPCallbackContext
 
class  MPCallbackList
 
class  MPCallbackWrapper
 Wraps the MPCallback in order to catch and store exceptions. More...
 
class  MPConstraint
 
struct  MPModelExportOptions
 Export options. More...
 
class  MPObjective
 A class to express a linear objective. More...
 
class  MPSolver
 
class  MPSolverInterface
 
class  MPSolverParameters
 
class  MPVariable
 The class for variables of a Mathematical Programming (MP) model. More...
 
class  NearestNeighbors
 --— Lin Kernighan --— More...
 
class  NearpParser
 
class  NeighborAcceptanceCriterion
 Neighbor acceptance criterion interface. More...
 
class  NeighborhoodLimit
 --— Limit the number of neighborhoods explored --— More...
 
class  NestedTimeLimit
 
class  NumericalRev
 Subclass of Rev<T> which adds numerical operations. More...
 
class  NumericalRevArray
 Subclass of RevArray<T> which adds numerical operations. More...
 
class  ObjectiveMonitor
 Base objective monitor class. All metaheuristics derive from this. More...
 
class  OptimizeVar
 
class  OrToolsVersion
 
class  Pack
 
class  PairExchangeOperator
 
class  PairExchangeRelocateOperator
 
class  PairNodeSwapActiveOperator
 
class  PairRelocateOperator
 
class  ParallelSavingsFilteredHeuristic
 
class  PathContainer
 
class  PathContainerImpl
 
class  PathEnergyCostChecker
 
class  PathLns
 --— Path-based Large Neighborhood Search --— More...
 
class  PathOperator
 
class  PathState
 
struct  PathWithLength
 
class  PdlpInterface
 
class  PdTspParser
 
class  PermutationApplier
 
class  PermutationCycleHandler
 
class  PermutationIndexComparisonByArcHead
 
class  PickupAndDeliveryData
 A utility class to maintain pickup and delivery information of nodes. More...
 
struct  PickupDeliveryInsertion
 
struct  PickupDeliveryPair
 
class  PiecewiseLinearExpr
 --— Piecewise Linear --— More...
 
class  PiecewiseLinearFunction
 
class  PiecewiseSegment
 
class  Preprocessor
 
class  PriorityQueueWithRestrictedPush
 
class  ProfiledDecisionBuilder
 
class  PropagationBaseObject
 NOLINT. More...
 
class  PropagationMonitor
 
class  PruningHamiltonianSolver
 
struct  QapProblem
 
class  Queue
 
class  RandomDemand
 Random demand. More...
 
class  RandomSolutionGenerator
 
class  RangeIntToIntFunction
 
class  RangeMinimumIndexQuery
 
class  RangeMinimumQuery
 
class  RangeMinMaxIndexFunction
 
class  RatioDistribution
 Statistic on the distribution of a sequence of ratios, displayed as %. More...
 
class  RegularLimit
 
class  Relocate
 --— Relocate --— More...
 
class  RelocateAndMakeActiveOperator
 -— RelocateAndMakeActiveOperator --— More...
 
class  RelocateAndMakeInactiveOperator
 --— RelocateAndMakeInactiveOperator --— More...
 
class  RelocateExpensiveChain
 
class  RelocatePathAndHeuristicInsertUnperformedOperator
 
class  RelocateSubtrip
 
class  Rev
 
class  RevArray
 
class  RevBitMatrix
 Matrix version of the RevBitSet class. More...
 
class  RevBitSet
 
class  ReversibleInterface
 
class  RevGrowingArray
 
class  RevGrowingMultiMap
 A basic backtrackable multi map that can only grow (except on backtrack). More...
 
class  RevImmutableMultiMap
 
class  RevIntSet
 
class  RevMap
 
class  RevPartialSequence
 --— RevPartialSequence --— More...
 
class  RevRepository
 
class  RevSwitch
 A reversible switch that can switch once from false to true. More...
 
class  RevVector
 A basic reversible vector implementation. More...
 
class  RootedTree
 
class  RoundTripDoubleFormat
 
class  RoutingCPSatWrapper
 
class  RoutingFilteredHeuristic
 Filter-based heuristic dedicated to routing. More...
 
class  RoutingGlopWrapper
 
class  RoutingIndexManager
 
class  RoutingLinearSolverWrapper
 
class  RoutingModelInspector
 
class  RoutingSolution
 
class  RuinAndRecreateDecisionBuilder
 
class  RuinProcedure
 Ruin interface. More...
 
class  RunningAverage
 
class  RunningMax
 
class  SatInterface
 
class  SavingsFilteredHeuristic
 
struct  ScipCallbackConstraintOptions
 
class  ScipConstraintHandler
 
class  ScipConstraintHandlerContext
 
struct  ScipConstraintHandlerDescription
 
class  ScipConstraintHandlerForMPCallback
 
class  SCIPInterface
 
class  ScipMPCallbackContext
 
class  ScopedFloatingPointEnv
 
struct  ScopedLocale
 
class  ScopedSolveInterrupterCallback
 
class  Search
 ---------------— Search class --------------— More...
 
class  SearchLimit
 Base class of all search limits. More...
 
class  SearchLog
 
class  SearchMonitor
 A search monitor is a simple set of callbacks to monitor all search events. More...
 
class  SequenceVar
 
class  SequenceVarElement
 
class  SequentialSavingsFilteredHeuristic
 
class  ServiceTimePlusTransition
 Service time (proportional to demand) + transition time callback. More...
 
class  Set
 
class  SetCoverDecision
 A helper class used to store the decisions made during a search. More...
 
class  SetCoverInvariant
 
class  SetCoverLagrangian
 
class  SetCoverMip
 
class  SetCoverModel
 Main class for describing a weighted set-covering problem. More...
 
class  SetCoverReader
 
class  SetRangeIterator
 
class  SetRangeWithCardinality
 
class  SharedTimeLimit
 Wrapper around TimeLimit to make it thread safe and add Stop() support. More...
 
class  ShortestPathsOnDagWrapper
 
class  SigintHandler
 
class  SimpleDynamicPartition
 
class  SimpleLinearSumAssignment
 
class  SimpleMaxFlow
 
class  SimpleMinCostFlow
 
class  SimpleRevFIFO
 
struct  SimpleTimeWindow
 
struct  SlopeAndYIntercept
 Structure to store the slope and y_intercept of a segment. More...
 
class  SmallRevBitSet
 
class  SolomonParser
 Solomon parser class. More...
 
class  SolutionCollector
 
class  SolutionPool
 
class  SolveInterrupter
 
class  Solver
 For the time being, Solver is neither MT_SAFE nor MT_HOT. More...
 
class  SolverLogger
 
class  SortedDisjointIntervalList
 
class  SparseBitset
 
class  SparsePermutation
 
class  StarGraphBase
 
class  Stat
 Base class for a statistic that can be pretty-printed. More...
 
struct  StateInfo
 ---------------— StateMarker / StateInfo struct --------— More...
 
struct  StateMarker
 
class  StatsGroup
 Base class to print a nice summary of a group of statistics. More...
 
class  SteepestSearch
 
class  StopServiceTimePlusTransition
 Stop service time + transition time callback. More...
 
class  StrongIndex
 
class  StrongInt64
 
class  SubDagComputer
 
class  SubsetIndexWithPriority
 Priority aggregate for the subset priority queue. More...
 
class  SwapActiveOperator
 --— SwapActiveOperator --— More...
 
class  SwapActiveToShortestPathOperator
 | / \ ^ More...
 
class  SwapIndexPairOperator
 
class  SweepArranger
 
class  SymmetryBreaker
 
class  SymmetryManager
 -------— Symmetry Breaking -------— More...
 
class  TabuList
 
class  TailArrayManager
 
class  ThreadPool
 
class  TimeDistribution
 
class  TimeLimit
 
class  Trace
 -------— Trace -------— More...
 
struct  Trail
 
class  TrivialSolutionGenerator
 
class  TspLibParser
 
class  TspLibTourParser
 Class parsing tour (solution) data in TSLIB95 format. More...
 
class  TSPLns
 
class  TSPOpt
 --— TSP-based operators --— More...
 
class  TspTWParser
 
class  TwoOpt
 --— 2Opt --— More...
 
class  UnsortedNullableRevBitset
 
class  VectorOrFunction
 Template to abstract the access to STL functions or vector values. More...
 
class  VectorOrFunction< ScalarType, std::vector< ScalarType > >
 Specialization for vectors. More...
 
class  VehicleTypeCurator
 
class  XpressInterface
 
class  XpressMPCallbackContext
 
class  ZVector
 

Typedefs

typedef KnapsackItemKnapsackItemPtr
 
template<typename IndexType , typename ValueType >
using StrictVector = glop::StrictITIVector<IndexType, ValueType>
 
using Cost = double
 Basic non-strict type for cost. The speed penalty for using double is ~2%.
 
using BaseInt = int
 
using SubsetRange = util_intops::StrongIntRange<SubsetIndex>
 
using ElementRange = util_intops::StrongIntRange<ElementIndex>
 
using ColumnEntryRange = util_intops::StrongIntRange<ColumnEntryIndex>
 
using CostAllocator = AlignedAllocator<Cost, kSetCoverAlignmentInBytes>
 
using ElementAllocator
 
using SubsetAllocator
 
using SubsetCostVector
 
using ElementCostVector
 
using SparseColumn
 
using SparseRow
 
using IntAllocator = AlignedAllocator<BaseInt, kSetCoverAlignmentInBytes>
 
using ElementToIntVector
 
using SubsetToIntVector
 
using SparseColumnView = util_intops::StrongVector<SubsetIndex, SparseColumn>
 
using SparseRowView = util_intops::StrongVector<ElementIndex, SparseRow>
 
using SubsetBoolVector = util_intops::StrongVector<SubsetIndex, bool>
 
using VariableDomainId = LocalSearchState::VariableDomainId
 
using NodeId = SubDagComputer::NodeId
 
using ArcId = SubDagComputer::ArcId
 
typedef std::function< int64_t(int64_t)> RoutingTransitCallback1
 
typedef std::function< int64_t(int64_t, int64_t)> RoutingTransitCallback2
 
using NodeIndex = BlossomGraph::NodeIndex
 
typedef int32_t ArcIndex
 
typedef int64_t FlowQuantity
 
using CostValue = BlossomGraph::CostValue
 
typedef EbertGraph< NodeIndex, ArcIndexStarGraph
 
typedef ForwardEbertGraph< NodeIndex, ArcIndexForwardStarGraph
 
typedef ForwardStaticGraph< NodeIndex, ArcIndexForwardStarStaticGraph
 
typedef ZVector< NodeIndexNodeIndexArray
 
typedef ZVector< ArcIndexArcIndexArray
 
typedef ZVector< FlowQuantityQuantityArray
 
typedef ZVector< CostValueCostArray
 
typedef int PathNodeIndex
 
typedef uint32_t PathDistance
 
typedef util::ReverseArcStaticGraph Graph
 Type of graph to use.
 
using GScipMessageHandler
 
typedef std::function< int64_t(RoutingNodeIndex, RoutingNodeIndex)> RoutingNodeEvaluator2
 
typedef std::function< int64_t(int, int)> EdgeWeights
 Mapping between an edge (given by its tail and its head) and its weight.
 
template<typename T , size_t alignment_bytes>
using AlignedAllocator
 Support for aligned containers in STL.
 
template<typename T , size_t alignment_bytes>
using AlignedVector = std::vector<T, AlignedAllocator<T, alignment_bytes>>
 
template<typename T >
using UnsafeDenseSet = DenseSet<T, false>
 
using random_engine_t = std::mt19937_64
 
typedef std::pair< int64_t, int64_t > Fraction
 
template<class Iterator >
using value_type_t = typename std::iterator_traits<Iterator>::value_type
 
using ScopedTimeDistributionUpdater = DisabledScopedTimeDistributionUpdater
 
using ScopedInstructionCounter = DisabledScopedInstructionCounter
 
typedef ZVector< int8_t > Int8ZVector
 Shorthands for all the types of ZVector's.
 
typedef ZVector< int16_t > Int16ZVector
 
typedef ZVector< int32_t > Int32ZVector
 
typedef ZVector< int64_t > Int64ZVector
 
typedef ZVector< uint8_t > UInt8ZVector
 
typedef ZVector< uint16_t > UInt16ZVector
 
typedef ZVector< uint32_t > UInt32ZVector
 
typedef ZVector< uint64_t > UInt64ZVector
 

Enumerations

enum class  SetCoverMipSolver : int {
  SCIP = 0 , SAT = 1 , GUROBI = 2 , GLOP = 3 ,
  PDLP = 4
}
 
enum  VarTypes {
  UNSPECIFIED , DOMAIN_INT_VAR , BOOLEAN_VAR , CONST_VAR ,
  VAR_ADD_CST , VAR_TIMES_CST , CST_SUB_VAR , OPP_VAR ,
  TRACE_VAR
}
 
enum class  DimensionSchedulingStatus { OPTIMAL , RELAXED_OPTIMAL_ONLY , INFEASIBLE }
 
enum class  PiecewiseEvaluationStatus { UNSPECIFIED = 0 , WITHIN_BOUNDS , SMALLER_THAN_LOWER_BOUND , LARGER_THAN_UPPER_BOUND }
 
enum class  CliqueResponse { CONTINUE , STOP }
 
enum class  BronKerboschAlgorithmStatus { COMPLETED , INTERRUPTED }
 
enum class  GScipCallbackResult {
  kDidNotRun = 1 , kDelayed = 2 , kDidNotFind = 3 , kFeasible = 4 ,
  kInfeasible = 5 , kUnbounded = 6 , kCutOff = 7 , kSeparated = 8 ,
  kNewRound = 9 , kReducedDomain = 10 , kConstraintAdded = 11 , kConstraintChanged = 12 ,
  kBranched = 13 , kSolveLp = 14 , kFoundSolution = 15 , kSuspend = 16 ,
  kSuccess = 17 , kDelayNode = 18
}
 Equivalent to type_result.h in SCIP. More...
 
enum class  RoundingLockDirection { kUp , kDown , kBoth }
 
enum class  ConstraintHandlerCallbackType {
  kSepaLp , kSepaSol , kEnfoLp , kEnfoPs ,
  kConsCheck , kConsLock
}
 
enum class  GScipMessageType { kInfoMessage , kDialogMessage , kWarningMessage }
 
enum class  MPCallbackEvent {
  kUnknown , kPolling , kPresolve , kSimplex ,
  kMip , kMipSolution , kMipNode , kBarrier ,
  kMessage , kMultiObj
}
 
enum class  ScipSeparationResult { kLazyConstraintAdded , kCuttingPlaneAdded , kDidNotFind }
 
enum  SolveStatus {
  OPTIMAL , FEASIBLE , INFEASIBLE , UNBOUNDED ,
  ABNORMAL , NOT_SOLVED , MODEL_IS_VALID , CANCELLED_BY_USER ,
  UNKNOWN_STATUS , MODEL_INVALID , INVALID_SOLVER_PARAMETERS , SOLVER_TYPE_UNAVAILABLE ,
  INCOMPATIBLE_OPTIONS
}
 
enum  CUSTOM_INTERRUPT_REASON { CALLBACK_EXCEPTION = 0 }
 
enum  XPRS_BASIS_STATUS { XPRS_AT_LOWER = 0 , XPRS_BASIC = 1 , XPRS_AT_UPPER = 2 , XPRS_FREE_SUPER = 3 }
 
enum class  RoutingOutputFormat {
  kNone , kTSPLIB , kCVRPLIB , kCARPLIB ,
  kNEARPLIB
}
 
enum class  ProtoWriteFormat { kProtoText , kProtoBinary , kJson , kCanonicalJson }
 

Functions

template<class Point >
Point BinarySearch (Point x_true, Point x_false, std::function< bool(Point)> f)
 
template<class Point >
Point BinarySearchMidpoint (Point x, Point y)
 
template<class Point , class Value >
std::pair< Point, Value > ConvexMinimum (absl::Span< const Point > sorted_points, std::function< Value(Point)> f)
 
template<class Point , class Value >
std::pair< Point, Value > ConvexMinimum (bool is_to_the_right, std::pair< Point, Value > current_min, absl::Span< const Point > sorted_points, std::function< Value(Point)> f)
 
template<class Point , class Value >
std::pair< Point, Value > RangeConvexMinimum (Point begin, Point end, absl::FunctionRef< Value(Point)> f)
 Searches in the range [begin, end), where Point supports basic arithmetic.
 
template<class Point , class Value >
std::pair< Point, Value > RangeConvexMinimum (std::pair< Point, Value > current_min, Point begin, Point end, absl::FunctionRef< Value(Point)> f)
 
std::vector< int > CountTriangles (const ::util::StaticGraph< int, int > &graph, int max_degree)
 HELPER FUNCTIONS: PUBLIC FOR UNIT TESTING ONLY.
 
void LocalBfs (const ::util::StaticGraph< int, int > &graph, int source, int stop_after_num_nodes, std::vector< int > *visited, std::vector< int > *num_within_radius, std::vector< bool > *tmp_mask)
 
bool InputContainsNan (absl::Span< const std::vector< double > > input)
 
void MinimizeLinearAssignment (absl::Span< const std::vector< double > > cost, absl::flat_hash_map< int, int > *direct_assignment, absl::flat_hash_map< int, int > *reverse_assignment)
 See IMPORTANT NOTE at the top of the file.
 
void MaximizeLinearAssignment (absl::Span< const std::vector< double > > cost, absl::flat_hash_map< int, int > *direct_assignment, absl::flat_hash_map< int, int > *reverse_assignment)
 See IMPORTANT NOTE at the top of the file.
 
bool CompareKnapsackItemWithEfficiencyInDecreasingEfficiencyOrder (const KnapsackItemWithEfficiency &item1, const KnapsackItemWithEfficiency &item2)
 Comparator used to sort item in decreasing efficiency order.
 
Select next search node to expand Select next item_i to assign (using primary propagator) - Generate a new search node where item_i is in the knapsack - Check validity of this new partial solution(using propagators) - If valid
 
Select next search node to expand Select next item_i to add this new search node to the search Generate a new search node where item_i is not in the knapsack Check validity of this new partial solution (using propagators) - If valid
 
absl::StatusOr< int64_t > NChooseK (int64_t n, int64_t k)
 
template<typename T >
void RadixSort (absl::Span< T > values)
 
template<typename T , int radix_width, int num_passes>
void RadixSortTpl (absl::Span< T > values)
 The internal template that does all the work.
 
constexpr SubsetIndex kNotFound (-1)
 
std::vector< SubsetIndex > ClearRandomSubsets (std::size_t num_subsets, SetCoverInvariant *inv)
 
std::vector< SubsetIndex > ClearRandomSubsets (absl::Span< const SubsetIndex > focus, std::size_t num_subsets, SetCoverInvariant *inv)
 Same as above, but clears the subset indices in focus.
 
std::vector< SubsetIndex > ClearMostCoveredElements (std::size_t max_num_subsets, SetCoverInvariant *inv)
 
std::vector< SubsetIndex > ClearMostCoveredElements (absl::Span< const SubsetIndex > focus, std::size_t num_subsets, SetCoverInvariant *inv)
 Same as above, but clears the subset indices in focus.
 
 DEFINE_STRONG_INT_TYPE (SubsetIndex, BaseInt)
 
 DEFINE_STRONG_INT_TYPE (ElementIndex, BaseInt)
 Element index.
 
 DEFINE_STRONG_INT_TYPE (ColumnEntryIndex, BaseInt)
 
 DEFINE_STRONG_INT_TYPE (RowEntryIndex, BaseInt)
 
SetCoverModel ReadBeasleySetCoverProblem (absl::string_view filename)
 
SetCoverModel ReadRailSetCoverProblem (absl::string_view filename)
 
uint64_t fasthash64 (const void *buf, size_t len, uint64_t seed)
 
static void mix (uint64_t &a, uint64_t &b, uint64_t &c)
 64 bit version.
 
void FixFlagsAndEnvironmentForSwig ()
 
void KeepAbslSymbols ()
 
int32_t strtoint32 (absl::string_view word)
 
int64_t strtoint64 (absl::string_view word)
 
int32_t atoi32 (absl::string_view word)
 Convenience versions of the above that take a string argument.
 
int64_t atoi64 (absl::string_view word)
 
int64_t GetProcessMemoryUsage ()
 GetProcessMemoryUsage.
 
void RunWorker (void *data)
 
int OrToolsMajorVersion ()
 
int OrToolsMinorVersion ()
 
int OrToolsPatchVersion ()
 
std::string OrToolsVersionString ()
 
template<class Var , class Element , class Proto , class Container >
void RealLoad (const AssignmentProto &assignment_proto, Container *const container, int(AssignmentProto::*GetSize)() const, const Proto &(AssignmentProto::*GetElem)(int) const)
 
template<class Var , class Element , class Proto , class Container >
void RealSave (AssignmentProto *const assignment_proto, const Container &container, Proto *(AssignmentProto::*Add)())
 
template<class Container , class Element >
void RealDebugString (const Container &container, std::string *const out)
 
void SetAssignmentFromAssignment (Assignment *target_assignment, const std::vector< IntVar * > &target_vars, const Assignment *source_assignment, const std::vector< IntVar * > &source_vars)
 NOLINT.
 
std::ostream & operator<< (std::ostream &out, const Assignment &assignment)
 
void InstallDemonProfiler (DemonProfiler *monitor)
 --— Forward Declarations and Profiling Support --—
 
DemonProfilerBuildDemonProfiler (Solver *solver)
 
void DeleteDemonProfiler (DemonProfiler *monitor)
 
void InstallLocalSearchProfiler (LocalSearchProfiler *monitor)
 
LocalSearchProfilerBuildLocalSearchProfiler (Solver *solver)
 
void DeleteLocalSearchProfiler (LocalSearchProfiler *monitor)
 
void CleanVariableOnFail (IntVar *var)
 ---------------— Queue class ---------------—
 
void RestoreBoolValue (IntVar *var)
 --— Trail --—
 
void InternalSaveBooleanVarValue (Solver *const solver, IntVar *const var)
 
bool LocalOptimumReached (Search *search)
 Returns true if a local optimum has been reached and cannot be improved.
 
bool AcceptDelta (Search *search, Assignment *delta, Assignment *deltadelta)
 
void AcceptNeighbor (Search *search)
 Notifies the search that a neighbor has been accepted by local search.
 
void AcceptUncheckedNeighbor (Search *search)
 
PropagationMonitorBuildTrace (Solver *s)
 
LocalSearchMonitorBuildLocalSearchMonitorPrimary (Solver *s)
 
ModelCacheBuildModelCache (Solver *solver)
 
PropagationMonitorBuildPrintTrace (Solver *s)
 
std::ostream & operator<< (std::ostream &out, const Solver *const s)
 ---------------— Useful Operators ---------------—
 
std::ostream & operator<< (std::ostream &out, const BaseObject *const o)
 
int64_t CpRandomSeed ()
 
int64_t Zero ()
 NOLINT.
 
int64_t One ()
 This method returns 1.
 
uint64_t Hash1 (uint64_t value)
 
uint64_t Hash1 (uint32_t value)
 
uint64_t Hash1 (int64_t value)
 
uint64_t Hash1 (int value)
 
uint64_t Hash1 (void *const ptr)
 
template<class T >
uint64_t Hash1 (const std::vector< T * > &ptrs)
 
uint64_t Hash1 (const std::vector< int64_t > &ptrs)
 
template<class T >
LocalSearchOperatorMakeLocalSearchOperator (Solver *solver, const std::vector< IntVar * > &vars, const std::vector< IntVar * > &secondary_vars, std::function< int(int64_t)> start_empty_path_class)
 Operator Factories.
 
template<class T >
LocalSearchOperatorMakeLocalSearchOperatorWithNeighbors (Solver *solver, const std::vector< IntVar * > &vars, const std::vector< IntVar * > &secondary_vars, std::function< int(int64_t)> start_empty_path_class, std::function< const std::vector< int > &(int, int)> get_neighbors)
 
template<class T >
bool IsArrayConstant (const std::vector< T > &values, const T &value)
 
template<class T >
bool IsArrayBoolean (const std::vector< T > &values)
 
template<class T >
bool AreAllOnes (const std::vector< T > &values)
 
template<class T >
bool AreAllNull (const std::vector< T > &values)
 
template<class T >
bool AreAllGreaterOrEqual (const std::vector< T > &values, const T &value)
 
template<class T >
bool AreAllLessOrEqual (const std::vector< T > &values, const T &value)
 
template<class T >
bool AreAllPositive (const std::vector< T > &values)
 
template<class T >
bool AreAllNegative (const std::vector< T > &values)
 
template<class T >
bool AreAllStrictlyPositive (const std::vector< T > &values)
 
template<class T >
bool AreAllStrictlyNegative (const std::vector< T > &values)
 
template<class T >
bool IsIncreasingContiguous (const std::vector< T > &values)
 
template<class T >
bool IsIncreasing (const std::vector< T > &values)
 
template<class T >
bool IsArrayInRange (const std::vector< IntVar * > &vars, T range_min, T range_max)
 
bool AreAllBound (const std::vector< IntVar * > &vars)
 
bool AreAllBooleans (const std::vector< IntVar * > &vars)
 
template<class T >
bool AreAllBoundOrNull (const std::vector< IntVar * > &vars, const std::vector< T > &values)
 
bool AreAllBoundTo (const std::vector< IntVar * > &vars, int64_t value)
 Returns true if all variables are assigned to 'value'.
 
int64_t MaxVarArray (const std::vector< IntVar * > &vars)
 
int64_t MinVarArray (const std::vector< IntVar * > &vars)
 
void FillValues (const std::vector< IntVar * > &vars, std::vector< int64_t > *const values)
 
int64_t PosIntDivUp (int64_t e, int64_t v)
 
int64_t PosIntDivDown (int64_t e, int64_t v)
 
std::vector< int64_t > ToInt64Vector (const std::vector< int > &input)
 --— Vector manipulations --—
 
LocalSearchFilterMakePathStateFilter (Solver *solver, std::unique_ptr< PathState > path_state, const std::vector< IntVar * > &nexts)
 
LocalSearchFilterMakeDimensionFilter (Solver *solver, std::unique_ptr< DimensionChecker > checker, const std::string &dimension_name)
 
std::string DefaultPhaseStatString (DecisionBuilder *db)
 -------— API -------—
 
void RegisterDemon (Solver *const solver, Demon *const demon, DemonProfiler *const monitor)
 --— Exported Methods for Unit Tests --—
 
void DemonProfilerAddFakeRun (DemonProfiler *const monitor, Demon *const demon, int64_t start_time, int64_t end_time, bool is_fail)
 
void DemonProfilerExportInformation (DemonProfiler *const monitor, const Constraint *const constraint, int64_t *const fails, int64_t *const initial_propagation_runtime, int64_t *const demon_invocations, int64_t *const total_demon_runtime, int *const demon_count)
 
void DemonProfilerBeginInitialPropagation (DemonProfiler *const monitor, Constraint *const constraint)
 
void DemonProfilerEndInitialPropagation (DemonProfiler *const monitor, Constraint *const constraint)
 
void LinkVarExpr (Solver *s, IntExpr *expr, IntVar *var)
 --— IntExprElement --—
 
ConstraintSetIsEqual (IntVar *const var, absl::Span< const int64_t > values, const std::vector< IntVar * > &vars)
 
ConstraintSetIsGreaterOrEqual (IntVar *const var, absl::Span< const int64_t > values, const std::vector< IntVar * > &vars)
 
IntExprBuildStartExpr (IntervalVar *var)
 --— Expression builders ---—
 
IntExprBuildDurationExpr (IntervalVar *var)
 
IntExprBuildEndExpr (IntervalVar *var)
 
IntExprBuildSafeStartExpr (IntervalVar *var, int64_t unperformed_value)
 
IntExprBuildSafeDurationExpr (IntervalVar *var, int64_t unperformed_value)
 
IntExprBuildSafeEndExpr (IntervalVar *var, int64_t unperformed_value)
 
std::unique_ptr< BinCapacitiesMakeBinCapacities (const std::vector< RoutingDimension * > &dimensions, const PathsMetadata &paths_metadata)
 
void FillPathEvaluation (const std::vector< int64_t > &path, const RoutingModel::TransitCallback2 &evaluator, std::vector< int64_t > *values)
 
void AppendTasksFromPath (absl::Span< const int64_t > path, const TravelBounds &travel_bounds, const RoutingDimension &dimension, DisjunctivePropagator::Tasks *tasks)
 
void FillTravelBoundsOfVehicle (int vehicle, const std::vector< int64_t > &path, const RoutingDimension &dimension, TravelBounds *travel_bounds)
 
void AppendTasksFromIntervals (const std::vector< IntervalVar * > &intervals, DisjunctivePropagator::Tasks *tasks)
 
IntVarLocalSearchFilterMakeVehicleBreaksFilter (const RoutingModel &routing_model, const RoutingDimension &dimension)
 
ConstraintMakeDifferentFromValues (Solver *solver, IntVar *var, std::vector< int64_t > values)
 
ConstraintMakeResourceConstraint (const RoutingModel::ResourceGroup *resource_group, const std::vector< IntVar * > *vehicle_resource_vars, RoutingModel *model)
 
ConstraintMakePathSpansAndTotalSlacks (const RoutingDimension *dimension, std::vector< IntVar * > spans, std::vector< IntVar * > total_slacks)
 
DecisionBuilderMakeSetValuesFromTargets (Solver *solver, std::vector< IntVar * > variables, std::vector< int64_t > targets)
 
DecisionBuilderMakeSetCumulsFromLocalDimensionCosts (Solver *solver, LocalDimensionCumulOptimizer *lp_optimizer, LocalDimensionCumulOptimizer *mp_optimizer, bool optimize_and_pack, std::vector< RoutingModel::RouteDimensionTravelInfo > dimension_travel_info_per_route)
 
DecisionBuilderMakeSetCumulsFromGlobalDimensionCosts (Solver *solver, GlobalDimensionCumulOptimizer *global_optimizer, GlobalDimensionCumulOptimizer *global_mp_optimizer, SearchMonitor *monitor, bool optimize_and_pack=false, std::vector< RoutingModel::RouteDimensionTravelInfo > dimension_travel_info_per_route={})
 Variant based on global optimizers, handling all routes together.
 
DecisionBuilderMakeRestoreDimensionValuesForUnchangedRoutes (RoutingModel *model)
 
IntVarLocalSearchFilterMakeMaxActiveVehiclesFilter (const RoutingModel &routing_model)
 Returns a filter ensuring that max active vehicles constraints are enforced.
 
IntVarLocalSearchFilterMakeNodeDisjunctionFilter (const RoutingModel &routing_model, bool filter_cost)
 Returns a filter ensuring that node disjunction constraints are enforced.
 
IntVarLocalSearchFilterMakeVehicleAmortizedCostFilter (const RoutingModel &routing_model)
 Returns a filter computing vehicle amortized costs.
 
IntVarLocalSearchFilterMakeTypeRegulationsFilter (const RoutingModel &routing_model)
 Returns a filter ensuring type regulation constraints are enforced.
 
IntVarLocalSearchFilterMakePathCumulFilter (const RoutingDimension &dimension, bool propagate_own_objective_value, bool filter_objective_cost, bool can_use_lp)
 Returns a filter handling dimension costs and constraints.
 
void AppendLightWeightDimensionFilters (const PathState *path_state, const std::vector< RoutingDimension * > &dimensions, std::vector< LocalSearchFilterManager::FilterEvent > *filters)
 
void AppendDimensionCumulFilters (const std::vector< RoutingDimension * > &dimensions, const RoutingSearchParameters &parameters, bool filter_objective_cost, bool use_chain_cumul_filter, std::vector< LocalSearchFilterManager::FilterEvent > *filters)
 
IntVarLocalSearchFilterMakePickupDeliveryFilter (const RoutingModel &routing_model, const std::vector< PickupDeliveryPair > &pairs, const std::vector< RoutingModel::PickupAndDeliveryPolicy > &vehicle_policies)
 
IntVarLocalSearchFilterMakeVehicleVarFilter (const RoutingModel &routing_model)
 Returns a filter checking that vehicle variable domains are respected.
 
IntVarLocalSearchFilterMakeCumulBoundsPropagatorFilter (const RoutingDimension &dimension)
 Returns a filter handling dimension cumul bounds.
 
IntVarLocalSearchFilterMakeGlobalLPCumulFilter (GlobalDimensionCumulOptimizer *optimizer, GlobalDimensionCumulOptimizer *mp_optimizer, bool filter_objective_cost)
 Returns a filter checking global linear constraints and costs.
 
LocalSearchFilterMakeResourceAssignmentFilter (LocalDimensionCumulOptimizer *optimizer, LocalDimensionCumulOptimizer *mp_optimizer, bool propagate_own_objective_value, bool filter_objective_cost)
 
IntVarLocalSearchFilterMakeCPFeasibilityFilter (RoutingModel *routing_model)
 Returns a filter checking the current solution using CP propagation.
 
LocalSearchFilterMakePathEnergyCostFilter (Solver *solver, std::unique_ptr< PathEnergyCostChecker > checker, absl::string_view dimension_name)
 
DecisionBuilderMakeRuinAndRecreateDecisionBuilder (const RoutingSearchParameters &parameters, RoutingModel *model, const Assignment *assignment, std::function< bool()> stop_search, LocalSearchFilterManager *filter_manager)
 
DecisionBuilderMakePerturbationDecisionBuilder (const RoutingSearchParameters &parameters, RoutingModel *model, const Assignment *assignment, std::function< bool()> stop_search, LocalSearchFilterManager *filter_manager)
 
std::unique_ptr< NeighborAcceptanceCriterionMakeNeighborAcceptanceCriterion (const RoutingSearchParameters &parameters)
 Returns a neighbor acceptance criterion based on the given parameters.
 
std::vector< bool > SlopeAndYInterceptToConvexityRegions (const std::vector< SlopeAndYIntercept > &slope_and_y_intercept)
 
std::vector< SlopeAndYInterceptPiecewiseLinearFormulationToSlopeAndYIntercept (const RoutingModel::RouteDimensionTravelInfo::TransitionInfo::PiecewiseLinearFormulation &pwl_function, int index_start, int index_end)
 
PiecewiseEvaluationStatus ComputePiecewiseLinearFormulationValue (const RoutingModel::RouteDimensionTravelInfo::TransitionInfo::PiecewiseLinearFormulation &pwl, int64_t x, int64_t *value, double delta)
 
int64_t ComputeConvexPiecewiseLinearFormulationValue (const RoutingModel::RouteDimensionTravelInfo::TransitionInfo::PiecewiseLinearFormulation &pwl, int64_t x, double delta)
 
bool ComputeVehicleToResourceClassAssignmentCosts (int v, const RoutingModel::ResourceGroup &resource_group, const util_intops::StrongVector< RoutingModel::ResourceClassIndex, absl::flat_hash_set< int > > &ignored_resources_per_class, const std::function< int64_t(int64_t)> &next_accessor, const std::function< int64_t(int64_t, int64_t)> &transit_accessor, bool optimize_vehicle_costs, LocalDimensionCumulOptimizer *lp_optimizer, LocalDimensionCumulOptimizer *mp_optimizer, std::vector< int64_t > *assignment_costs, std::vector< std::vector< int64_t > > *cumul_values, std::vector< std::vector< int64_t > > *break_values)
 
int64_t ComputeBestVehicleToResourceAssignment (const std::vector< int > &vehicles, const util_intops::StrongVector< RoutingModel::ResourceClassIndex, std::vector< int > > &resource_indices_per_class, const util_intops::StrongVector< RoutingModel::ResourceClassIndex, absl::flat_hash_set< int > > &ignored_resources_per_class, std::function< const std::vector< int64_t > *(int)> vehicle_to_resource_class_assignment_costs, std::vector< int > *resource_indices)
 
std::string Int64ToStr (int64_t number)
 
std::string DomainToString (const ::google::protobuf::RepeatedField< int64_t > *domain)
 
std::string VariableToString (std::pair< sat::IntegerVariableProto, int > &variable_pair, const sat::CpSolverResponse &response_)
 
std::string ConstraintToString (const sat::ConstraintProto &constraint, const sat::CpModelProto &model_, bool show_enforcement=true)
 
std::string VariablesToString (absl::flat_hash_map< std::string, std::pair< sat::IntegerVariableProto, int > > &variables, absl::flat_hash_map< std::string, std::vector< int > > &variable_instances, absl::flat_hash_map< std::string, absl::flat_hash_set< std::string > > &variable_childs, const sat::CpSolverResponse &response_, absl::string_view variable, std::string prefix="")
 
RoutingModelParameters DefaultRoutingModelParameters ()
 
RoutingSearchParameters DefaultRoutingSearchParameters ()
 static
 
RoutingSearchParameters DefaultSecondaryRoutingSearchParameters ()
 
std::string FindErrorInRoutingSearchParameters (const RoutingSearchParameters &search_parameters)
 
std::vector< std::string > FindErrorsInRoutingSearchParameters (const RoutingSearchParameters &search_parameters)
 
bool SolveModelWithSat (RoutingModel *model, const RoutingSearchParameters &search_parameters, const Assignment *initial_solution, Assignment *solution)
 
FirstSolutionStrategy::Value AutomaticFirstSolutionStrategy (bool has_pickup_deliveries, bool has_node_precedences, bool has_single_vehicle_node)
 
std::vector< int64_t > ComputeVehicleEndChainStarts (const RoutingModel &model)
 
DecisionBuilderMakeSweepDecisionBuilder (RoutingModel *model, bool check_assignment)
 
DecisionBuilderMakeAllUnperformed (RoutingModel *model)
 Returns a DecisionBuilder making all nodes unperformed.
 
 DEFINE_INT_TYPE (RoutingNodeIndex, int)
 
 DEFINE_INT_TYPE (RoutingCostClassIndex, int)
 
 DEFINE_INT_TYPE (RoutingDimensionIndex, int)
 
 DEFINE_INT_TYPE (RoutingDisjunctionIndex, int)
 
 DEFINE_INT_TYPE (RoutingVehicleClassIndex, int)
 
 DEFINE_INT_TYPE (RoutingResourceClassIndex, int)
 
bool FindMostExpensiveArcsOnRoute (int num_arcs, int64_t start, const std::function< int64_t(int64_t)> &next_accessor, const std::function< bool(int64_t)> &is_end, const std::function< int64_t(int64_t, int64_t, int64_t)> &arc_cost_for_route_start, std::vector< std::pair< int64_t, int > > *most_expensive_arc_starts_and_ranks, std::pair< int, int > *first_expensive_arc_indices)
 
BaseAssignVariables::Mode ChooseMode (Solver::IntValueStrategy val_str)
 
int ComputeFormVarStatus (glp_prob *const problem, const int num_cstrs, const int k)
 
double ComputeFormVarReducedCost (glp_prob *const problem, const int num_cstrs, const int k)
 
double ComputeFormVarPrimalValue (glp_prob *const problem, const int num_cstrs, const int k)
 
double ComputeFormVarLowerBound (glp_prob *const problem, const int num_cstrs, const int k)
 
double ComputeFormVarUpperBound (glp_prob *const problem, const int num_cstrs, const int k)
 
void SetupGlpkEnvAutomaticDeletion ()
 
std::string SolutionStatusString (int status)
 Formats a solution status (GLP_OPT,...).
 
std::string BasisStatusString (int stat)
 Formats a linear constraint or variable basis status (GLP_BS,...).
 
std::string ReturnCodeString (const int rc)
 
std::string TruncateAndQuoteGLPKName (const std::string_view original_name)
 
template<typename DistanceType >
std::pair< DistanceType, std::vector< int > > SimpleOneToOneShortestPath (int source, int destination, absl::Span< const int > tails, absl::Span< const int > heads, absl::Span< const DistanceType > lengths, DistanceType limit=std::numeric_limits< DistanceType >::max())
 
template<typename WeightFunctionType , typename GraphType >
absl::StatusOr< std::vector< std::pair< typename GraphType::NodeIndex, typename GraphType::NodeIndex > > > ComputeMinimumWeightMatching (const GraphType &graph, const WeightFunctionType &weight)
 Computes a minimum weight perfect matching on an undirected graph.
 
template<typename WeightFunctionType , typename GraphType >
absl::StatusOr< std::vector< std::pair< typename GraphType::NodeIndex, typename GraphType::NodeIndex > > > ComputeMinimumWeightMatchingWithMIP (const GraphType &graph, const WeightFunctionType &weight)
 
void FindCliques (std::function< bool(int, int)> graph, int node_count, std::function< bool(const std::vector< int > &)> callback)
 
void CoverArcsByCliques (std::function< bool(int, int)> graph, int node_count, std::function< bool(const std::vector< int > &)> callback)
 
PathWithLength ConstrainedShortestPathsOnDag (const int num_nodes, absl::Span< const ArcWithLengthAndResources > arcs_with_length_and_resources, int source, int destination, const std::vector< double > &max_resources)
 
std::vector< int > GetInversePermutation (absl::Span< const int > permutation)
 
PathWithLength ShortestPathsOnDag (const int num_nodes, absl::Span< const ArcWithLength > arcs_with_length, const int source, const int destination)
 
std::vector< PathWithLengthKShortestPathsOnDag (const int num_nodes, absl::Span< const ArcWithLength > arcs_with_length, const int source, const int destination, const int path_count)
 
template<class GraphType >
absl::Status TopologicalOrderIsValid (const GraphType &graph, absl::Span< const typename GraphType::NodeIndex > topological_order)
 
template<typename GraphType >
std::vector< typename GraphType::NodeIndex > NodePathImpliedBy (absl::Span< const typename GraphType::ArcIndex > arc_path, const GraphType &graph)
 
template<class GraphType >
void CheckNodeIsValid (typename GraphType::NodeIndex node, const GraphType &graph)
 
template<typename GraphType >
bool BuildLineGraph (const GraphType &graph, GraphType *const line_graph)
 
template<typename Graph >
bool IsEulerianGraph (const Graph &graph, bool assume_connectivity=true)
 Returns true if a graph is Eulerian, aka all its nodes are of even degree.
 
template<typename NodeIndex , typename Graph >
bool IsSemiEulerianGraph (const Graph &graph, std::vector< NodeIndex > *odd_nodes, bool assume_connectivity=true)
 
template<typename NodeIndex , typename Graph >
std::vector< NodeIndexBuildEulerianPathFromNode (const Graph &graph, NodeIndex root)
 
template<typename NodeIndex , typename Graph >
std::vector< NodeIndexBuildEulerianTourFromNode (const Graph &graph, NodeIndex root, bool assume_connectivity=true)
 
template<typename Graph >
std::vector< typename Graph::NodeIndexBuildEulerianTour (const Graph &graph, bool assume_connectivity=true)
 
template<typename Graph >
std::vector< typename Graph::NodeIndexBuildEulerianPath (const Graph &graph, bool assume_connectivity=true)
 
template<typename CostType , typename CostFunction >
HamiltonianPathSolver< CostType, CostFunction > MakeHamiltonianPathSolver (int num_nodes, CostFunction cost)
 Utility function to simplify building a HamiltonianPathSolver from a functor.
 
template<class GraphType >
KShortestPaths YenKShortestPaths (const GraphType &graph, const std::vector< PathDistance > &arc_lengths, NodeIndex source, NodeIndex destination, unsigned k)
 
template<typename Graph >
std::vector< typename Graph::ArcIndexBuildKruskalMinimumSpanningTreeFromSortedArcs (const Graph &graph, absl::Span< const typename Graph::ArcIndex > sorted_arcs)
 
template<typename Graph , typename ArcComparator >
std::vector< typename Graph::ArcIndexBuildKruskalMinimumSpanningTree (const Graph &graph, const ArcComparator &arc_comparator)
 
template<typename Graph , typename ArcValue >
std::vector< typename Graph::ArcIndexBuildPrimMinimumSpanningTree (const Graph &graph, const ArcValue &arc_value)
 
template<class DistanceType >
std::ostream & operator<< (std::ostream &out, DistanceAndParentArc< DistanceType > distance_and_parent_arc)
 
template<class DistanceType , class Graph , class ArcLengthFunctor , class SettledNodeCallbackType >
std::vector< absl::flat_hash_map< int, DistanceAndParentArc< DistanceType > > > MultiDijkstra (const Graph &graph, ArcLengthFunctor arc_length_functor, const std::vector< std::vector< int > > &source_sets, SettledNodeCallbackType settled_node_callback)
 
template<typename Graph >
absl::StatusOr< RootedTree< typename Graph::NodeType > > RootedTreeFromGraph (typename Graph::NodeType root, const Graph &graph, std::vector< typename Graph::NodeType > *topological_order=nullptr, std::vector< typename Graph::NodeType > *depths=nullptr)
 
template<typename Graph >
absl::StatusOr< RootedTree< typename Graph::NodeIndex > > RootedTreeFromGraph (const typename Graph::NodeIndex root, const Graph &graph, std::vector< typename Graph::NodeIndex > *const topological_order, std::vector< typename Graph::NodeIndex > *const depths)
 
template<class GraphType >
void ComputeManyToManyShortestPathsWithMultipleThreadsInternal (const GraphType &graph, const std::vector< PathDistance > &arc_lengths, const std::vector< typename GraphType::NodeIndex > &sources, const std::vector< typename GraphType::NodeIndex > &destinations, int num_threads, PathContainer *const paths)
 
template<>
void ComputeManyToManyShortestPathsWithMultipleThreads (const ListGraph<> &graph, const std::vector< PathDistance > &arc_lengths, const std::vector< ListGraph<>::NodeIndex > &sources, const std::vector< ListGraph<>::NodeIndex > &destinations, int num_threads, PathContainer *const path_container)
 
template<>
void ComputeManyToManyShortestPathsWithMultipleThreads (const StaticGraph<> &graph, const std::vector< PathDistance > &arc_lengths, const std::vector< StaticGraph<>::NodeIndex > &sources, const std::vector< StaticGraph<>::NodeIndex > &destinations, int num_threads, PathContainer *const path_container)
 
template<>
void ComputeManyToManyShortestPathsWithMultipleThreads (const ReverseArcListGraph<> &graph, const std::vector< PathDistance > &arc_lengths, const std::vector< ReverseArcListGraph<>::NodeIndex > &sources, const std::vector< ReverseArcListGraph<>::NodeIndex > &destinations, int num_threads, PathContainer *const path_container)
 
template<>
void ComputeManyToManyShortestPathsWithMultipleThreads (const ReverseArcStaticGraph<> &graph, const std::vector< PathDistance > &arc_lengths, const std::vector< ReverseArcStaticGraph<>::NodeIndex > &sources, const std::vector< ReverseArcStaticGraph<>::NodeIndex > &destinations, int num_threads, PathContainer *const path_container)
 
template<>
void ComputeManyToManyShortestPathsWithMultipleThreads (const ReverseArcMixedGraph<> &graph, const std::vector< PathDistance > &arc_lengths, const std::vector< ReverseArcMixedGraph<>::NodeIndex > &sources, const std::vector< ReverseArcMixedGraph<>::NodeIndex > &destinations, int num_threads, PathContainer *const path_container)
 
template<class GraphType >
void GetGraphNodes (const GraphType &graph, std::vector< NodeIndex > *nodes)
 Utility function which returns a vector containing all nodes of a graph.
 
template<class GraphType >
void GetGraphNodesFromGraph (const GraphType &graph, std::vector< typename GraphType::NodeIndex > *nodes)
 
template<class GraphType >
void ComputeOneToAllShortestPaths (const GraphType &graph, const std::vector< PathDistance > &arc_lengths, typename GraphType::NodeIndex source, PathContainer *const path_container)
 Computes shortest paths from the node 'source' to all nodes in the graph.
 
template<class GraphType >
void ComputeOneToManyShortestPaths (const GraphType &graph, const std::vector< PathDistance > &arc_lengths, typename GraphType::NodeIndex source, const std::vector< typename GraphType::NodeIndex > &destinations, PathContainer *const path_container)
 Computes shortest paths from the node 'source' to nodes in 'destinations'.
 
template<class GraphType >
std::vector< typename GraphType::NodeIndex > ComputeOneToOneShortestPath (const GraphType &graph, const std::vector< PathDistance > &arc_lengths, typename GraphType::NodeIndex source, typename GraphType::NodeIndex destination)
 
template<class GraphType >
void ComputeManyToAllShortestPathsWithMultipleThreads (const GraphType &graph, const std::vector< PathDistance > &arc_lengths, const std::vector< typename GraphType::NodeIndex > &sources, int num_threads, PathContainer *const path_container)
 
template<class GraphType >
void ComputeManyToManyShortestPathsWithMultipleThreads (const GraphType &graph, const std::vector< PathDistance > &arc_lengths, const std::vector< typename GraphType::NodeIndex > &sources, const std::vector< typename GraphType::NodeIndex > &destinations, int num_threads, PathContainer *const path_container)
 
template<>
void ComputeManyToManyShortestPathsWithMultipleThreads (const ListGraph<> &graph, const std::vector< PathDistance > &arc_lengths, const std::vector< ListGraph<>::NodeIndex > &sources, const std::vector< ListGraph<>::NodeIndex > &destinations, int num_threads, PathContainer *path_container)
 
template<>
void ComputeManyToManyShortestPathsWithMultipleThreads (const StaticGraph<> &graph, const std::vector< PathDistance > &arc_lengths, const std::vector< StaticGraph<>::NodeIndex > &sources, const std::vector< StaticGraph<>::NodeIndex > &destinations, int num_threads, PathContainer *path_container)
 
template<>
void ComputeManyToManyShortestPathsWithMultipleThreads (const ReverseArcListGraph<> &graph, const std::vector< PathDistance > &arc_lengths, const std::vector< ReverseArcListGraph<>::NodeIndex > &sources, const std::vector< ReverseArcListGraph<>::NodeIndex > &destinations, int num_threads, PathContainer *path_container)
 
template<>
void ComputeManyToManyShortestPathsWithMultipleThreads (const ReverseArcStaticGraph<> &graph, const std::vector< PathDistance > &arc_lengths, const std::vector< ReverseArcStaticGraph<>::NodeIndex > &sources, const std::vector< ReverseArcStaticGraph<>::NodeIndex > &destinations, int num_threads, PathContainer *path_container)
 
template<>
void ComputeManyToManyShortestPathsWithMultipleThreads (const ReverseArcMixedGraph<> &graph, const std::vector< PathDistance > &arc_lengths, const std::vector< ReverseArcMixedGraph<>::NodeIndex > &sources, const std::vector< ReverseArcMixedGraph<>::NodeIndex > &destinations, int num_threads, PathContainer *path_container)
 
template<class GraphType >
void ComputeAllToAllShortestPathsWithMultipleThreads (const GraphType &graph, const std::vector< PathDistance > &arc_lengths, int num_threads, PathContainer *const path_container)
 Computes shortest paths between all nodes of the graph.
 
void ConvertFlowModelToDimacs (const FlowModelProto &flow_model, std::string *dimacs)
 
bool ConvertDimacsToFlowModel (absl::string_view file, FlowModelProto *flow_model)
 
void SolveMinCostFlow (const FlowModelProto &flow_model, double *loading_time, double *solving_time)
 Loads a FlowModelProto proto into the MinCostFlow class and solves it.
 
void SolveMaxFlow (const FlowModelProto &flow_model, double *loading_time, double *solving_time)
 Loads a FlowModelProto proto into the MaxFlow class and solves it.
 
const GScipVariableOptions & DefaultGScipVariableOptions ()
 
const GScipConstraintOptions & DefaultGScipConstraintOptions ()
 
SCIP_RESULT ConvertGScipCallbackResult (const GScipCallbackResult result)
 
int ConstraintHandlerResultPriority (const GScipCallbackResult result, const ConstraintHandlerCallbackType callback_type)
 
GScipCallbackResult MergeConstraintHandlerResults (const GScipCallbackResult result1, const GScipCallbackResult result2, const ConstraintHandlerCallbackType callback_type)
 
SCIP_RETCODE DropAllEvents (GScipEventHandler &handler)
 
GScipLinearExpr GScipDifference (GScipLinearExpr left, const GScipLinearExpr &right)
 Returns left - right.
 
GScipLinearExpr GScipNegate (GScipLinearExpr expr)
 Returns -expr.
 
GScipLinearRange GScipLe (const GScipLinearExpr left, const GScipLinearExpr &right)
 
absl::Status GScipCreateAbs (GScip *gscip, SCIP_Var *x, SCIP_Var *abs_x, absl::string_view name)
 
absl::Status GScipCreateMaximum (GScip *gscip, const GScipLinearExpr &resultant, const std::vector< GScipLinearExpr > &terms, absl::string_view name)
 
absl::Status GScipCreateMinimum (GScip *gscip, const GScipLinearExpr &resultant, const std::vector< GScipLinearExpr > &terms, absl::string_view name)
 
absl::Status GScipAddQuadraticObjectiveTerm (GScip *gscip, std::vector< SCIP_Var * > quadratic_variables1, std::vector< SCIP_Var * > quadratic_variables2, std::vector< double > quadratic_coefficients, absl::string_view name)
 
absl::Status GScipCreateIndicatorRange (GScip *gscip, const GScipIndicatorRangeConstraint &indicator_range, absl::string_view name="", const GScipConstraintOptions &options=GScipConstraintOptions())
 Supports unbounded variables in indicator_range.range.variables.
 
void GScipSetTimeLimit (absl::Duration time_limit, GScipParameters *parameters)
 
absl::Duration GScipTimeLimit (const GScipParameters &parameters)
 
bool GScipTimeLimitSet (const GScipParameters &parameters)
 
void GScipSetMaxNumThreads (int num_threads, GScipParameters *parameters)
 CHECK fails if num_threads < 1.
 
int GScipMaxNumThreads (const GScipParameters &parameters)
 Returns 1 if the number of threads it not specified.
 
bool GScipMaxNumThreadsSet (const GScipParameters &parameters)
 
void GScipSetLogLevel (GScipParameters *parameters, int log_level)
 
int GScipLogLevel (const GScipParameters &parameters)
 
bool GScipLogLevelSet (const GScipParameters &parameters)
 
void GScipSetOutputEnabled (GScipParameters *parameters, bool output_enabled)
 Sets the log level to 4 if enabled, 0 if disabled (see above).
 
bool GScipOutputEnabled (const GScipParameters &parameters)
 Checks if the log level is equal to zero.
 
bool GScipOutputEnabledSet (const GScipParameters &parameters)
 
void GScipSetRandomSeed (GScipParameters *parameters, int random_seed)
 
int GScipRandomSeed (const GScipParameters &parameters)
 Returns -1 if unset.
 
bool GScipRandomSeedSet (const GScipParameters &parameters)
 
void GScipSetCatchCtrlC (bool catch_ctrl_c, GScipParameters *parameters)
 Sets the misc/catchctrlc property.
 
bool GScipCatchCtrlC (const GScipParameters &parameters)
 
bool GScipCatchCtrlCSet (const GScipParameters &parameters)
 Returns true when the misc/catchctrlc property is set.
 
void DisableAllCutsExceptUserDefined (GScipParameters *parameters)
 Turns off all SCIP separators.
 
absl::Status LegacyScipSetSolverSpecificParameters (absl::string_view parameters, SCIP *scip)
 
bool GurobiIsCorrectlyInstalled ()
 
void LoadGurobiFunctions (DynamicLibrary *gurobi_dynamic_library)
 
std::vector< std::string > GurobiDynamicLibraryPotentialPaths ()
 
absl::Status LoadGurobiDynamicLibrary (std::vector< std::string > potential_paths)
 
absl::StatusOr< GRBenv * > GetGurobiEnv ()
 
testing::Matcher< std::string > EmptyOrGurobiLicenseWarning ()
 
testing::Matcher< std::string > EmptyOrGurobiLicenseWarningIfGurobi (const bool is_gurobi)
 
std::string GurobiParamInfoForLogging (GRBenv *grb, bool one_liner_output)
 
MPSolverInterfaceBuildBopInterface (MPSolver *const solver)
 Register BOP in the global linear solver factory.
 
MPSolverInterfaceBuildCBCInterface (MPSolver *const solver)
 
MPSolverInterfaceBuildCLPInterface (MPSolver *const solver)
 
MPSolverInterfaceBuildCplexInterface (bool mip, MPSolver *const solver)
 
MPSolverInterfaceBuildGLOPInterface (MPSolver *const solver)
 Register GLOP in the global linear solver factory.
 
MPSolver::ResultStatus GlopToMPSolverResultStatus (glop::ProblemStatus s)
 
MPSolver::BasisStatus GlopToMPSolverVariableStatus (glop::VariableStatus s)
 
glop::VariableStatus MPSolverToGlopVariableStatus (MPSolver::BasisStatus s)
 
MPSolver::BasisStatus GlopToMPSolverConstraintStatus (glop::ConstraintStatus s)
 
glop::ConstraintStatus MPSolverToGlopConstraintStatus (MPSolver::BasisStatus s)
 
void GLPKGatherInformationCallback (glp_tree *tree, void *info)
 Function to be called in the GLPK callback.
 
MPSolverInterfaceBuildGLPKInterface (bool mip, MPSolver *const solver)
 
MPSolverInterfaceBuildGurobiInterface (bool mip, MPSolver *const solver)
 
MPSolverInterfaceBuildHighsInterface (bool mip, MPSolver *const solver)
 Register PDLP in the global linear solver factory.
 
MPSolverInterfaceBuildKnapsackInterface (MPSolver *const solver)
 Register Knapsack solver in the global linear solver factory.
 
std::ostream & operator<< (std::ostream &stream, const LinearExpr &linear_expr)
 
LinearExpr operator+ (LinearExpr lhs, const LinearExpr &rhs)
 
LinearExpr operator- (LinearExpr lhs, const LinearExpr &rhs)
 
LinearExpr operator* (LinearExpr lhs, double rhs)
 
LinearExpr operator/ (LinearExpr lhs, double rhs)
 
LinearExpr operator* (double lhs, LinearExpr rhs)
 
LinearRange operator<= (const LinearExpr &lhs, const LinearExpr &rhs)
 
LinearRange operator== (const LinearExpr &lhs, const LinearExpr &rhs)
 
LinearRange operator>= (const LinearExpr &lhs, const LinearExpr &rhs)
 
bool SolverTypeIsMip (MPModelRequest::SolverType solver_type)
 There is a homonymous version taking a MPSolver::OptimizationProblemType.
 
MPSolverInterfaceBuildPdlpInterface (MPSolver *const solver)
 Register PDLP in the global linear solver factory.
 
MPSolverInterfaceBuildSatInterface (MPSolver *const solver)
 Register Sat in the global linear solver factory.
 
MPSolverInterfaceBuildSCIPInterface (MPSolver *const solver)
 
MPSolverInterfaceBuildXpressInterface (bool mip, MPSolver *const solver)
 
bool XpressIsCorrectlyInstalled ()
 
absl::string_view ToString (MPSolver::OptimizationProblemType optimization_problem_type)
 
bool AbslParseFlag (const absl::string_view text, MPSolver::OptimizationProblemType *solver_type, std::string *error)
 
bool MPSolverResponseStatusIsRpcError (MPSolverResponseStatus status)
 
bool SolverTypeIsMip (MPSolver::OptimizationProblemType solver_type)
 
std::ostream & operator<< (std::ostream &os, MPSolver::OptimizationProblemType optimization_problem_type)
 
std::ostream & operator<< (std::ostream &os, MPSolver::ResultStatus status)
 
std::string AbslUnparseFlag (MPSolver::OptimizationProblemType solver_type)
 
std::string ToString (MPCallbackEvent event)
 
absl::StatusOr< std::string > ExportModelAsLpFormat (const MPModelProto &model, const MPModelExportOptions &options)
 
absl::StatusOr< std::string > ExportModelAsMpsFormat (const MPModelProto &model, const MPModelExportOptions &options)
 
absl::Status WriteModelToMpsFile (absl::string_view filename, const MPModelProto &model, const MPModelExportOptions &options)
 
std::string FindErrorInMPModelProto (const MPModelProto &model, double abs_value_threshold, const bool accept_trivially_infeasible_bounds)
 
std::optional< LazyMutableCopy< MPModelProto > > ExtractValidMPModelOrPopulateResponseStatus (const MPModelRequest &request, MPSolutionResponse *response)
 
std::optional< LazyMutableCopy< MPModelProto > > GetMPModelOrPopulateResponse (LazyMutableCopy< MPModelRequest > &request, MPSolutionResponse *response)
 
std::string FindFeasibilityErrorInSolutionHint (const MPModelProto &model, double tolerance)
 
std::string FindErrorInMPModelDeltaProto (const MPModelDeltaProto &delta, const MPModelProto &model)
 
void MergeMPConstraintProtoExceptTerms (const MPConstraintProto &from, MPConstraintProto *to)
 
void ApplyVerifiedMPModelDelta (const MPModelDeltaProto &delta, MPModelProto *model)
 
MPSolutionResponse GlopSolveProto (LazyMutableCopy< MPModelRequest > request, std::atomic< bool > *interrupt_solve, std::function< void(const std::string &)> logging_callback)
 
std::string GlopSolverVersion ()
 Returns a string that describes the version of the GLOP solver.
 
absl::Status SetSolverSpecificParameters (absl::string_view parameters, GRBenv *gurobi)
 
absl::StatusOr< MPSolutionResponse > GurobiSolveProto (LazyMutableCopy< MPModelRequest > request, GRBenv *gurobi_env)
 
absl::Status SetSolverSpecificParameters (const std::string &parameters, Highs &highs)
 
absl::StatusOr< MPSolutionResponse > HighsSolveProto (LazyMutableCopy< MPModelRequest > request)
 Solve the input MIP model with the HIGHS solver.
 
absl::StatusOr< MPSolutionResponse > PdlpSolveProto (LazyMutableCopy< MPModelRequest > request, const bool relax_integer_variables, const std::atomic< bool > *interrupt_solve)
 
MPSolutionResponse ConvertStatusOrMPSolutionResponse (bool log_error, absl::StatusOr< MPSolutionResponse > response)
 
template<typename P >
std::string EncodeParametersAsString (const P &parameters)
 
MPSolutionResponse SatSolveProto (LazyMutableCopy< MPModelRequest > request, std::atomic< bool > *interrupt_solve, std::function< void(const std::string &)> logging_callback, std::function< void(const MPSolution &)> solution_callback)
 
std::string SatSolverVersion ()
 Returns a string that describes the version of the CP-SAT solver.
 
glop::ProblemStatus ApplyMipPresolveSteps (const glop::GlopParameters &glop_params, MPModelProto *model, std::vector< std::unique_ptr< glop::Preprocessor > > *for_postsolve, SolverLogger *logger)
 
std::string FindErrorInMPModelForScip (const MPModelProto &model, SCIP *scip)
 
absl::StatusOr< MPSolutionResponse > ScipSolveProto (LazyMutableCopy< MPModelRequest > request)
 
MPSolutionResponse XPressSolveProto (LazyMutableCopy< MPModelRequest > request)
 Solves the input request.
 
bool LinearConstraintIsViolated (const ScipConstraintHandlerContext &context, const LinearRange &constraint)
 
ScipSeparationResult RunSeparation (internal::ScipCallbackRunner *runner, const ScipConstraintHandlerContext &context, absl::Span< SCIP_CONS * > constraints, bool is_integral)
 
template<typename Constraint >
void RegisterConstraintHandler (ScipConstraintHandler< Constraint > *handler, SCIP *scip)
 handler is not owned but held.
 
template<typename ConstraintData >
void AddCallbackConstraint (SCIP *scip, ScipConstraintHandler< ConstraintData > *handler, const std::string &constraint_name, const ConstraintData *constraint_data, const ScipCallbackConstraintOptions &options)
 constraint_data is not owned but held.
 
template<typename ConstraintData >
void RegisterConstraintHandler (ScipConstraintHandler< ConstraintData > *handler, SCIP *scip)
 
MPSolutionResponse SolveMPModel (LazyMutableCopy< MPModelRequest > request, const SolveInterrupter *interrupter)
 
bool SolverTypeSupportsInterruption (const MPModelRequest::SolverType solver)
 
std::string MPModelRequestLoggingInfo (const MPModelRequest &request)
 
std::string getSolverVersion (XPRSprob const &prob)
 
bool readParameter (XPRSprob const &prob, std::string const &name, std::string const &value)
 Apply the specified name=value setting to prob.
 
void printError (const XPRSprob &mLp, int line)
 
void XPRS_CC XpressIntSolCallbackImpl (XPRSprob cbprob, void *cbdata)
 
void XPRS_CC optimizermsg (XPRSprob prob, void *data, const char *sMsg, int nLen, int nMsgLvl)
 
int getnumcols (const XPRSprob &mLp)
 
int getnumrows (const XPRSprob &mLp)
 
int getitcnt (const XPRSprob &mLp)
 
int getnodecnt (const XPRSprob &mLp)
 
int setobjoffset (const XPRSprob &mLp, double value)
 
void addhint (const XPRSprob &mLp, int length, const double solval[], const int colind[])
 
void interruptXPRESS (XPRSprob &xprsProb, CUSTOM_INTERRUPT_REASON reason)
 
static int MPSolverToXpressBasisStatus (MPSolver::BasisStatus mpsolver_basis_status)
 Transform MPSolver basis status to XPRESS status.
 
static MPSolver::BasisStatus XpressToMPSolverBasisStatus (int xpress_basis_status)
 Transform XPRESS basis status to MPSolver basis status.
 
static std::map< std::string, int > & getMapStringControls ()
 
static std::map< std::string, int > & getMapDoubleControls ()
 
static std::map< std::string, int > & getMapIntControls ()
 
static std::map< std::string, int > & getMapInt64Controls ()
 
std::vector< int > XpressBasisStatusesFrom (const std::vector< MPSolver::BasisStatus > &statuses)
 
template<class Container >
void splitMyString (const std::string &str, Container &cont, char delim=' ')
 
const char * stringToCharPtr (std::string &var)
 
absl::StatusOr< glop::DenseRowParseSolFile (absl::string_view file_name, const glop::LinearProgram &model)
 Parse a solution to model from a file.
 
absl::StatusOr< MPSolutionResponse > ParseSolFile (absl::string_view file_name, const MPModelProto &model)
 
absl::StatusOr< glop::DenseRowParseSolString (const std::string &solution, const glop::LinearProgram &model)
 Parse a solution to model from a string.
 
absl::StatusOr< MPSolutionResponse > ParseSolString (const std::string &solution, const MPModelProto &model)
 
void ParseAndSolve (const std::string &filename, absl::string_view solver, const std::string &params)
 
::absl::Status PortableFileSetContents (absl::string_view file_name, absl::string_view content)
 
::absl::Status PortableFileGetContents (absl::string_view file_name, std::string *output)
 
bool PortableTemporaryFile (const char *directory_prefix, std::string *filename_out)
 Returns true if successful. Outputs temp file to filename.
 
::absl::Status PortableDeleteFile (absl::string_view file_name)
 
std::string ProtobufTextFormatPrintToStringForFlag (const google::protobuf::Message &proto)
 
std::string ProtobufTextFormatPrintToStringForFlag (const google::protobuf::MessageLite &proto)
 Prints an error message when compiling with lite protos.
 
template<class P >
std::string ProtobufDebugString (const P &message)
 
template<class P >
std::string ProtobufShortDebugString (const P &message)
 
template<typename ProtoEnumType >
std::string ProtoEnumToString (ProtoEnumType enum_value)
 
template<typename ProtoType >
bool ProtobufTextFormatMergeFromString (absl::string_view proto_text_string, ProtoType *proto)
 
template<typename ProtoType >
bool ProtobufParseTextProtoForFlag (absl::string_view text, ProtoType *message_out, std::string *error_out)
 
int32_t GetSeed (bool deterministic)
 Random seed generator.
 
void DisplayPlan (const RoutingIndexManager &manager, const RoutingModel &routing, const operations_research::Assignment &plan, bool use_same_vehicle_costs, int64_t max_nodes_per_group, int64_t same_vehicle_cost, const operations_research::RoutingDimension &capacity_dimension, const operations_research::RoutingDimension &time_dimension)
 
void DisplayPlan (const operations_research::RoutingIndexManager &manager, const operations_research::RoutingModel &routing, const operations_research::Assignment &plan, bool use_same_vehicle_costs, int64_t max_nodes_per_group, int64_t same_vehicle_cost, const operations_research::RoutingDimension &capacity_dimension, const operations_research::RoutingDimension &time_dimension)
 
::absl::Status ReadFile (absl::string_view file_name, CapacityPlanningInstance *request)
 
RoutingOutputFormat RoutingOutputFormatFromString (std::string_view format)
 
template<typename T >
std::string FormatStatistic (absl::string_view name, T value, RoutingOutputFormat format)
 Formats a solution or solver statistic according to the given format.
 
template<>
std::string FormatStatistic (absl::string_view name, double value, RoutingOutputFormat format)
 
template<typename T >
void PrintStatistic (absl::string_view name, T value, RoutingOutputFormat format)
 
template<size_t alignment_bytes, typename Value >
Value * AlignUp (Value *ptr)
 
template<size_t alignment_bytes, typename Value >
Value * AlignDown (Value *ptr)
 
template<size_t alignment_bytes, typename Value >
bool IsAligned (Value *ptr)
 Returns true when ptr is aligned to alignment_bytes bytes.
 
uint64_t OneBit64 (int pos)
 Returns a word with only bit pos set.
 
uint32_t OneBit32 (int pos)
 
uint64_t BitCount64 (uint64_t n)
 Returns the number of bits set in n.
 
uint32_t BitCount32 (uint32_t n)
 
uint64_t LeastSignificantBitWord64 (uint64_t n)
 Returns a word with only the least significant bit of n set.
 
uint32_t LeastSignificantBitWord32 (uint32_t n)
 
int LeastSignificantBitPosition64DeBruijn (uint64_t n)
 
int LeastSignificantBitPosition64Default (uint64_t n)
 
int LeastSignificantBitPosition64 (uint64_t n)
 
int LeastSignificantBitPosition32DeBruijn (uint32_t n)
 
int LeastSignificantBitPosition32Default (uint32_t n)
 
int LeastSignificantBitPosition32 (uint32_t n)
 
int MostSignificantBitPosition64Default (uint64_t n)
 Returns the most significant bit position in n.
 
int MostSignificantBitPosition64 (uint64_t n)
 
int MostSignificantBitPosition32Default (uint32_t n)
 
int MostSignificantBitPosition32 (uint32_t n)
 
uint64_t OneRange64 (uint64_t s, uint64_t e)
 Returns a word with bits from s to e set.
 
uint32_t OneRange32 (uint32_t s, uint32_t e)
 
uint64_t IntervalUp64 (uint64_t s)
 Returns a word with s least significant bits unset.
 
uint32_t IntervalUp32 (uint32_t s)
 
uint64_t IntervalDown64 (uint64_t s)
 Returns a word with the s most significant bits unset.
 
uint32_t IntervalDown32 (uint32_t s)
 
uint32_t BitPos64 (uint64_t pos)
 Bit operators used to manipulates bitsets.
 
uint32_t BitPos32 (uint32_t pos)
 
uint64_t BitOffset64 (uint64_t pos)
 Returns the word number corresponding to bit number pos.
 
uint32_t BitOffset32 (uint32_t pos)
 
uint64_t BitLength64 (uint64_t size)
 Returns the number of words needed to store size bits.
 
uint32_t BitLength32 (uint32_t size)
 
uint64_t BitShift64 (uint64_t v)
 Returns the bit number in the bitset of the first bit of word number v.
 
uint32_t BitShift32 (uint32_t v)
 
bool IsBitSet64 (const uint64_t *const bitset, uint64_t pos)
 Returns true if the bit pos is set in bitset.
 
bool IsBitSet32 (const uint32_t *const bitset, uint32_t pos)
 
void SetBit64 (uint64_t *const bitset, uint64_t pos)
 Sets the bit pos to true in bitset.
 
void SetBit32 (uint32_t *const bitset, uint32_t pos)
 
void ClearBit64 (uint64_t *const bitset, uint64_t pos)
 Sets the bit pos to false in bitset.
 
void ClearBit32 (uint32_t *const bitset, uint32_t pos)
 
uint64_t BitCountRange64 (const uint64_t *bitset, uint64_t start, uint64_t end)
 Returns the number of bits set in bitset between positions start and end.
 
uint32_t BitCountRange32 (const uint32_t *bitset, uint32_t start, uint32_t end)
 
bool IsEmptyRange64 (const uint64_t *bitset, uint64_t start, uint64_t end)
 Returns true if no bits are set in bitset between start and end.
 
bool IsEmptyRange32 (const uint32_t *bitset, uint32_t start, uint32_t end)
 
int64_t LeastSignificantBitPosition64 (const uint64_t *bitset, uint64_t start, uint64_t end)
 Returns the first bit set in bitset between start and max_bit.
 
int LeastSignificantBitPosition32 (const uint32_t *bitset, uint32_t start, uint32_t end)
 
int64_t MostSignificantBitPosition64 (const uint64_t *bitset, uint64_t start, uint64_t end)
 Returns the last bit set in bitset between min_bit and start.
 
int MostSignificantBitPosition32 (const uint32_t *bitset, uint32_t start, uint32_t end)
 
int64_t UnsafeLeastSignificantBitPosition64 (const uint64_t *bitset, uint64_t start, uint64_t end)
 
int32_t UnsafeLeastSignificantBitPosition32 (const uint32_t *bitset, uint32_t start, uint32_t end)
 
int64_t UnsafeMostSignificantBitPosition64 (const uint64_t *bitset, uint64_t start, uint64_t end)
 
int32_t UnsafeMostSignificantBitPosition32 (const uint32_t *bitset, uint32_t start, uint32_t end)
 
uint64_t TwoBitsFromPos64 (uint64_t pos)
 Returns a mask with the bits pos % 64 and (pos ^ 1) % 64 sets.
 
absl::StatusOr< std::string > ReadFileToString (absl::string_view filename)
 Reads a file, optionally gzipped, to a string.
 
absl::Status ReadFileToProto (absl::string_view filename, google::protobuf::Message *proto, bool allow_partial)
 
absl::Status StringToProto (absl::string_view data, google::protobuf::Message *proto, bool allow_partial=false)
 Exactly like ReadFileToProto(), but directly from the contents.
 
absl::Status WriteProtoToFile (absl::string_view filename, const google::protobuf::Message &proto, ProtoWriteFormat proto_write_format, bool gzipped, bool append_extension_to_file_name)
 
template<typename Proto >
absl::StatusOr< Proto > ReadFileToProto (absl::string_view filename, bool allow_partial=false)
 
template<typename Proto >
std::vector< Proto > ReadAllRecordsOrDie (absl::string_view filename)
 
template<typename Proto >
std::vector< Proto > ReadAllRecordsOrDie (File *file)
 
template<typename Proto >
Proto ReadOneRecordOrDie (absl::string_view filename)
 
template<typename Proto >
void WriteRecordsOrDie (absl::string_view filename, const std::vector< Proto > &protos)
 
std::ostream & operator<< (std::ostream &out, const RoundTripDoubleFormat &format)
 
void ComputeScalingErrors (absl::Span< const double > input, absl::Span< const double > lb, absl::Span< const double > ub, double scaling_factor, double *max_relative_coeff_error, double *max_scaled_sum_error)
 
double GetBestScalingOfDoublesToInt64 (absl::Span< const double > input, absl::Span< const double > lb, absl::Span< const double > ub, int64_t max_absolute_sum)
 
void GetBestScalingOfDoublesToInt64 (absl::Span< const double > input, int64_t max_absolute_sum, double *scaling_factor, double *max_relative_coeff_error)
 
int64_t ComputeGcdOfRoundedDoubles (absl::Span< const double > x, double scaling_factor)
 
int fast_ilogb (double value)
 
void fast_scalbn_inplace (double &mutable_value, int exponent)
 
double fast_scalbn (double value, int exponent)
 
template<typename FloatType >
bool IsPositiveOrNegativeInfinity (FloatType x)
 
template<typename FloatType >
bool AreWithinAbsoluteOrRelativeTolerances (FloatType x, FloatType y, FloatType relative_tolerance, FloatType absolute_tolerance)
 
template<typename FloatType >
bool AreWithinAbsoluteTolerance (FloatType x, FloatType y, FloatType absolute_tolerance)
 
template<typename FloatType >
bool IsSmallerWithinTolerance (FloatType x, FloatType y, FloatType tolerance)
 
template<typename FloatType >
bool IsIntegerWithinTolerance (FloatType x, FloatType tolerance)
 
template<typename FloatType >
FloatType Interpolate (FloatType x, FloatType y, FloatType alpha)
 Returns alpha * x + (1 - alpha) * y.
 
bool ParseTextProtoForFlag (const absl::string_view text, google::protobuf::Message *const message_out, std::string *const error_out)
 
std::string FullProtocolMessageAsString (const google::protobuf::Message &message, int indent_level)
 
template<class Proto >
absl::StatusOr< Proto * > SafeProtoDownCast (google::protobuf::Message *proto)
 Implementation of function templates.
 
template<class Proto >
absl::StatusOr< const Proto * > SafeProtoConstDownCast (const google::protobuf::Message *proto)
 
QapProblem ReadQapProblemOrDie (absl::string_view filepath)
 
RangeIntToIntFunctionMakeBareIntToIntFunction (std::function< int64_t(int64_t)> f)
 
RangeIntToIntFunctionMakeCachedIntToIntFunction (const std::function< int64_t(int64_t)> &f, int64_t domain_start, int64_t domain_end)
 
RangeMinMaxIndexFunctionMakeCachedRangeMinMaxIndexFunction (const std::function< int64_t(int64_t)> &f, int64_t domain_start, int64_t domain_end)
 
Fraction RationalApproximation (const double x, const double precision)
 
bool AtMinOrMaxInt64 (int64_t x)
 Checks if x is equal to the min or the max value of an int64_t.
 
int64_t CapOpp (int64_t v)
 Note(user): -kint64min != kint64max, but kint64max == ~kint64min.
 
int64_t CapAbs (int64_t v)
 
int64_t TwosComplementAddition (int64_t x, int64_t y)
 -------— Overflow utility functions -------—
 
int64_t TwosComplementSubtraction (int64_t x, int64_t y)
 
bool AddHadOverflow (int64_t x, int64_t y, int64_t sum)
 
bool SubHadOverflow (int64_t x, int64_t y, int64_t diff)
 
bool AddOverflows (int64_t x, int64_t y)
 
int64_t SubOverflows (int64_t x, int64_t y)
 
template<typename IntegerType >
bool SafeAddInto (IntegerType a, IntegerType *b)
 
int64_t CapWithSignOf (int64_t x)
 Returns kint64max if x >= 0 and kint64min if x < 0.
 
int64_t CapAddGeneric (int64_t x, int64_t y)
 
int64_t CapSubGeneric (int64_t x, int64_t y)
 
int64_t CapProdGeneric (int64_t x, int64_t y)
 
template<typename T >
CapOrFloatAdd (T x, T y)
 
int64_t CapAdd (int64_t x, int64_t y)
 
void CapAddTo (int64_t x, int64_t *y)
 
int64_t CapSub (int64_t x, int64_t y)
 
int64_t CapProd (int64_t x, int64_t y)
 
template<class Iterator , class Compare = std::less<value_type_t<Iterator>>>
void IncrementalSort (int max_comparisons, Iterator begin, Iterator end, Compare comp=Compare{}, bool is_stable=false)
 
template<class Iterator , class Compare = std::less<value_type_t<Iterator>>>
void InsertionSort (Iterator begin, Iterator end, Compare comp=Compare{})
 
template<class Iterator , class Compare = std::less<value_type_t<Iterator>>>
void IncrementalSort (Iterator begin, Iterator end, Compare comp=Compare{}, bool is_stable=false)
 
bool IntervalsAreSortedAndNonAdjacent (absl::Span< const ClosedInterval > intervals)
 
int64_t CeilRatio (int64_t value, int64_t positive_coeff)
 
int64_t FloorRatio (int64_t value, int64_t positive_coeff)
 
std::ostream & operator<< (std::ostream &out, const ClosedInterval &interval)
 
std::ostream & operator<< (std::ostream &out, const std::vector< ClosedInterval > &intervals)
 
std::ostream & operator<< (std::ostream &out, const Domain &domain)
 
int64_t SumOfKMinValueInDomain (const Domain &domain, int k)
 Returns the sum of smallest k values in the domain.
 
int64_t SumOfKMaxValueInDomain (const Domain &domain, int k)
 Returns the sum of largest k values in the domain.
 
std::string MemoryUsage ()
 Returns the current thread's total memory usage in an human-readable string.
 
template<class T >
std::string JoinDebugString (const std::vector< T > &v, absl::string_view separator)
 Join v[i].DebugString().
 
template<class T >
std::string JoinDebugStringPtr (const std::vector< T > &v, absl::string_view separator)
 Join v[i]->DebugString().
 
template<class T >
std::string JoinNamePtr (const std::vector< T > &v, absl::string_view separator)
 Join v[i]->name().
 
template<class T >
std::string JoinNameFieldPtr (const std::vector< T > &v, absl::string_view separator)
 Join v[i]->name.
 
std::string CropMultiLineString (const std::string &s, int max_line_length, int max_num_lines)
 
template<typename StrongIndexName >
std::ostream & operator<< (std::ostream &os, StrongIndex< StrongIndexName > arg)
 
template<typename Sink , typename... T>
void AbslStringify (Sink &sink, StrongIndex< T... > arg)
 
template<typename StrongIntegerName >
std::ostream & operator<< (std::ostream &os, StrongInt64< StrongIntegerName > arg)
 
template<typename Sink , typename... T>
void AbslStringify (Sink &sink, StrongInt64< T... > arg)
 
 STRONG_TYPE_ARITHMETIC_OP (StrongIndex, int,+)
 
 STRONG_TYPE_ARITHMETIC_OP (StrongIndex, int, -)
 
 STRONG_TYPE_ARITHMETIC_OP (StrongIndex, int, *)
 
 STRONG_TYPE_ARITHMETIC_OP (StrongIndex, int, %)
 
 STRONG_TYPE_ARITHMETIC_OP (StrongInt64, int64_t,+)
 
 STRONG_TYPE_ARITHMETIC_OP (StrongInt64, int64_t, -)
 
 STRONG_TYPE_ARITHMETIC_OP (StrongInt64, int64_t, *)
 
 STRONG_TYPE_ARITHMETIC_OP (StrongInt64, int64_t,/)
 
 STRONG_TYPE_ARITHMETIC_OP (StrongInt64, int64_t,<<)
 
 STRONG_TYPE_ARITHMETIC_OP (StrongInt64, int64_t, > >)
 
 STRONG_TYPE_ARITHMETIC_OP (StrongInt64, int64_t, %)
 
 STRONG_TYPE_COMPARISON_OP (StrongIndex, int,==)
 
 STRONG_TYPE_COMPARISON_OP (StrongIndex, int, !=)
 
 STRONG_TYPE_COMPARISON_OP (StrongIndex, int,<=)
 
 STRONG_TYPE_COMPARISON_OP (StrongIndex, int, >=)
 
 STRONG_TYPE_COMPARISON_OP (StrongInt64, int64_t,==)
 
 STRONG_TYPE_COMPARISON_OP (StrongInt64, int64_t, !=)
 
 STRONG_TYPE_COMPARISON_OP (StrongInt64, int64_t,<=)
 
 STRONG_TYPE_COMPARISON_OP (StrongInt64, int64_t, >=)
 
template<typename StrongIndexName , typename H >
AbslHashValue (H h, const StrongIndex< StrongIndexName > &i)
 – ABSL HASHING SUPPORT --------------------------------------------------—
 
template<typename StrongIntegerName , typename H >
AbslHashValue (H h, const StrongInt64< StrongIntegerName > &i)
 
bool ProbablyRunningInsideUnitTest ()
 
float AlignedVectorSum (absl::Span< const float > values)
 
float VectorSum (absl::Span< const float > values)
 Computes the sum of values without assuming anything.
 
void LoadXpressFunctions (DynamicLibrary *xpress_dynamic_library)
 
void printXpressBanner (bool error)
 clang-format on
 
std::vector< std::string > XpressDynamicLibraryPotentialPaths ()
 
absl::Status LoadXpressDynamicLibrary (std::string &xpresspath)
 
void log_message_about_XPRSinit_argument ()
 
void log_full_license_error (int code, const std::string &xpress_lib_dir)
 
bool initXpressEnv (bool verbose, int xpress_oem_license_key)
 ! init XPRESS environment.
 
template<class T >
DemonMakeConstraintDemon0 (Solver *const s, T *const ct, void(T::*method)(), const std::string &name)
 
template<class P >
std::string ParameterDebugString (P param)
 
template<class P >
std::string ParameterDebugString (P *param)
 Support limited to pointers to classes which define DebugString().
 
template<class T , class P >
DemonMakeConstraintDemon1 (Solver *const s, T *const ct, void(T::*method)(P), const std::string &name, P param1)
 
template<class T , class P , class Q >
DemonMakeConstraintDemon2 (Solver *const s, T *const ct, void(T::*method)(P, Q), const std::string &name, P param1, Q param2)
 
template<class T , class P , class Q , class R >
DemonMakeConstraintDemon3 (Solver *const s, T *const ct, void(T::*method)(P, Q, R), const std::string &name, P param1, Q param2, R param3)
 
template<class T >
DemonMakeDelayedConstraintDemon0 (Solver *const s, T *const ct, void(T::*method)(), const std::string &name)
 
template<class T , class P >
DemonMakeDelayedConstraintDemon1 (Solver *const s, T *const ct, void(T::*method)(P), const std::string &name, P param1)
 
template<class T , class P , class Q >
DemonMakeDelayedConstraintDemon2 (Solver *const s, T *const ct, void(T::*method)(P, Q), const std::string &name, P param1, Q param2)
 

Variables

static constexpr Cost kMaxPossibleCost = std::numeric_limits<Cost>::max()
 
static constexpr double kInfinity = std::numeric_limits<float>::infinity()
 
constexpr int kSetCoverAlignmentInBytes = 64
 
static const int kUnassigned = -1
 --— Routing model --—
 
constexpr std::size_t kMaxGLPKNameLen = 255
 
const PathDistance kDisconnectedPathDistance
 
std::function< int(GRBenv **, const char *, const char *, const char *, int, const char *)> GRBisqp = nullptr
 This is the 'define' section.
 
std::function< int(GRBmodel *model, const char *attrname)> GRBisattravailable
 
std::function< int(GRBmodel *model, const char *attrname, int *valueP)> GRBgetintattr = nullptr
 
std::function< int(GRBmodel *model, const char *attrname, int newvalue)> GRBsetintattr = nullptr
 
std::function< int(GRBmodel *model, const char *attrname, int element, int *valueP)> GRBgetintattrelement = nullptr
 
std::function< int(GRBmodel *model, const char *attrname, int element, int newvalue)> GRBsetintattrelement = nullptr
 
std::function< int(GRBmodel *model, const char *attrname, int first, int len, int *values)> GRBgetintattrarray = nullptr
 
std::function< int(GRBmodel *model, const char *attrname, int first, int len, int *newvalues)> GRBsetintattrarray = nullptr
 
std::function< int(GRBmodel *model, const char *attrname, int len, int *ind, int *newvalues)> GRBsetintattrlist = nullptr
 
std::function< int(GRBmodel *model, const char *attrname, int element, char *valueP)> GRBgetcharattrelement = nullptr
 
std::function< int(GRBmodel *model, const char *attrname, int element, char newvalue)> GRBsetcharattrelement = nullptr
 
std::function< int(GRBmodel *model, const char *attrname, int first, int len, char *values)> GRBgetcharattrarray = nullptr
 
std::function< int(GRBmodel *model, const char *attrname, int first, int len, char *newvalues)> GRBsetcharattrarray = nullptr
 
std::function< int(GRBmodel *model, const char *attrname, int len, int *ind, char *newvalues)> GRBsetcharattrlist = nullptr
 
std::function< int(GRBmodel *model, const char *attrname, double *valueP)> GRBgetdblattr = nullptr
 
std::function< int(GRBmodel *model, const char *attrname, double newvalue)> GRBsetdblattr = nullptr
 
std::function< int(GRBmodel *model, const char *attrname, int element, double *valueP)> GRBgetdblattrelement = nullptr
 
std::function< int(GRBmodel *model, const char *attrname, int element, double newvalue)> GRBsetdblattrelement = nullptr
 
std::function< int(GRBmodel *model, const char *attrname, int first, int len, double *values)> GRBgetdblattrarray = nullptr
 
std::function< int(GRBmodel *model, const char *attrname, int first, int len, double *newvalues)> GRBsetdblattrarray = nullptr
 
std::function< int(GRBmodel *model, const char *attrname, int len, int *ind, double *newvalues)> GRBsetdblattrlist = nullptr
 
std::function< int(GRBmodel *model, const char *attrname, char **valueP)> GRBgetstrattr = nullptr
 
std::function< int(GRBmodel *model, const char *attrname, const char *newvalue)> GRBsetstrattr = nullptr
 
std::function< int(GRBmodel *model, int(GUROBI_STDCALL *cb)(CB_ARGS), void *usrdata)> GRBsetcallbackfunc = nullptr
 
std::function< int(void *cbdata, int where, int what, void *resultP)> GRBcbget
 
std::function< int(void *cbdata, const double *solution, double *objvalP)> GRBcbsolution = nullptr
 
std::function< int(void *cbdata, int cutlen, const int *cutind, const double *cutval, char cutsense, double cutrhs)> GRBcbcut = nullptr
 
std::function< int(void *cbdata, int lazylen, const int *lazyind, const double *lazyval, char lazysense, double lazyrhs)> GRBcblazy = nullptr
 
std::function< int(GRBmodel *model, int *numnzP, int *vbeg, int *vind, double *vval, int start, int len)> GRBgetvars = nullptr
 
std::function< int(GRBmodel *model)> GRBoptimize = nullptr
 
std::function< int(GRBmodel *model)> GRBcomputeIIS = nullptr
 
std::function< int(GRBmodel *model, const char *filename)> GRBwrite = nullptr
 
std::function< int(GRBenv *env, GRBmodel **modelP, const char *Pname, int numvars, double *obj, double *lb, double *ub, char *vtype, char **varnames)> GRBnewmodel = nullptr
 
std::function< int(GRBmodel *model, int numnz, int *vind, double *vval, double obj, double lb, double ub, char vtype, const char *varname)> GRBaddvar = nullptr
 
std::function< int(GRBmodel *model, int numvars, int numnz, int *vbeg, int *vind, double *vval, double *obj, double *lb, double *ub, char *vtype, char **varnames)> GRBaddvars = nullptr
 
std::function< int(GRBmodel *model, int numnz, int *cind, double *cval, char sense, double rhs, const char *constrname)> GRBaddconstr = nullptr
 
std::function< int(GRBmodel *model, int numconstrs, int numnz, int *cbeg, int *cind, double *cval, char *sense, double *rhs, char **constrnames)> GRBaddconstrs = nullptr
 
std::function< int(GRBmodel *model, int numnz, int *cind, double *cval, double lower, double upper, const char *constrname)> GRBaddrangeconstr = nullptr
 
std::function< int(GRBmodel *model, int numsos, int nummembers, int *types, int *beg, int *ind, double *weight)> GRBaddsos = nullptr
 
std::function< int(GRBmodel *model, const char *name, int resvar, int nvars, const int *vars, double constant)> GRBaddgenconstrMax = nullptr
 
std::function< int(GRBmodel *model, const char *name, int resvar, int nvars, const int *vars, double constant)> GRBaddgenconstrMin = nullptr
 
std::function< int(GRBmodel *model, const char *name, int resvar, int argvar)> GRBaddgenconstrAbs = nullptr
 
std::function< int(GRBmodel *model, const char *name, int resvar, int nvars, const int *vars)> GRBaddgenconstrAnd = nullptr
 
std::function< int(GRBmodel *model, const char *name, int resvar, int nvars, const int *vars)> GRBaddgenconstrOr = nullptr
 
std::function< int(GRBmodel *model, const char *name, int binvar, int binval, int nvars, const int *vars, const double *vals, char sense, double rhs)> GRBaddgenconstrIndicator = nullptr
 
std::function< int(GRBmodel *model, int numlnz, int *lind, double *lval, int numqnz, int *qrow, int *qcol, double *qval, char sense, double rhs, const char *QCname)> GRBaddqconstr = nullptr
 
std::function< int(GRBmodel *model, int numqnz, int *qrow, int *qcol, double *qval)> GRBaddqpterms = nullptr
 
std::function< int(GRBmodel *model, int len, int *ind)> GRBdelvars = nullptr
 
std::function< int(GRBmodel *model, int len, int *ind)> GRBdelconstrs = nullptr
 
std::function< int(GRBmodel *model, int len, int *ind)> GRBdelsos = nullptr
 
std::function< int(GRBmodel *model, int len, int *ind)> GRBdelgenconstrs
 
std::function< int(GRBmodel *model, int len, int *ind)> GRBdelqconstrs = nullptr
 
std::function< int(GRBmodel *model)> GRBdelq = nullptr
 
std::function< int(GRBmodel *model, int cnt, int *cind, int *vind, double *val)> GRBchgcoeffs = nullptr
 
std::function< int(GRBmodel *model)> GRBupdatemodel = nullptr
 
std::function< int(GRBmodel *model)> GRBfreemodel = nullptr
 
std::function< void(GRBmodel *model)> GRBterminate = nullptr
 
std::function< int(GRBmodel *model, int index, int priority, double weight, double abstol, double reltol, const char *name, double constant, int lnz, int *lind, double *lval)> GRBsetobjectiven = nullptr
 
std::function< int(GRBenv *env, const char *paramname, int *valueP)> GRBgetintparam = nullptr
 
std::function< int(GRBenv *env, const char *paramname, double *valueP)> GRBgetdblparam = nullptr
 
std::function< int(GRBenv *env, const char *paramname, char *valueP)> GRBgetstrparam = nullptr
 
std::function< int(GRBenv *env, const char *paramname, int *valueP, int *minP, int *maxP, int *defP)> GRBgetintparaminfo = nullptr
 
std::function< int(GRBenv *env, const char *paramname, double *valueP, double *minP, double *maxP, double *defP)> GRBgetdblparaminfo = nullptr
 
std::function< int(GRBenv *env, const char *paramname, char *valueP, char *defP)> GRBgetstrparaminfo = nullptr
 
std::function< int(GRBenv *env, const char *paramname)> GRBgetparamtype
 
std::function< int(GRBenv *env, int i, char **paramnameP)> GRBgetparamname
 
std::function< int(GRBenv *env, const char *paramname, const char *value)> GRBsetparam = nullptr
 
std::function< int(GRBenv *env, const char *paramname, int value)> GRBsetintparam = nullptr
 
std::function< int(GRBenv *env, const char *paramname, double value)> GRBsetdblparam = nullptr
 
std::function< int(GRBenv *env, const char *paramname, const char *value)> GRBsetstrparam = nullptr
 
std::function< int(GRBenv *env)> GRBresetparams = nullptr
 
std::function< int(GRBenv *dest, GRBenv *src)> GRBcopyparams = nullptr
 
std::function< int(GRBenv *env)> GRBgetnumparams = nullptr
 
std::function< int(GRBenv **envP)> GRBemptyenv = nullptr
 
std::function< int(GRBenv **envP, const char *logfilename)> GRBloadenv = nullptr
 
std::function< int(GRBenv *env)> GRBstartenv = nullptr
 
std::function< GRBenv *(GRBmodel *model)> GRBgetenv = nullptr
 
std::function< void(GRBenv *env)> GRBfreeenv = nullptr
 
std::function< const char *(GRBenv *env)> GRBgeterrormsg = nullptr
 
std::function< void(int *majorP, int *minorP, int *technicalP)> GRBversion
 
std::function< char *(void)> GRBplatform = nullptr
 
constexpr NamedOptimizationProblemType kOptimizationProblemTypeNames []
 
constexpr double kDefaultPrimalTolerance = 1e-07
 
static const uint64_t kAllBits64 = uint64_t{0xFFFFFFFFFFFFFFFF}
 Basic bit operations.
 
static const uint64_t kAllBitsButLsb64 = uint64_t{0xFFFFFFFFFFFFFFFE}
 
static const uint32_t kAllBits32 = 0xFFFFFFFFU
 
ABSL_CONST_INIT const bool kStdToCharsDoubleIsSupported
 
constexpr double kRoundTripTestNumber = 0.10000000000000002
 
constexpr absl::string_view kRoundTripTestNumberStr
 
constexpr bool kAsanEnabled = false
 
constexpr bool kMsanEnabled = false
 
constexpr bool kTsanEnabled = false
 
constexpr bool kAnyXsanEnabled
 
std::function< int(XPRSprob *p_prob)> XPRScreateprob = nullptr
 This is the 'define' section.
 
std::function< int(XPRSprob prob)> XPRSdestroyprob = nullptr
 
std::function< int(const char *path)> XPRSinit = nullptr
 
std::function< int(void)> XPRSfree = nullptr
 
std::function< int(char *buffer, int maxbytes)> XPRSgetlicerrmsg = nullptr
 
std::function< int(int *p_i, char *p_c)> XPRSlicense = nullptr
 
std::function< int(char *banner)> XPRSgetbanner = nullptr
 
std::function< int(char *version)> XPRSgetversion = nullptr
 
std::function< int(XPRSprob prob, int control)> XPRSsetdefaultcontrol = nullptr
 
std::function< int(XPRSprob prob, int reason)> XPRSinterrupt = nullptr
 
std::function< int(XPRSprob prob, int control, int value)> XPRSsetintcontrol = nullptr
 
std::function< int(XPRSprob prob, int control, XPRSint64 value)> XPRSsetintcontrol64 = nullptr
 
std::function< int(XPRSprob prob, int control, double value)> XPRSsetdblcontrol = nullptr
 
std::function< int(XPRSprob prob, int control, const char *value)> XPRSsetstrcontrol = nullptr
 
std::function< int(XPRSprob prob, int control, int *p_value)> XPRSgetintcontrol = nullptr
 
std::function< int(XPRSprob prob, int control, XPRSint64 *p_value)> XPRSgetintcontrol64 = nullptr
 
std::function< int(XPRSprob prob, int control, double *p_value)> XPRSgetdblcontrol = nullptr
 
std::function< int(XPRSprob prob, int control, char *value, int maxbytes, int *p_nbytes)> XPRSgetstringcontrol = nullptr
 
std::function< int(XPRSprob prob, int attrib, int *p_value)> XPRSgetintattrib = nullptr
 
std::function< int(XPRSprob prob, int attrib, double *p_value)> XPRSgetdblattrib = nullptr
 
std::function< int(XPRSprob prob, const char *name, int *p_id, int *p_type)> XPRSgetcontrolinfo = nullptr
 
std::function< int(XPRSprob prob, const char *probname, int ncols, int nrows, const char rowtype[], const double rhs[], const double rng[], const double objcoef[], const int start[], const int collen[], const int rowind[], const double rowcoef[], const double lb[], const double ub[])> XPRSloadlp = nullptr
 
std::function< int(XPRSprob prob, const char *probname, int ncols, int nrows, const char rowtype[], const double rhs[], const double rng[], const double objcoef[], const XPRSint64 start[], const int collen[], const int rowind[], const double rowcoef[], const double lb[], const double ub[])> XPRSloadlp64 = nullptr
 
std::function< int(XPRSprob prob, double objcoef[], int first, int last)> XPRSgetobj = nullptr
 
std::function< int(XPRSprob prob, double rhs[], int first, int last)> XPRSgetrhs = nullptr
 
std::function< int(XPRSprob prob, double rng[], int first, int last)> XPRSgetrhsrange = nullptr
 
std::function< int(XPRSprob prob, double lb[], int first, int last)> XPRSgetlb = nullptr
 
std::function< int(XPRSprob prob, double ub[], int first, int last)> XPRSgetub = nullptr
 
std::function< int(XPRSprob prob, int row, int col, double *p_coef)> XPRSgetcoef = nullptr
 
std::function< int(XPRSprob prob, int nrows, int ncoefs, const char rowtype[], const double rhs[], const double rng[], const int start[], const int colind[], const double rowcoef[])> XPRSaddrows = nullptr
 
std::function< int(XPRSprob prob, int nrows, const int rowind[])> XPRSdelrows = nullptr
 
std::function< int(XPRSprob prob, int ncols, int ncoefs, const double objcoef[], const int start[], const int rowind[], const double rowcoef[], const double lb[], const double ub[])> XPRSaddcols = nullptr
 
std::function< int(XPRSprob prob, int type, const char names[], int first, int last)> XPRSaddnames = nullptr
 
std::function< int(XPRSprob prob, int type, char names[], int first, int last)> XPRSgetnames = nullptr
 
std::function< int(XPRSprob prob, int ncols, const int colind[])> XPRSdelcols = nullptr
 
std::function< int(XPRSprob prob, int ncols, const int colind[], const char coltype[])> XPRSchgcoltype = nullptr
 
std::function< int(XPRSprob prob, const int rowstat[], const int colstat[])> XPRSloadbasis = nullptr
 
std::function< int(XPRSprob prob)> XPRSpostsolve = nullptr
 
std::function< int(XPRSprob prob, int objsense)> XPRSchgobjsense = nullptr
 
std::function< int(XPRSprob prob, char *errmsg)> XPRSgetlasterror = nullptr
 
std::function< int(XPRSprob prob, int rowstat[], int colstat[])> XPRSgetbasis = nullptr
 
std::function< int(XPRSprob prob, const char *filename, const char *flags)> XPRSwriteprob = nullptr
 
std::function< int(XPRSprob prob, char rowtype[], int first, int last)> XPRSgetrowtype = nullptr
 
std::function< int(XPRSprob prob, char coltype[], int first, int last)> XPRSgetcoltype = nullptr
 
std::function< int(XPRSprob prob, int nbounds, const int colind[], const char bndtype[], const double bndval[])> XPRSchgbounds = nullptr
 
std::function< int(XPRSprob prob, int length, const double solval[], const int colind[], const char *name)> XPRSaddmipsol = nullptr
 
std::function< int(XPRSprob prob, double x[], double slack[], double duals[], double djs[])> XPRSgetlpsol = nullptr
 
std::function< int(XPRSprob prob, double x[], double slack[])> XPRSgetmipsol = nullptr
 
std::function< int(XPRSprob prob, int ncols, const int colind[], const double objcoef[])> XPRSchgobj = nullptr
 
std::function< int(XPRSprob prob, int row, int col, double coef)> XPRSchgcoef = nullptr
 
std::function< int(XPRSprob prob, int ncoefs, const int rowind[], const int colind[], const double rowcoef[])> XPRSchgmcoef = nullptr
 
std::function< int(XPRSprob prob, int nrows, const int rowind[], const double rhs[])> XPRSchgrhs = nullptr
 
std::function< int(XPRSprob prob, int nrows, const int rowind[], const double rng[])> XPRSchgrhsrange = nullptr
 
std::function< int(XPRSprob prob, int nrows, const int rowind[], const char rowtype[])> XPRSchgrowtype = nullptr
 
std::function< int(XPRSprob prob, void(XPRS_CC *f_intsol)(XPRSprob cbprob, void *cbdata), void *p, int priority)> XPRSaddcbintsol = nullptr
 
std::function< int(XPRSprob prob, void(XPRS_CC *f_intsol)(XPRSprob cbprob, void *cbdata), void *p)> XPRSremovecbintsol = nullptr
 
std::function< int(XPRSprob prob, void(XPRS_CC *f_message)(XPRSprob cbprob, void *cbdata, const char *msg, int msglen, int msgtype), void *p, int priority)> XPRSaddcbmessage = nullptr
 
std::function< int(XPRSprob prob, const char *flags)> XPRSlpoptimize = nullptr
 
std::function< int(XPRSprob prob, const char *flags)> XPRSmipoptimize = nullptr
 

Detailed Description

In SWIG mode, we don't want anything besides these top-level includes.

Initial version of this code was provided by RTE.

Reversible (i.e Backtrackable) classes, used to simplify coding propagators.

Defines the random engine type to use within operations_research code.

Needed before fenv_access. See https://github.com/microsoft/STL/issues/2613.

Various utility functions on bitsets.

Basic types and classes used by the sat solver.

Utility functions to interact with an lp solver from the SAT context.

Common utilities for parsing routing instances.

An object oriented wrapper for linear constraints in ModelStorage.

Basic utility functions on Fractional or row/column of Fractional.

Common types and constants used by the Linear Programming solver.

Utilities to display linear expression in a human-readable way.

Heuristics.

Formatting functions for GLPK constants.

--— activity a before activity b or activity b before activity a --—

--— interval <binary relation> interval --—

This file implements the table constraints.

--— Constant Restart --—

-------— Restart -------—

-------— NestedOptimize -------—

-------— SolveOnce -------—

A limit whose Check function is the OR of two underlying limits.

-------— Guided Local Search -------—

-------— Simulated Annealing -------—

-------— Metaheuristics ------—

--— All Solution Collector --—

--— N Best Solution Collector --—

--— Best Solution Collector --—

--— Last Solution Collector --—

--— AssignAllVariablesFromAssignment decision builder --—

--— AssignAllVariables --—

--— AssignVariablesValues decision --—

--— AssignOneVariableValue decision --—

--— AssignOneVariableValueOrDoNothing decision --—

--— AssignOneVariableValueOrFail decision --—

-------— Variable Assignments -------—

-------— Try Decision Builder -------—

-------— ClosureDecision ------—

-------— Compose Decision Builder -------—

-------— Composite Decision Builder -----—

-------— Callback-based search monitors -------—

--— Decisions and DecisionBuilders on interval vars --—

AllUnperformed.

ResourceGroup.

Trace settings.

Range constraints.

--— Dimension --—

Packing constraints.

--— Concatenation of operators --—

Increments the current value of variables.

--— Move Toward Target Local Search operator --—

--— Path cumul constraints --—

--— Int Var and associated methods --—

--— IsMemberCt --—

-------— Member -------—

--— is_between_cst Constraint --—

--— BetweenCt --—

--— is_lesser_equal_cst Constraint --—

--— is_greater_equal_cst Constraint --—

--— is_diff_cst Constraint --—

--— is_equal_cst Constraint --—

Different constraints.

Less or equal constraint.

Greater or equal constraint.

Array Expression constraints.

--— IntExprEvaluatorElementCt --—

--— IntIntExprFunctionElement --—

--— IntExprFunctionElement --—

Count constraints.

---------------— Solver class --------------—

-------— Trail and Reversibility -------—

--— Storing and Restoring assignments --—

AllDifferent constraints.

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.

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.

Todo
(user): refine this toplevel comment when this file settles.

Two dynamic partition classes: one that incrementally splits a partition into more and more parts; one that incrementally merges a partition into less and less parts.

GLOSSARY: The partition classes maintain a partition of N integers 0..N-1 (aka "elements") into disjoint equivalence classes (aka "parts").

SAFETY: Like vector<int> crashes when used improperly, these classes are not "safe": most of their methods may crash if called with invalid arguments. The client code is responsible for using this class properly. A few DCHECKs() will help catch bugs, though.

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. This class solves the graph automorphism problem (https://en.wikipedia.org/wiki/Graph_automorphism), a variant of the famous graph isomorphism problem (https://en.wikipedia.org/wiki/Graph_isomorphism).

The algorithm is largely based on the following article, published in 2008: "Faster Symmetry Discovery using Sparsity of Symmetries" by Darga, Sakallah and Markov. http://web.eecs.umich.edu/~imarkov/pubs/conf/dac08-sym.pdf.

See the comments on the class below for more details.

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. IMPORTANT NOTE: we advise using the code in graph/linear_assignment.h whose complexity is usually much smaller.

Todo
(user): base this code on LinearSumAssignment.

For each of the four functions declared in this file, in case the input parameter 'cost' contains NaN, the function will return without invoking the Hungarian algorithm, and the output parameters 'direct_assignment' and 'reverse_assignment' will be left unchanged. An O(n^4) implementation of the Kuhn-Munkres algorithm (a.k.a. the Hungarian algorithm) for solving the assignment problem. The assignment problem takes a set of agents, a set of tasks and a cost associated with assigning each agent to each task and produces an optimal (i.e., least cost) assignment of agents to tasks. The code also enables computing a maximum assignment by changing the input matrix.

This code is based on (read: translated from) the Java version (read: translated from) the Python version at http://www.clapper.org/software/python/munkres/.

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. This can be MUCH faster than std::sort() on numerical arrays (int32_t, float, int64_t, double, ..), when the size is ≥8k: ~10x faster on int32_t or float data ~3-5x faster on int64_t or double data

Unlike std::sort(), it uses extra, temporary buffers: the radix/count-sort counters, and a copy of the data, i.e. between 1x and 2x your input size.

RadixSort() falls back to std::sort() for small sizes, so that you get the best performance in any case.

CAVEAT: std::sort() is very fast when the array is almost-sorted, or almost reverse-sorted: in this case, RadixSort() can easily be much slower. But the worst-case performance of RadixSort() is much faster than the worst-case performance of std::sort(). To be sure, you should benchmark your use case.

Todo
: it could be even faster than that when the values are in [0..N) for a known value N that's significantly lower than the max integer value.

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. Representation class for the weighted set-covering problem.

Let E be a "universe" set, let (S_j) be a family (j in J) of subsets of E, and c_j costs associated to each S_j. Note that J = {j in 1..S}.

The minimum-cost set-covering problem consists in finding K (for covering), a subset of J such that the union of all the S_j for k in K is equal to E (the subsets indexed by K "cover" E), while minimizing total cost sum c_k (k in K).

In Mixed-Integer Programming and matrix terms, the goal is to find values of binary variables x_j, where x_j is 1 when subset S_j is in K, 0 otherwise, that minimize the sum of c_j * x_j subject to M.x >= 1. Each row corresponds to an element in E.

The matrix M for linear constraints is defined as follows:

  • it has as many rows as there are elements in E.
  • its columns are such that M(i, j) = 1 iff the i-th element of E is present in S_j.

We alse use m to denote E, the number of elements, and n to denote S, the number of subsets. Finally, nnz or #nz denotes the numbers of non-zeros, i.e. the sum of the cardinalities of all the subsets.

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. Architecture-neutral plug compatible replacements for strtol() friends. See strtoint.h for details on how to use this component.

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. Architecture-neutral plug compatible replacements for strtol() friends.

Long's have different lengths on ILP-32 and LP-64 platforms, and so overflow behavior across the two varies when strtol() and similar are used to parse 32-bit integers. Similar problems exist with atoi(), because although it has an all-integer interface, it uses strtol() internally, and so suffers from the same narrowing problems on assignments to int.

Examples: errno = 0; i = strtol("3147483647", nullptr, 10); printf("%d, errno %d\n", i, errno); ///< 32-bit platform: 2147483647, errno 34 ///< 64-bit platform: -1147483649, errno 0

printf("%d\n", atoi("3147483647")); ///< 32-bit platform: 2147483647 ///< 64-bit platform: -1147483649

A way round this is to define local replacements for these, and use them instead of the standard libc functions.

In most 32-bit cases the replacements can be inlined away to a call to the libc function. In a couple of 64-bit cases, however, adapters are required, to provide the right overflow and errno behavior.

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. ref: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/lib/gtl/top_n.h This simple class finds the top n elements of an incrementally provided set of elements which you push one at a time. If the number of elements exceeds n, the lowest elements are incrementally dropped. At the end you get a vector of the top elements sorted in descending order (through Extract() or ExtractNondestructive()), or a vector of the top elements but not sorted (through ExtractUnsorted() or ExtractUnsortedNondestructive()).

The value n is specified in the constructor. If there are p elements pushed altogether: The total storage requirements are O(min(n, p)) elements The running time is O(p * log(min(n, p))) comparisons If n is a constant, the total storage required is a constant and the running time is linear in p.

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. This file defines the needed classes to efficiently perform Local Search in Bop. Local Search is a technique used to locally improve an existing solution by flipping a limited number of variables. To be successful the produced solution has to satisfy all constraints of the problem and improve the objective cost.

The class BopLocalSearchOptimizer is the only public interface for Local Search in Bop. For unit-testing purposes this file also contains the four internal classes AssignmentAndConstraintFeasibilityMaintainer, OneFlipConstraintRepairer, SatWrapper and LocalSearchAssignmentIterator. They are implementation details and should not be used outside of bop_ls.

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. Solver for Boolean Optimization Problems built on top of the SAT solver. To optimize a problem the solver uses several optimization strategies like Local Search (LS), Large Neighborhood Search (LNS), and Linear Programming (LP). See bop_parameters.proto to tune the strategies.

Note
the BopSolver usage is limited to:
  • Boolean variables,
  • Linear constraints and linear optimization objective,
  • Integral weights for both constraints and objective,
  • Minimization. To deal with maximization, integral variables and floating weights, one can use the bop::IntegralSolver.

Usage example: const LinearBooleanProblem problem = BuildProblem(); BopSolver bop_solver(problem); BopParameters bop_parameters; bop_parameters.set_max_deterministic_time(10); bop_solver.SetParameters(bop_parameters); const BopSolveStatus solve_status = bop_solver.Solve(); if (solve_status == BopSolveStatus::OPTIMAL_SOLUTION_FOUND) { ... }

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. This file contains some BopOptimizerBase implementations that are "complete" solvers. That is, they work on the full problem, and can solve the problem (and prove optimality) by themselves. Moreover, they can be run for short period of time and resumed later from the state they where left off.

The idea is that it is worthwhile spending some time in these algorithms, because in some situation they can improve the current upper/lower bound or even solve the problem to optimality.

Note(user): The GuidedSatFirstSolutionGenerator can also be used as a complete SAT solver provided that we keep running it after it has found a first solution. This is the default behavior of the kNotGuided policy.

These magic numbers are there to make sure we pop the correct sentinels throughout the search.

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. Collection of objects used to extend the Constraint Solver library. This file contains a set of objects that simplifies writing extensions of the library. The main objects that define extensions are:

This constraint implements evaluator(index) == var. It is delayed such that propagation only occurs when all variables have been touched. The range of the evaluator is [range_start, range_end).

--— Member(IntVar, IntSet) --—

Constraint enforcing that status[i] is true iff there's a path defined on next variables from sources[i] to sinks[i].

A local search operator that compares the current assignment with a target one, and that generates neighbors corresponding to a single variable being changed from its current value to its target value.

--— Sum Objective filter ---— Maintains the sum of costs of variables, where the subclass implements CostOfSynchronizedVariable() and FillCostOfBoundDeltaVariable() to compute the cost of a variable depending on its value. An assignment is accepted by this filter if the total cost is allowed depending on the relation defined by filter_enum:

--— Class Dimension Less Than Constant --—

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. This file contains implementations of several resource constraints. The implemented constraints are:

  • Disjunctive: forces a set of intervals to be non-overlapping
  • Cumulative: forces a set of intervals with associated demands to be such that the sum of demands of the intervals containing any given integer does not exceed a capacity. In addition, it implements the SequenceVar that allows ranking decisions on a set of interval variables.

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. Implementation of all classes related to routing and search. This includes decision builders, local search neighborhood operators and local search filters.

Todo
(user): Move all existing routing search code here.

Sweep heuristic

Todo
(user): Clean up to match other first solution strategies.

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. This file contains implementations of several scheduling constraints. The implemented constraints are:

  • Cover constraints: ensure that an interval is the convex hull of a set of interval variables. This includes the performed status (one interval performed implies the cover var performed, all intervals unperformed implies the cover var unperformed, cover var unperformed implies all intervals unperformed, cover var performed implis at least one interval performed).

    Todo

    (user) : treat optional intervals

    (user) : Call DecisionVisitor and pass name of variable

--— BaseAssignmentSelector --—

Collect last solution, useful when optimizing

collect all solutions

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. Struct and utility functions used by the code in parser.yy Included in parser.tab.hh.

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. LU decomposition algorithm of a sparse matrix B with Markowitz pivot selection strategy. The algorithm constructs a lower matrix L, upper matrix U, row permutation P and a column permutation Q such that L.U = P.B.Q^{-1}.

The current algorithm is a mix of ideas that can be found in the literature and of some optimizations tailored for its use in a revised simplex algorithm (like a fast processing of the singleton columns present in B). It constructs L and U column by column from left to right.

A key concept is the one of the residual matrix which is the bottom right square submatrix that still needs to be factorized during the classical Gaussian elimination. The algorithm maintains the non-zero pattern of its rows and its row/column degrees.

At each step, a number of columns equal to 'markowitz_zlatev_parameter' are chosen as candidates from the residual matrix. They are the ones with minimal residual column degree. They can be found easily because the columns of the residual matrix are kept in a priority queue.

We compute the numerical value of these residual columns like in a left-looking algorithm by solving a sparse lower-triangular system with the current L constructed so far. Note that this step is highly optimized for sparsity and we reuse the computations done in the previous steps (if the candidate column was already considered before). As a by-product, we also get the corresponding column of U.

Among the entries of these columns, a pivot is chosen such that the product: (num_column_entries - 1) * (num_row_entries - 1) is minimized. Only the pivots with a magnitude greater than 'lu_factorization_pivot_threshold' times the maximum magnitude of the corresponding residual column are considered for stability reasons.

Once the pivot is chosen, the residual column divided by the pivot becomes a column of L, and the non-zero pattern of the new residual submatrix is updated by subtracting the outer product of this pivot column times the pivot row. The product minimized above is thus an upper bound of the number of fill-in created during a step.

References:

J. R. Gilbert and T. Peierls, "Sparse partial pivoting in time proportional to arithmetic operations," SIAM J. Sci. Statist. Comput., 9 (1988): 862-874.

I.S. Duff, A.M. Erisman and J.K. Reid, "Direct Methods for Sparse Matrices", Clarendon, Oxford, UK, 1987, ISBN 0-19-853421-3, http://www.amazon.com/dp/0198534213

T.A. Davis, "Direct methods for Sparse Linear Systems", SIAM, Philadelphia, 2006, ISBN-13: 978-0-898716-13, http://www.amazon.com/dp/0898716136

Todo
(user): Determine whether any of these would bring any benefit:
  • S.C. Eisenstat and J.W.H. Liu, "The theory of elimination trees for sparse unsymmetric matrices," SIAM J. Matrix Anal. Appl., 26:686-705, January 2005
  • S.C. Eisenstat and J.W.H. Liu. "Algorithmic aspects of elimination trees for sparse unsymmetric matrices," SIAM J. Matrix Anal. Appl., 29:1363-1381, January 2008.
  • http://perso.ens-lyon.fr/~bucar/papers/kauc.pdf

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. This file contains the presolving code for a LinearProgram.

A classical reference is: E. D. Andersen, K. D. Andersen, "Presolving in linear programming.", Mathematical Programming 71 (1995) 221-245.

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. Solves a Linear Programming problem using the Revised Simplex algorithm as described by G.B. Dantzig. The general form is: min c.x where c and x are n-vectors, subject to Ax = b where A is an mxn-matrix, b an m-vector, with l <= x <= u, i.e. l_i <= x_i <= u_i for all i in {1 .. m}.

c.x is called the objective function. Each row a_i of A is an n-vector, and a_i.x = b_i is a linear constraint. A is called the constraint matrix. b is called the right hand side (rhs) of the problem. The constraints l_i <= x_i <= u_i are called the generalized bounds of the problem (most introductory textbooks only deal with x_i >= 0, as did the first version of the Simplex algorithm). Note that l_i and u_i can be -infinity and +infinity, respectively.

To simplify the entry of data, this code actually handles problems in the form: min c.x where c and x are n-vectors, subject to: A1 x <= b1 A2 x >= b2 A3 x = b3 l <= x <= u

It transforms the above problem into min c.x where c and x are n-vectors, subject to: A1 x + s1 = b1 A2 x - s2 = b2 A3 x = b3 l <= x <= u s1 >= 0, s2 >= 0 where xT = (x1, x2, x3), s1 is an m1-vector (m1 being the height of A1), s2 is an m2-vector (m2 being the height of A2).

The following are very good references for terminology, data structures, and algorithms. They all contain a wealth of references.

Vasek Chvátal, "Linear Programming," W.H. Freeman, 1983. ISBN 978-0716715870. http://www.amazon.com/dp/0716715872

Robert J. Vanderbei, "Linear Programming: Foundations and Extensions," Springer, 2010, ISBN-13: 978-1441944979 http://www.amazon.com/dp/1441944974

Istvan Maros, "Computational Techniques of the Simplex Method.", Springer, 2002, ISBN 978-1402073328 http://www.amazon.com/dp/1402073321 Short description of the dual simplex algorithm.

The dual simplex algorithm uses the same data structure as the primal, but progresses towards the optimal solution in a different way:

  • It tries to keep the dual values dual-feasible at all time which means that the reduced costs are of the correct sign depending on the bounds of the non-basic variables. As a consequence the values of the basic variable are out of bound until the optimal is reached.
  • A basic leaving variable is selected first (dual pricing) and then a corresponding entering variable is selected. This is done in such a way that the dual objective value increases (lower bound on the optimal solution).
  • Once the basis pivot is chosen, the variable values and the reduced costs are updated the same way as in the primal algorithm.

Good references on the Dual simplex algorithm are:

Robert Fourer, "Notes on the Dual simplex Method", March 14, 1994. http://users.iems.northwestern.edu/~4er/WRITINGS/dual.pdf

Achim Koberstein, "The dual simplex method, techniques for a fast and stable implementation", PhD, Paderborn, Univ., 2005. http://digital.ub.uni-paderborn.de/hs/download/pdf/3885?originalFilename=true

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. This headers defines APIs that wrap GLPK APIs for indices of variables from the computational form.

In GLPK (for details see glpk-5.0/doc/glpk.pdf available from glpk-5.0.tar.gz) the general form of the problem is:

min (or max) z = c^T x_S + c_0 s.t. x_R = A x_S l_R <= x_R <= u_R l_S <= x_S <= u_S

where: x_S are the structural variables x_R are the auxiliary variables used to define constraints

This is this form that is used by most GLPK's APIs.

But to implement the simplex algorithms, GLPK uses the following computational form:

min (or max) z = (0 | c)^T x + c_0 s.t. (I | -A) x = 0 l <= x <= u

where: x = (x_R | x_S)

That is it merges the auxiliary and structural variables in a single set of variables.

The dual of this problem is, when the primal is a minimization:

max Z = l^T λ_l + u^T λ_u s.t. (I | -A)^T π + λ_l + λ_u = (O | c)^T λ_l >= 0, λ_u <= 0

and if the primal is a maximization:

min Z = l^T λ_l + u^T λ_u s.t. (I | -A)^T π + λ_l + λ_u = (O | c)^T λ_l <= 0, λ_u >= 0

There is a reduced cost λ_k for each variable x_k:

λ = λ_l + λ_u

This header contains basic adapter functions that takes the index of a variable x in the computational form and use the corresponding API for either x_R or x_S (a.k.a. primal values) and for the corresponding reduced costs λ (a.k.a. dual values).

This logic is usually necessary when using advanced APIs that deal with indices in the computational form.

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. Simple interface to solve the linear sum assignment problem. It uses about twice as much memory as directly using the LinearSumAssignment class template, but it is as fast and presents a simpler interface. This is the class you should use in most situations.

The assignment problem: Given N "left" nodes and N "right" nodes, and a set of left->right arcs with integer costs, find a perfect matching (i.e., each "left" node is assigned to one "right" node) that minimizes the overall cost.

Example usage:

#include "ortools/graph/assignment.h"

SimpleLinearSumAssignment assignment; for (int arc = 0; arc < num_arcs; ++arc) { assignment.AddArcWithCost(head(arc), tail(arc), cost(arc)); } if (assignment.Solve() == SimpleLinearSumAssignment::OPTIMAL) { printf("A perfect matching exists.\n"); printf("The best possible cost is %d.\n", assignment.OptimalCost()); printf("An optimal assignment is:\n"); for (int node = 0; node < assignment.NumNodes(); ++node) { printf("left node %d assigned to right node %d with cost %d.\n", node, assignment.RightMate(node), assignment.AssignmentCost(node)); } printf("Note that it may not be the unique optimal assignment."); } else { printf("There is an issue with the input or no perfect matching exists."); }

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. ChristofidesPathSolver computes an approximate solution to the Traveling Salesman Problen using the Christofides algorithm (c.f. https://en.wikipedia.org/wiki/Christofides_algorithm).

Note
the algorithm guarantees finding a solution within 3/2 of the optimum when using minimum weight perfect matching in the matching phase. The complexity of the algorithm is dominated by the complexity of the matching algorithm: O(n^2 * log(n)) if minimal matching is used, or at least O(n^3) or O(nmlog(n)) otherwise, depending on the implementation of the perfect matching algorithm used, where n is the number of nodes and m is the number of edges of the subgraph induced by odd-degree nodes of the minimum spanning tree.

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. Maximal clique algorithms, based on the Bron-Kerbosch algorithm. See http://en.wikipedia.org/wiki/Bron-Kerbosch_algorithm and C. Bron and J. Kerbosch, Joep, "Algorithm 457: finding all cliques of an undirected graph", CACM 16 (9): 575-577, 1973. http://dl.acm.org/citation.cfm?id=362367&bnc=1.

Keywords: undirected graph, clique, clique cover, Bron, Kerbosch.

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. A few variations on a theme of the "star" graph representation by Ebert, as described in J. Ebert, "A versatile data structure for edge-oriented graph algorithms." Communications of the ACM 30(6):513-519 (June 1987). http://portal.acm.org/citation.cfm?id=214769

In this file there are three representations that have much in common. The general one, called simply EbertGraph, contains both forward- and backward-star representations. The other, called ForwardEbertGraph, contains only the forward-star representation of the graph, and is appropriate for applications where the reverse arcs are not needed.

The point of including all the representations in this one file is to capitalize, where possible, on the commonalities among them, and those commonalities are mostly factored out into base classes as described below. Despite the commonalities, however, each of the three representations presents a somewhat different interface because of their different underlying semantics. A quintessential example is that the AddArc() method, very natural for the EbertGraph representation, cannot exist for an inherently static representation like ForwardStaticGraph.

Many clients are expected to use the interfaces to the graph objects directly, but some clients are parameterized by graph type and need a consistent interface for their underlying graph objects. For such clients, a small library of class templates is provided to give a consistent interface to clients where the underlying graph interfaces differ. Examples are the AnnotatedGraphBuildManager<> template, which provides a uniform interface for building the various types of graphs; and the TailArrayManager<> template, which provides a uniform interface for applications that need to map from arc indices to arc tail nodes, accounting for the fact that such a mapping has to be requested explicitly from the ForwardStaticGraph and ForwardStarGraph representations.

There are two base class templates, StarGraphBase, and EbertGraphBase; their purpose is to hold methods and data structures that are in common among their descendants. Only classes that are leaves in the following hierarchy tree are eligible for free-standing instantiation and use by clients. The parentheses around StarGraphBase and EbertGraphBase indicate that they should not normally be instantiated by clients:

In the general EbertGraph case, the graph is represented with three arrays. Let n be the number of nodes and m be the number of arcs. Let i be an integer in [0..m-1], denoting the index of an arc.

  • head_[i] contains the end-node of arc i,
  • head_[-i-1] contains the start-node of arc i.
    Note
    in two's-complement arithmetic, -i-1 = ~i. Consequently:
  • head_[~i] contains the end-node of the arc reverse to arc i,
  • head_[i] contains the start-node of the arc reverse to arc i.
    Note
    if arc (u, v) is defined, then the data structure also stores (v, u). Arc ~i thus denotes the arc reverse to arc i. This is what makes this representation useful for undirected graphs and for implementing algorithms like bidirectional shortest paths. Also note that the representation handles multi-graphs. If several arcs going from node u to node v are added to the graph, they will be handled as separate arcs.
    Now, for an integer u in [0..n-1] denoting the index of a node:
  • first_incident_arc_[u] denotes the first arc in the adjacency list of u.
  • going from an arc i, the adjacency list can be traversed using j = next_adjacent_arc_[i].

The EbertGraph implementation has the following benefits:

  • It is able to handle both directed or undirected graphs.
  • Being based on indices, it is easily serializable. Only the contents of the head_ array need to be stored. Even so, serialization is currently not implemented.
  • The node indices and arc indices can be stored in 32 bits, while still allowing to go a bit further than the 4-gigabyte limitation (48 gigabytes for a pure graph, without capacities or costs.)
  • The representation can be recomputed if edges have been loaded from
  • The representation can be recomputed if edges have been loaded from external memory or if edges have been re-ordered.
  • The memory consumption is: 2 * m * sizeof(NodeIndexType)
    • 2 * m * sizeof(ArcIndexType)
    • n * sizeof(ArcIndexType) plus a small constant.

The EbertGraph implementation differs from the implementation described in [Ebert 1987] in the following respects:

  • arcs are represented using an (i, ~i) approach, whereas Ebert used (i, -i). Indices for direct arcs thus start at 0, in a fashion that is compatible with the index numbering in C and C++. Note that we also tested a (2*i, 2*i+1) storage pattern, which did not show any speed benefit, and made the use of the API much more difficult.
  • because of this, the 'nil' values for nodes and arcs are not 0, as Ebert first described. The value for the 'nil' node is set to -1, while the value for the 'nil' arc is set to the smallest integer representable with ArcIndexSize bytes.
  • it is possible to add arcs to the graph, with AddArc, in a much simpler way than described by Ebert.
  • Todo
    (user) although it is already possible, using the GroupForwardArcsByFunctor method, to group all the outgoing (resp. incoming) arcs of a node, the iterator logic could still be improved to allow traversing the outgoing (resp. incoming) arcs in O(out_degree(node)) (resp. O(in_degree(node))) instead of O(degree(node)).

The ForwardEbertGraph representation is like the EbertGraph case described above, with the following modifications:

  • The part of the head_[] array with negative indices is absent. In its place is a pointer tail_ which, if assigned, points to an array of tail nodes indexed by (nonnegative) arc index. In typical usage tail_ is NULL and the memory for the tail nodes need not be allocated.
  • The array of arc tails can be allocated as needed and populated from the adjacency lists of the graph.
  • Representing only the forward star of each node implies that the graph cannot be serialized directly nor rebuilt from scratch from just the head_ array. Rebuilding from scratch requires constructing the array of arc tails from the adjacency lists first, and serialization can be done either by first constructing the array of arc tails from the adjacency lists, or by serializing directly from the adjacency lists.
  • The memory consumption is: m * sizeof(NodeIndexType)
    • m * sizeof(ArcIndexType)
    • n * sizeof(ArcIndexType) plus a small constant when the array of arc tails is absent. Allocating the arc tail array adds another m * sizeof(NodeIndexType).

The ForwardStaticGraph representation is restricted yet farther than ForwardEbertGraph, with the benefit that it provides higher performance to those applications that can use it.

  • As with ForwardEbertGraph, the presence of the array of arc tails is optional.
  • The outgoing adjacency list for each node is stored in a contiguous segment of the head_[] array, obviating the next_adjacent_arc_ structure entirely and ensuring good locality of reference for applications that iterate over outgoing adjacency lists.
  • The memory consumption is: m * sizeof(NodeIndexType)
    • n * sizeof(ArcIndexType) plus a small constant when the array of arc tails is absent. Allocating the arc tail array adds another m * sizeof(NodeIndexType).

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. Utility to build Eulerian paths and tours on a graph. For more information, see https://en.wikipedia.org/wiki/Eulerian_path. As of 10/2015, only undirected graphs are supported.

Usage:

  • Building an Eulerian tour on a ReverseArcListGraph: ReverseArcListGraph<int, int> graph; ///< Fill graph std::vector<int> tour = BuildEulerianTour(graph);
  • Building an Eulerian path on a ReverseArcListGraph: ReverseArcListGraph<int, int> graph; ///< Fill graph std::vector<int> tour = BuildEulerianPath(graph);

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. Temporary utility class needed as long as we have two slightly different graph interface: The one in ebert_graph.h and the one in graph.h

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. Solves the Shortest Hamiltonian Path Problem using a complete algorithm. The algorithm was first described in M. Held, R.M. Karp, A dynamic programming approach to sequencing problems, J. SIAM 10 (1962) 196-210

The Shortest Hamiltonian Path Problem (SHPP) is similar to the Traveling Salesperson Problem (TSP). You have to visit all the cities, starting from a given one and you do not need to return to your starting point. With the TSP, you can start anywhere, but you have to return to your start location.

By complete we mean that the algorithm guarantees to compute the optimal solution. The algorithm uses dynamic programming. Its time complexity is O(n^2 * 2^(n-1)), where n is the number of nodes to be visited, and '^' denotes exponentiation. Its space complexity is O(n * 2 ^ (n - 1)).

Note
the naive implementation of the SHPP exploring all permutations without memorizing intermediate results would have a complexity of (n - 1)! (factorial of (n - 1) ), which is much higher than n^2 * 2^(n-1). To convince oneself of this, just use Stirling's formula: n! ~ sqrt(2 * pi * n)*( n / exp(1)) ^ n. Because of these complexity figures, the algorithm is not practical for problems with more than 20 nodes.

Here is how the algorithm works: Let us denote the nodes to be visited by their indices 0 .. n - 1 Let us pick 0 as the starting node. Let d(i,j) denote the distance (or cost) from i to j. f(S, j) where S is a set of nodes and j is a node in S is defined as follows: f(S, j) = min (i in S \ {j}, f(S \ {j}, i) + cost(i, j)) (j is an element of S)

Note
this formulation, from the original Held-Karp paper is a bit different, but equivalent to the one used in Caseau and Laburthe, Solving Small TSPs with Constraints, 1997, ICLP f(S, j) = min (i in S, f(S \ {i}, i) + cost(i, j)) (j is not an element of S)

The advantage of the Held and Karp formulation is that it enables:

  • to build the dynamic programming lattice layer by layer starting from the subsets with cardinality 1, and increasing the cardinality.
  • to traverse the dynamic programming lattice using sequential memory accesses, making the algorithm cache-friendly, and faster, despite the large amount of computation needed to get the position when f(S, j) is stored.
  • Todo
    (user): implement pruning procedures on top of the Held-Karp algorithm.

The set S can be represented by an integer where bit i corresponds to element i in the set. In the following S denotes the integer corresponding to set S.

The dynamic programming iteration is implemented in the method Solve. The optimal value of the Hamiltonian path starting at 0 is given by min (i in S, f(2 ^ n - 1, i)) The optimal value of the Traveling Salesman tour is given by f(2 ^ n, 0). (There is actually no need to duplicate the first node, as all the paths are computed from node 0.)

To implement dynamic programming, we store the preceding results of computing f(S,j) in an array M[Offset(S,j)]. See the comments about LatticeMemoryManager::BaseOffset() to see how this is computed.

Keywords: Traveling Salesman, Hamiltonian Path, Dynamic Programming, Held, Karp.

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. Algorithms to compute k-shortest paths. Currently, only Yen's algorithm is implemented.

Todo
(user): implement Lawler's modification: https://pubsonline.informs.org/doi/abs/10.1287/mnsc.18.7.401
Algo. Neg. weights Neg.-weight loops Graph type Loopless paths
Yen No No (Un)directed Yes

Loopless path: path not going through the same node more than once. Also called simple path.

Design choices The design takes some inspiration from shortest_paths.h and bounded_dijkstra.h, but the shortest-path and k-shortest-path problems have vastly different structures. For instance, a path container that only stores distances, like DistanceContainer in shortest_paths.h, is irrelevant as an output for this problem: it can only characterize one path, the shortest one. This is why the results are stored in an intermediate structure, containing the paths (as a sequence of nodes, just like PathContainerImpl subclasses) and their distance.

Only the one-to-one k-shortest-path problem is well-defined. Variants with multiple sources and/or destinations pose representational challenges whose solution is likely to be algorithm-dependent. Optimizations of path storage such as PathTree are not general enough to store k shortest paths: the set of paths for a given index for many sources/destinations is not ensured to form a set for each index. (While the first paths will form such a tree, storing different second paths for each source-destination pair may be impossible to do in a tree.)

Unlike the functions in shortest_paths.h, the functions in this file directly return their result, to follow the current best practices.

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. An implementation of a push-relabel algorithm for the max flow problem.

In the following, we consider a graph G = (V,E,s,t) where V denotes the set of nodes (vertices) in the graph, E denotes the set of arcs (edges). s and t denote distinguished nodes in G called source and target. n = V denotes the number of nodes in the graph, and m = E denotes the number of arcs in the graph.

Each arc (v,w) is associated a capacity c(v,w).

A flow is a function from E to R such that:

a) f(v,w) <= c(v,w) for all (v,w) in E (capacity constraint.)

b) f(v,w) = -f(w,v) for all (v,w) in E (flow antisymmetry constraint.)

c) sum on v f(v,w) = 0 (flow conservation.)

The goal of this algorithm is to find the maximum flow from s to t, i.e. for example to maximize sum v f(s,v).

The starting reference for this class of algorithms is: A.V. Goldberg and R.E. Tarjan. A new approach to the maximum flow problem. ACM Symposium on Theory of Computing, pp. 136-146. http://portal.acm.org/citation.cfm?id=12144.

The basic idea of the algorithm is to handle preflows instead of flows, and to refine preflows until a maximum flow is obtained. A preflow is like a flow, except that the inflow can be larger than the outflow. If it is the case at a given node v, it is said that there is an excess at node v, and inflow = outflow + excess.

More formally, a preflow is a function f such that:

1) f(v,w) <= c(v,w) for all (v,w) in E (capacity constraint). c(v,w) is a value representing the maximum capacity for arc (v,w).

2) f(v,w) = -f(w,v) for all (v,w) in E (flow antisymmetry constraint)

3) excess(v) = sum on u f(u,v) >= 0 is the excess at node v, the algebraic sum of all the incoming preflows at this node.

Each node has an associated "height", in addition to its excess. The height of the source is defined to be equal to n, and cannot change. The height of the target is defined to be zero, and cannot change either. The height of all the other nodes is initialized at zero and is updated during the algorithm (see below). For those who want to know the details, the height of a node, corresponds to a reduced cost, and this enables one to prove that the algorithm actually computes the max flow. Note that the height of a node can be initialized to the distance to the target node in terms of number of nodes. This has not been tried in this implementation.

A node v is said to be active if excess(v) > 0.

In this case the following operations can be applied to it:

  • if there are admissible incident arcs, i.e. arcs which are not saturated, and whose head's height is lower than the height of the active node considered, a PushFlow operation can be applied. It consists in sending as much flow as both the excess at the node and the capacity of the arc permit.
  • if there are no admissible arcs, the active node considered is relabeled, i.e. its height is increased to 1 + the minimum height of its neighboring nodes on admissible arcs. This is implemented in Discharge, which itself calls PushFlow and Relabel.

Before running Discharge, it is necessary to initialize the algorithm with a preflow. This is done in InitializePreflow, which saturates all the arcs leaving the source node, and sets the excess at the heads of those arcs accordingly.

The algorithm terminates when there are no remaining active nodes, i.e. all the excesses at all nodes are equal to zero. In this case, a maximum flow is obtained.

The complexity of this algorithm depends amongst other things on the choice of the next active node. It has been shown, for example in: L. Tuncel, "On the Complexity of Preflow-Push Algorithms for Maximum-Flow Problems", Algorithmica 11(4): 353-359 (1994). and J. Cheriyan and K. Mehlhorn, "An analysis of the highest-level selection rule in the preflow-push max-flow algorithm", Information processing letters, 69(5):239-242 (1999). http://www.math.uwaterloo.ca/~jcheriya/PS_files/me3.0.ps

...that choosing the active node with the highest level yields a complexity of O(n^2 * sqrt(m)).

Todo
(user): implement the above active node choice rule.

This has been validated experimentally in: R.K. Ahuja, M. Kodialam, A.K. Mishra, and J.B. Orlin, "Computational Investigations of Maximum Flow Algorithms", EJOR 97:509-542(1997). http://jorlin.scripts.mit.edu/docs/publications/58-comput%20investigations%20of.pdf.

Todo
(user): an alternative would be to evaluate: A.V. Goldberg, "The Partial Augment-Relabel Algorithm for the Maximum Flow Problem.” In Proceedings of Algorithms ESA, LNCS 5193:466-477, Springer 2008. http://www.springerlink.com/index/5535k2j1mt646338.pdf

An interesting general reference on network flows is: R. K. Ahuja, T. L. Magnanti, J. B. Orlin, "Network Flows: Theory, Algorithms, and Applications," Prentice Hall, 1993, ISBN: 978-0136175490, http://www.amazon.com/dp/013617549X

Keywords: Push-relabel, max-flow, network, graph, Goldberg, Tarjan, Dinic, Dinitz.

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. An implementation of a cost-scaling push-relabel algorithm for the min-cost flow problem.

In the following, we consider a graph G = (V,E) where V denotes the set of nodes (vertices) in the graph, E denotes the set of arcs (edges). n = V denotes the number of nodes in the graph, and m = E denotes the number of arcs in the graph.

With each arc (v,w) is associated a nonnegative capacity u(v,w) (where 'u' stands for "upper bound") and a unit cost c(v,w). With each node v is associated a quantity named supply(v), which represents a supply of fluid (if >0) or a demand (if <0). Furthermore, no fluid is created in the graph so sum_{v in V} supply(v) = 0.

A flow is a function from E to R such that: a) f(v,w) <= u(v,w) for all (v,w) in E (capacity constraint). b) f(v,w) = -f(w,v) for all (v,w) in E (flow antisymmetry constraint). c) sum on v f(v,w) + supply(w) = 0 (flow conservation).

The cost of a flow is sum on (v,w) in E ( f(v,w) * c(v,w) ) [Note: It can be confusing to beginners that the cost is actually double the amount that it might seem at first because of flow antisymmetry.]

The problem to solve: find a flow of minimum cost such that all the fluid flows from the supply nodes to the demand nodes.

The principles behind this algorithm are the following: 1/ handle pseudo-flows instead of flows and refine pseudo-flows until an epsilon-optimal minimum-cost flow is obtained, 2/ deal with epsilon-optimal pseudo-flows.

1/ A pseudo-flow is like a flow, except that a node's outflow minus its inflow can be different from its supply. If it is the case at a given node v, it is said that there is an excess (or deficit) at node v. A deficit is denoted by a negative excess and inflow = outflow + excess. (Look at ortools/graph/max_flow.h to see that the definition of preflow is more restrictive than the one for pseudo-flow in that a preflow only allows non-negative excesses, i.e., no deficit.) More formally, a pseudo-flow is a function f such that: a) f(v,w) <= u(v,w) for all (v,w) in E (capacity constraint). b) f(v,w) = -f(w,v) for all (v,w) in E (flow antisymmetry constraint).

For each v in E, we also define the excess at node v, the algebraic sum of all the incoming preflows at this node, added together with the supply at v. excess(v) = sum on u f(u,v) + supply(v)

The goal of the algorithm is to obtain excess(v) = 0 for all v in V, while consuming capacity on some arcs, at the lowest possible cost.

2/ Internally to the algorithm and its analysis (but invisibly to the client), each node has an associated "price" (or potential), in addition to its excess. It is formally a function from E to R (the set of real numbers.). For a given price function p, the reduced cost of an arc (v,w) is: c_p(v,w) = c(v,w) + p(v) - p(w) (c(v,w) is the cost of arc (v,w).) For those familiar with linear programming, the price function can be viewed as a set of dual variables.

For a constant epsilon >= 0, a pseudo-flow f is said to be epsilon-optimal with respect to a price function p if for every residual arc (v,w) in E, c_p(v,w) >= -epsilon.

A flow f is optimal if and only if there exists a price function p such that no arc is admissible with respect to f and p.

If the arc costs are integers, and epsilon < 1/n, any epsilon-optimal flow is optimal. The integer cost case is handled by multiplying all the arc costs and the initial value of epsilon by (n+1). When epsilon reaches 1, and the solution is epsilon-optimal, it means: for all residual arc (v,w) in E, (n+1) * c_p(v,w) >= -1, thus c_p(v,w) >= -1/(n+1) > -1/n, and the solution is optimal.

A node v is said to be active if excess(v) > 0. In this case the following operations can be applied to it:

  • if there are admissible incident arcs, i.e. arcs which are not saturated, and whose reduced costs are negative, a PushFlow operation can be applied. It consists in sending as much flow as both the excess at the node and the capacity of the arc permit.
  • if there are no admissible arcs, the active node considered is relabeled, This is implemented in Discharge, which itself calls PushFlow and Relabel.

Discharge itself is called by Refine. Refine first saturates all the admissible arcs, then builds a stack of active nodes. It then applies Discharge for each active node, possibly adding new ones in the process, until no nodes are active. In that case an epsilon-optimal flow is obtained.

Optimize iteratively calls Refine, while epsilon > 1, and divides epsilon by alpha (set by default to 5) before each iteration.

The algorithm starts with epsilon = C, where C is the maximum absolute value of the arc costs. In the integer case which we are dealing with, since all costs are multiplied by (n+1), the initial value of epsilon is (n+1)*C. The algorithm terminates when epsilon = 1, and Refine() has been called. In this case, a minimum-cost flow is obtained.

The complexity of the algorithm is O(n^2*m*log(n*C)) where C is the value of the largest arc cost in the graph.

IMPORTANT: The algorithm is not able to detect the infeasibility of a problem (i.e., when a bottleneck in the network prohibits sending all the supplies.) Worse, it could in some cases loop forever. This is why feasibility checking is enabled by default (FLAGS_min_cost_flow_check_feasibility=true.) Feasibility checking is implemented using a max-flow, which has a much lower complexity. The impact on performance is negligible, while the risk of being caught in an endless loop is removed. Note that using the feasibility checker roughly doubles the memory consumption.

The starting reference for this class of algorithms is: A.V. Goldberg and R.E. Tarjan, "Finding Minimum-Cost Circulations by Successive Approximation." Mathematics of Operations Research, Vol. 15, 1990:430-466. http://portal.acm.org/citation.cfm?id=92225

Implementation issues are tackled in: A.V. Goldberg, "An Efficient Implementation of a Scaling Minimum-Cost Flow Algorithm," Journal of Algorithms, (1997) 22:1-29 http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.31.258

A.V. Goldberg and M. Kharitonov, "On Implementing Scaling Push-Relabel Algorithms for the Minimum-Cost Flow Problem", Network flows and matching: First DIMACS implementation challenge, DIMACS Series in Discrete Mathematics and Theoretical Computer Science, (1993) 12:157-198. ftp://dimacs.rutgers.edu/pub/netflow/submit/papers/Goldberg-mincost/scalmin.ps and in: U. Bunnagel, B. Korte, and J. Vygen. “Efficient implementation of the Goldberg-Tarjan minimum-cost flow algorithm.” Optimization Methods and Software (1998) vol. 10, no. 2:157-174. http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.84.9897

We have tried as much as possible in this implementation to keep the notations and namings of the papers cited above, except for 'demand' or 'balance' which have been replaced by 'supply', with the according sign changes to better accommodate with the API of the rest of our tools. A demand is denoted by a negative supply.

Todo
(user): See whether the following can bring any improvements on real-life problems. R.K. Ahuja, A.V. Goldberg, J.B. Orlin, and R.E. Tarjan, "Finding minimum-cost flows by double scaling," Mathematical Programming, (1992) 53:243-266. http://www.springerlink.com/index/gu7404218u6kt166.pdf

An interesting general reference on network flows is: R. K. Ahuja, T. L. Magnanti, J. B. Orlin, "Network Flows: Theory, Algorithms, and Applications," Prentice Hall, 1993, ISBN: 978-0136175490, http://www.amazon.com/dp/013617549X

Keywords: Push-relabel, min-cost flow, network, graph, Goldberg, Tarjan, Dinic, Dinitz.

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. Runs multiple Dijkstra searches simultaneously (single-threaded, but growing their search radii at the same time) on the same graph. Supports custom arc length functors, and custom stopping criterion and tracking.

EXAMPLE: With two sources and a custom stopping criterion that stops the first Dijkstra when it has settled 1000 nodes and the second when it has reached the search radius 123.45:

ListGraph<> graph; ///< From ortools/graph/graph.h ... build the graph ... int source1 = ... , source2 = ...; vector<double> arc_lengths(graph.num_arcs(), 0); ... set the arc lengths ... int num_nodes_to_settle_in_first_search = 1000; std::vector<absl::flat_hash_map<int, DistanceAndParentArc<double>>> reached_nodes; ///< One map per source: node -> DistanceAndParentArc. reached_nodes = MultiDijkstra<double>( graph, [&arc_lengths](int a) { return arc_lengths[a]; }, {{source1}, {source2}}, [&num_nodes_to_settle_in_first_search]( int settled_node, int source_index, double settled_distance) { if (source_index == 0) { return –num_nodes_to_settle_in_first_search == 0; } else { return settled_distance >= 123.45; } });

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. Implementation of the Blossom V min-cost perfect matching algorithm. The main source for the algo is the paper: "Blossom V: A new implementation of a minimum cost perfect matching algorithm", Vladimir Kolmogorov.

The Algorithm is a primal-dual algorithm. It always maintains a dual-feasible solution. We recall some notations here, but see the paper for more details as it is well written.

Todo
(user): This is a work in progress. The algo is not fully implemented yet. The initial version is closer to Blossom IV since we update the dual values for all trees at once with the same delta.

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. Find paths and compute path distances between nodes on a rooted tree.

A tree is a connected undirected graph with no cycles. A rooted tree is a directed graph derived from a tree, where a node is designated as the root, and then all edges are directed towards the root.

This file provides the class RootedTree, which stores a rooted tree on dense integer nodes a single vector, and a function RootedTreeFromGraph(), which converts the adjacency list of a an undirected tree to a RootedTree.

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. This file contains functions to compute shortest paths on Ebert graphs using Dijkstra's algorithm, E.W. Dijkstra, "A note on two problems in connexion with graphs". Numerische Mathematik 1:269–271, 1959. See for example: http://www.springerlink.com/content/uu8608u0u27k7256/fulltext.pdf. More information can also be found on Wikipedia: http://en.wikipedia.org/wiki/Dijkstra's_algorithm

This is a unidirectional implementation of Dijkstra's algorithm. A bidirectional is available in bidirectional_dijkstra.h for specific use cases.

Each 1-to-many shortest path computation is run in a separate thread. Users should select the number of threads to use according to the number of cores available (each thread will use up one core). However, increasing the number of threads also increases temporary memory used by each 1-to-many computation.

Also included are classes to store path data resulting from shortest path computations (cf. PathContainer).

Usage example computing all-pair shortest paths on a graph: StaticGraph graph(...,...); std::vector<uint32_t> arc_lengths(...,...); ... populate graph and arc lengths ... PathContainer container; PathContainer::BuildInMemoryCompactPathContainer(&container); ComputeAllToAllShortestPathsWithMultipleThreads(graph, arc_lengths, /*num_threads=*‍/4, &container);

Usage example computing shortest paths between a subset of graph nodes: StaticGraph graph(...,...); std::vector<uint32_t> arc_lengths(...,...); ... populate graph and arc lengths ... vector<NodeIndex> sources; vector<NodeIndex> sinks; ... fill sources and sinks ... PathContainer container; PathContainer::BuildInMemoryCompactPathContainer(&container); ComputeManyToManyShortestPathsWithMultipleThreads(graph, arc_lengths, sources, sinks, /*num_threads=*‍/4, &container);

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. Provides a safe C++ interface for SCIP constraint handlers, which are described at https://www.scipopt.org/doc/html/CONS.php. For instructions to write a constraint handler, see the documentation of GScipConstraintHandler. Examples can be found in gscip_constraint_handler_test.cc.

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. Provides a safe C++ interface for SCIP event handlers, which are described at https://www.scipopt.org/doc/html/EVENT.php.

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. Additional nonlinear constraints not supported directly by SCIP.

The primary purpose of this file is to support the nonlinear constraints of MPSolver proto API.

WARNING(rander): as these constraints are not natively supported in SCIP, they will generally not be a single SCIP_CONS* created, but will typically result in multiple SCIP_CONS* and SCIP_VAR* being created. Direct access to these intermediate variables and constraints is currently not provided.

Todo
(user): either implement with SCIP constraint handlers or use a solver independent implementation.

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. Interface to dedicated knapsack solvers covering multi-dimensional 0-1 knapsacks. Current solvers handle only integer coefficients so a scaling phase is performed before solving the problem.

Todo
(user): handle timeouts, compute row and column statuses.
Todo
(user): post c++ 14, instead use std::pair<MPSolver::OptimizationProblemType, const absl::string_view> once pair gets a constexpr constructor.

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. This file provides a simplified C++ API for using callbacks with SCIP and MPSolver. It can be used directly by users, although in most cases, the mp_callback.h should be sufficient (in fact, SCIP's mp_callback.h implementation is built on top of this).

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. Functions for solving optimization models defined by MPModelRequest.

See linear_solver.proto for further documentation.

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. Storage classes for Linear Programs.

LinearProgram stores the complete data for a Linear Program:

  • objective coefficients and offset,
  • cost coefficients,
  • coefficient matrix,
  • bounds for each variable,
  • bounds for each constraint.

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. Utility helpers for manipulating LinearProgram and other types defined in lp_data.

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. We use typedefs as much as possible to later permit the usage of types such as quad-doubles or rationals.

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. The SparseMatrixScaler class provides tools to scale a SparseMatrix, i.e. reduce the range of its coefficients and make for each column and each row the maximum magnitude of its coefficients equal to 1.

In the case there are bounds or costs on the columns or a right-hand side related to each row, SparseMatrixScaler provides the tools to scale those appropriately.

More precisely, suppose we have the Linear Program: min c.x s.t A.x = b with l <= x <= u

The rows of A are scaled by left-multiplying it by a diagonal matrix R whose elements R_ii correspond to the scaling factor of row i. The columns of A are scaled by right-multiplying it by a diagonal matrix C whose elements C_jj correspond to the scaling factor of column j.

We obtain a matrix A' = R.A.C.

We wish to scale x, c, b, l, u so as to work on the scaled problem: min c'.x' s.t A'.x' = b' with l' <= x' <= u'

The right-hand side b needs to be left-multiplied by R, the cost function c needs to be right-multiplied by C. Finally, x, and its lower- and upper-bound vectors l and u need to be left-multiplied by C^-1.

Note also that the dual vector y is scaled as follows: y'.R = y, thus y' = y.R^-1.

The complete transformation is thus: A' = R.A.C, b' = R.b, c' = c.C, x' = C^-1.x, l' = C^-1.l, u' = C^-1.u, y' = y.R^-1.

The validity of the above transformation can be checked by computing: c'.x' = c.C.C^-1.x = c.x. and: A'.x' = R.A.C.C^-1.x = R.A.x = R.b = b'.

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. A reader for files in the MPS format. see http://lpsolve.sourceforge.net/5.5/mps-format.htm and http://www.ici.ro/camo/language/ml11.htm.

MPS stands for Mathematical Programming System.

The format was invented by IBM in the 60's, and has become the de facto standard. We developed this reader to be able to read benchmark data files. Using the MPS file format for new models is discouraged.

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. A reader for files in the SOL format. see https://en.wikipedia.org/wiki/Sol_(format)

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. The following are very good references for terminology, data structures, and algorithms:

I.S. Duff, A.M. Erisman and J.K. Reid, "Direct Methods for Sparse Matrices", Clarendon, Oxford, UK, 1987, ISBN 0-19-853421-3, http://www.amazon.com/dp/0198534213.

T.A. Davis, "Direct methods for Sparse Linear Systems", SIAM, Philadelphia, 2006, ISBN-13: 978-0-898716-13, http://www.amazon.com/dp/0898716136.

Both books also contain a wealth of references.

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. Classes to represent sparse vectors.

The following are very good references for terminology, data structures, and algorithms:

I.S. Duff, A.M. Erisman and J.K. Reid, "Direct Methods for Sparse Matrices", Clarendon, Oxford, UK, 1987, ISBN 0-19-853421-3, http://www.amazon.com/dp/0198534213.

T.A. Davis, "Direct methods for Sparse Linear Systems", SIAM, Philadelphia, 2006, ISBN-13: 978-0-898716-13, http://www.amazon.com/dp/0898716136.

Both books also contain a wealth of references.

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. A read only view for sparse vectors that implements various utilities.

This header defines:

  • SparseVectorView<T>: a sparse vector as a span of int64_t ids and another span of values of type T. The underlying data is not owned and the user must ensure the data outlives the view.
  • Overloaded MakeView factories to avoid explicit template arguments.

The utilities implemented by SparseVectorView<T> include:

  • const range iterations over the (id, value) pairs.
  • .as_map<IdT>() member function that returns the view as a absl::flat_hash_map<IdT, T> Example: const std::vector<int64_t> ids = {2, 5, 7}; const std::vector<double> values= {1.0, 3.0, 1.0}; const SparseVectorView<double> view = MakeView(ids, values);

Now view.ids => [2, 5, 7] and view.values => [1.0, 3.0, 1.0]. To iterate over the (id, value) pairs:

for(const auto [id, value] : view) { ... }

To get a map that casts the ids to the strong int type VariableId:

auto map = view.as_map<VariableId>();

For more information, see the class comments below.

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. IWYU pragma: private, include "ortools/math_opt/cpp/math_opt.h" IWYU pragma: friend "ortools/math_opt/cpp/.*" Data types for using callbacks with Solve() and IncrementalSolver.

Callbacks allow to user to observe the progress of a solver and modify its behavior mid solve. This is supported by allowing the user to a function of type Callback as an optional argument to Solve() and IncrementalSolver::Solve(). This function is called periodically throughout the solve process. This file defines the data types needed to use this callback.

The example below registers a callback that listens for feasible solutions the solvers finds along the way and accumulates them in a list for analysis after the solve.

using operations_research::math_opt::CallbackData; using operations_research::math_opt::CallbackRegistration; using operations_research::math_opt::CallbackResult; using operations_research::math_opt::Model; using ::operations_research::math_opt::SolveResult; using operations_research::math_opt::Solve; using operations_research::math_opt::Variable; using operations_research::math_opt::VariableMap;

Model model; Variable x = model.AddBinaryVariable(); model.Maximize(x); CallbackRegistration cb_reg; cb_reg.events = { operations_research::math_opt::CALLBACK_EVENT_MIP_SOLUTION}; std::vector<VariableMap<double>> solutions; auto cb = [&solutions](const CallbackData& cb_data) { ///<

Note
this assumes the callback is always called from the same thread. ///< Gurobi always does this, multi-threaded SCIP does not. solutions.push_back(cb_data.solution); return CallbackResult(); }; absl::StatusOr<SolveResult> result = Solve( model, operations_research::math_opt::SOLVER_TYPE_GUROBI, /*parameters=‍/{}, /*model_parameters=*‍/{}, cb_reb, cb);

At the termination of the example, solutions will have {{x, 1.0}}, and possibly {{x, 0.0}} as well.

If the callback argument to Solve() is not null, it will be invoked on the events specified by the callback_registration argument (and when the callback is null, callback_registration must not request any events or will CHECK fail). Some solvers do not support callbacks or certain events, in this case the callback is ignored.

Todo
(b/180617976): change this behavior.

Some solvers may call callback from multiple threads (SCIP will, Gurobi will not). You should either solve with one thread (see solver_parameters.threads), write a threadsafe callback, or consult the documentation of your underlying solver.

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. IWYU pragma: private, include "ortools/math_opt/cpp/math_opt.h" IWYU pragma: friend "ortools/math_opt/cpp/.*"

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. Matchers for MathOpt types, specifically SolveResult and nested fields.

The matchers defined here are useful for writing unit tests checking that the result of Solve(), absl::StatusOr<SolveResult>, meets expectations. We give some examples below. All code is assumed with the following setup:

namespace operations_research::math_opt { using testing::status::IsOkAndHolds;

Model model; const Variable x = model.AddContinuousVariable(0.0, 1.0); const Variable y = model.AddContinuousVariable(0.0, 1.0); const LinearConstraint c = model.AddLinearConstraint(x + y <= 1); model.Maximize(2*x + y);

Example 1.a: result is OK, optimal, and objective value approximately 42. EXPECT_THAT(Solve(model, SolverType::kGlop), IsOkAndHolds(IsOptimal(42)));

Example 1.b: equivalent to 1.a. ASSERT_OK_AND_ASSIGN(const SolveResult result, Solve(model, SolverType::kGlop)); EXPECT_THAT(result, IsOptimal(42));

Example 2: result is OK, optimal, and best solution is x=1, y=0. ASSERT_OK_AND_ASSIGN(const SolveResult result, Solve(model, SolverType::kGlop)); ASSERT_THAT(result, IsOptimal()); EXPECT_THAT(result.variable_value(), IsNear({{x, 1}, {y, 0}});

Note
the second ASSERT ensures that if the solution is not optimal, then result.variable_value() will not run (the function will crash if the solver didn't find a solution). Further, MathOpt guarantees there is a solution when the termination reason is optimal.

Example 3: result is OK, check the solution without specifying termination. ASSERT_OK_AND_ASSIGN(const SolveResult result, Solve(model, SolverType::kGlop)); EXPECT_THAT(result, HasBestSolution({{x, 1}, {y, 0}}));

Example 4: multiple possible termination reason, primal ray optional: ASSERT_OK_AND_ASSIGN(const SolveResult result, Solve(model, SolverType::kGlop)); ASSERT_THAT(result, TerminatesWithOneOf( TerminationReason::kUnbounded, TerminationReason::kInfeasibleOrUnbounded)); if(!result.primal_rays.empty()) { EXPECT_THAT(result.primal_rays[0], PrimalRayIsNear({{x, 1,}, {y, 0}})); }

Tips on writing good tests:

  • Use ASSERT_OK_AND_ASSIGN(const SolveResult result, Solve(...)) to ensure the test terminates immediately if Solve() does not return OK.
  • If you ASSERT_THAT(result, IsOptimal()), you can assume that you have a feasible primal solution afterwards. Otherwise, make no assumptions on the contents of result (e.g. do not assume result contains a primal ray just because the termination reason was UNBOUNDED).
  • For problems that are infeasible, the termination reasons INFEASIBLE and DUAL_INFEASIBLE are both possible. Likewise, for unbounded problems, you can get both UNBOUNDED and DUAL_INFEASIBLE. See TerminatesWithOneOf() below to make assertions in this case. Note also that some solvers have solver specific parameters to ensure that DUAL_INFEASIBLE will not be returned (e.g. for Gurobi, use DualReductions or InfUnbdInfo).
  • The objective value and variable values should always be compared up to a tolerance, even if your decision variables are integer. The matchers defined have a configurable tolerance with default value 1e-5.
  • Primal and dual rays are unique only up to a constant scaling. The matchers provided rescale both expected and actual before comparing.
  • Take care on problems with multiple optimal solutions. Do not rely on a particular solution being returned in your test, as the test will break when we upgrade the solver.

This file also defines functions to let gunit print various MathOpt types.

To see the error messages these matchers generate, run blaze test experimental/users/rander/math_opt:matchers_error_messages which is a fork of matchers_test.cc where the assertions are all negated (note that every test should fail).

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. IWYU pragma: private, include "ortools/math_opt/cpp/math_opt.h" IWYU pragma: friend "ortools/math_opt/cpp/.*" Functions and classes used to solve a Model.

The main entry point is the Solve() function.

For users that need incremental solving, there is the IncrementalSolver class.

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. IWYU pragma: private, include "ortools/math_opt/cpp/math_opt.h" IWYU pragma: friend "ortools/math_opt/cpp/.*" This headers defines C++ wrappers of solver specific initialization parameters that can be streamed to be exchanged with another process.

Parameters that can't be streamed (for example instances of C/C++ types that only exist in the process memory) are dealt with implementations of the NonStreamableSolverInitArguments.

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. IWYU pragma: private, include "ortools/math_opt/cpp/math_opt.h" IWYU pragma: friend "ortools/math_opt/cpp/.*" An object oriented wrapper for variables in ModelStorage (used internally by Model) with support for arithmetic operations to build linear expressions and express linear constraints.

Types are:

  • Variable: a reference to a variable of an ModelStorage.
  • LinearExpression: a weighted sum of variables with an optional offset; something like 3*x + 2*y + 5.
  • LinearTerm: a term of a linear expression, something like 2*x. It is used as an intermediate in the arithmetic operations that builds linear expressions.
  • (Lower|Upper)BoundedLinearExpression: two classes representing the result of the comparison of a LinearExpression with a constant. For example 3*x / + 2*y + 5 >= 3.
      - BoundedLinearExpression: the result of the comparison of a linear
        expression with two bounds, an upper bound and a lower bound. For example
        `2 <= 3*x + 2*y + 5 <= 3`; or `4 >= 3*x + 2*y + 5 >= 1`.
    
      - QuadraticTermKey: a key used internally to represent a pair of Variables.
    
      - QuadraticTerm: a term representing the product of a scalar coefficient
        and two Variables (possibly the same); something like `2*x*y` or `3*x*x`.
        It is used as an intermediate in the arithmetic operations that build
        quadratic expressions.
    
      - QuadraticExpression: a sum of a quadratic terms, linear terms, and a
        scalar offset; something like `3*x*y + 2*x*x + 4x + 5`.
    
      - VariablesEquality: the result of comparing two Variable instances with
        the == operator. For example `a == b`. This intermediate class support
        implicit conversion to both bool and BoundedLinearExpression types. This
        enables using variables as key of maps (using the conversion to bool)
        without preventing adding constraints of variable equality.
    
    The basic arithmetic operators are overloaded for those types so that we can
    write math expressions with variables to build linear expressions. The >=, <=
    and == comparison operators are overloaded to produce BoundedLinearExpression
    that can be used to build constraints.
    
    For example we can have:
      const Variable x = ...;
      const Variable y = ...;
      const LinearExpression expr = 2 * x + 3 * y - 2;
      const BoundedLinearExpression bounded_expr = 1 <= 2 * x + 3 * y - 2 <= 10;
    
    To making working with containers of doubles/Variables/LinearExpressions
    easier, the template methods Sum() and InnerProduct() are provided, e.g.
      const std::vector<int> ints = ...;
      const std::vector<double> doubles = ...;
      const std::vector<Variable> vars = ...;
      const std::vector<LinearTerm> terms = ...;
      const std::vector<LinearExpression> exprs = ...;
      const LinearExpression s1 = Sum(ints);
      const LinearExpression s2 = Sum(doubles);
      const LinearExpression s3 = Sum(vars);
      const LinearExpression s4 = Sum(terms);
      const LinearExpression s5 = Sum(exprs);
      const LinearExpression p1 = InnerProduct(ints, vars);
      const LinearExpression p2 = InnerProduct(terms, doubles);
      const LinearExpression p3 = InnerProduct(doubles, exprs);
    These methods work on any iterable type (defining begin() and end()). For
    InnerProduct, the inputs must be of equal size, and a compile time error will
    be generated unless at least one input is a container of a type implicitly
    convertible to double.
    
    Pre C++20, avoid the use of std::accumulate and std::inner_product with
    LinearExpression, they cause a quadratic blowup in running time.
    
    While there is some complexity in the source, users typically should not need
    to look at types other than Variable and LinearExpression too closely. Their
    code usually will only refer to those types. 
    

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. Let L be a matrix and b a vector so that a(w) = L * w + b. Then

max_w{ a(w) * x : w in W} = max_w{ w' * L' * x : w in W} + b * x

where ' is the transpose operation. Because of this we can focus on max_w{ l(w) * x : w in W}.

We need the dual to be an LP even when uncertainty_model contains ranged constraints, so we use the LP reformulation of go/mathopt-dual from go/mathopt-traditional-dual#lp-reformulation-split. Using that reformulation, for any fixed x the dual of max_w{ w' * L' * x : w in W} is

min_{y, yp, yn, r, rp, rn} obj(yp, yn, rp, rn)

A' y + r == L' * x
sign constraints on y and r
yp + yn == y
rp + rn == r
yp, rp >= 0
yn, rn <= 0
IntegerValue y
const Variable x
Definition qp_tests.cc:127

where

obj(yp, yn, rp, rn) = uc * yp + lc * yn + uv * rp + lv * rn

with the convention 0 * infinity = 0 * -infinity = 0.

In this dual form x is not multiplied with w so we can consider x a variable instead of a fixed value.

Then max_w{ a(w) * x : w in W} <= rhs is equivalent to

obj(yp, yn, rp, rn) + b * x <= rhs
A' y + r == L' * x
sign constraints on y and r
yp + yn == y
rp + rn == r
yp, rp >= 0
yn, rn <= 0
int64_t b
Definition table.cc:45
Note
we can use the equalities yp + yn == y and rp + rn == r to eliminate variables y and r to reduce the number of constraints and variables in the reformulation.

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. This header groups parameteric tests to validates behaviors common to MIP and LP solvers.

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. How each parameter is tested:

Parameter IpParameterTest generic_test.h LargeInstanceTest
time_limit x x
iteration_limit x x
node_limit x x
cutoff_limit x x
objective_limit x x
best_bound_limit x x
solution_limit x x

enable_output | | x | threads | | | random_seed | x | | absolute_gap_tol | x | | x relative_gap_tol | x | | x solution_pool_size | | | lp_algorithm | x (bad) | | presolve | x | | cuts | x | | x heuristics | | | scaling | | |

solution_pool_size is tested in ip_multiple_solutions_tests.cc.

Testing some parameters requires that other parameters/stats are supported:

  • presolve (IpParameterTest) requires message callbacks
  • cuts (IpParameterTest) must disable presolve
  • cuts (LargeInstanceTest) needs node_limit=1.
  • lp_algorithm (IpParameterTest) test is just a no-crash test without supporting iteration counts in SolveStats.
  • solution_limit (IpParameterTest) requires a hint.
Todo

(b/180024054): add tests for:

  • threads
  • heuristics
  • scaling
  • lp_algorithm, differentiate between primal and dual simplex. E.g. find a problem with LP relaxation that is both infeasible and dual infeasible, disable presolve, and solve. When using primal simplex, we should get termination reason kInfeasible, but dual simplex should give kInfeasibleOrUnbounded.

(b/272268188): test the interaction between cutoff and primal + dual infeasibility.

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.

Todo
(b/180024054): the following parameters are not tested:
  • time_limit
  • threads
  • scaling

The following parameters are under-tested:

  • lp_algorithm
Note
cuts and heuristics do not apply for LP. enable_output is tested in generic_tests.h.

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.

Todo

(user): These tests are incomplete in a few ways; see mip_tests.cc

(user): Expand tests so they check primal, dual and/or primal-dual infeasible cases as appropriate.

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. This code builds an arc-flow generator for vector-bin-packing problems. see https://people.math.gatech.edu/~tetali/PUBLIS/CKPT.pdf It implements a non-recursive version of algorithm 1 described in: http://www.dcc.fc.up.pt/~fdabrandao/papers/arcflow_manuscript.pdf And in (poster version): http://www.dcc.fc.up.pt/~fdabrandao/papers/arcflow_poster.pdf Available at: https://drive.google.com/open?id=1y-Vs1orv-QHO4lb2sjVWrZr9GQd5d2st https://drive.google.com/open?id=1fsWRqgNJ_3ClrhoKIeVc1EOd5s8Mj33i (poster) Some improvements are not yet implemented:

  • Lifted stated: when storing a state of the dynamic programming forward pass, one can lift a state. A lifted state of a state S is a maximal increase of S that does not lose any state in the forward pass. A simple example is the following: bin, 1 dimension, capacity 5 After adding item 1 in the DP pass, the state is (2). The lifted state is (3) that is (5) - (2) which is the maximal increase of (2) that does not loose any state. To limit time spent computing this, one can lift a state only if the remaining number of item is below a threshold.

Disable the backward pass (compress state towards the bin capacity). Although this reduces the graph a lot, this simplication is not valid when the cost is not the number of bins, but a function of the capacity used (useful for fair allocation).

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. Parses vector packing data files, and creates a VectorBinPackingProblem

The supported file formats are:

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. A parser for CARPLIB instances. The base files are available online, as well as a description of the (Spanish-based) format: https://www.uv.es/belengue/carp.html ("CARPLIB") https://www.uv.es/~belengue/carp/READ_ME

The goal is to find routes starting and ending at a depot which visit a set of arcs (whereas a VRP visits nodes). The objective is to minimize the total cost, which is due to either servicing an edge (i.e. performing the required action) or traversing an edge (to get to another point in space). Not all arcs/edges in the graph must be serviced.

By this formulation, the total cost of servicing is known in advance. All vehicles start at the same node, the depot, having index 1. Servicing an edge requires resources, vehicles have a limited capacity. All vehicles have the same capacity.

The format of the data is the following:

NOMBRE : <INSTANCE-NAME> COMENTARIO : <ARBITRARY-COMMENT> VERTICES : <NUMBER-OF-NODES, int> ARISTAS_REQ : <NUMBER-OF-EDGES-WITH-NONZERO-SERVICING, int> ARISTAS_NOREQ : <NUMBER-OF-EDGES-WITH-ZERO-SERVICING, int> VEHICULOS : <NUMBER-OF-VEHICLES, int> CAPACIDAD : <CAPACITY-OF-EACH-VEHICLE, int> TIPO_COSTES_ARISTAS : EXPLICITOS COSTE_TOTAL_REQ : <TOTAL-SERVICING-COST> LISTA_ARISTAS_REQ : ( <HEAD-NODE-OF-EDGE, int>, <TAIL-NODE-OF-EDGE, int> ) coste <TRAVERSING-COST, int> demanda <SERVICING, int> <repeated, one edge per line> LISTA_ARISTAS_NOREQ : ( <HEAD-NODE-OF-EDGE, int>, <TAIL-NODE-OF-EDGE, int> ) coste <TRAVERSING-COST, int> <repeated, one edge per line> DEPOSITO : 1

While the file format is defined with 1-based indexing, the output of the parser is always 0-based. Users of this parser should never see any 1-based index; only 0-based index should be used to query values.

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. This header provides functions to help create random instances of the vehicle routing problem; random capacities and random time windows.

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. Reader for Multicommodity fixed-charge Network Design (MCND) files using the .dow format.

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. A parser for Li&Lim PDPTW (pickup and delivery problems with time windows) instances. The goal is to find routes starting and end at a depot which visit a set of nodes. Nodes are grouped in pairs of pickup and delivery nodes. The pickup node of each pair has to be performed before the delivery node and both nodes have to be on the same route. The objective is first to minimize the number of routes and then to minimize the total distance traveled, distances being measured with the Euclidean distance between nodes. Routes are subject to two other types of constraints:

  • time windows restricting the time during which a node can be visited,
  • vehicle capacity which limits the load of the vehicles performing the routes (each node has a corresponding demand which must be picked up or delivered by the vehicle).

The format of the data is the following:

  • one row to describe vehicles (which are all identical): <number of vehicles> <vehicle capacity> <speed>
  • followed by a row per node: <node id> <x> <y> <demand> <ready time> <due date> <service time> <pickup index> <delivery index>

Node 0 corresponds to the depot. For pickup nodes, pickup index is 0, and delivery index gives the index of the corresponding delivery node. For delivery tasks, delivery index is 0, and pickup index gives the index of the corresponding pickup node. The value of travel time is equal to the value of distance.

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. A parser for NEARPLIB instances. The base files are available online, as well as a description of the format: https://www.sintef.no/projectweb/top/nearp/documentation/

The goal is to find routes starting and ending at a depot which visit a set of arcs (directed), edges (undirected), and nodes, whereas a VRP only visits nodes. The objective is to minimize the total cost, which is due to either servicing a part of the graph (i.e. performing the required action) or traversing an edge (to get to another point in space). Not all arcs/edges in the graph must be serviced. These components are summarized in NEARP: node-edge-arc routing problem. The problem is sometimes also called MCGRP: mixed capacitated generalized routing problem.

All vehicles start at the same node, the depot. Its index is often 1, but many instances have another depot. Servicing a part of the graph requires resources, vehicles have a limited capacity. All vehicles have the same capacity.

The format of the data is the following (from https://www.sintef.no/projectweb/top/nearp/documentation/):

Name: <Instance name> Optimal value: <Optimal value, -1 if unknown> #Vehicles: <Max. number of vehicles, -1 if unconstrained> Capacity: <Vehicle capacity Q> Depot: <Index of depot node> #Nodes: <number of nodes> #Edges: <number of edges> #Arcs: <number of arcs> #Required N: <number of required nodes> #Required E: <number of required edges> #Required A: <number of required arcs>

% Required nodes: Ni q_i s_i NODE INDEX, DEMAND, SERVICE COST

% Required edges: Ek i j q_ij c_ij s_ij EDGE INDEX, FROM NODE, TO NODE, TRAVERSAL COST, DEMAND, SERVICE COST

% Non-required edges: NrEl i j c_ij EDGE INDEX, FROM NODE, TO NODE, TRAVERSAL COST

% Required arcs: Ar i j q_ij c_ij ARC INDEX, FROM NODE, TO NODE, TRAVERSAL COST, DEMAND, SERVICE COST

% Non-required arcs: NrAs i j c_ij ARC INDEX, FROM NODE, TO NODE, TRAVERSAL COST

For nodes, the index is of the form NX, where X is the node index (for instance, N1 is the first node that requires servicing). The elements of each section are not necessarily sorted. Nodes are indexed together, with no separation between those that require servicing and those that do not, from 1 to the number of nodes. Conversely, arcs and edges have separate indexing depending on whether they require indexing: E1 to EM all require servicing, NrE1 to NrEN do not, for a total of M + N edges (respectively, for arcs, A1 to AK and NrA1 to NrAL for K + L arcs).

While the file format is defined with 1-based indexing, the output of the parser is always 0-based. Users of this parser should never see any 1-based index; only 0-based index should be used to query values.

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. A TSPPD parser used to parse instances of Traveling Salesman Problems with pickup and delivery constraints. This format was created by Stefan Ropke. https://link.springer.com/article/10.1007%2Fs10107-008-0234-9

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. A parser for "Solomon" instances. The Solomon file library is a set of Capacitated Vehicle Routing Problems with Time Windows created by Pr. Marius Solomon.

The goal is to find routes starting and ending at a depot which visit a set of nodes. The objective is first to minimize the number of routes and then to minimize the total distance traveled, distances being measured with the Euclidean distance. There are two types of constraints limiting the route lengths:

  • time windows restricting the time during which a node can be visited
  • vehicle capacity which limits the load of the vehicles performing the routes (each node has a corresponding demand which must be picked up by the vehicle).

The format of the data is the following:

<instance_name> VEHICLE NUMBER CAPACITY <number of nodes> <vehicle capacity> CUSTOMER CUST NO. XCOORD. YCOORD. DEMAND READY TIME DUE DATE SERVICE TIME <node id> <x> <y> <demand> <ready time> <due date> <service time>

The parser supports both standard instance files and zipped archives containing multiple instances.

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. Utilities to serialize VRP-like solutions in standardised formats: either TSPLIB or CVRPLIB.

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. A TSPLIB parser. The TSPLIB is a library containing Traveling Salesman Problems and other vehicle routing problems. Limitations:

  • only TSP and CVRP files are currently supported.
  • XRAY1, XRAY2 and SPECIAL edge weight types are not supported.

Takes as input a data file, potentially gzipped. The data must follow the TSPLIB95 format (described at http://www.iwr.uni-heidelberg.de/groups/comopt/software/TSPLIB95/DOC.PS).

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. A TSPTW parser.

Takes as input a data file, potentially gzipped. The data must follow the format described at http://lopez-ibanez.eu/tsptw-instances and https://homepages.dcc.ufmg.br/~rfsilva/tsptw.

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. This file contains the solver internal representation of the clauses and the classes used for their propagation.

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. Algorithms to encode constraints into their SAT representation. Currently, this contains one possible encoding of a cardinality constraint as used by the core-based optimization algorithm in optimization.h.

This is also known as the incremental totalizer encoding in the literature.

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. This file contains all the top-level logic responsible for driving the search of a satisfiability integer problem. What decision we take next, which new Literal associated to an IntegerLiteral we create and when we restart.

For an optimization problem, our algorithm solves a sequence of decision problem using this file as an entry point. Note that some heuristics here still use the objective if there is one in order to orient the search towards good feasible solution though.

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. This file contains the entry point for our presolve/inprocessing code.

Todo
(user): for now it is mainly presolve, but the idea is to call these function during the search so they should be as incremental as possible. That is avoid doing work that is not useful because nothing changed or exploring parts that were not done during the last round.

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. This file implements a SAT solver. see http://en.wikipedia.org/wiki/Boolean_satisfiability_problem for more detail.

Todo
(user): Expand.

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. Implementation of a pure SAT presolver. This roughly follows the paper:

"Effective Preprocessing in SAT through Variable and Clause Elimination", Niklas Een and Armin Biere, published in the SAT 2005 proceedings.

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. Simple framework for choosing and distributing a solver "sub-tasks" on a set of threads.

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. A Project Scheduling Library parser. See: http://www.om-db.wi.tum.de/psplib/ # PSP-Lib homepage.

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. Provides functions and data structures that make it easier to work with aligned memory:

  • AlignedAllocator<T, n>, an extension of std::allocator<T> that also takes an explicit memory alignment parameter. The memory blocks returned by the allocator are aligned to this number of bytes, i.e. the address of the beginning of the block will be N * alignment_bytes for some N.
  • AlignedVector<>, a specialization of std::vector<> that uses the aligned allocator to create blocks with explicit allocations.
  • AlignUp and AlignDown are functions that align a pointer to the given number of bytes.

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. A very simple flattened 2D array of fixed size. It's movable, copyable. It can also be assigned. This was originally made to replace uses of vector<vector<...>> where each vector had a fixed size: vector<vector<>> has much worse performance in a highly concurrent setting, because it does a lot of memory allocations.

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. Classes and function to convert floating point numbers to string so that no information is lost (i.e. that we can make a round trip from double to string and back to double without losing data).

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. Utility functions on IEEE floating-point numbers. Implemented on float, double, and long double.

Also a placeholder for tools controlling and checking FPU rounding modes.

IMPORTANT NOTICE: you need to compile your binary with -frounding-math if you want to use rounding modes.

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. This file contains and adjustable priority queue templated by an Element class that must:

  • Be efficiently copiable and storable in a std::vector<Element>.
  • Be comparable via the templated Compare class. Top() will returns the element with the largest priority (like std::priority_queue).
  • Implements the "int Index() const" function that must returns an integer that uniquely identify this particular element. Ideally this index must be dense in [0, max_num_elements).

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. Classes for permuting indexable, ordered containers of data without depending on that data to be accessible in any particular way. The client needs to give us two things:

  1. a permutation to apply to some container(s) of data, and
  2. a description of how to move data around in the container(s).

The permutation (1) comes to us in the form of an array argument to PermutationApplier::Apply(), along with index values that tell us where in that array the permutation of interest lies. Typically those index values will span the entire array that describes the permutation.

Applying a permutation involves decomposing the permutation into disjoint cycles and walking each element of the underlying data one step around the unique cycle in which it participates. The decomposition into disjoint cycles is done implicitly on the fly as the code in PermutationApplier::Apply() advances through the array describing the permutation. As an important piece of bookkeeping to support the decomposition into cycles, the elements of the permutation array typically get modified somehow to indicate which ones have already been used.

At first glance, it would seem that if the containers are indexable, we don't need anything more complicated than just the permutation and the container of data we want to permute; it would seem we can just use the container's operator[] to retrieve and assign elements within the container. Unfortunately it's not so simple because the containers of interest can be indexable without providing any consistent way of accessing their contents that applies to all the containers of interest. For instance, if we could insist that every indexable container must define a value_type& operator[] we could simply use that for the assignments we need to do while walking around cycles of the permutation. This is not guaranteed though (common examples are std::vector<bool> or containers of bit-sized integers for which no c++ reference exists). This is the main reason we need a codified description (2) of how to move data around in the indexable container. That description comes to us via the PermutationApplier constructor's argument which is a PermutationCycleHandler instance. Such an object has three important methods defined: SetTempFromIndex(), SetIndexFromIndex(), and SetIndexFromTemp(). Those methods embody all we need to know about how to move data in the indexable container(s) underlying the PermutationCycleHandler.

Another reason we need the description (2) of how to move elements around in the container(s) is that it is often important to permute side-by-side containers of elements according to the same permutation. This situation, too, is covered by defining a PermutationCycleHandler that knows about multiple underlying indexable containers.

The above-mentioned PermutationCycleHandler methods embody knowledge of how to assign elements. It happens that PermutationCycleHandler is also a convenient place to embody the knowledge of how to keep track of which permutation elements have been consumed by the process of walking data around cycles. We depend on the PermutationCycleHandler instance we're given to define SetSeen() and Unseen() methods for that purpose.

For the common case in which elements can be accessed using operator[](), we provide the class template ArrayIndexCycleHandler.

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. This file implements piecewise linear functions over int64_t. It is built by inserting segments.

This class maintains a minimal internal representation and checks for overflow.

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. We use the notation min(arr, i, j) for the minimum arr[x] such that i <= x and x < j. Range Minimum Query (RMQ) is a data structure preprocessing an array arr so that querying min(arr, i, j) takes O(1) time. The preprocessing takes O(n*log(n)) time and memory.

Note
There exists an O(n) preprocessing algorithm, but it is considerably more involved and the hidden constants behind it are much higher.

The algorithms are well explained in Wikipedia: https://en.wikipedia.org/wiki/Range_minimum_query.

Implementation: The idea is to cache every min(arr, i, j) where j - i is a power of two, i.e. j = i + 2^k for some k. Provided this information, we can answer all queries in O(1): given a pair (i, j) find the maximum k such that i + 2^k < j and note that std::min(min(arr, i, i+2^k), min(arr, j-2^k, j)) = min(arr, i, j).

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. The header defines an interface for functions taking and returning an int64_t and supporting range queries over their domain and codomain.

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. This file contains implementations for saturated addition, subtraction and multiplication. Currently, there are three versions of the code. The code using the built-ins provided since GCC 5.0 now compiles really well with clang/LLVM on both x86_64 and ARM. It should therefore be the standard, but not for multiplication, see below.

For example, on ARM, only 4 instructions are needed, two of which are additions that can be executed in parallel.

On x86_64, we're keeping the code with inline assembly for GCC as GCC does manage to compile the code with built-ins properly. On x86_64, the product of two 64-bit registers is a 128-bit integer stored in two 64-bit registers. It's the carry flag that is set when the result exceeds 64 bits, not the overflow flag. Since the built-in uses the overflow flag, we have to resort on the assembly-based version of the code.

Sadly, MSVC does not support the built-ins nor does it support inline assembly. We have to rely on the generic, C++ only version of the code which is much slower.

Todo

(user): make this implementation the default everywhere.

(user): investigate the code generated by MSVC.

HACK(user): We spare significant time if we use an initializer here, because InlineVector<1> is able to recognize the fast path or "exactly one element". I was unable to obtain the same performance with any other recipe, I always had at least 1 more cycle. See BM_SingleIntervalDomainConstructor. Since the constructor takes very few cycles (most likely less than 10), that's quite significant.

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. Helper classes to track statistics of a program component.

Usage example: ///< Suppose you have a class that contains a factorization of a matrix B and ///< a Solve() function to solve the linear system B.x = a.

///< You will hold your stats in a Stats stats_ class member: struct Stats : public StatsGroup { Stats() : StatsGroup("BasisFactorization"), solve_time("solve_time", this), input_vector_density("input_vector_density", this), estimated_accuracy("estimated_accuracy", this) {}

TimeDistribution solve_time; RatioDistribution input_vector_density;

///< Values of a few components of B.x - a, updated on each solve. DoubleDistribution estimated_accuracy; }

///< You then add a few lines to your Solve() function: void Solve() { stats_.solve_time.StartTimer(); stats_.input_vector_density.Add(ComputeDensity()); ... ///< Do the work. stats_.estimated_accuracy.Add(EstimateAccuracy()); stats_.solve_time.StopTimerAndAddElapsedTime(); }

///< Now, calling stats_.StatString() will give you a summary of your stats: BasisFactorization { solve_time : num [min, max] average std_deviation total input_vector_density : num [min, max] average std_deviation estimated_accuracy : num [min, max] average std_deviation }

For measuring time, another alternative is to use the SCOPED_TIME_STAT macro. In our example above, you don't need to define the solve_time distribution and you can just do:

void Solve() { SCOPED_TIME_STAT(&stats_); ... }

This automatically adds a TimeDistribution with name "Solve" to stats_ and times your function calls!

IMPORTANT: The SCOPED_TIME_STAT() macro only does something if OR_STATS is defined, so you need to build your code with blaze build –copt='-DOR_STATS'. The idea is that by default the instrumentation is off. You can also use the macro IF_STATS_ENABLED() that does nothing if OR_STATS is not defined or just translates to its argument otherwise.

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. Generates strongly typed integer types.

StrongIndex is a simple template class mechanism for defining "logical" index-like class types that support some of the same functionalities as int, but which prevent assignment, construction, and other operations from other similar integer-like types. Essentially, the template class StrongIndex<StrongIndexName> has the additional property that it cannot be assigned to or constructed from another StrongIndex with a different StrongIndexName.

Usage DEFINE_STRONG_INDEX_TYPE(name); where name is the desired (unique) name for the "logical" index type.

StrongInt64 is a more general strong integer class based on int64_t. It has the same general type safeness, and supports more integer operators.

Usage DEFINE_STRONG_INT64_TYPE(name); where name is the desired (unique) name for the "logical" int64_t type.

SUPPORTED OPERATIONS -----------------------------------------------------—

The StrongIndex type is limited and only supports following operators are supported: unary: ++ (both prefix and postfix), comparison: ==, !=, <, <=, >, >=; assignment: =, +=, -=,; stream: <<. Each operator allows the same StrongIndexName and the int to be used on both left- and right-hand sides.

The StrongInt64 type supports all integer operators across StrongInt64 with the same StrongIntegerName and int64_t.

Both support an accessor value() returning the stored value.

The classes also define hash functors that allows the strong types to be used as key to hashable containers.

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. Set of integer tuples (fixed-size arrays, all of the same size) with a basic API. It supports several types of integer arrays transparently, with an inherent storage based on int64_t arrays.

The key feature is the "lazy" copy:

  • Copying an IntTupleSet won't actually copy the data right away; we will just have several IntTupleSet pointing at the same data.
  • Modifying an IntTupleSet which shares his data with others will create a new, modified instance of the data payload, and make the IntTupleSet point to that new data.
  • Modifying an IntTupleSet that doesn't share its data with any other IntTupleSet will modify the data directly. Therefore, you don't need to use const IntTupleSet& in methods. Just do: void MyMethod(IntTupleSet tuple_set) { ... }

This class is thread hostile as the copy and reference counter are not protected by a mutex.

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. Fast summation of arrays (vectors, spans) of numbers.

Speed: up to 2x faster than Eigen for float arrays with ~100 elements or more (as of 2023-05). Precision: Better or comparable precision to std::accumulate<> on the same value type. That said, the precision is inferior to precise sum algorithm such as ::AccurateSum.

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. An array class for storing arrays of integers.

The range of indices is specified at the construction of the object. The minimum and maximum indices are inclusive. Think of the Pascal syntax array[min_index..max_index] of ...

For example, ZVector<int32_t>(-100000,100000) will store 200001 signed integers of 32 bits each, and the possible range of indices will be -100000..100000.

Copyright 2019-2023 RTE 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.

Typedef Documentation

◆ AlignedAllocator

template<typename T , size_t alignment_bytes>
using operations_research::AlignedAllocator
Initial value:
internal::AllocatorWithAlignment<T, alignment_bytes, 0>

Support for aligned containers in STL.

An allocator that always aligns its memory to alignment_bytes.

Definition at line 72 of file aligned_memory.h.

◆ AlignedVector

template<typename T , size_t alignment_bytes>
using operations_research::AlignedVector = std::vector<T, AlignedAllocator<T, alignment_bytes>>

A version of std::vector<T> whose data() pointer is always aligned to alignment_bytes.

Definition at line 78 of file aligned_memory.h.

◆ ArcId

using operations_research::ArcId = SubDagComputer::ArcId

Definition at line 4032 of file local_search.cc.

◆ ArcIndex

Definition at line 200 of file ebert_graph.h.

◆ ArcIndexArray

◆ BaseInt

Base non-strict integer type for counting elements and subsets. Using ints makes it possible to represent problems with more than 2 billion (2e9) elements and subsets. If need arises one day, BaseInt can be split into SubsetBaseInt and ElementBaseInt. Quick testing has shown a slowdown of about 20-25% when using int64_t.

Definition at line 68 of file set_cover_model.h.

◆ ColumnEntryRange

Definition at line 85 of file set_cover_model.h.

◆ Cost

using operations_research::Cost = double

Basic non-strict type for cost. The speed penalty for using double is ~2%.

Definition at line 61 of file set_cover_model.h.

◆ CostAllocator

◆ CostArray

Definition at line 209 of file ebert_graph.h.

◆ CostValue

typedef BlossomGraph::CostValue operations_research::CostValue = BlossomGraph::CostValue

Definition at line 202 of file ebert_graph.h.

◆ EdgeWeights

typedef std::function<int64_t(int, int)> operations_research::EdgeWeights

Mapping between an edge (given by its tail and its head) and its weight.

Definition at line 89 of file simple_graph.h.

◆ ElementAllocator

Initial value:
AlignedAllocator<ElementIndex, kSetCoverAlignmentInBytes>

Definition at line 93 of file set_cover_model.h.

◆ ElementCostVector

◆ ElementRange

Definition at line 84 of file set_cover_model.h.

◆ ElementToIntVector

◆ FlowQuantity

Definition at line 201 of file ebert_graph.h.

◆ ForwardStarGraph

◆ ForwardStarStaticGraph

◆ Fraction

typedef std::pair<int64_t, int64_t> operations_research::Fraction

The type Fraction represents a number in the form of two integers: numerator and denominator. This type is used to display the rational approximation of a Fractional number.

Definition at line 25 of file rational_approximation.h.

◆ Graph

Type of graph to use.

Definition at line 174 of file solve_flow_model.cc.

◆ GScipMessageHandler

Initial value:
std::function<void(GScipMessageType type, absl::string_view message)>
std::string message
Definition trace.cc:397

An optional callback function to redirect the SCIP logging messages.

The input message usually ends with a newline character. This may not be the case though when the internal buffer of SCIP is full, in the case this function is called with a partial message. This will also happen when the last message the solve ends with an unfinished line.

Definition at line 36 of file gscip_message_handler.h.

◆ Int16ZVector

Definition at line 158 of file zvector.h.

◆ Int32ZVector

Definition at line 159 of file zvector.h.

◆ Int64ZVector

Definition at line 160 of file zvector.h.

◆ Int8ZVector

Shorthands for all the types of ZVector's.

Definition at line 157 of file zvector.h.

◆ IntAllocator

◆ KnapsackItemPtr

◆ NodeId

using operations_research::NodeId = SubDagComputer::NodeId

Definition at line 3986 of file local_search.cc.

◆ NodeIndex

Standard instantiation of ForwardEbertGraph (named 'ForwardStarGraph') of EbertGraph (named 'StarGraph'); and relevant type shortcuts. Unless their use cases prevent them from doing so, users are encouraged to use StarGraph or ForwardStarGraph according to whether or not they require reverse arcs to be represented explicitly. Along with either graph representation, the other type shortcuts here will often come in handy.

Definition at line 199 of file ebert_graph.h.

◆ NodeIndexArray

◆ PathDistance

Storing distances on 32 bits to limit memory consumption of distance matrices. If distances don't fit on 32 bits, scaling and losing a bit of precision should be acceptable in practice.

Definition at line 80 of file shortest_paths.h.

◆ PathNodeIndex

Deprecated
type.

Definition at line 449 of file hamiltonian_path.h.

◆ QuantityArray

◆ random_engine_t

using operations_research::random_engine_t = std::mt19937_64

Definition at line 23 of file random_engine.h.

◆ RoutingNodeEvaluator2

typedef std::function<int64_t(RoutingNodeIndex, RoutingNodeIndex)> operations_research::RoutingNodeEvaluator2

Definition at line 30 of file cvrptw_lib.h.

◆ RoutingTransitCallback1

typedef std::function<int64_t(int64_t)> operations_research::RoutingTransitCallback1

Definition at line 50 of file routing_types.h.

◆ RoutingTransitCallback2

typedef std::function<int64_t(int64_t, int64_t)> operations_research::RoutingTransitCallback2

Definition at line 51 of file routing_types.h.

◆ ScopedInstructionCounter

◆ ScopedTimeDistributionUpdater

If OR_STATS is not defined, we remove some instructions that may be time consuming.

Definition at line 414 of file stats.h.

◆ SparseColumn

◆ SparseColumnView

Views of the sparse vectors. These need not be aligned as it's their contents that need to be aligned.

Definition at line 116 of file set_cover_model.h.

◆ SparseRow

◆ SparseRowView

◆ StarGraph

◆ StrictVector

template<typename IndexType , typename ValueType >
using operations_research::StrictVector = glop::StrictITIVector<IndexType, ValueType>

Definition at line 43 of file set_cover_mip.cc.

◆ SubsetAllocator

Initial value:
AlignedAllocator<SubsetIndex, kSetCoverAlignmentInBytes>

Definition at line 95 of file set_cover_model.h.

◆ SubsetBoolVector

Definition at line 119 of file set_cover_model.h.

◆ SubsetCostVector

◆ SubsetRange

Definition at line 83 of file set_cover_model.h.

◆ SubsetToIntVector

◆ UInt16ZVector

Definition at line 162 of file zvector.h.

◆ UInt32ZVector

Definition at line 163 of file zvector.h.

◆ UInt64ZVector

Definition at line 164 of file zvector.h.

◆ UInt8ZVector

Definition at line 161 of file zvector.h.

◆ UnsafeDenseSet

template<typename T >
using operations_research::UnsafeDenseSet = DenseSet<T, false>

Like DenseSet, but does not automatically resize the internal position vector, which is ~30% faster.

Definition at line 135 of file dense_set.h.

◆ value_type_t

template<class Iterator >
using operations_research::value_type_t = typename std::iterator_traits<Iterator>::value_type

Definition at line 24 of file sort.h.

◆ VariableDomainId

using operations_research::VariableDomainId = LocalSearchState::VariableDomainId

Definition at line 3867 of file local_search.cc.

Enumeration Type Documentation

◆ BronKerboschAlgorithmStatus

The status value returned by BronKerboschAlgorithm::Run and BronKerboschAlgorithm::RunIterations.

Enumerator
COMPLETED 

The algorithm has enumerated all maximal cliques.

INTERRUPTED 

The search algorithm was interrupted either because it reached the iteration limit or because the clique callback returned CliqueResponse::STOP.

Definition at line 72 of file cliques.h.

◆ CliqueResponse

Possible return values of the callback for reporting cliques. The returned value determines whether the algorithm will continue the search.

Enumerator
CONTINUE 

The algorithm will continue searching for other maximal cliques.

STOP 

The algorithm will stop the search immediately. The search can be resumed by calling BronKerboschAlgorithm::Run (resp. RunIterations) again.

Definition at line 62 of file cliques.h.

◆ ConstraintHandlerCallbackType

Helpers for implementing callbacks Enum with supported user-implementable callback functions in the SCIP constraint handler. Non-user-implementable functions are not included here (e.g. CONSFREE). Same order as in type_cons.h.

Enumerator
kSepaLp 
kSepaSol 
kEnfoLp 
kEnfoPs 

Unsupported: kEnfoRelax, ///< CONSENFORELAX.

kConsCheck 
kConsLock 

Unsupported: kConsProp, ///< CONSPROP Unsupported: kConsPresol, ///< CONSPRESOL Unsupported: kConsResProp, ///< CONSRESPROP

Definition at line 462 of file gscip_constraint_handler.h.

◆ CUSTOM_INTERRUPT_REASON

Enumerator
CALLBACK_EXCEPTION 

Definition at line 199 of file xpress_interface.cc.

◆ DimensionSchedulingStatus

Enumerator
OPTIMAL 

An optimal solution was found respecting all constraints.

RELAXED_OPTIMAL_ONLY 

An optimal solution was found, however constraints which were relaxed were violated.

INFEASIBLE 

A solution could not be found.

Definition at line 157 of file routing_lp_scheduling.h.

◆ GScipCallbackResult

Equivalent to type_result.h in SCIP.

Enumerator
kDidNotRun 
kDelayed 
kDidNotFind 
kFeasible 
kInfeasible 
kUnbounded 
kCutOff 
kSeparated 
kNewRound 

The method added a cutting plane and a new separation round should immediately start.

kReducedDomain 
kConstraintAdded 
kConstraintChanged 
kBranched 
kSolveLp 
kFoundSolution 
kSuspend 

The method interrupted its execution, but can continue if needed.

kSuccess 
kDelayNode 

The processing of the branch-and-bound node should stopped and continued later.

Definition at line 23 of file gscip_callback_result.h.

◆ GScipMessageType

Scip message handlers have three methods to log messages. This enum enables using the same function for all three types of messages.

Enumerator
kInfoMessage 
kDialogMessage 
kWarningMessage 

Definition at line 28 of file gscip_message_handler.h.

◆ MPCallbackEvent

The current state of the solver when the callback is invoked.

For Gurobi, similar to the int 'where' in the Gurobi callback API. See http://www.gurobi.com/documentation/8.0/refman/callback_codes.html for details.

Enumerator
kUnknown 
kPolling 

For regaining control of the main thread in single threaded applications, not for interacting with the solver.

kPresolve 

The solver is currently running presolve.

kSimplex 

The solver is currently running the simplex method.

kMip 

The solver is in the MIP loop (called periodically before starting a new node). Useful to early termination.

kMipSolution 

Called every time a new MIP incumbent is found.

kMipNode 

Called once per pass of the cut loop inside each MIP node.

kBarrier 

Called in each iterate of IPM/barrier method.

kMessage 

The solver is about to log out a message, use this callback to capture it.

kMultiObj 

The solver is in multi-objective optimization.

Definition at line 34 of file linear_solver_callback.h.

◆ PiecewiseEvaluationStatus

Simple struct returned by ComputePiecewiseLinearFormulationValue() to indicate if the value could be computed and if not, on what side the value was from the definition interval.

Enumerator
UNSPECIFIED 
WITHIN_BOUNDS 
SMALLER_THAN_LOWER_BOUND 
LARGER_THAN_UPPER_BOUND 

Definition at line 1008 of file routing_lp_scheduling.h.

◆ ProtoWriteFormat

Specifies how the proto should be formatted when writing it to a file. kCanonicalJson converts field names to lower camel-case.

Enumerator
kProtoText 
kProtoBinary 
kJson 
kCanonicalJson 

Definition at line 61 of file file_util.h.

◆ RoundingLockDirection

Advanced use only. Indicates that if a variable moves in this direction, it can cause a constraint violation. kBoth is the safest option and always valid, but it is the least flexible for SCIP.

Enumerator
kUp 
kDown 
kBoth 

Definition at line 109 of file gscip_constraint_handler.h.

◆ RoutingOutputFormat

Indicates the format in which the output should be done. This enumeration is used for solutions and solver statistics.

Enumerator
kNone 
kTSPLIB 
kCVRPLIB 
kCARPLIB 
kNEARPLIB 

Definition at line 39 of file solution_serializer.h.

◆ ScipSeparationResult

Enumerator
kLazyConstraintAdded 
kCuttingPlaneAdded 
kDidNotFind 

Definition at line 95 of file scip_callback.cc.

◆ SetCoverMipSolver

enum class operations_research::SetCoverMipSolver : int
strong
Enumerator
SCIP 
SAT 
GUROBI 
GLOP 
PDLP 

Definition at line 22 of file set_cover_mip.h.

◆ SolveStatus

Enumerator
OPTIMAL 
FEASIBLE 
INFEASIBLE 
UNBOUNDED 
ABNORMAL 
NOT_SOLVED 
MODEL_IS_VALID 
CANCELLED_BY_USER 
UNKNOWN_STATUS 
MODEL_INVALID 
INVALID_SOLVER_PARAMETERS 
SOLVER_TYPE_UNAVAILABLE 
INCOMPATIBLE_OPTIONS 

Definition at line 144 of file model_builder_helper.h.

◆ VarTypes

This enum is used internally to do dynamic typing on subclasses of integer variables.

Enumerator
UNSPECIFIED 
DOMAIN_INT_VAR 
BOOLEAN_VAR 
CONST_VAR 
VAR_ADD_CST 
VAR_TIMES_CST 
CST_SUB_VAR 
OPP_VAR 
TRACE_VAR 

Definition at line 126 of file constraint_solveri.h.

◆ XPRS_BASIS_STATUS

Enumerator
XPRS_AT_LOWER 
XPRS_BASIC 
XPRS_AT_UPPER 
XPRS_FREE_SUPER 

Definition at line 206 of file xpress_interface.cc.

Function Documentation

◆ AbslHashValue() [1/2]

template<typename StrongIndexName , typename H >
H operations_research::AbslHashValue ( H h,
const StrongIndex< StrongIndexName > & i )

– ABSL HASHING SUPPORT --------------------------------------------------—

Definition at line 338 of file strong_integers.h.

◆ AbslHashValue() [2/2]

template<typename StrongIntegerName , typename H >
H operations_research::AbslHashValue ( H h,
const StrongInt64< StrongIntegerName > & i )

Definition at line 343 of file strong_integers.h.

◆ AbslParseFlag()

bool operations_research::AbslParseFlag ( const absl::string_view text,
MPSolver::OptimizationProblemType * solver_type,
std::string * error )

Definition at line 639 of file linear_solver.cc.

◆ AbslStringify() [1/2]

template<typename Sink , typename... T>
void operations_research::AbslStringify ( Sink & sink,
StrongIndex< T... > arg )

Definition at line 256 of file strong_integers.h.

◆ AbslStringify() [2/2]

template<typename Sink , typename... T>
void operations_research::AbslStringify ( Sink & sink,
StrongInt64< T... > arg )

Definition at line 267 of file strong_integers.h.

◆ AbslUnparseFlag()

std::string operations_research::AbslUnparseFlag ( MPSolver::OptimizationProblemType solver_type)
inline

Definition at line 1013 of file linear_solver.h.

◆ AcceptDelta()

bool operations_research::AcceptDelta ( Search * search,
Assignment * delta,
Assignment * deltadelta )

Returns true if the search accepts the delta (actually checking this by calling AcceptDelta on the monitors of the search).

Definition at line 1380 of file constraint_solver.cc.

◆ AcceptNeighbor()

void operations_research::AcceptNeighbor ( Search * search)

Notifies the search that a neighbor has been accepted by local search.

Definition at line 1384 of file constraint_solver.cc.

◆ AcceptUncheckedNeighbor()

void operations_research::AcceptUncheckedNeighbor ( Search * search)

Definition at line 1386 of file constraint_solver.cc.

◆ AddCallbackConstraint()

template<typename ConstraintData >
void operations_research::AddCallbackConstraint ( SCIP * scip,
ScipConstraintHandler< ConstraintData > * handler,
const std::string & constraint_name,
const ConstraintData * constraint_data,
const ScipCallbackConstraintOptions & options )

constraint_data is not owned but held.

Definition at line 261 of file scip_callback.h.

◆ AddHadOverflow()

bool operations_research::AddHadOverflow ( int64_t x,
int64_t y,
int64_t sum )
inline

Helper function that returns true if an overflow has occurred in computing sum = x + y. sum is expected to be computed elsewhere.

Overflow cannot occur if operands have different signs. It can only occur if sign(x) == sign(y) and sign(sum) != sign(x), which is equivalent to: sign(x) != sign(sum) && sign(y) != sign(sum). This is captured when the expression below is negative.

Definition at line 98 of file saturated_arithmetic.h.

◆ addhint()

void operations_research::addhint ( const XPRSprob & mLp,
int length,
const double solval[],
const int colind[] )

The OR-Tools API does not allow setting a name for the solution passing NULL to XPRESS will have it generate a unique ID for the solution

Definition at line 190 of file xpress_interface.cc.

◆ AddOverflows()

bool operations_research::AddOverflows ( int64_t x,
int64_t y )
inline

A note on overflow treatment. kint64min and kint64max are treated as infinity. Thus if the computation overflows, the result is always kint64m(ax/in).

Note(user): this is actually wrong: when computing A-B, if A is kint64max and B is finite, then A-B won't be kint64max: overflows aren't sticky.

Todo
(user): consider making some operations overflow-sticky, some others not, but make an explicit choice throughout.

Definition at line 122 of file saturated_arithmetic.h.

◆ AlignDown()

template<size_t alignment_bytes, typename Value >
Value * operations_research::AlignDown ( Value * ptr)
inline

Returns the nearest smaller or equal address that is a multiple of alignment_bytes. When ptr is already aligned to alignment_bytes, returns it unchanged

Definition at line 56 of file aligned_memory.h.

◆ AlignedVectorSum()

float operations_research::AlignedVectorSum ( absl::Span< const float > values)
inline

Computes the sum of values, assuming that the first element of values is aligned to 16 bytes.

Definition at line 32 of file vector_sum.h.

◆ AlignUp()

template<size_t alignment_bytes, typename Value >
Value * operations_research::AlignUp ( Value * ptr)
inline

Functions for working with pointers and rounding them up and down to a given alignment. Returns the nearest greater or equal address that is a multiple of alignment_bytes. When ptr is already aligned to alignment_bytes, returns it unchanged.

Definition at line 45 of file aligned_memory.h.

◆ AppendDimensionCumulFilters()

void operations_research::AppendDimensionCumulFilters ( const std::vector< RoutingDimension * > & dimensions,
const RoutingSearchParameters & parameters,
bool filter_objective_cost,
bool use_chain_cumul_filter,
std::vector< LocalSearchFilterManager::FilterEvent > * filters )

Filter priority depth increases with complexity of filtering.

  • Dimensions without any cumul-related costs or constraints will have a ChainCumulFilter, lowest priority depth.
  • Dimensions with cumul costs or constraints, but no global span cost and/or precedences will have a PathCumulFilter.
  • Dimensions with a global span cost coefficient and/or precedences will have a global LP filter.
Note
We always add the [Chain|Path]CumulFilter to filter each route's feasibility separately to try and cut bad decisions earlier in the search, but we don't propagate the computed cost if the LPCumulFilter is already doing it.

Definition at line 2169 of file routing_filters.cc.

◆ AppendLightWeightDimensionFilters()

void operations_research::AppendLightWeightDimensionFilters ( const PathState * path_state,
const std::vector< RoutingDimension * > & dimensions,
std::vector< LocalSearchFilterManager::FilterEvent > * filters )

Appends dimension-based filters to the given list of filters using a path state.

For every dimension that fits, add a DimensionChecker. Add a DimensionChecker for every dimension.

Fill path capacities and classes.

For each class, retrieve the demands of each node. Dimension store evaluators with a double indirection for compacity: vehicle -> vehicle_class -> evaluator_index. We replicate this in DimensionChecker, except we expand evaluator_index to an array of values for all nodes.

Fill node capacities.

Make the dimension checker and pass ownership to the filter.

Definition at line 2096 of file routing_filters.cc.

◆ AppendTasksFromIntervals()

void operations_research::AppendTasksFromIntervals ( const std::vector< IntervalVar * > & intervals,
DisjunctivePropagator::Tasks * tasks )

Definition at line 694 of file routing_breaks.cc.

◆ AppendTasksFromPath()

void operations_research::AppendTasksFromPath ( absl::Span< const int64_t > path,
const TravelBounds & travel_bounds,
const RoutingDimension & dimension,
DisjunctivePropagator::Tasks * tasks )

Add task associated to visit i. Visits start at Cumul(path[i]) - before_visit and end at Cumul(path[i]) + after_visit

Tasks from travels. A travel task starts at Cumul(path[i]) + pre_travel, last for FixedTransitVar(path[i]) - pre_travel - post_travel, and must end at the latest at Cumul(path[i+1]) - post_travel.

Definition at line 610 of file routing_breaks.cc.

◆ ApplyMipPresolveSteps()

glop::ProblemStatus operations_research::ApplyMipPresolveSteps ( const glop::GlopParameters & glop_params,
MPModelProto * model,
std::vector< std::unique_ptr< glop::Preprocessor > > * for_postsolve,
SolverLogger * logger )

Applies presolve steps to improve the MIP -> IP imperfect conversion. The stricter the domain of the variables, the more room we have for scaling the constraint to integers and prevent overflow. Similarly if we can remove singleton continuous variables, it is just good to do so.

Returns the presolve status which can currently be:

  • INIT for most cases were nothing was proven during this step.
  • PRIMAL_INFEASIBLE if the model was proven infeasible.
  • INFEASIBLE_OR_UNBOUNDED if the presolve couldn't distinguish between these two statuses.
  • ABNORMAL if an error occurred.
Todo
(user): General constraints are currently not supported.

We need to copy the hint because LinearProgramToMPModelProto() loose it.

Todo
(user): Remove this back and forth conversion. We could convert the LinearProgram directly to a CpModelProto, or we could have a custom implementation of these presolve steps.

These presolve might change the problem size.

Todo
(user): transform the hint instead of disabling presolve.
Todo
(user): Usually it is good to run the ImpliedFreePreprocessor before this one. However this seems to cause problem on atm20-100.mps. Moreover, for the conversion, it is better to have tight bounds even if the bound propagator is supposed to undo what this presolve would have done.

Finally, we make sure all domains contain zero.

Restore the hint, note that none of the presolve steps we run here change the number of variables in the model.

Definition at line 36 of file sat_solver_utils.cc.

◆ ApplyVerifiedMPModelDelta()

void operations_research::ApplyVerifiedMPModelDelta ( const MPModelDeltaProto & delta,
MPModelProto * model )

Applies the given model_delta to "model". Assumes that FindErrorInMPModelDeltaProto() found no error. For full error checking, please use ExtractValidMPModelOrPopulateResponseStatus() instead.

Apply the delta to the variables: first, resize the variable array.

Then, apply the variable overrides.

Apply the delta to the constraints: first, resize the constraint array.

Then, apply the constraint overrides.

Fast path for added constraints.

Special case: the override is neutralized.

Otherwise we have to apply the term overrides. We can't do that in less than O(baseline + override_ct) because the baseline doesn't have a lookup-friendly data structure. But we still try to do it as efficiently as possible. In particular, we only use O(override_ct) extra memory.

Add the term overrides which haven't been used: those are added terms.

Definition at line 983 of file model_validator.cc.

◆ AreAllBooleans()

bool operations_research::AreAllBooleans ( const std::vector< IntVar * > & vars)
inline

Definition at line 3284 of file constraint_solveri.h.

◆ AreAllBound()

bool operations_research::AreAllBound ( const std::vector< IntVar * > & vars)
inline

Definition at line 3275 of file constraint_solveri.h.

◆ AreAllBoundOrNull()

template<class T >
bool operations_research::AreAllBoundOrNull ( const std::vector< IntVar * > & vars,
const std::vector< T > & values )

Returns true if all the variables are assigned to a single value, or if their corresponding value is null.

Definition at line 3291 of file constraint_solveri.h.

◆ AreAllBoundTo()

bool operations_research::AreAllBoundTo ( const std::vector< IntVar * > & vars,
int64_t value )
inline

Returns true if all variables are assigned to 'value'.

Definition at line 3302 of file constraint_solveri.h.

◆ AreAllGreaterOrEqual()

template<class T >
bool operations_research::AreAllGreaterOrEqual ( const std::vector< T > & values,
const T & value )

Definition at line 3205 of file constraint_solveri.h.

◆ AreAllLessOrEqual()

template<class T >
bool operations_research::AreAllLessOrEqual ( const std::vector< T > & values,
const T & value )

Definition at line 3215 of file constraint_solveri.h.

◆ AreAllNegative()

template<class T >
bool operations_research::AreAllNegative ( const std::vector< T > & values)

Definition at line 3230 of file constraint_solveri.h.

◆ AreAllNull()

template<class T >
bool operations_research::AreAllNull ( const std::vector< T > & values)

Definition at line 3200 of file constraint_solveri.h.

◆ AreAllOnes()

template<class T >
bool operations_research::AreAllOnes ( const std::vector< T > & values)

Definition at line 3195 of file constraint_solveri.h.

◆ AreAllPositive()

template<class T >
bool operations_research::AreAllPositive ( const std::vector< T > & values)

Definition at line 3225 of file constraint_solveri.h.

◆ AreAllStrictlyNegative()

template<class T >
bool operations_research::AreAllStrictlyNegative ( const std::vector< T > & values)

Definition at line 3240 of file constraint_solveri.h.

◆ AreAllStrictlyPositive()

template<class T >
bool operations_research::AreAllStrictlyPositive ( const std::vector< T > & values)

Definition at line 3235 of file constraint_solveri.h.

◆ AreWithinAbsoluteOrRelativeTolerances()

template<typename FloatType >
bool operations_research::AreWithinAbsoluteOrRelativeTolerances ( FloatType x,
FloatType y,
FloatType relative_tolerance,
FloatType absolute_tolerance )

Tests whether x and y are close to one another using absolute and relative tolerances. Returns true if |x - y| <= a (with a being the absolute_tolerance). The above case is useful for values that are close to zero. Returns true if |x - y| <= max(x, y) * r. (with r being the relative tolerance.) The cases for infinities are treated separately to avoid generating NaNs.

Definition at line 126 of file fp_utils.h.

◆ AreWithinAbsoluteTolerance()

template<typename FloatType >
bool operations_research::AreWithinAbsoluteTolerance ( FloatType x,
FloatType y,
FloatType absolute_tolerance )

Tests whether x and y are close to one another using an absolute tolerance. Returns true if |x - y| <= a (with a being the absolute_tolerance). The cases for infinities are treated separately to avoid generating NaNs.

Definition at line 147 of file fp_utils.h.

◆ assign()

Select next search node to expand Select next item_i to operations_research::assign ( using primary propagator)
new

The following code defines needed classes for the KnapsackGenericSolver class which is the entry point to extend knapsack with new constraints such as conflicts between items.

Constraints are enforced using KnapsackPropagator objects, in the current code there is one propagator per dimension (KnapsackCapacityPropagator). One of those propagators, named primary propagator, is used to guide the search, i.e. decides which item should be assigned next. Roughly speaking the search algorithm is:

  • While not optimal

◆ AtMinOrMaxInt64()

bool operations_research::AtMinOrMaxInt64 ( int64_t x)
inline

Checks if x is equal to the min or the max value of an int64_t.

Definition at line 53 of file saturated_arithmetic.h.

◆ atoi32()

int32_t operations_research::atoi32 ( absl::string_view word)
inline

Convenience versions of the above that take a string argument.

Definition at line 56 of file strtoint.h.

◆ atoi64()

int64_t operations_research::atoi64 ( absl::string_view word)
inline

Definition at line 57 of file strtoint.h.

◆ AutomaticFirstSolutionStrategy()

operations_research::FirstSolutionStrategy::Value operations_research::AutomaticFirstSolutionStrategy ( bool has_pickup_deliveries,
bool has_node_precedences,
bool has_single_vehicle_node )
  • Models with pickup/deliveries or node precedences are best handled by PARALLEL_CHEAPEST_INSERTION.
  • As of January 2018, models with single nodes and at least one node with only one allowed vehicle are better solved by PATH_MOST_CONSTRAINED_ARC.
  • In all other cases, PATH_CHEAPEST_ARC is used.
    Todo
    (user): Make this smarter.

Returns the best value for the automatic first solution strategy, based on the given model parameters.

Definition at line 182 of file routing_search.cc.

◆ BasisStatusString()

std::string operations_research::BasisStatusString ( const int stat)

Formats a linear constraint or variable basis status (GLP_BS,...).

Definition at line 49 of file glpk_formatters.cc.

◆ BinarySearch()

template<class Point >
Point operations_research::BinarySearch ( Point x_true,
Point x_false,
std::function< bool(Point)> f )

EXAMPLE: ///< Finds the value x in [0,Pi/2] such that cos(x)=2sin(x): BinarySearch<double>(/*x_true=*‍/0.0, /*x_false=*‍/M_PI/2, [](double x) { return cos(x) >= 2*sin(x); });

Note
x_true > x_false is supported: it works either way.

Ideally, f is a monotonic boolean function, such that:

  • f(x_true) = true
  • f(x_false) = false
  • there exists X such that f(x)=true for all x between x_true and X, and f(x)=false for all x between X and x_false.

In those conditions, this returns that value X (note that f(X) is true). See below for the NON-MONOTONIC case.

Also note that 'Point' may be floating-point types: the function will still converge when the midpoint can't be distinguished from one of the limits, which will always happen. You can use other types than numerical types, too. absl::Duration is naturally supported.

OVERFLOWS and NON-NUMERICAL TYPES: If your points may be subject to overflow (e.g. ((kint32max-1) + (kint32max))/2 will overflow an int32_t), or they don't support doing (x+y)/2, you can specialize BinarySearchMidpoint() to suit your needs. See the examples in the unit test.

NON-MONOTONIC FUNCTIONS: If f isn't monotonic, the binary search will still run with it typical complexity, and finish. The Point X that it returns will be a "local" inflexion point, meaning that the smallest possible move of that point X to a point X' (in the x_true->x_false direction deduced from the arguments) would make f(X') return false. EXAMPLES:

  • If Point=int32_t, then the returned X verifies f(X) = true and f(X') = false with X' = X + (x_true < x_false ? 1 : -1).
  • If Point=double, ditto with X' = X * (1 + (x_true < x_false ? ε : -ε)), where ε = std::numeric_limits<double>::epsilon().

Note also that even if f() is non-deterministic, i.e. f(X) can sometimes return true and sometimes false for the same X, then the binary search will still finish, but it's hard to say anything about the returned X.

NOTE(user): If your "Point" type doesn't support the + or the /2 operations, we could imagine using the same trick as IsNanGeneric() to make BinarySearch() work for your use case.

NOTE(user): If your "Point" type doesn't support the + or the /2 operations, we could imagine using the same trick as IsNanGeneric() to make BinarySearch() work for your use case.

Definition at line 211 of file binary_search.h.

◆ BinarySearchMidpoint()

template<class Point >
Point operations_research::BinarySearchMidpoint ( Point x,
Point y )

Used by BinarySearch(). This is just (x+y)/2, with some DCHECKs to catch overflows. You should override (i.e. specialize) it if you risk getting overflows or need something more complicated than (x+y)/2. See examples in the unit test.

For integers using two's complement (all compilers in practice up to c++17, and all compilers in theory starting from c++20), we can use a trick from Hacker's delight. See e.g. https://lemire.me/blog/2022/12/06/fast-midpoint-between-two-integers-without-overflow/

For integers of the same sign, avoid overflows with a simple trick.

For integers using two's complement (all compilers in practice up to c++17, and all compilers in theory starting from c++20), we can use a trick from Hacker's delight. See e.g. https://lemire.me/blog/2022/12/06/fast-midpoint-between-two-integers-without-overflow/

For integers of the same sign, avoid overflows with a simple trick.

Definition at line 180 of file binary_search.h.

◆ BitCount32()

uint32_t operations_research::BitCount32 ( uint32_t n)
inline

Definition at line 57 of file bitset.h.

◆ BitCount64()

uint64_t operations_research::BitCount64 ( uint64_t n)
inline

Returns the number of bits set in n.

Definition at line 46 of file bitset.h.

◆ BitCountRange32()

uint32_t operations_research::BitCountRange32 ( const uint32_t * bitset,
uint32_t start,
uint32_t end )

◆ BitCountRange64()

uint64_t operations_research::BitCountRange64 ( const uint64_t * bitset,
uint64_t start,
uint64_t end )

Returns the number of bits set in bitset between positions start and end.

◆ BitLength32()

uint32_t operations_research::BitLength32 ( uint32_t size)
inline

Definition at line 343 of file bitset.h.

◆ BitLength64()

uint64_t operations_research::BitLength64 ( uint64_t size)
inline

Returns the number of words needed to store size bits.

Definition at line 342 of file bitset.h.

◆ BitOffset32()

uint32_t operations_research::BitOffset32 ( uint32_t pos)
inline

Definition at line 339 of file bitset.h.

◆ BitOffset64()

uint64_t operations_research::BitOffset64 ( uint64_t pos)
inline

Returns the word number corresponding to bit number pos.

Definition at line 338 of file bitset.h.

◆ BitPos32()

uint32_t operations_research::BitPos32 ( uint32_t pos)
inline

Definition at line 335 of file bitset.h.

◆ BitPos64()

uint32_t operations_research::BitPos64 ( uint64_t pos)
inline

Bit operators used to manipulates bitsets.

--— Bitset operators --— Bitset: array of uint32_t/uint64_t words Returns the bit number in the word computed by BitOffsetXX, corresponding to the bit at position pos in the bitset.

Note
'& 63' is faster than '% 64'
Todo
(user): rename BitPos and BitOffset to something more understandable.

Definition at line 334 of file bitset.h.

◆ BitShift32()

uint32_t operations_research::BitShift32 ( uint32_t v)
inline

Definition at line 347 of file bitset.h.

◆ BitShift64()

uint64_t operations_research::BitShift64 ( uint64_t v)
inline

Returns the bit number in the bitset of the first bit of word number v.

Definition at line 346 of file bitset.h.

◆ BuildBopInterface()

MPSolverInterface * operations_research::BuildBopInterface ( MPSolver *const solver)

Register BOP in the global linear solver factory.

--— Solver --—

Definition at line 391 of file bop_interface.cc.

◆ BuildCBCInterface()

MPSolverInterface * operations_research::BuildCBCInterface ( MPSolver *const solver)

Definition at line 533 of file cbc_interface.cc.

◆ BuildCLPInterface()

MPSolverInterface * operations_research::BuildCLPInterface ( MPSolver *const solver)

Definition at line 625 of file clp_interface.cc.

◆ BuildCplexInterface()

MPSolverInterface * operations_research::BuildCplexInterface ( bool mip,
MPSolver *const solver )

Definition at line 1286 of file cplex_interface.cc.

◆ BuildDemonProfiler()

DemonProfiler * operations_research::BuildDemonProfiler ( Solver * solver)
extern

Definition at line 445 of file demon_profiler.cc.

◆ BuildDurationExpr()

IntExpr * operations_research::BuildDurationExpr ( IntervalVar * var)

Definition at line 171 of file sched_expr.cc.

◆ BuildEndExpr()

IntExpr * operations_research::BuildEndExpr ( IntervalVar * var)

Definition at line 181 of file sched_expr.cc.

◆ BuildEulerianPath()

template<typename Graph >
std::vector< typename Graph::NodeIndex > operations_research::BuildEulerianPath ( const Graph & graph,
bool assume_connectivity = true )

Builds an Eulerian path/trail on an undirected graph. This function works only on Reverse graphs (cf. ortools/graph/graph.h). Returns an empty tour if a tour cannot be built.

Definition at line 141 of file eulerian_path.h.

◆ BuildEulerianPathFromNode()

template<typename NodeIndex , typename Graph >
std::vector< NodeIndex > operations_research::BuildEulerianPathFromNode ( const Graph & graph,
NodeIndex root )

Builds an Eulerian path/trail on an undirected graph starting from node root. Supposes the graph is connected and is eulerian or semi-eulerian. This is an implementation of Hierholzer's algorithm. If m is the number of edges in the graph and n the number of nodes, time and memory complexity is O(n + m).

Definition at line 78 of file eulerian_path.h.

◆ BuildEulerianTour()

template<typename Graph >
std::vector< typename Graph::NodeIndex > operations_research::BuildEulerianTour ( const Graph & graph,
bool assume_connectivity = true )

Same as above but without specifying a start/end root node (node 0 is taken as default root).

Definition at line 131 of file eulerian_path.h.

◆ BuildEulerianTourFromNode()

template<typename NodeIndex , typename Graph >
std::vector< NodeIndex > operations_research::BuildEulerianTourFromNode ( const Graph & graph,
NodeIndex root,
bool assume_connectivity = true )

Builds an Eulerian tour/circuit/cycle starting and ending at node root on an undirected graph. This function works only on Reverse graphs (cf. ortools/graph/graph.h). Returns an empty tour if either root is invalid or if a tour cannot be built.

Definition at line 119 of file eulerian_path.h.

◆ BuildGLOPInterface()

MPSolverInterface * operations_research::BuildGLOPInterface ( MPSolver *const solver)

Register GLOP in the global linear solver factory.

Definition at line 441 of file glop_interface.cc.

◆ BuildGLPKInterface()

MPSolverInterface * operations_research::BuildGLPKInterface ( bool mip,
MPSolver *const solver )

Definition at line 964 of file glpk_interface.cc.

◆ BuildGurobiInterface()

MPSolverInterface * operations_research::BuildGurobiInterface ( bool mip,
MPSolver *const solver )

Definition at line 1403 of file gurobi_interface.cc.

◆ BuildHighsInterface()

MPSolverInterface * operations_research::BuildHighsInterface ( bool mip,
MPSolver *const solver )

Register PDLP in the global linear solver factory.

Definition at line 298 of file highs_interface.cc.

◆ BuildKnapsackInterface()

MPSolverInterface * operations_research::BuildKnapsackInterface ( MPSolver *const solver)

Register Knapsack solver in the global linear solver factory.

Definition at line 362 of file knapsack_interface.cc.

◆ BuildKruskalMinimumSpanningTree()

template<typename Graph , typename ArcComparator >
std::vector< typename Graph::ArcIndex > operations_research::BuildKruskalMinimumSpanningTree ( const Graph & graph,
const ArcComparator & arc_comparator )

Version taking an arc comparator to sort graph arcs. Usage: ListGraph<int, int> graph(...); const auto arc_cost = [&graph](int arc) { return f(graph.Tail(arc), graph.Head(arc)); }; std::vector<int> mst = BuildKruskalMinimumSpanningTree( graph, [&arc_cost](int a, int b) { return arc_cost(a) < arc_cost(b); });

Definition at line 88 of file minimum_spanning_tree.h.

◆ BuildKruskalMinimumSpanningTreeFromSortedArcs()

template<typename Graph >
std::vector< typename Graph::ArcIndex > operations_research::BuildKruskalMinimumSpanningTreeFromSortedArcs ( const Graph & graph,
absl::Span< const typename Graph::ArcIndex > sorted_arcs )

Implementation of Kruskal's mininumum spanning tree algorithm (c.f. https://en.wikipedia.org/wiki/Kruskal%27s_algorithm). Returns the index of the arcs appearing in the tree; will return a forest if the graph is disconnected. Nodes without any arcs will be ignored. Each arc of the graph is interpreted as an undirected arc. Complexity of the algorithm is O(E * log(E)) where E is the number of arcs in the graph. Memory usage is O(E * log(E)).

Todo
(user): Add a global Minimum Spanning Tree API automatically switching between Prim and Kruskal depending on problem size.

Version taking sorted graph arcs. Allows somewhat incremental recomputation of minimum spanning trees as most of the processing time is spent sorting arcs. Usage: ListGraph<int, int> graph(...); std::vector<int> sorted_arcs = ...; std::vector<int> mst = BuildKruskalMinimumSpanningTreeFromSortedArcs( graph, sorted_arcs);

Definition at line 49 of file minimum_spanning_tree.h.

◆ BuildLineGraph()

template<typename GraphType >
bool operations_research::BuildLineGraph ( const GraphType & graph,
GraphType *const line_graph )

Builds a directed line graph for 'graph' (see "directed line graph" in http://en.wikipedia.org/wiki/Line_graph). Arcs of the original graph become nodes and the new graph contains only nodes created from arcs in the original graph (we use the notation (a->b) for these new nodes); the index of the node (a->b) in the new graph is exactly the same as the index of the arc a->b in the original graph. An arc from node (a->b) to node (c->d) in the new graph is added if and only if b == c in the original graph. This method expects that 'line_graph' is an empty graph (it has no nodes and no arcs). Returns false on an error.

Sizing then filling.

Definition at line 2093 of file ebert_graph.h.

◆ BuildLocalSearchMonitorPrimary()

LocalSearchMonitor * operations_research::BuildLocalSearchMonitorPrimary ( Solver * s)
extern

Definition at line 3227 of file constraint_solver.cc.

◆ BuildLocalSearchProfiler()

LocalSearchProfiler * operations_research::BuildLocalSearchProfiler ( Solver * solver)
extern

Definition at line 4582 of file local_search.cc.

◆ BuildModelCache()

ModelCache * operations_research::BuildModelCache ( Solver * solver)
extern

Definition at line 846 of file model_cache.cc.

◆ BuildPdlpInterface()

MPSolverInterface * operations_research::BuildPdlpInterface ( MPSolver *const solver)
extern

Register PDLP in the global linear solver factory.

Definition at line 314 of file pdlp_interface.cc.

◆ BuildPrimMinimumSpanningTree()

template<typename Graph , typename ArcValue >
std::vector< typename Graph::ArcIndex > operations_research::BuildPrimMinimumSpanningTree ( const Graph & graph,
const ArcValue & arc_value )

Implementation of Prim's mininumum spanning tree algorithm (c.f. https://en.wikipedia.org/wiki/Prim's_algorithm) on undirected connected graphs. Returns the index of the arcs appearing in the tree. Complexity of the algorithm is O(E * log(V)) where E is the number of arcs in the graph, V is the number of vertices. Memory usage is O(V) + memory taken by the graph. Usage: ListGraph<int, int> graph(...); const auto arc_cost = [&graph](int arc) -> int64_t { return f(graph.Tail(arc), graph.Head(arc)); }; std::vector<int> mst = BuildPrimMinimumSpanningTree(graph, arc_cost);

This struct represents entries in the adjustable priority queue which maintains active nodes (not added to the tree yet) in decreasing insertion cost order. AdjustablePriorityQueue requires the existence of the SetHeapIndex and GetHeapIndex methods.

Definition at line 114 of file minimum_spanning_tree.h.

◆ BuildPrintTrace()

PropagationMonitor * operations_research::BuildPrintTrace ( Solver * s)
extern

Definition at line 877 of file trace.cc.

◆ BuildSafeDurationExpr()

IntExpr * operations_research::BuildSafeDurationExpr ( IntervalVar * var,
int64_t unperformed_value )

Definition at line 196 of file sched_expr.cc.

◆ BuildSafeEndExpr()

IntExpr * operations_research::BuildSafeEndExpr ( IntervalVar * var,
int64_t unperformed_value )

Definition at line 201 of file sched_expr.cc.

◆ BuildSafeStartExpr()

IntExpr * operations_research::BuildSafeStartExpr ( IntervalVar * var,
int64_t unperformed_value )

Definition at line 191 of file sched_expr.cc.

◆ BuildSatInterface()

MPSolverInterface * operations_research::BuildSatInterface ( MPSolver *const solver)
extern

Register Sat in the global linear solver factory.

Definition at line 275 of file sat_interface.cc.

◆ BuildSCIPInterface()

MPSolverInterface * operations_research::BuildSCIPInterface ( MPSolver *const solver)
extern

Definition at line 1155 of file scip_interface.cc.

◆ BuildStartExpr()

IntExpr * operations_research::BuildStartExpr ( IntervalVar * var)

--— Expression builders ---—

--— API --—

Generic code for start/end/duration expressions. This is not done in a superclass as this is not compatible with the current class hierarchy.

Definition at line 161 of file sched_expr.cc.

◆ BuildTrace()

PropagationMonitor * operations_research::BuildTrace ( Solver * s)
extern

Definition at line 3151 of file constraint_solver.cc.

◆ BuildXpressInterface()

MPSolverInterface * operations_research::BuildXpressInterface ( bool mip,
MPSolver *const solver )
extern

Definition at line 2096 of file xpress_interface.cc.

◆ CapAbs()

int64_t operations_research::CapAbs ( int64_t v)
inline

Definition at line 61 of file saturated_arithmetic.h.

◆ CapAdd()

int64_t operations_research::CapAdd ( int64_t x,
int64_t y )
inline

Definition at line 292 of file saturated_arithmetic.h.

◆ CapAddGeneric()

int64_t operations_research::CapAddGeneric ( int64_t x,
int64_t y )
inline

The following implementations are here for GCC because it does not compiled the built-ins correctly. The code is either too long without branches or contains jumps. These implementations are probably optimal on x86_64. Simple implementations which use the built-ins provided by both GCC and clang. clang compiles to very good code for both x86_64 and ARM. This is the preferred implementation in general. Generic implementations. They are very good for addition and subtraction, less so for multiplication.

Definition at line 233 of file saturated_arithmetic.h.

◆ CapAddTo()

void operations_research::CapAddTo ( int64_t x,
int64_t * y )
inline

Definition at line 302 of file saturated_arithmetic.h.

◆ CapOpp()

int64_t operations_research::CapOpp ( int64_t v)
inline

Note(user): -kint64min != kint64max, but kint64max == ~kint64min.

Definition at line 59 of file saturated_arithmetic.h.

◆ CapOrFloatAdd()

template<typename T >
T operations_research::CapOrFloatAdd ( T x,
T y )

A generic, safer version of CapAdd() where we don't silently convert double or int32_t to int64_t. When the inputs are floating-point, uses '+', else uses CapAdd() for int64_t, and a (slow-ish) int32_t version for int.

Definition at line 329 of file saturated_arithmetic.h.

◆ CapProd()

int64_t operations_research::CapProd ( int64_t x,
int64_t y )
inline

Definition at line 314 of file saturated_arithmetic.h.

◆ CapProdGeneric()

int64_t operations_research::CapProdGeneric ( int64_t x,
int64_t y )
inline

The generic algorithm computes a bound on the number of bits necessary to store the result. For this it uses the position of the most significant bits of each of the arguments. If the result needs at least 64 bits, then return a capped value. If the result needs at most 63 bits, then return the product. Otherwise, the result may use 63 or 64 bits: compute the product as a uint64_t, and cap it if necessary.

Let MSB(x) denote the most significant bit of x. We have: MSB(x) + MSB(y) <= MSB(x * y) <= MSB(x) + MSB(y) + 1

Catch a == 0 or b == 0 now, as MostSignificantBitPosition64(0) == 0.

Todo
(user): avoid this by writing function Log2(a) with Log2(0) == -1.

The corner case is when msb_sum == 62, i.e. at least 63 bits will be needed to store the product. The following product will never overflow on uint64_t, since msb_sum == 62.

The overflow cases are captured by one of the following conditions: (cap >= 0 && u_prod >= static_cast<uint64_t>(kint64max) or (cap < 0 && u_prod >= static_cast<uint64_t>(kint64min)). These can be optimized as follows (and if the condition is false, it is safe to compute x * y.

Definition at line 258 of file saturated_arithmetic.h.

◆ CapSub()

int64_t operations_research::CapSub ( int64_t x,
int64_t y )
inline

Definition at line 304 of file saturated_arithmetic.h.

◆ CapSubGeneric()

int64_t operations_research::CapSubGeneric ( int64_t x,
int64_t y )
inline

Definition at line 238 of file saturated_arithmetic.h.

◆ CapWithSignOf()

int64_t operations_research::CapWithSignOf ( int64_t x)
inline

Returns kint64max if x >= 0 and kint64min if x < 0.

return kint64max if x >= 0 or kint64max + 1 (== kint64min) if x < 0.

Definition at line 143 of file saturated_arithmetic.h.

◆ CeilRatio()

int64_t operations_research::CeilRatio ( int64_t value,
int64_t positive_coeff )
Todo
(user): Use MathUtil::CeilOfRatio / FloorOfRatio instead.

Definition at line 95 of file sorted_interval_list.cc.

◆ CheckNodeIsValid()

template<class GraphType >
void operations_research::CheckNodeIsValid ( typename GraphType::NodeIndex node,
const GraphType & graph )

Definition at line 315 of file dag_shortest_path.h.

◆ ChooseMode()

BaseAssignVariables::Mode operations_research::ChooseMode ( Solver::IntValueStrategy val_str)

Definition at line 2106 of file search.cc.

◆ CleanVariableOnFail()

void operations_research::CleanVariableOnFail ( IntVar * var)
extern

---------------— Queue class ---------------—

--— API --—

Definition at line 6391 of file expressions.cc.

◆ ClearBit32()

void operations_research::ClearBit32 ( uint32_t *const bitset,
uint32_t pos )
inline

Definition at line 369 of file bitset.h.

◆ ClearBit64()

void operations_research::ClearBit64 ( uint64_t *const bitset,
uint64_t pos )
inline

Sets the bit pos to false in bitset.

Definition at line 366 of file bitset.h.

◆ ClearMostCoveredElements() [1/2]

std::vector< SubsetIndex > operations_research::ClearMostCoveredElements ( absl::Span< const SubsetIndex > focus,
std::size_t max_num_subsets,
SetCoverInvariant * inv )

Same as above, but clears the subset indices in focus.

This is the vector we will return.

Collect the sets which have at least one element whose coverage > 1, even if those sets are not removable.

Now intersect with focus: sampled_subsets = focus ⋂ impacted_subsets. NOTE(user): this might take too long.

Todo
(user):find another algorithm if necessary.

Actually sample sampled_subset.

Todo
(user): find another algorithm if necessary.

Testing has shown that sorting sampled_subsets is not necessary. Now, un-select the subset in sampled_subsets.

Definition at line 594 of file set_cover_heuristics.cc.

◆ ClearMostCoveredElements() [2/2]

std::vector< SubsetIndex > operations_research::ClearMostCoveredElements ( std::size_t num_subsets,
SetCoverInvariant * inv )

Clears the variables (subsets) that cover the most covered elements. This is capped by num_subsets. If the cap is reached, the subsets are chosen randomly. Returns the list of the chosen subset indices. This indices can then be used ax a focus.

Definition at line 588 of file set_cover_heuristics.cc.

◆ ClearRandomSubsets() [1/2]

std::vector< SubsetIndex > operations_research::ClearRandomSubsets ( absl::Span< const SubsetIndex > focus,
std::size_t num_subsets,
SetCoverInvariant * inv )

Same as above, but clears the subset indices in focus.

Note
num_deselected may exceed num_subsets by more than 1.

Definition at line 560 of file set_cover_heuristics.cc.

◆ ClearRandomSubsets() [2/2]

std::vector< SubsetIndex > operations_research::ClearRandomSubsets ( std::size_t num_subsets,
SetCoverInvariant * inv )

Randomly clears a proportion num_subsets variables in the solution. Returns a list of subset indices to be potentially reused as a focus. Randomly clears at least num_subsets variables in the solution. There can be more than num_subsets variables cleared because the intersecting subsets are also removed from the solution. Returns a list of subset indices that can be reused as a focus.

Definition at line 555 of file set_cover_heuristics.cc.

◆ CompareKnapsackItemWithEfficiencyInDecreasingEfficiencyOrder()

bool operations_research::CompareKnapsackItemWithEfficiencyInDecreasingEfficiencyOrder ( const KnapsackItemWithEfficiency & item1,
const KnapsackItemWithEfficiency & item2 )

Comparator used to sort item in decreasing efficiency order.

Definition at line 732 of file knapsack_solver.cc.

◆ ComputeAllToAllShortestPathsWithMultipleThreads()

template<class GraphType >
void operations_research::ComputeAllToAllShortestPathsWithMultipleThreads ( const GraphType & graph,
const std::vector< PathDistance > & arc_lengths,
int num_threads,
PathContainer *const path_container )

Computes shortest paths between all nodes of the graph.

Definition at line 314 of file shortest_paths.h.

◆ ComputeBestVehicleToResourceAssignment()

int64_t operations_research::ComputeBestVehicleToResourceAssignment ( const std::vector< int > & vehicles,
const util_intops::StrongVector< RoutingModel::ResourceClassIndex, std::vector< int > > & resource_indices_per_class,
const util_intops::StrongVector< RoutingModel::ResourceClassIndex, absl::flat_hash_set< int > > & ignored_resources_per_class,
std::function< const std::vector< int64_t > *(int)> vehicle_to_resource_class_assignment_costs,
std::vector< int > * resource_indices )

Finds the approximate (*) min-cost (i.e. best) assignment of all vehicles v ∈ 'vehicles' to resources, i.e. indices in [0..num_resources), where the costs of assigning a vehicle v to a resource r of class r_c is given by 'vehicle_to_resource_class_assignment_costs(v)[r_c]', unless the latter is empty in which case vehicle v does not need a resource.

Returns the cost of that optimal assignment, or -1 if it's infeasible. Moreover, if 'resource_indices' != nullptr, it assumes that its size is the global number of vehicles, and assigns its element #v with the resource r assigned to v, or -1 if none.

(*) COST SCALING: When the costs are so large that they could possibly yield int64_t overflow, this method returns a lower bound of the actual optimal cost, and the assignment output in 'resource_indices' may be suboptimal if that lower bound isn't tight (but it should be very close).

COMPLEXITY: in practice, should be roughly O(num_resource_classes * vehicles.size() + resource_indices->size()).

When returning infeasible, 'resource_indices' must be cleared, so we do it here preemptively.

Collect vehicle_to_resource_class_assignment_costs(v) for all v ∈ vehicles. Then detect trivial infeasibility cases, before doing the min-cost-flow:

  • There are not enough resources overall.
  • There is no resource assignable to a vehicle that needs one.

Catch infeasibility cases where ComputeVehicleToResourceClassAssignmentCosts() hasn't "properly" initialized the vehicle to resource class assignment costs (this can happen for instance in the ResourceGroupAssignmentFilter when routes are synchronized with an impossible first solution).

We may need to apply some cost scaling when using SimpleMinCostFlow. With our graph it seems having 4 * max_arc_cost * num_nodes ≤ kint64max is sufficient. To do that, we first find the maximum arc cost.

To avoid potential int64_t overflows, we slightly tweak the above formula. NOTE(user): SimpleMinCostFlow always adds a sink and source node (we probably shouldn't add a sink/source node ourselves in the graph).

We use a power of 2 for the cost scaling factor, to have clean (in)accuracy properties. Note also that we must round down the costs.

Then, we create the SimpleMinCostFlow and run the assignment algorithm. NOTE(user): We often don't create as many arcs as outlined below, especially when num_vehicles_to_assign < vehicles.size(). But since we want to eventually make this whole function incremental, we prefer sticking with the whole 'vehicles' set.

Used to store the arc indices, if we need to later recover the solution.

Add a source → vehicle arc to the min-cost-flow graph.

Add vehicle → resource-class arcs to the min-cost-flow graph.

Add resource-class->sink arcs to the flow. The capacity on these arcs is the number of available resources for the corresponding class.

Set the flow supply.

Solve the min-cost flow and return its cost.

Fill the resource indices corresponding to the min-cost assignment.

No resource needed for this vehicle.

Definition at line 2792 of file routing_lp_scheduling.cc.

◆ ComputeConvexPiecewiseLinearFormulationValue()

int64_t operations_research::ComputeConvexPiecewiseLinearFormulationValue ( const RoutingModel::RouteDimensionTravelInfo::TransitionInfo::PiecewiseLinearFormulation & pwl,
int64_t x,
double delta = 0 )

Like ComputePiecewiseLinearFormulationValue(), computes pwl(x) for pwl a PiecewiseLinearFormulation. For convex PiecewiseLinearFormulations, if x is outside the bounds of the function, instead of returning an error like in PiecewiseLinearFormulation, the function will still be defined by its outer segments.

The status should be specified.

x is in the bounds, therefore, simply return the computed value.

In the convex case, if x <= lower_bound, the most restrictive constraint will be the first one.

In the convex case, if x >= upper_bound, the most restrictive constraint will be the last one.

Definition at line 1364 of file routing_lp_scheduling.cc.

◆ ComputeFormVarLowerBound()

double operations_research::ComputeFormVarLowerBound ( glp_prob *const problem,
const int num_cstrs,
const int k )
inline

Returns the lower bound of the variable k of the computational form by calling either glp_get_row_lb() or glp_get_col_lb().

See ComputeFormVarStatus() for details about k.

Definition at line 118 of file glpk_computational_form.h.

◆ ComputeFormVarPrimalValue()

double operations_research::ComputeFormVarPrimalValue ( glp_prob *const problem,
const int num_cstrs,
const int k )
inline

Returns the primal value of the variable k of the computational form by calling either glp_get_row_prim() or glp_get_col_prim().

See ComputeFormVarStatus() for details about k.

Definition at line 108 of file glpk_computational_form.h.

◆ ComputeFormVarReducedCost()

double operations_research::ComputeFormVarReducedCost ( glp_prob *const problem,
const int num_cstrs,
const int k )
inline

Returns the reduced cost of the variable k of the computational form by calling either glp_get_row_dual() or glp_get_col_dual().

See ComputeFormVarStatus() for details about k.

Definition at line 98 of file glpk_computational_form.h.

◆ ComputeFormVarStatus()

int operations_research::ComputeFormVarStatus ( glp_prob *const problem,
const int num_cstrs,
const int k )
inline

Returns the status of the variable k of the computational form by calling either glp_get_row_stat() or glp_get_col_stat().

Here k is an index in the joint set of indices of variables and constraints in the computational form (see the comment at the top of this header for details):

  • 1 <= k <= num_cstrs: index of the k-th auxiliary variable in the general form (the variable associate with the k-th constraint).
  • num_cstrs + 1 <= k <= num_cstrs + num_vars: index of the (k-num_cstrs)-th structural variable in the general form.

Definition at line 88 of file glpk_computational_form.h.

◆ ComputeFormVarUpperBound()

double operations_research::ComputeFormVarUpperBound ( glp_prob *const problem,
const int num_cstrs,
const int k )
inline

Returns the upper bound of the variable k of the computational form by calling either glp_get_row_ub() or glp_get_col_ub().

See ComputeFormVarStatus() for details about k.

Definition at line 128 of file glpk_computational_form.h.

◆ ComputeGcdOfRoundedDoubles()

int64_t operations_research::ComputeGcdOfRoundedDoubles ( absl::Span< const double > x,
double scaling_factor )

Returns the Greatest Common Divisor of the numbers round(fabs(x[i] * scaling_factor)). The numbers 0 are ignored and if they are all zero then the result is 1. Note that round(fabs()) is the same as fabs(round()) since the numbers are rounded away from zero.

GCD(gcd, value) = GCD(value, gcd % value);

Definition at line 209 of file fp_utils.cc.

◆ ComputeManyToAllShortestPathsWithMultipleThreads()

template<class GraphType >
void operations_research::ComputeManyToAllShortestPathsWithMultipleThreads ( const GraphType & graph,
const std::vector< PathDistance > & arc_lengths,
const std::vector< typename GraphType::NodeIndex > & sources,
int num_threads,
PathContainer *const path_container )

Computes shortest paths from the nodes in 'sources' to all nodes in the graph.

Definition at line 239 of file shortest_paths.h.

◆ ComputeManyToManyShortestPathsWithMultipleThreads() [1/11]

template<class GraphType >
void operations_research::ComputeManyToManyShortestPathsWithMultipleThreads ( const GraphType & graph,
const std::vector< PathDistance > & arc_lengths,
const std::vector< typename GraphType::NodeIndex > & sources,
const std::vector< typename GraphType::NodeIndex > & destinations,
int num_threads,
PathContainer *const path_container )

Computes shortest paths from the nodes in 'sources' to the nodes in 'destinations'.

Definition at line 252 of file shortest_paths.h.

◆ ComputeManyToManyShortestPathsWithMultipleThreads() [2/11]

template<>
void operations_research::ComputeManyToManyShortestPathsWithMultipleThreads ( const ListGraph<> & graph,
const std::vector< PathDistance > & arc_lengths,
const std::vector< ListGraph<>::NodeIndex > & sources,
const std::vector< ListGraph<>::NodeIndex > & destinations,
int num_threads,
PathContainer *const path_container )

Definition at line 527 of file shortest_paths.cc.

◆ ComputeManyToManyShortestPathsWithMultipleThreads() [3/11]

template<>
void operations_research::ComputeManyToManyShortestPathsWithMultipleThreads ( const ListGraph<> & graph,
const std::vector< PathDistance > & arc_lengths,
const std::vector< ListGraph<>::NodeIndex > & sources,
const std::vector< ListGraph<>::NodeIndex > & destinations,
int num_threads,
PathContainer * path_container )

Definition at line 527 of file shortest_paths.cc.

◆ ComputeManyToManyShortestPathsWithMultipleThreads() [4/11]

template<>
void operations_research::ComputeManyToManyShortestPathsWithMultipleThreads ( const ReverseArcListGraph<> & graph,
const std::vector< PathDistance > & arc_lengths,
const std::vector< ReverseArcListGraph<>::NodeIndex > & sources,
const std::vector< ReverseArcListGraph<>::NodeIndex > & destinations,
int num_threads,
PathContainer *const path_container )

Definition at line 547 of file shortest_paths.cc.

◆ ComputeManyToManyShortestPathsWithMultipleThreads() [5/11]

template<>
void operations_research::ComputeManyToManyShortestPathsWithMultipleThreads ( const ReverseArcListGraph<> & graph,
const std::vector< PathDistance > & arc_lengths,
const std::vector< ReverseArcListGraph<>::NodeIndex > & sources,
const std::vector< ReverseArcListGraph<>::NodeIndex > & destinations,
int num_threads,
PathContainer * path_container )

Definition at line 547 of file shortest_paths.cc.

◆ ComputeManyToManyShortestPathsWithMultipleThreads() [6/11]

template<>
void operations_research::ComputeManyToManyShortestPathsWithMultipleThreads ( const ReverseArcMixedGraph<> & graph,
const std::vector< PathDistance > & arc_lengths,
const std::vector< ReverseArcMixedGraph<>::NodeIndex > & sources,
const std::vector< ReverseArcMixedGraph<>::NodeIndex > & destinations,
int num_threads,
PathContainer *const path_container )

Definition at line 569 of file shortest_paths.cc.

◆ ComputeManyToManyShortestPathsWithMultipleThreads() [7/11]

template<>
void operations_research::ComputeManyToManyShortestPathsWithMultipleThreads ( const ReverseArcMixedGraph<> & graph,
const std::vector< PathDistance > & arc_lengths,
const std::vector< ReverseArcMixedGraph<>::NodeIndex > & sources,
const std::vector< ReverseArcMixedGraph<>::NodeIndex > & destinations,
int num_threads,
PathContainer * path_container )

Definition at line 569 of file shortest_paths.cc.

◆ ComputeManyToManyShortestPathsWithMultipleThreads() [8/11]

template<>
void operations_research::ComputeManyToManyShortestPathsWithMultipleThreads ( const ReverseArcStaticGraph<> & graph,
const std::vector< PathDistance > & arc_lengths,
const std::vector< ReverseArcStaticGraph<>::NodeIndex > & sources,
const std::vector< ReverseArcStaticGraph<>::NodeIndex > & destinations,
int num_threads,
PathContainer *const path_container )

Definition at line 558 of file shortest_paths.cc.

◆ ComputeManyToManyShortestPathsWithMultipleThreads() [9/11]

template<>
void operations_research::ComputeManyToManyShortestPathsWithMultipleThreads ( const ReverseArcStaticGraph<> & graph,
const std::vector< PathDistance > & arc_lengths,
const std::vector< ReverseArcStaticGraph<>::NodeIndex > & sources,
const std::vector< ReverseArcStaticGraph<>::NodeIndex > & destinations,
int num_threads,
PathContainer * path_container )

Definition at line 558 of file shortest_paths.cc.

◆ ComputeManyToManyShortestPathsWithMultipleThreads() [10/11]

template<>
void operations_research::ComputeManyToManyShortestPathsWithMultipleThreads ( const StaticGraph<> & graph,
const std::vector< PathDistance > & arc_lengths,
const std::vector< StaticGraph<>::NodeIndex > & sources,
const std::vector< StaticGraph<>::NodeIndex > & destinations,
int num_threads,
PathContainer *const path_container )

Definition at line 537 of file shortest_paths.cc.

◆ ComputeManyToManyShortestPathsWithMultipleThreads() [11/11]

template<>
void operations_research::ComputeManyToManyShortestPathsWithMultipleThreads ( const StaticGraph<> & graph,
const std::vector< PathDistance > & arc_lengths,
const std::vector< StaticGraph<>::NodeIndex > & sources,
const std::vector< StaticGraph<>::NodeIndex > & destinations,
int num_threads,
PathContainer * path_container )

Definition at line 537 of file shortest_paths.cc.

◆ ComputeManyToManyShortestPathsWithMultipleThreadsInternal()

template<class GraphType >
void operations_research::ComputeManyToManyShortestPathsWithMultipleThreadsInternal ( const GraphType & graph,
const std::vector< PathDistance > & arc_lengths,
const std::vector< typename GraphType::NodeIndex > & sources,
const std::vector< typename GraphType::NodeIndex > & destinations,
int num_threads,
PathContainer *const paths )

Removing duplicate sources to allow mutex-free implementation (and it's more efficient); same with destinations for efficiency reasons.

Definition at line 491 of file shortest_paths.cc.

◆ ComputeMinimumWeightMatching()

template<typename WeightFunctionType , typename GraphType >
absl::StatusOr< std::vector< std::pair< typename GraphType::NodeIndex, typename GraphType::NodeIndex > > > operations_research::ComputeMinimumWeightMatching ( const GraphType & graph,
const WeightFunctionType & weight )

Computes a minimum weight perfect matching on an undirected graph.

Adding both arcs is redundant for MinCostPerfectMatching.

Definition at line 112 of file christofides.h.

◆ ComputeMinimumWeightMatchingWithMIP()

template<typename WeightFunctionType , typename GraphType >
absl::StatusOr< std::vector< std::pair< typename GraphType::NodeIndex, typename GraphType::NodeIndex > > > operations_research::ComputeMinimumWeightMatchingWithMIP ( const GraphType & graph,
const WeightFunctionType & weight )

Computes a minimum weight perfect matching on an undirected graph using a Mixed Integer Programming model.

Todo
(user): Handle infeasible cases if this algorithm is used outside of Christofides.

The model is composed of Boolean decision variables to select matching arcs and constraints ensuring that each node appears in exactly one selected arc. The objective is to minimize the sum of the weights of selected arcs. It is assumed the graph is symmetrical.

Creating arc-selection Boolean variable.

Creating matching constraint: for all node i, sum(j) arc(i,j) + sum(j) arc(j,i) = 1

Definition at line 148 of file christofides.h.

◆ ComputeOneToAllShortestPaths()

template<class GraphType >
void operations_research::ComputeOneToAllShortestPaths ( const GraphType & graph,
const std::vector< PathDistance > & arc_lengths,
typename GraphType::NodeIndex source,
PathContainer *const path_container )

Computes shortest paths from the node 'source' to all nodes in the graph.

In all the functions below the arc_lengths vector represents the lengths of the arcs of the graph (arc_lengths[arc] is the length of arc). Resulting shortest paths are stored in a path container 'path_container'.

Definition at line 187 of file shortest_paths.h.

◆ ComputeOneToManyShortestPaths()

template<class GraphType >
void operations_research::ComputeOneToManyShortestPaths ( const GraphType & graph,
const std::vector< PathDistance > & arc_lengths,
typename GraphType::NodeIndex source,
const std::vector< typename GraphType::NodeIndex > & destinations,
PathContainer *const path_container )

Computes shortest paths from the node 'source' to nodes in 'destinations'.

Definition at line 199 of file shortest_paths.h.

◆ ComputeOneToOneShortestPath()

template<class GraphType >
std::vector< typename GraphType::NodeIndex > operations_research::ComputeOneToOneShortestPath ( const GraphType & graph,
const std::vector< PathDistance > & arc_lengths,
typename GraphType::NodeIndex source,
typename GraphType::NodeIndex destination )

Computes the shortest path from the node 'source' to the node 'destination' and returns that path as a vector of nodes. If there is no path from 'source' to 'destination', the returned vector is empty.

To get distance information, use ComputeOneToManyShortestPaths with a single destination and a PathContainer built with BuildPathDistanceContainer (if you just need the distance) or BuildInMemoryCompactPathContainer (otherwise).

Definition at line 218 of file shortest_paths.h.

◆ ComputePiecewiseLinearFormulationValue()

PiecewiseEvaluationStatus operations_research::ComputePiecewiseLinearFormulationValue ( const RoutingModel::RouteDimensionTravelInfo::TransitionInfo::PiecewiseLinearFormulation & pwl,
int64_t x,
int64_t * value,
double delta = 0 )

Computes pwl(x) for pwl a PieceWiseLinearFormulation. Returns a PieceWiseEvaluationStatus to indicate if the value could be computed (filled in value) and if not, why.

Search for first element xi such that xi < x.

Checking bounds

Definition at line 1338 of file routing_lp_scheduling.cc.

◆ ComputeScalingErrors()

void operations_research::ComputeScalingErrors ( absl::Span< const double > input,
absl::Span< const double > lb,
absl::Span< const double > ub,
double scaling_factor,
double * max_relative_coeff_error,
double * max_scaled_sum_error )

This computes:

The max_relative_coeff_error, which is the maximum over all coeff of |round(factor * x[i]) / (factor * x[i]) - 1|.

The max_scaled_sum_error which is a bound on the maximum difference between the exact scaled sum and the rounded one. One needs to divide this by scaling_factor to have the maximum absolute error on the original sum.

Definition at line 177 of file fp_utils.cc.

◆ ComputeVehicleEndChainStarts()

std::vector< int64_t > operations_research::ComputeVehicleEndChainStarts ( const RoutingModel & model)

Computes and returns the first node in the end chain of each vehicle in the model, based on the current bound NextVar values.

Find the chains of nodes (when nodes have their "Next" value bound in the current solution, it forms a link in a chain). Eventually, starts[end] will contain the index of the first node of the chain ending at node 'end' and ends[start] will be the last node of the chain starting at node 'start'. Values of starts[node] and ends[node] for other nodes is used for intermediary computations and do not necessarily reflect actual chain starts and ends.

Each node starts as a singleton chain.

Merge the sub-chain starting from 'node' and ending at 'current' with the existing sub-chain starting at 'current'.

Set the 'end_chain_starts' for every vehicle.

Definition at line 194 of file routing_search.cc.

◆ ComputeVehicleToResourceClassAssignmentCosts()

bool operations_research::ComputeVehicleToResourceClassAssignmentCosts ( int v,
const RoutingModel::ResourceGroup & resource_group,
const util_intops::StrongVector< RoutingModel::ResourceClassIndex, absl::flat_hash_set< int > > & ignored_resources_per_class,
const std::function< int64_t(int64_t)> & next_accessor,
const std::function< int64_t(int64_t, int64_t)> & transit_accessor,
bool optimize_vehicle_costs,
LocalDimensionCumulOptimizer * lp_optimizer,
LocalDimensionCumulOptimizer * mp_optimizer,
std::vector< int64_t > * assignment_costs,
std::vector< std::vector< int64_t > > * cumul_values,
std::vector< std::vector< int64_t > > * break_values )

Computes the vehicle-to-resource-class assignment costs for the given vehicle to all resource classes in the group, and sets these costs in 'assignment_costs' (if non-null). The latter is cleared and kept empty if the vehicle 'v' should not have a resource assigned to it. optimize_vehicle_costs indicates if the costs should be optimized or if we merely care about feasibility (cost of 0) and infeasibility (cost of -1) of the assignments. The cumul and break values corresponding to the assignment of each resource are also set in cumul_values and break_values, if non-null.

The model's time limit has been reached, stop everything.

NOTE(user): The resource class computation should allow us to catch all incompatibility reasons between vehicles and resources. If the following DCHECK fails, the resource classes should be adapted accordingly.

Couldn't assign any resource to this vehicle.

We already used the mp optimizer, so we don't need to recompute anything. If all assignment costs are negative, it means no resource is feasible for this vehicle.

A timeout was reached during optimization.

Definition at line 2646 of file routing_lp_scheduling.cc.

◆ ConstrainedShortestPathsOnDag()

PathWithLength operations_research::ConstrainedShortestPathsOnDag ( int num_nodes,
absl::Span< const ArcWithLengthAndResources > arcs_with_length_and_resources,
int source,
int destination,
const std::vector< double > & max_resources )

Returns {+inf, {}, {}} if there is no path of finite length from the source to the destination. Dies if arcs_with_length_and_resources has a cycle.

Definition at line 39 of file dag_constrained_shortest_path.cc.

◆ ConstraintHandlerResultPriority()

int operations_research::ConstraintHandlerResultPriority ( GScipCallbackResult result,
ConstraintHandlerCallbackType callback_type )

In callbacks, SCIP requires the first SCIP_RESULT in a priority list be returned when multiple results are applicable. This is a unified order of the priorities extracted from type_cons.h. The higher the result, the higher priority it is.

Larger number indicates higher priority in what should be returned.

In type_cons.h, callback results are consistently ordered across all constraint handler callback methods except that SCIP_SOLVELP (kSolveLp) takes higher priority than SCIP_BRANCHED (kBranched) in CONSENFOLP, and the reverse is true for CONSENFORELAX and CONSENFOLP.

kConstraintChanged, kFoundSolution, and kSuspend are not used in constraint handlers.

Definition at line 251 of file gscip_constraint_handler.cc.

◆ ConstraintToString()

std::string operations_research::ConstraintToString ( const sat::ConstraintProto & constraint,
const sat::CpModelProto & model_,
bool show_enforcement = true )

Enforcement literal.

Definition at line 3035 of file routing_lp_scheduling.cc.

◆ ConvertDimacsToFlowModel()

bool operations_research::ConvertDimacsToFlowModel ( absl::string_view file,
FlowModelProto * flow_model )

Note(user): Going from Dimacs to flow adds an extra copy, but for now we don't really care of the Dimacs file reading performance. Returns true if the file was converted correctly.

Definition at line 102 of file solve_flow_model.cc.

◆ ConvertFlowModelToDimacs()

void operations_research::ConvertFlowModelToDimacs ( const FlowModelProto & flow_model,
std::string * dimacs )

See http://lpsolve.sourceforge.net/5.5/DIMACS_mcf.htm for the dimacs file format of a min cost flow problem.

Todo
(user): This currently only works for min cost flow problem.

We need to compute the num_nodes from the nodes appearing in the arcs.

Problem size and type.

Nodes.

Arcs.

Definition at line 57 of file solve_flow_model.cc.

◆ ConvertGScipCallbackResult()

SCIP_RESULT operations_research::ConvertGScipCallbackResult ( const GScipCallbackResult result)

Definition at line 20 of file gscip_callback_result.cc.

◆ ConvertStatusOrMPSolutionResponse()

MPSolutionResponse operations_research::ConvertStatusOrMPSolutionResponse ( bool log_error,
absl::StatusOr< MPSolutionResponse > response )
inline

Some SolveWithProto() returns a StatusOr<MPModelResponse>, this utility just convert bad absl::StatusOr to a proper error in MPModelResponse.

Todo
(user): All SolveWithProto() should just fill the appropriate response instead.

Definition at line 41 of file proto_utils.h.

◆ ConvexMinimum() [1/2]

template<class Point , class Value >
std::pair< Point, Value > operations_research::ConvexMinimum ( absl::Span< const Point > sorted_points,
std::function< Value(Point)> f )

Returns the minimum of a convex function on a discrete set of sorted points. It is an error to call this with an empty set of points.

We assume the function is "unimodal" with potentially more than one minimum. That is strictly decreasing, then have a minimum that can have many points, and then is strictly increasing. In this case if we have two points with exactly the same value, one of the minimum is always between the two. We will only return one of the minimum.

Note
if we allow for non strictly decreasing/increasing, then you have corner cases where one need to check all points to find the minimum. For instance, if the function is constant except at one point where it is lower.

The usual algorithm to optimize such a function is a ternary search. However here we assume calls to f() are expensive, and we try to minimize those. So we use a slightly different algorithm than: https://en.wikipedia.org/wiki/Ternary_search

Todo
(user): Some relevant optimizations:
  • Abort early if we know a lower bound on the min.
  • Seed with a starting point if we know one.
  • We technically do not need the points to be sorted and can use linear-time median computation to speed this up.
Todo
(user): replace std::function by absl::FunctionRef here and in BinarySearch().

Definition at line 314 of file binary_search.h.

◆ ConvexMinimum() [2/2]

template<class Point , class Value >
std::pair< Point, Value > operations_research::ConvexMinimum ( bool is_to_the_right,
std::pair< Point, Value > current_min,
absl::Span< const Point > sorted_points,
std::function< Value(Point)> f )

Internal part of ConvexMinimum() that can also be used directly in some situation when we already know some value of f(). This assumes that we already have a current_min candidate that is either before or after all the points in sorted_points.

Definition at line 323 of file binary_search.h.

◆ CountTriangles()

std::vector< int > operations_research::CountTriangles ( const ::util::StaticGraph< int, int > & graph,
int max_degree )

HELPER FUNCTIONS: PUBLIC FOR UNIT TESTING ONLY.

Returns, for each node A, the number of pairs of nodes (B, C) such that arcs A->B, A->C and B->C exist. Skips nodes with degree > max_degree (this allows to remain linear in the number of nodes, but gives partial results). The complexity is O(num_nodes * max_degree²).

DIFFERENTIATION: In unit test CollisionImpliesIsomorphismInPractice, this metric differentiated 33 of the 34 non-isomorphic collisions found across 200K graphs: only one remained.

Example graph differentiated by this metric, but not by LocalBfsFprint(): ,-1-3-. ,-1-3-. 0 | | 5 and 0 X 5 ‘-2-3-’ ‘-2-4-’

Definition at line 52 of file find_graph_symmetries.cc.

◆ CoverArcsByCliques()

void operations_research::CoverArcsByCliques ( std::function< bool(int, int)> graph,
int node_count,
std::function< bool(const std::vector< int > &)> callback )

Covers the maximum number of arcs of the graph with cliques. The graph is described by the graph callback. graph->Run(i, j) indicates if there is an arc between i and j. This function takes ownership of 'callback' and deletes it after it has run. It calls 'callback' upon each clique. It ignores cliques of size 1.

Definition at line 242 of file cliques.cc.

◆ CpRandomSeed()

int64_t operations_research::CpRandomSeed ( )
inline

Definition at line 178 of file constraint_solver.h.

◆ CropMultiLineString()

std::string operations_research::CropMultiLineString ( const std::string & s,
int max_line_length,
int max_num_lines )

Crops a multi-line string horizontally and vertically, as needed. Skipped lines (to spare vertical space) are replaced by "... [42 LINES CROPPED] ..." and non-skipped but cropped lines (to spare horizontal space) are replaced by "%prefix% ..[35 CHARS CROPPED].. %suffix%" where prefix% and suffix% are equally-sized (possibly off-by-one) substrings of the line, to fit in the required width.

Warning
The code is intended to be used for debugging and visual aid. While it shouldn't crash, it makes a few shortcuts and can violate the requirements (eg. some lines may be longer than max_line_length).

We ignore the terminating newline for line accounting, but we do output it back in the end.

There's a corner case for max_num_lines=0. See the unit test.

We only fill the special line mentioning the skipped lines after we're done with the horizontal crops, in the loop below.

Definition at line 25 of file string_util.cc.

◆ DefaultGScipConstraintOptions()

const GScipConstraintOptions & operations_research::DefaultGScipConstraintOptions ( )

Definition at line 292 of file gscip.cc.

◆ DefaultGScipVariableOptions()

const GScipVariableOptions & operations_research::DefaultGScipVariableOptions ( )

Definition at line 287 of file gscip.cc.

◆ DefaultPhaseStatString()

std::string operations_research::DefaultPhaseStatString ( DecisionBuilder * db)

-------— API -------—

Definition at line 1121 of file default_search.cc.

◆ DefaultRoutingModelParameters()

RoutingModelParameters operations_research::DefaultRoutingModelParameters ( )

Definition at line 41 of file routing_parameters.cc.

◆ DefaultRoutingSearchParameters()

RoutingSearchParameters operations_research::DefaultRoutingSearchParameters ( )

static

Definition at line 214 of file routing_parameters.cc.

◆ DefaultSecondaryRoutingSearchParameters()

RoutingSearchParameters operations_research::DefaultSecondaryRoutingSearchParameters ( )

Definition at line 220 of file routing_parameters.cc.

◆ DEFINE_INT_TYPE() [1/6]

operations_research::DEFINE_INT_TYPE ( RoutingCostClassIndex ,
int  )

◆ DEFINE_INT_TYPE() [2/6]

operations_research::DEFINE_INT_TYPE ( RoutingDimensionIndex ,
int  )

◆ DEFINE_INT_TYPE() [3/6]

operations_research::DEFINE_INT_TYPE ( RoutingDisjunctionIndex ,
int  )

◆ DEFINE_INT_TYPE() [4/6]

operations_research::DEFINE_INT_TYPE ( RoutingNodeIndex ,
int  )

Defining common types used in the routing library outside the main RoutingModel class has several purposes: 1) It allows some small libraries to avoid a dependency on routing.{h,cc}, eg. routing_neighborhoods.h. 2) It allows an easier wrapping via SWIG, which can have issues with intra-class types. Users that depend on routing.{h,cc} should just use the RoutingModel:: equivalent, eg. RoutingModel::NodeIndex.

◆ DEFINE_INT_TYPE() [5/6]

operations_research::DEFINE_INT_TYPE ( RoutingResourceClassIndex ,
int  )

◆ DEFINE_INT_TYPE() [6/6]

operations_research::DEFINE_INT_TYPE ( RoutingVehicleClassIndex ,
int  )

◆ DEFINE_STRONG_INT_TYPE() [1/4]

operations_research::DEFINE_STRONG_INT_TYPE ( ColumnEntryIndex ,
BaseInt  )

Position in a vector. The vector may either represent a column, i.e. a subset with all its elements, or a row, i,e. the list of subsets which contain a given element.

◆ DEFINE_STRONG_INT_TYPE() [2/4]

operations_research::DEFINE_STRONG_INT_TYPE ( ElementIndex ,
BaseInt  )

Element index.

◆ DEFINE_STRONG_INT_TYPE() [3/4]

operations_research::DEFINE_STRONG_INT_TYPE ( RowEntryIndex ,
BaseInt  )

◆ DEFINE_STRONG_INT_TYPE() [4/4]

operations_research::DEFINE_STRONG_INT_TYPE ( SubsetIndex ,
BaseInt  )

We make heavy use of strong typing to avoid obvious mistakes. Subset index.

◆ DeleteDemonProfiler()

void operations_research::DeleteDemonProfiler ( DemonProfiler * monitor)
extern

Definition at line 453 of file demon_profiler.cc.

◆ DeleteLocalSearchProfiler()

void operations_research::DeleteLocalSearchProfiler ( LocalSearchProfiler * monitor)
extern

Definition at line 4589 of file local_search.cc.

◆ DemonProfilerAddFakeRun()

void operations_research::DemonProfilerAddFakeRun ( DemonProfiler *const monitor,
Demon *const demon,
int64_t start_time,
int64_t end_time,
bool is_fail )

Definition at line 470 of file demon_profiler.cc.

◆ DemonProfilerBeginInitialPropagation()

void operations_research::DemonProfilerBeginInitialPropagation ( DemonProfiler *const monitor,
Constraint *const constraint )

Definition at line 488 of file demon_profiler.cc.

◆ DemonProfilerEndInitialPropagation()

void operations_research::DemonProfilerEndInitialPropagation ( DemonProfiler *const monitor,
Constraint *const constraint )

Definition at line 493 of file demon_profiler.cc.

◆ DemonProfilerExportInformation()

void operations_research::DemonProfilerExportInformation ( DemonProfiler *const monitor,
const Constraint *const constraint,
int64_t *const fails,
int64_t *const initial_propagation_runtime,
int64_t *const demon_invocations,
int64_t *const total_demon_runtime,
int *const demon_count )

Definition at line 476 of file demon_profiler.cc.

◆ DisableAllCutsExceptUserDefined()

void operations_research::DisableAllCutsExceptUserDefined ( GScipParameters * parameters)

Turns off all SCIP separators.

The only way in SCIP's C API to disable all cuts except user-defined ones is to disable each individual cut. This may change if SCIP gets updated; the list below is for SCIP 7.0.1. See https://scip.zib.de/doc/html/group__SEPARATORS.php for a list of all cuts.

Definition at line 147 of file gscip_parameters.cc.

◆ DisplayPlan() [1/2]

void operations_research::DisplayPlan ( const operations_research::RoutingIndexManager & manager,
const operations_research::RoutingModel & routing,
const operations_research::Assignment & plan,
bool use_same_vehicle_costs,
int64_t max_nodes_per_group,
int64_t same_vehicle_cost,
const operations_research::RoutingDimension & capacity_dimension,
const operations_research::RoutingDimension & time_dimension )

Route plan displayer.

Todo
(user): Move the display code to the routing library.

◆ DisplayPlan() [2/2]

void operations_research::DisplayPlan ( const RoutingIndexManager & manager,
const RoutingModel & routing,
const operations_research::Assignment & plan,
bool use_same_vehicle_costs,
int64_t max_nodes_per_group,
int64_t same_vehicle_cost,
const operations_research::RoutingDimension & capacity_dimension,
const operations_research::RoutingDimension & time_dimension )

Display plan cost.

Display dropped orders.

Display actual output for each vehicle.

Definition at line 160 of file cvrptw_lib.cc.

◆ DomainToString()

std::string operations_research::DomainToString ( const ::google::protobuf::RepeatedField< int64_t > * domain)

Definition at line 2981 of file routing_lp_scheduling.cc.

◆ DropAllEvents()

SCIP_RETCODE operations_research::DropAllEvents ( GScipEventHandler & handler)

Calls SCIPdropEvent() for all events in caught_events_ and clear this collection.

This is not a member function since it needs to be visible to the SCIP Exit callback function.

Definition at line 133 of file gscip_event_handler.cc.

◆ EmptyOrGurobiLicenseWarning()

testing::Matcher< std::string > operations_research::EmptyOrGurobiLicenseWarning ( )

Returns a matcher that either matches an empty string or the logs printed to stdout by Gurobi when a license is about to expire.

Definition at line 23 of file gurobi_stdout_matchers.cc.

◆ EmptyOrGurobiLicenseWarningIfGurobi()

testing::Matcher< std::string > operations_research::EmptyOrGurobiLicenseWarningIfGurobi ( bool is_gurobi)

Returns either a matcher for the empty string when is_gurobi is false or the result of EmptyOrGurobiLicenseWarning() when true.

This is a convenience function for generic tests shared between Gurobi and other solvers.

Definition at line 30 of file gurobi_stdout_matchers.cc.

◆ EncodeParametersAsString()

template<typename P >
std::string operations_research::EncodeParametersAsString ( const P & parameters)

Returns a string that should be used in MPModelRequest's solver_specific_parameters field to encode the glop parameters.

The returned string's content depends on the version of the proto library that is linked in the binary.

By default it will contain the textual representation of the input proto. But when the proto-lite is used, it will contain the binary stream of the proto instead since it is not possible to build the textual representation in that case.

This function will test if the proto-lite is used and expect a binary stream when it is the case. So in order for your code to be portable, you should always use this function to set the specific parameters.

Proto-lite disables some features of protobufs and messages inherit from MessageLite directly instead of inheriting from Message (which is itself a specialization of MessageLite). See https://protobuf.dev/reference/cpp/cpp-generated/#message for details.

Here we use SerializeToString() instead of SerializeAsString() since the later ignores errors and returns an empty string instead (which can be a valid value when no fields are set).

Definition at line 75 of file proto_utils.h.

◆ ExportModelAsLpFormat()

absl::StatusOr< std::string > operations_research::ExportModelAsLpFormat ( const MPModelProto & model,
const MPModelExportOptions & options = MPModelExportOptions() )

Outputs the current model (variables, constraints, objective) as a string encoded in the so-called "CPLEX LP file format" as generated by SCIP. The LP file format is easily readable by a human.

Returns false if some error has occurred during execution. The validity of names is automatically checked. If a variable name or a constraint name is invalid or non-existent, a new valid name is automatically generated.

If 'obfuscated' is true, the variable and constraint names of proto_ are not used. Variable and constraint names of the form "V12345" and "C12345" are used instead.

For more information about the different LP file formats: http://lpsolve.sourceforge.net/5.5/lp-format.htm The following give a reasonable idea of the CPLEX LP file format: http://lpsolve.sourceforge.net/5.5/CPLEX-format.htm https://www.ibm.com/docs/en/icos/12.8.0.0?topic=cplex-lp-file-format-algebraic-representation http://www.gurobi.com/documentation/5.1/reference-manual/node871

Definition at line 221 of file model_exporter.cc.

◆ ExportModelAsMpsFormat()

absl::StatusOr< std::string > operations_research::ExportModelAsMpsFormat ( const MPModelProto & model,
const MPModelExportOptions & options = MPModelExportOptions() )

Outputs the current model (variables, constraints, objective) as a string encoded in MPS file format, using the "free" MPS format.

Returns false if some error has occurred during execution. Models with maximization objectives trigger an error, because MPS can encode only minimization problems.

The validity of names is automatically checked. If a variable name or a constraint name is invalid or non-existent, a new valid name is automatically generated.

Name validity and obfuscation works exactly as in ExportModelAsLpFormat().

For more information about the MPS format: http://en.wikipedia.org/wiki/MPS_(format) A close-to-original description coming from OSL: http://tinyurl.com/mps-format-by-osl A recent description from CPLEX: http://tinyurl.com/mps-format-by-cplex CPLEX extensions: http://tinyurl.com/mps-extensions-by-cplex Gurobi's description: http://www.gurobi.com/documentation/5.1/reference-manual/node869

Definition at line 238 of file model_exporter.cc.

◆ ExtractValidMPModelOrPopulateResponseStatus()

std::optional< LazyMutableCopy< MPModelProto > > operations_research::ExtractValidMPModelOrPopulateResponseStatus ( const MPModelRequest & request,
MPSolutionResponse * response )

If the model is valid and non-empty, returns it (possibly after extracting the model_delta). If invalid or empty, updates response and returns null.

Definition at line 687 of file model_validator.cc.

◆ fast_ilogb()

int operations_research::fast_ilogb ( double value)

This is a fast implementation of the C99 function ilogb for normalized doubles with the caveat that it returns -1023 for zero, and 1024 for infinity an NaNs.

Get little-endian bit-representation of the floating point value.

Definition at line 233 of file fp_utils.cc.

◆ fast_scalbn()

double operations_research::fast_scalbn ( double value,
int exponent )

This is a fast implementation of the C99 function scalbn, with the caveat that it works on normalized numbers and if the result underflows, overflows, or is applied to a NaN or an +-infinity, the result is undefined behavior.

Note
the version of the function that takes a reference, modifies the given value.

Binary representation is: (sign-bit)(11 exponent bits)(52 mantissa bits)

This addition relies on the fact that signed numbers are written in two-s complement, and is correct as long as the sum does not overflow/underflow the result.

Definition at line 246 of file fp_utils.cc.

◆ fast_scalbn_inplace()

void operations_research::fast_scalbn_inplace ( double & mutable_value,
int exponent )

Definition at line 242 of file fp_utils.cc.

◆ fasthash64()

uint64_t operations_research::fasthash64 ( const void * buf,
size_t len,
uint64_t seed )

Definition at line 36 of file hash.cc.

◆ FillPathEvaluation()

void operations_research::FillPathEvaluation ( const std::vector< int64_t > & path,
const RoutingModel::TransitCallback2 & evaluator,
std::vector< int64_t > * values )
Todo
(user): Apply -pointer-following.

Definition at line 6095 of file routing.cc.

◆ FillTravelBoundsOfVehicle()

void operations_research::FillTravelBoundsOfVehicle ( int vehicle,
const std::vector< int64_t > & path,
const RoutingDimension & dimension,
TravelBounds * travel_bounds )

Fill path and min/max/pre/post travel bounds.

Definition at line 665 of file routing_breaks.cc.

◆ FillValues()

void operations_research::FillValues ( const std::vector< IntVar * > & vars,
std::vector< int64_t > *const values )
inline

Definition at line 3331 of file constraint_solveri.h.

◆ FindCliques()

void operations_research::FindCliques ( std::function< bool(int, int)> graph,
int node_count,
std::function< bool(const std::vector< int > &)> callback )

This method implements the 'version2' of the Bron-Kerbosch algorithm to find all maximal cliques in a undirected graph.

Finds all maximal cliques, even of size 1, in the graph described by the graph callback. graph->Run(i, j) indicates if there is an arc between i and j. This function takes ownership of 'callback' and deletes it after it has run. If 'callback' returns true, then the search for cliques stops.

Definition at line 228 of file cliques.cc.

◆ FindErrorInMPModelDeltaProto()

std::string operations_research::FindErrorInMPModelDeltaProto ( const MPModelDeltaProto & delta,
const MPModelProto & model )

Like FindErrorInMPModelProto, but for a MPModelDeltaProto applied to a given baseline model (assumed valid, eg. FindErrorInMPModelProto(model)=""). Works in O(|model_delta|) + O(num_vars in model), but the latter term has a very small constant factor.

Validate delta variables.

NOTE(user): It is OK for the override proto to be empty, i.e. be a non-override.

Now we "officially" add the new variables to "num_vars".

Validate delta constraints. We can avoid going over the full var_index/coefficient of the original constraint, since the overrides are self-sufficient (i.e. the override var_index/coefficients are valid iff they would be valid in a standalone, new constraint). So we use a partial proto merger to avoid those in the baseline constraint.

NOTE(user): We don't need to do the merging of var_index/coefficient: that part of the merged constraint will be valid iff the override is valid as a standalone var_index/coefficient map. So we simply validate a reduced version of the actual "merged" constraint, by removing the var_index/coefficient of the baseline. Benefit: the complexity is O(|constraint override|) even if the baseline constraint was huge.

Definition at line 842 of file model_validator.cc.

◆ FindErrorInMPModelForScip()

std::string operations_research::FindErrorInMPModelForScip ( const MPModelProto & model,
SCIP * scip )

Returns "" iff the model seems valid for SCIP, else returns a human-readable error message. Assumes that FindErrorInMPModelProto(model) found no error.

Definition at line 568 of file scip_proto_solver.cc.

◆ FindErrorInMPModelProto()

std::string operations_research::FindErrorInMPModelProto ( const MPModelProto & model,
double abs_value_threshold = 0.0,
bool accept_trivially_infeasible_bounds = false )

Returns an empty string iff the model is valid and not trivially infeasible. Otherwise, returns a description of the first error or trivial infeasibility variable or constraint bound encountered.

abs_value_threshold is the (exclusive) limit for the abs value of constraint coefficients, objective coefficients, etc. If unspecified, or 0, it defaults to FLAGS_model_validator_infinity.

NOTE(user): the code of this method (and the client code too!) is considerably simplified by this string-based, simple API. If clients require it, we could add a formal error status enum.

NOTE(user): Empty models are considered fine by this function, although it is not clear whether MPSolver::Solve() will always respond in the same way, depending on the solvers.

Validate variables.

Validate constraints.

Constraint protos can be huge, theoretically. So we guard against that.

Validate general constraints.

Validate objectives.

Validate the solution hint.

Validate the annotations.

Parameters
accept_trivially_infeasible_boundsIf false, variable and constraint bounds like [lb=1.2, ub=0.7] yield an error, and also integer variable bounds like [0.7, 0.8].

Definition at line 558 of file model_validator.cc.

◆ FindErrorInRoutingSearchParameters()

std::string operations_research::FindErrorInRoutingSearchParameters ( const RoutingSearchParameters & search_parameters)

Returns an empty std::string if the routing search parameters are valid, and a non-empty, human readable error description if they're not.

Definition at line 234 of file routing_parameters.cc.

◆ FindErrorsInRoutingSearchParameters()

std::vector< std::string > operations_research::FindErrorsInRoutingSearchParameters ( const RoutingSearchParameters & search_parameters)

Returns a list of std::string describing the errors in the routing search parameters. Returns an empty vector if the parameters are valid.

Check that all local search operators are set to either BOOL_TRUE or BOOL_FALSE (and not BOOL_UNSPECIFIED). Do that only in non-portable mode, since it needs proto reflection etc.

Definition at line 241 of file routing_parameters.cc.

◆ FindFeasibilityErrorInSolutionHint()

std::string operations_research::FindFeasibilityErrorInSolutionHint ( const MPModelProto & model,
double tolerance )
Todo
(user): Add a general FindFeasibilityErrorInSolution() and factor out the common code.

Returns an empty string if the solution hint given in the model is a feasible solution. Otherwise, returns a description of the first reason for infeasibility.

This function can be useful for debugging/checking that the given solution hint is feasible when it is expected to be the case. The feasibility is checked up to the given tolerance using the ::operations_research::IsLowerWithinTolerance() function.

First, we validate the solution hint.

Special error message for the empty case.

To be feasible, the hint must not be partial.

All the values must be exactly in the variable bounds.

All the constraints must be satisfiable.

Definition at line 781 of file model_validator.cc.

◆ FindMostExpensiveArcsOnRoute()

bool operations_research::FindMostExpensiveArcsOnRoute ( int num_arcs,
int64_t start,
const std::function< int64_t(int64_t)> & next_accessor,
const std::function< bool(int64_t)> & is_end,
const std::function< int64_t(int64_t, int64_t, int64_t)> & arc_cost_for_route_start,
std::vector< std::pair< int64_t, int > > * most_expensive_arc_starts_and_ranks,
std::pair< int, int > * first_expensive_arc_indices )

Returns false if the route starting with 'start' is empty. Otherwise sets most_expensive_arc_starts_and_ranks and first_expensive_arc_indices according to the most expensive chains on the route, and returns true.

Empty route.

Note
The negative ranks are so that for a given cost, lower ranks are given higher priority.

Definition at line 120 of file routing_utils.cc.

◆ FixFlagsAndEnvironmentForSwig()

void operations_research::FixFlagsAndEnvironmentForSwig ( )

Definition at line 29 of file logging.cc.

◆ FloorRatio()

int64_t operations_research::FloorRatio ( int64_t value,
int64_t positive_coeff )

Definition at line 102 of file sorted_interval_list.cc.

◆ FormatStatistic() [1/2]

template<>
std::string operations_research::FormatStatistic ( absl::string_view name,
double value,
RoutingOutputFormat format )
inline

Specialization for doubles to show a higher precision: without this specialization, 591.556557 is displayed as 591.557.

Definition at line 271 of file solution_serializer.h.

◆ FormatStatistic() [2/2]

template<typename T >
std::string operations_research::FormatStatistic ( absl::string_view name,
T value,
RoutingOutputFormat format )

Formats a solution or solver statistic according to the given format.

Todo
(user): think about using an enum instead of names (or even a full-fledged struct/class) for the various types of fields.

For CARPLIB, the statistics do not have names, it's up to the user to memorize their order.

Definition at line 248 of file solution_serializer.h.

◆ FullProtocolMessageAsString()

std::string operations_research::FullProtocolMessageAsString ( const google::protobuf::Message & message,
int indent_level )

Prints a proto2 message as a string, it behaves like TextFormat::Print() but also prints the default values of unset fields which is useful for printing parameters.

Definition at line 60 of file proto_tools.cc.

◆ GetBestScalingOfDoublesToInt64() [1/2]

double operations_research::GetBestScalingOfDoublesToInt64 ( absl::Span< const double > input,
absl::Span< const double > lb,
absl::Span< const double > ub,
int64_t max_absolute_sum )

Returns the scaling factor like above with the extra conditions:

Definition at line 186 of file fp_utils.cc.

◆ GetBestScalingOfDoublesToInt64() [2/2]

void operations_research::GetBestScalingOfDoublesToInt64 ( absl::Span< const double > input,
int64_t max_absolute_sum,
double * scaling_factor,
double * max_relative_coeff_error )

Given an array of doubles, this computes a positive scaling factor such that the scaled doubles can then be rounded to integers with little or no loss of precision, and so that the L1 norm of these integers is <= max_sum. More precisely, the following formulas will hold (x[i] is input[i], for brevity):

  • For all i, |round(factor * x[i]) / factor - x[i]| <= error * |x[i]|
  • The sum over i of |round(factor * x[i])| <= max_sum.

The algorithm tries to minimize "error" (which is the relative error for one coefficient). Note however than in really broken cases, the error might be infinity and the factor zero.

Note on the algorithm:

  • It only uses factors of the form 2^n (i.e. ldexp(1.0, n)) for simplicity.
  • The error will be zero in many practical instances. For example, if x contains only integers with low magnitude; or if x contains doubles whose exponents cover a small range.
  • It chooses the factor as high as possible under the given constraints, as a result the numbers produced may be large. To balance this, we recommend to divide the scaled integers by their gcd() which will result in no loss of precision and will help in many practical cases.

    Todo
    (user): incorporate the gcd computation here? The issue is that I am not sure if I just do factor /= gcd that round(x * factor) will be the same.

Definition at line 197 of file fp_utils.cc.

◆ GetGraphNodes()

template<class GraphType >
void operations_research::GetGraphNodes ( const GraphType & graph,
std::vector< NodeIndex > * nodes )

Utility function which returns a vector containing all nodes of a graph.

Definition at line 160 of file shortest_paths.h.

◆ GetGraphNodesFromGraph()

template<class GraphType >
void operations_research::GetGraphNodesFromGraph ( const GraphType & graph,
std::vector< typename GraphType::NodeIndex > * nodes )

Definition at line 171 of file shortest_paths.h.

◆ GetGurobiEnv()

absl::StatusOr< GRBenv * > operations_research::GetGurobiEnv ( )

Definition at line 453 of file environment.cc.

◆ GetInversePermutation()

std::vector< int > operations_research::GetInversePermutation ( absl::Span< const int > permutation)

Definition at line 92 of file dag_constrained_shortest_path.cc.

◆ getitcnt()

int operations_research::getitcnt ( const XPRSprob & mLp)

Definition at line 170 of file xpress_interface.cc.

◆ getMapDoubleControls()

static std::map< std::string, int > & operations_research::getMapDoubleControls ( )
static

Definition at line 507 of file xpress_interface.cc.

◆ getMapInt64Controls()

static std::map< std::string, int > & operations_research::getMapInt64Controls ( )
static

Definition at line 829 of file xpress_interface.cc.

◆ getMapIntControls()

static std::map< std::string, int > & operations_research::getMapIntControls ( )
static

Definition at line 592 of file xpress_interface.cc.

◆ getMapStringControls()

static std::map< std::string, int > & operations_research::getMapStringControls ( )
static

Definition at line 492 of file xpress_interface.cc.

◆ GetMPModelOrPopulateResponse()

std::optional< LazyMutableCopy< MPModelProto > > operations_research::GetMPModelOrPopulateResponse ( LazyMutableCopy< MPModelRequest > & request,
MPSolutionResponse * response )

Same as ExtractValidMPModelOrPopulateResponseStatus() but if we already have ownership of the request, do not do any copy even when needed. Note that the MPModelProto in the request will be cleared in this case.

Extract the baseline model.

Note
we move it out of the request if we have ownership.

NOTE(user): This library needs to be portable, so we can't include file/base/helpers.h; see ../port/file.h.

Validate the baseline model.

If the baseline is valid and we have a model delta, validate the delta, then apply it.

Deal with errors.

Definition at line 693 of file model_validator.cc.

◆ getnodecnt()

int operations_research::getnodecnt ( const XPRSprob & mLp)

Definition at line 176 of file xpress_interface.cc.

◆ getnumcols()

int operations_research::getnumcols ( const XPRSprob & mLp)

Definition at line 158 of file xpress_interface.cc.

◆ getnumrows()

int operations_research::getnumrows ( const XPRSprob & mLp)

Definition at line 164 of file xpress_interface.cc.

◆ GetProcessMemoryUsage()

int64_t operations_research::GetProcessMemoryUsage ( )

GetProcessMemoryUsage.

Returns the memory usage of the process.

Definition at line 88 of file sysinfo.cc.

◆ GetSeed()

int32_t operations_research::GetSeed ( bool deterministic)

Random seed generator.

Definition at line 35 of file cvrptw_lib.cc.

◆ getSolverVersion()

std::string operations_research::getSolverVersion ( XPRSprob const & prob)

XPRS_VERSION gives the version number as MAJOR*100 + RELEASE. It does not include the build number.

Definition at line 44 of file xpress_interface.cc.

◆ GlopSolveProto()

MPSolutionResponse operations_research::GlopSolveProto ( LazyMutableCopy< MPModelRequest > request,
std::atomic< bool > * interrupt_solve = nullptr,
std::function< void(const std::string &)> logging_callback = nullptr )

Solve the input LP model with the GLOP solver.

If possible, std::move the request into this function call to avoid a copy.

If you need to change the solver parameters, please use the EncodeParametersAsString() function to set the solver_specific_parameters field.

The optional interrupt_solve can be used to interrupt the solve early. It must only be set to true, never reset to false. It is also used internally by the solver that will set it to true for its own internal logic. As a consequence the caller should ignore the stored value and should not use the same atomic for different concurrent calls.

The optional logging_callback will be called when the GLOP parameter log_search_progress is set to true. Passing a callback will disable the default logging to INFO. Note though that by default the GLOP parameter log_to_stdout is true so even with a callback, the logs will appear on stdout too unless log_to_stdout is set to false. The enable_internal_solver_output in the request will act as the GLOP parameter log_search_progress.

Todo
(user): We do not support all the parameters here. In particular the logs before the solver is called will not be appended to the response. Fix that, and remove code duplication for the logger config. One way should be to not touch/configure anything if the logger is already created while calling SolveCpModel() and call a common config function from here or from inside Solve()?

Set it now so that it can be overwritten by the solver specific parameters.

See EncodeParametersAsString() documentation.

Model validation and delta handling.

Convert and clear the request and mp_model as it is no longer needed.

TimeLimit and interrupt solve.

Solve and set response status.

Fill in solution.

Definition at line 107 of file glop_proto_solver.cc.

◆ GlopSolverVersion()

std::string operations_research::GlopSolverVersion ( )

Returns a string that describes the version of the GLOP solver.

Definition at line 234 of file glop_proto_solver.cc.

◆ GlopToMPSolverConstraintStatus()

MPSolver::BasisStatus operations_research::GlopToMPSolverConstraintStatus ( glop::ConstraintStatus s)

Definition at line 91 of file glop_utils.cc.

◆ GlopToMPSolverResultStatus()

MPSolver::ResultStatus operations_research::GlopToMPSolverResultStatus ( glop::ProblemStatus s)

Note(user): MPSolver does not have the equivalent of INFEASIBLE_OR_UNBOUNDED however UNBOUNDED is almost never relevant in applications, so we decided to report this status as INFEASIBLE since it should almost always be the case. Historically, we where reporting ABNORMAL, but that was more confusing than helpful.

Todo
(user): We could argue that it is infeasible to find the optimal of an unbounded problem. So it might just be simpler to completely get rid of the MpSolver::UNBOUNDED status that seems to never be used programmatically.

Definition at line 18 of file glop_utils.cc.

◆ GlopToMPSolverVariableStatus()

MPSolver::BasisStatus operations_research::GlopToMPSolverVariableStatus ( glop::VariableStatus s)

Definition at line 57 of file glop_utils.cc.

◆ GLPKGatherInformationCallback()

void operations_research::GLPKGatherInformationCallback ( glp_tree * tree,
void * info )

Function to be called in the GLPK callback.

The best bound and the number of nodes change only when GLPK branches, generates cuts or finds an integer solution.

Get total number of nodes

Get best bound

Definition at line 63 of file glpk_interface.cc.

◆ GScipAddQuadraticObjectiveTerm()

absl::Status operations_research::GScipAddQuadraticObjectiveTerm ( GScip * gscip,
std::vector< SCIP_Var * > quadratic_variables1,
std::vector< SCIP_Var * > quadratic_variables2,
std::vector< double > quadratic_coefficients,
absl::string_view name = "" )
Warning
DO NOT CHANGE THE OBJECTIVE DIRECTION AFTER CALLING THIS METHOD.

This is implemented by modeling the quadratic term with an an inequality constraint and a single extra variable, which is then added to the objective. The inequality will be in the wrong direction if you change the objective direction after calling this method.

maximize z z <= Q(x, y) => 0 <= Q(x, y) - z <= inf

minimize z z >= Q(x, y) => 0 >= Q(x, y) - z >= -inf

Definition at line 149 of file gscip_ext.cc.

◆ GScipCatchCtrlC()

bool operations_research::GScipCatchCtrlC ( const GScipParameters & parameters)

Returns the misc/catchctrlc property; true if not set (the default SCIP behavior).

Definition at line 136 of file gscip_parameters.cc.

◆ GScipCatchCtrlCSet()

bool operations_research::GScipCatchCtrlCSet ( const GScipParameters & parameters)

Returns true when the misc/catchctrlc property is set.

Definition at line 143 of file gscip_parameters.cc.

◆ GScipCreateAbs()

absl::Status operations_research::GScipCreateAbs ( GScip * gscip,
SCIP_Var * x,
SCIP_Var * abs_x,
absl::string_view name = "" )

Adds the constraint y = abs(x). May create auxiliary variables. Supports unbounded x.

Definition at line 75 of file gscip_ext.cc.

◆ GScipCreateIndicatorRange()

absl::Status operations_research::GScipCreateIndicatorRange ( GScip * gscip,
const GScipIndicatorRangeConstraint & indicator_range,
absl::string_view name,
const GScipConstraintOptions & options )

Supports unbounded variables in indicator_range.range.variables.

want z -> lb <= a * x <=> z -> -lb >= -a * x

Definition at line 179 of file gscip_ext.cc.

◆ GScipCreateMaximum()

absl::Status operations_research::GScipCreateMaximum ( GScip * gscip,
const GScipLinearExpr & resultant,
const std::vector< GScipLinearExpr > & terms,
absl::string_view name = "" )

Adds the constraint resultant = maximum(terms). Supports unbounded variables in terms.

Todo
(user): it may be better to write this in terms of the disjuntive constraint, we need to support disjunctions in gscip.h to do this.

z_i in {0,1}, indicates if y = x_i

x_i <= y z_i => y <= x_i \sum_i z_i == 1

x_i <= y

z_i => y <= x_i

sum_i z_i = 1.

Definition at line 82 of file gscip_ext.cc.

◆ GScipCreateMinimum()

absl::Status operations_research::GScipCreateMinimum ( GScip * gscip,
const GScipLinearExpr & resultant,
const std::vector< GScipLinearExpr > & terms,
absl::string_view name = "" )

Adds the constraint resultant = minimum(terms). Supports unbounded variables in terms.

Definition at line 138 of file gscip_ext.cc.

◆ GScipDifference()

GScipLinearExpr operations_research::GScipDifference ( GScipLinearExpr left,
const GScipLinearExpr & right )

Returns left - right.

Definition at line 43 of file gscip_ext.cc.

◆ GScipLe()

GScipLinearRange operations_research::GScipLe ( const GScipLinearExpr left,
const GScipLinearExpr & right )

Returns the range -inf <= left.terms - right.terms <= right.offset - left.offset

Definition at line 62 of file gscip_ext.cc.

◆ GScipLogLevel()

int operations_research::GScipLogLevel ( const GScipParameters & parameters)

Definition at line 88 of file gscip_parameters.cc.

◆ GScipLogLevelSet()

bool operations_research::GScipLogLevelSet ( const GScipParameters & parameters)

Definition at line 93 of file gscip_parameters.cc.

◆ GScipMaxNumThreads()

int operations_research::GScipMaxNumThreads ( const GScipParameters & parameters)

Returns 1 if the number of threads it not specified.

Definition at line 70 of file gscip_parameters.cc.

◆ GScipMaxNumThreadsSet()

bool operations_research::GScipMaxNumThreadsSet ( const GScipParameters & parameters)

Definition at line 77 of file gscip_parameters.cc.

◆ GScipNegate()

GScipLinearExpr operations_research::GScipNegate ( GScipLinearExpr expr)

Returns -expr.

Definition at line 52 of file gscip_ext.cc.

◆ GScipOutputEnabled()

bool operations_research::GScipOutputEnabled ( const GScipParameters & parameters)

Checks if the log level is equal to zero.

Definition at line 104 of file gscip_parameters.cc.

◆ GScipOutputEnabledSet()

bool operations_research::GScipOutputEnabledSet ( const GScipParameters & parameters)

Definition at line 109 of file gscip_parameters.cc.

◆ GScipRandomSeed()

int operations_research::GScipRandomSeed ( const GScipParameters & parameters)

Returns -1 if unset.

Definition at line 119 of file gscip_parameters.cc.

◆ GScipRandomSeedSet()

bool operations_research::GScipRandomSeedSet ( const GScipParameters & parameters)

Definition at line 126 of file gscip_parameters.cc.

◆ GScipSetCatchCtrlC()

void operations_research::GScipSetCatchCtrlC ( const bool catch_ctrl_c,
GScipParameters *const parameters )

Sets the misc/catchctrlc property.

Definition at line 130 of file gscip_parameters.cc.

◆ GScipSetLogLevel()

void operations_research::GScipSetLogLevel ( GScipParameters * parameters,
int log_level )

log_level must be in [0, 5], where 0 is none, 5 is most verbose, and the default is 4. CHECK fails on bad log_level. Default level displays standard search logs.

Definition at line 81 of file gscip_parameters.cc.

◆ GScipSetMaxNumThreads()

void operations_research::GScipSetMaxNumThreads ( int num_threads,
GScipParameters * parameters )

CHECK fails if num_threads < 1.

Definition at line 64 of file gscip_parameters.cc.

◆ GScipSetOutputEnabled()

void operations_research::GScipSetOutputEnabled ( GScipParameters * parameters,
bool output_enabled )

Sets the log level to 4 if enabled, 0 if disabled (see above).

Definition at line 97 of file gscip_parameters.cc.

◆ GScipSetRandomSeed()

void operations_research::GScipSetRandomSeed ( GScipParameters * parameters,
int random_seed )

Sets an initial seed (shift) for all pseudo-random number generators used within SCIP. Valid values are [0:INT_MAX] i.e. [0:2^31-1]. If an invalid value is passed, 0 would be stored instead.

Definition at line 113 of file gscip_parameters.cc.

◆ GScipSetTimeLimit()

void operations_research::GScipSetTimeLimit ( absl::Duration time_limit,
GScipParameters * parameters )

Definition at line 36 of file gscip_parameters.cc.

◆ GScipTimeLimit()

absl::Duration operations_research::GScipTimeLimit ( const GScipParameters & parameters)

Definition at line 45 of file gscip_parameters.cc.

◆ GScipTimeLimitSet()

bool operations_research::GScipTimeLimitSet ( const GScipParameters & parameters)

Definition at line 60 of file gscip_parameters.cc.

◆ GurobiDynamicLibraryPotentialPaths()

std::vector< std::string > operations_research::GurobiDynamicLibraryPotentialPaths ( )

Look for libraries pointed by GUROBI_HOME first.

Search for canonical places.

Definition at line 346 of file environment.cc.

◆ GurobiIsCorrectlyInstalled()

bool operations_research::GurobiIsCorrectlyInstalled ( )

This returns true if the Gurobi shared library is properly loaded (otherwise, tries to find it and load it) and if a Gurobi license can be obtained (it does that by trying to grab a license and then release it).

Definition at line 33 of file environment.cc.

◆ GurobiParamInfoForLogging()

std::string operations_research::GurobiParamInfoForLogging ( GRBenv * grb,
bool one_liner_output = false )

Returns a human-readable listing of all gurobi parameters that are set to non-default values, and their current value in the given environment. If all parameters are at their default value, returns the empty string. To produce a one-liner string, use one_liner_output=true.

This ensure that strcmp does not go beyond the end of the char array.

Definition at line 27 of file gurobi_util.cc.

◆ GurobiSolveProto()

absl::StatusOr< MPSolutionResponse > operations_research::GurobiSolveProto ( LazyMutableCopy< MPModelRequest > request,
GRBenv * gurobi_env = nullptr )

Solves the input request.

By default this function creates a new primary Gurobi environment, but an existing one can be passed as parameter. This can be useful with single-use Gurobi licenses since it is not possible to create a second environment if one already exists with those licenses.

Please note though that the provided environment should not be actively used by another thread at the same time.

We set gurobi_env to point to a new environment if no existing one is provided. We must make sure that we free this environment when we exit this function.

gurobi_env references ther GRBenv argument.

Set solution hints if any.

Using GRBaddrangeconstr for constraints that don't require it adds a slack which is not always removed by presolve.

If the presolve deletes all variables, there's no best bound.

NOTE, GurobiSolveProto() is exposed to external clients via MPSolver API, which assumes the solution values of integer variables are rounded to integer values.

Definition at line 274 of file gurobi_proto_solver.cc.

◆ Hash1() [1/7]

uint64_t operations_research::Hash1 ( const std::vector< int64_t > & ptrs)
inline

Definition at line 273 of file constraint_solveri.h.

◆ Hash1() [2/7]

template<class T >
uint64_t operations_research::Hash1 ( const std::vector< T * > & ptrs)

Definition at line 263 of file constraint_solveri.h.

◆ Hash1() [3/7]

uint64_t operations_research::Hash1 ( int value)
inline

Definition at line 251 of file constraint_solveri.h.

◆ Hash1() [4/7]

uint64_t operations_research::Hash1 ( int64_t value)
inline

Definition at line 247 of file constraint_solveri.h.

◆ Hash1() [5/7]

uint64_t operations_research::Hash1 ( uint32_t value)
inline

Definition at line 236 of file constraint_solveri.h.

◆ Hash1() [6/7]

uint64_t operations_research::Hash1 ( uint64_t value)
inline

Hash functions

Todo
(user): use murmurhash.

value = (value << 21) - value - 1;

value * 265

value * 21

Definition at line 225 of file constraint_solveri.h.

◆ Hash1() [7/7]

uint64_t operations_research::Hash1 ( void *const ptr)
inline

Definition at line 253 of file constraint_solveri.h.

◆ HighsSolveProto()

absl::StatusOr< MPSolutionResponse > operations_research::HighsSolveProto ( LazyMutableCopy< MPModelRequest > request)

Solve the input MIP model with the HIGHS solver.

Todo
(user): Set model name.

Mark integrality.

Objective coefficients.

Todo
(user): Support variable names.
Todo
Todo
(user): Support hints.
Todo
(user): Support constraint names.

Logging.

Todo
(user): report feasible status.

Definition at line 45 of file highs_proto_solver.cc.

◆ IncrementalSort() [1/2]

template<class Iterator , class Compare = std::less<value_type_t<Iterator>>>
void operations_research::IncrementalSort ( int max_comparisons,
Iterator begin,
Iterator end,
Compare comp = Compare{},
bool is_stable = false )

Sorts the elements in the range [begin, end) in ascending order using the comp predicate. The order of equal elements is guaranteed to be preserved only if is_stable is true.

This function performs well if the elements in the range [begin, end) are almost sorted.

The algorithm operates as follows: 1) Check that the range [begin, end) is already sorted by performing a single iteration of bubble-sort. 2) Try to sort the range with insertion sort. Insertion sort will stop if it uses the comp predicate more than max_comparisons. Note that the algorithm may actually use the comp predicate more than max_comparisons in order to complete its current insertion. 3) If insertion sort exceeds the maximum number of comparisons, the range is sorted using std::stable_sort if is_stable is true or std::sort otherwise.

The first two steps of this algorithm are inspired by the ones recommended in Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.

Ranges of at most one element are already sorted.

Perform a single iteration of bubble-sort to place the smallest unsorted element to its correct position.

We know that the elements in the range [begin, last_sorted) are the smallest elements of [begin, end) and are sorted.

Stop if insertion sort was able to sort the range.

Definition at line 46 of file sort.h.

◆ IncrementalSort() [2/2]

template<class Iterator , class Compare = std::less<value_type_t<Iterator>>>
void operations_research::IncrementalSort ( Iterator begin,
Iterator end,
Compare comp = Compare{},
bool is_stable = false )

Sorts the elements in the range [begin, end) in ascending order using the comp predicate. The order of equal elements is guaranteed to be preserved only if is_stable is true.

This function performs well if the elements in the range [begin, end) are almost sorted.

Definition at line 129 of file sort.h.

◆ initXpressEnv()

bool operations_research::initXpressEnv ( bool verbose,
int xpress_oem_license_key )

! init XPRESS environment.

if not an OEM key

XPRSbanner informs about Xpress version, options and error messages

if OEM key

get the license error message

Definition at line 263 of file environment.cc.

◆ InputContainsNan()

bool operations_research::InputContainsNan ( absl::Span< const std::vector< double > > input)

Definition at line 643 of file hungarian.cc.

◆ InsertionSort()

template<class Iterator , class Compare = std::less<value_type_t<Iterator>>>
void operations_research::InsertionSort ( Iterator begin,
Iterator end,
Compare comp = Compare{} )

Sorts the elements in the range [begin, end) in ascending order using the comp predicate. The order of equal elements is guaranteed to be preserved.

This function performs well if the elements in the range [begin, end) are almost sorted.

This algorithm is inspired by the ones recommended in Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.

Ranges of at most one element are already sorted.

Perform a single iteration of bubble-sort to place the smallest unsorted element to its correct position.

We know that the elements in the range [begin, last_sorted) are the smallest elements of [begin, end) and are sorted.

Definition at line 95 of file sort.h.

◆ InstallDemonProfiler()

void operations_research::InstallDemonProfiler ( DemonProfiler * monitor)
extern

--— Forward Declarations and Profiling Support --—

--— Exported Functions --—

Definition at line 443 of file demon_profiler.cc.

◆ InstallLocalSearchProfiler()

void operations_research::InstallLocalSearchProfiler ( LocalSearchProfiler * monitor)
extern

Definition at line 4578 of file local_search.cc.

◆ Int64ToStr()

std::string operations_research::Int64ToStr ( int64_t number)

Definition at line 2975 of file routing_lp_scheduling.cc.

◆ InternalSaveBooleanVarValue()

void operations_research::InternalSaveBooleanVarValue ( Solver *const solver,
IntVar *const var )

Definition at line 965 of file constraint_solver.cc.

◆ Interpolate()

template<typename FloatType >
FloatType operations_research::Interpolate ( FloatType x,
FloatType y,
FloatType alpha )
inline

Returns alpha * x + (1 - alpha) * y.

Definition at line 246 of file fp_utils.h.

◆ interruptXPRESS()

void operations_research::interruptXPRESS ( XPRSprob & xprsProb,
CUSTOM_INTERRUPT_REASON reason )

Reason values below 1000 are reserved by XPRESS

Definition at line 201 of file xpress_interface.cc.

◆ IntervalDown32()

uint32_t operations_research::IntervalDown32 ( uint32_t s)
inline

Definition at line 320 of file bitset.h.

◆ IntervalDown64()

uint64_t operations_research::IntervalDown64 ( uint64_t s)
inline

Returns a word with the s most significant bits unset.

Definition at line 315 of file bitset.h.

◆ IntervalsAreSortedAndNonAdjacent()

bool operations_research::IntervalsAreSortedAndNonAdjacent ( absl::Span< const ClosedInterval > intervals)

Returns true iff we have:

  • The intervals appear in increasing order.
  • for all i: intervals[i].start <= intervals[i].end (should always be true, by construction, but bad intervals can in practice escape detection in opt mode).
  • for all i but the last: intervals[i].end + 1 < intervals[i+1].start

First test make sure that intervals[i - 1].end + 1 will not overflow.

Definition at line 40 of file sorted_interval_list.cc.

◆ IntervalUp32()

uint32_t operations_research::IntervalUp32 ( uint32_t s)
inline

Definition at line 309 of file bitset.h.

◆ IntervalUp64()

uint64_t operations_research::IntervalUp64 ( uint64_t s)
inline

Returns a word with s least significant bits unset.

Definition at line 304 of file bitset.h.

◆ IsAligned()

template<size_t alignment_bytes, typename Value >
bool operations_research::IsAligned ( Value * ptr)
inline

Returns true when ptr is aligned to alignment_bytes bytes.

Definition at line 64 of file aligned_memory.h.

◆ IsArrayBoolean()

template<class T >
bool operations_research::IsArrayBoolean ( const std::vector< T > & values)

Definition at line 3185 of file constraint_solveri.h.

◆ IsArrayConstant()

template<class T >
bool operations_research::IsArrayConstant ( const std::vector< T > & values,
const T & value )

Definition at line 3175 of file constraint_solveri.h.

◆ IsArrayInRange()

template<class T >
bool operations_research::IsArrayInRange ( const std::vector< IntVar * > & vars,
T range_min,
T range_max )

Definition at line 3265 of file constraint_solveri.h.

◆ IsBitSet32()

bool operations_research::IsBitSet32 ( const uint32_t *const bitset,
uint32_t pos )
inline

Definition at line 353 of file bitset.h.

◆ IsBitSet64()

bool operations_research::IsBitSet64 ( const uint64_t *const bitset,
uint64_t pos )
inline

Returns true if the bit pos is set in bitset.

Definition at line 350 of file bitset.h.

◆ IsEmptyRange32()

bool operations_research::IsEmptyRange32 ( const uint32_t * bitset,
uint32_t start,
uint32_t end )

◆ IsEmptyRange64()

bool operations_research::IsEmptyRange64 ( const uint64_t * bitset,
uint64_t start,
uint64_t end )

Returns true if no bits are set in bitset between start and end.

◆ IsEulerianGraph()

template<typename Graph >
bool operations_research::IsEulerianGraph ( const Graph & graph,
bool assume_connectivity = true )

Returns true if a graph is Eulerian, aka all its nodes are of even degree.

Definition at line 45 of file eulerian_path.h.

◆ IsIncreasing()

template<class T >
bool operations_research::IsIncreasing ( const std::vector< T > & values)

Definition at line 3255 of file constraint_solveri.h.

◆ IsIncreasingContiguous()

template<class T >
bool operations_research::IsIncreasingContiguous ( const std::vector< T > & values)

Definition at line 3245 of file constraint_solveri.h.

◆ IsIntegerWithinTolerance()

template<typename FloatType >
bool operations_research::IsIntegerWithinTolerance ( FloatType x,
FloatType tolerance )
inline

Returns true if x is within tolerance of any integer. Always returns false for x equal to +/- infinity.

Definition at line 167 of file fp_utils.h.

◆ IsPositiveOrNegativeInfinity()

template<typename FloatType >
bool operations_research::IsPositiveOrNegativeInfinity ( FloatType x)
inline

Definition at line 113 of file fp_utils.h.

◆ IsSemiEulerianGraph()

template<typename NodeIndex , typename Graph >
bool operations_research::IsSemiEulerianGraph ( const Graph & graph,
std::vector< NodeIndex > * odd_nodes,
bool assume_connectivity = true )

Returns true if a graph is Semi-Eulerian, aka at most two of its nodes are of odd degree. odd_nodes is filled with odd nodes of the graph.

Definition at line 59 of file eulerian_path.h.

◆ IsSmallerWithinTolerance()

template<typename FloatType >
bool operations_research::IsSmallerWithinTolerance ( FloatType x,
FloatType y,
FloatType tolerance )

Returns true if x is less than y or slighlty greater than y with the given absolute or relative tolerance.

Definition at line 159 of file fp_utils.h.

◆ JoinDebugString()

template<class T >
std::string operations_research::JoinDebugString ( const std::vector< T > & v,
absl::string_view separator )

Join v[i].DebugString().

Converts a vector into a string by calling the given method (or simply getting the given string member), on all elements, and concatenating the obtained strings with the given separator.

Definition at line 40 of file string_array.h.

◆ JoinDebugStringPtr()

template<class T >
std::string operations_research::JoinDebugStringPtr ( const std::vector< T > & v,
absl::string_view separator )

Join v[i]->DebugString().

Definition at line 47 of file string_array.h.

◆ JoinNameFieldPtr()

template<class T >
std::string operations_research::JoinNameFieldPtr ( const std::vector< T > & v,
absl::string_view separator )

Join v[i]->name.

Definition at line 60 of file string_array.h.

◆ JoinNamePtr()

template<class T >
std::string operations_research::JoinNamePtr ( const std::vector< T > & v,
absl::string_view separator )

Join v[i]->name().

Definition at line 54 of file string_array.h.

◆ KeepAbslSymbols()

void operations_research::KeepAbslSymbols ( )

Definition at line 37 of file logging.cc.

◆ kNotFound()

SubsetIndex operations_research::kNotFound ( - 1)
constexpr

◆ KShortestPathsOnDag()

std::vector< PathWithLength > operations_research::KShortestPathsOnDag ( int num_nodes,
absl::Span< const ArcWithLength > arcs_with_length,
int source,
int destination,
int path_count )

Returns the k-shortest paths by increasing length. Returns fewer than k paths if there are fewer than k paths from the source to the destination. Returns {{+inf, {}, {}}} if there is no path of finite length from the source to the destination. Dies if arcs_with_length has a cycle.

Definition at line 106 of file dag_shortest_path.cc.

◆ LeastSignificantBitPosition32() [1/2]

int operations_research::LeastSignificantBitPosition32 ( const uint32_t * bitset,
uint32_t start,
uint32_t end )

◆ LeastSignificantBitPosition32() [2/2]

int operations_research::LeastSignificantBitPosition32 ( uint32_t n)
inline

Definition at line 186 of file bitset.h.

◆ LeastSignificantBitPosition32DeBruijn()

int operations_research::LeastSignificantBitPosition32DeBruijn ( uint32_t n)
inline

Definition at line 148 of file bitset.h.

◆ LeastSignificantBitPosition32Default()

int operations_research::LeastSignificantBitPosition32Default ( uint32_t n)
inline

Definition at line 157 of file bitset.h.

◆ LeastSignificantBitPosition64() [1/2]

int64_t operations_research::LeastSignificantBitPosition64 ( const uint64_t * bitset,
uint64_t start,
uint64_t end )

Returns the first bit set in bitset between start and max_bit.

◆ LeastSignificantBitPosition64() [2/2]

int operations_research::LeastSignificantBitPosition64 ( uint64_t n)
inline

Definition at line 131 of file bitset.h.

◆ LeastSignificantBitPosition64DeBruijn()

int operations_research::LeastSignificantBitPosition64DeBruijn ( uint64_t n)
inline

initialized by 'kTab[(kSeq << i) >> 58] = i

Definition at line 85 of file bitset.h.

◆ LeastSignificantBitPosition64Default()

int operations_research::LeastSignificantBitPosition64Default ( uint64_t n)
inline

Definition at line 97 of file bitset.h.

◆ LeastSignificantBitWord32()

uint32_t operations_research::LeastSignificantBitWord32 ( uint32_t n)
inline

Definition at line 68 of file bitset.h.

◆ LeastSignificantBitWord64()

uint64_t operations_research::LeastSignificantBitWord64 ( uint64_t n)
inline

Returns a word with only the least significant bit of n set.

Definition at line 67 of file bitset.h.

◆ LegacyScipSetSolverSpecificParameters()

absl::Status operations_research::LegacyScipSetSolverSpecificParameters ( absl::string_view parameters,
SCIP * scip )

Definition at line 35 of file legacy_scip_params.cc.

◆ LinearConstraintIsViolated()

bool operations_research::LinearConstraintIsViolated ( const ScipConstraintHandlerContext & context,
const LinearRange & constraint )

Definition at line 101 of file scip_callback.cc.

◆ LinkVarExpr()

void operations_research::LinkVarExpr ( Solver * s,
IntExpr * expr,
IntVar * var )

--— IntExprElement --—

-------— BaseIntExpr ------—

Definition at line 7461 of file expressions.cc.

◆ LoadGurobiDynamicLibrary()

absl::Status operations_research::LoadGurobiDynamicLibrary ( std::vector< std::string > potential_paths)

clang-format off Force the loading of the gurobi dynamic library. It returns true if the library was successfully loaded. This method can only be called once. Successive calls are no-op.

Note
it does not check if a token license can be grabbed.

Definition at line 418 of file environment.cc.

◆ LoadGurobiFunctions()

void operations_research::LoadGurobiFunctions ( DynamicLibrary * gurobi_dynamic_library)

This was generated with the parse_header.py script. See the comment at the top of the script.

This is the 'assign' section.

Definition at line 235 of file environment.cc.

◆ LoadXpressDynamicLibrary()

absl::Status operations_research::LoadXpressDynamicLibrary ( std::string & xpresspath)

Force the loading of the xpress dynamic library. It returns true if the library was successfully loaded. This method can only be called once. Successive calls are no-op.

Note
it does not check if a token license can be grabbed.

Definition at line 221 of file environment.cc.

◆ LoadXpressFunctions()

void operations_research::LoadXpressFunctions ( DynamicLibrary * xpress_dynamic_library)

This was generated with the parse_header_xpress.py script. See the comment at the top of the script.

This is the 'assign' section.

Definition at line 103 of file environment.cc.

◆ LocalBfs()

void operations_research::LocalBfs ( const ::util::StaticGraph< int, int > & graph,
int source,
int stop_after_num_nodes,
std::vector< int > * visited,
std::vector< int > * num_within_radius,
std::vector< bool > * tmp_mask )

Runs a Breadth-First-Search locally: it stops when we settled the given number of nodes, though it will finish the current radius. visited will contain either the full connected components, or all the nodes with distance ≤ R+1 from the source, where R is the radius where we stopped. num_within_radius contains the increasing number of nodes within distance 0, 1, .., R+1 of the source.

We already know all the nodes at the next distance.

Clean up 'tmp_mask' sparsely.

If we explored the whole connected component, num_within_radius contains a spurious entry: remove it.

Parameters
tmp_maskFor performance, the user provides us with an already- allocated bitmask of size graph.num_nodes() with all values set to "false", which we'll restore in the same state upon return.

Definition at line 73 of file find_graph_symmetries.cc.

◆ LocalOptimumReached()

bool operations_research::LocalOptimumReached ( Search * search)

Returns true if a local optimum has been reached and cannot be improved.

Utility methods to ensure the communication between local search and the search.

Definition at line 1378 of file constraint_solver.cc.

◆ log_full_license_error()

void operations_research::log_full_license_error ( int code,
const std::string & xpress_lib_dir )

Definition at line 343 of file environment.cc.

◆ log_message_about_XPRSinit_argument()

void operations_research::log_message_about_XPRSinit_argument ( )

Definition at line 354 of file environment.cc.

◆ MakeAllUnperformed()

DecisionBuilder * operations_research::MakeAllUnperformed ( RoutingModel * model)

Returns a DecisionBuilder making all nodes unperformed.

Definition at line 4808 of file routing_search.cc.

◆ MakeBareIntToIntFunction()

RangeIntToIntFunction * operations_research::MakeBareIntToIntFunction ( std::function< int64_t(int64_t)> f)

A copy of f is going to be stored in the returned object, so its closure should remain intact as long as the returned object is being used.

Definition at line 227 of file range_query_function.cc.

◆ MakeBinCapacities()

std::unique_ptr< BinCapacities > operations_research::MakeBinCapacities ( const std::vector< RoutingDimension * > & dimensions,
const PathsMetadata & paths_metadata )

If the dimension is not unary, skip.

If the dimension has no constant-signed transit evaluator, skip.

For each vehicle, if the sign of its evaluator is constant, set a transit evaluator to pass to BinCapacities.

Vehicle load changes monotonically along the route. If transit signs are >= 0, the min load is at start, the max at end. If transit signs are <= 0, the max load is at start, the min at end. The encoding into BinCapacities associates a bin dimension with this routing dimension, with bin capacity = vehicle capacity - min load, and bin item size = abs(transit(node)).

Definition at line 4841 of file routing.cc.

◆ MakeCachedIntToIntFunction()

RangeIntToIntFunction * operations_research::MakeCachedIntToIntFunction ( const std::function< int64_t(int64_t)> & f,
int64_t domain_start,
int64_t domain_end )

It is assumed that f is defined over the interval [domain_start, domain_end). The function scans f once and it is safe to destroy f and its closure after MakeCachedIntToIntFunction returns.

Definition at line 232 of file range_query_function.cc.

◆ MakeCachedRangeMinMaxIndexFunction()

RangeMinMaxIndexFunction * operations_research::MakeCachedRangeMinMaxIndexFunction ( const std::function< int64_t(int64_t)> & f,
int64_t domain_start,
int64_t domain_end )

It is safe to destroy the first argument and its closure after MakeCachedRangeMinMaxIndexFunction returns.

Definition at line 238 of file range_query_function.cc.

◆ MakeConstraintDemon0()

template<class T >
Demon * operations_research::MakeConstraintDemon0 ( Solver *const s,
T *const ct,
void(T::* method )(),
const std::string & name )

Definition at line 530 of file constraint_solveri.h.

◆ MakeConstraintDemon1()

template<class T , class P >
Demon * operations_research::MakeConstraintDemon1 ( Solver *const s,
T *const ct,
void(T::* method )(P),
const std::string & name,
P param1 )

Definition at line 571 of file constraint_solveri.h.

◆ MakeConstraintDemon2()

template<class T , class P , class Q >
Demon * operations_research::MakeConstraintDemon2 ( Solver *const s,
T *const ct,
void(T::* method )(P, Q),
const std::string & name,
P param1,
Q param2 )

Definition at line 610 of file constraint_solveri.h.

◆ MakeConstraintDemon3()

template<class T , class P , class Q , class R >
Demon * operations_research::MakeConstraintDemon3 ( Solver *const s,
T *const ct,
void(T::* method )(P, Q, R),
const std::string & name,
P param1,
Q param2,
R param3 )

Definition at line 653 of file constraint_solveri.h.

◆ MakeCPFeasibilityFilter()

IntVarLocalSearchFilter * operations_research::MakeCPFeasibilityFilter ( RoutingModel * routing_model)

Returns a filter checking the current solution using CP propagation.

Definition at line 3090 of file routing_filters.cc.

◆ MakeCumulBoundsPropagatorFilter()

IntVarLocalSearchFilter * operations_research::MakeCumulBoundsPropagatorFilter ( const RoutingDimension & dimension)

Returns a filter handling dimension cumul bounds.

Definition at line 2585 of file routing_filters.cc.

◆ MakeDelayedConstraintDemon0()

template<class T >
Demon * operations_research::MakeDelayedConstraintDemon0 ( Solver *const s,
T *const ct,
void(T::* method )(),
const std::string & name )

Definition at line 693 of file constraint_solveri.h.

◆ MakeDelayedConstraintDemon1()

template<class T , class P >
Demon * operations_research::MakeDelayedConstraintDemon1 ( Solver *const s,
T *const ct,
void(T::* method )(P),
const std::string & name,
P param1 )

Definition at line 729 of file constraint_solveri.h.

◆ MakeDelayedConstraintDemon2()

template<class T , class P , class Q >
Demon * operations_research::MakeDelayedConstraintDemon2 ( Solver *const s,
T *const ct,
void(T::* method )(P, Q),
const std::string & name,
P param1,
Q param2 )

Definition at line 773 of file constraint_solveri.h.

◆ MakeDifferentFromValues()

Constraint * operations_research::MakeDifferentFromValues ( Solver * solver,
IntVar * var,
std::vector< int64_t > values )

Definition at line 59 of file routing_constraints.cc.

◆ MakeDimensionFilter()

LocalSearchFilter * operations_research::MakeDimensionFilter ( Solver * solver,
std::unique_ptr< DimensionChecker > checker,
const std::string & dimension_name )

Make a filter that translates solver events to the input checker's interface. Since DimensionChecker has a PathState, the filter returned by this must be synchronized to the corresponding PathStateFilter:

  • Relax() must be called after the PathStateFilter's.
  • Accept() must be called after.
  • Synchronize() must be called before.
  • Revert() must be called before.

Definition at line 3400 of file local_search.cc.

◆ MakeGlobalLPCumulFilter()

IntVarLocalSearchFilter * operations_research::MakeGlobalLPCumulFilter ( GlobalDimensionCumulOptimizer * optimizer,
GlobalDimensionCumulOptimizer * mp_optimizer,
bool filter_objective_cost )

Returns a filter checking global linear constraints and costs.

Definition at line 2723 of file routing_filters.cc.

◆ MakeHamiltonianPathSolver()

template<typename CostType , typename CostFunction >
HamiltonianPathSolver< CostType, CostFunction > operations_research::MakeHamiltonianPathSolver ( int num_nodes,
CostFunction cost )

Utility function to simplify building a HamiltonianPathSolver from a functor.

Definition at line 598 of file hamiltonian_path.h.

◆ MakeLocalSearchOperator()

template<class T >
LocalSearchOperator * operations_research::MakeLocalSearchOperator ( Solver * solver,
const std::vector< IntVar * > & vars,
const std::vector< IntVar * > & secondary_vars,
std::function< int(int64_t)> start_empty_path_class )

Operator Factories.

--— Operator factory --—

Definition at line 2425 of file local_search.cc.

◆ MakeLocalSearchOperatorWithNeighbors()

template<class T >
LocalSearchOperator * operations_research::MakeLocalSearchOperatorWithNeighbors ( Solver * solver,
const std::vector< IntVar * > & vars,
const std::vector< IntVar * > & secondary_vars,
std::function< int(int64_t)> start_empty_path_class,
std::function< const std::vector< int > &(int, int)> get_neighbors )

Definition at line 2434 of file local_search.cc.

◆ MakeMaxActiveVehiclesFilter()

IntVarLocalSearchFilter * operations_research::MakeMaxActiveVehiclesFilter ( const RoutingModel & routing_model)

Returns a filter ensuring that max active vehicles constraints are enforced.

Definition at line 118 of file routing_filters.cc.

◆ MakeNeighborAcceptanceCriterion()

std::unique_ptr< NeighborAcceptanceCriterion > operations_research::MakeNeighborAcceptanceCriterion ( const RoutingSearchParameters & parameters)

Returns a neighbor acceptance criterion based on the given parameters.

Definition at line 270 of file routing_ils.cc.

◆ MakeNodeDisjunctionFilter()

IntVarLocalSearchFilter * operations_research::MakeNodeDisjunctionFilter ( const RoutingModel & routing_model,
bool filter_cost )

Returns a filter ensuring that node disjunction constraints are enforced.

Definition at line 273 of file routing_filters.cc.

◆ MakePathCumulFilter()

IntVarLocalSearchFilter * operations_research::MakePathCumulFilter ( const RoutingDimension & dimension,
bool propagate_own_objective_value,
bool filter_objective_cost,
bool can_use_lp )

Returns a filter handling dimension costs and constraints.

Definition at line 2036 of file routing_filters.cc.

◆ MakePathEnergyCostFilter()

LocalSearchFilter * operations_research::MakePathEnergyCostFilter ( Solver * solver,
std::unique_ptr< PathEnergyCostChecker > checker,
absl::string_view dimension_name )

Definition at line 3217 of file routing_filters.cc.

◆ MakePathSpansAndTotalSlacks()

Constraint * operations_research::MakePathSpansAndTotalSlacks ( const RoutingDimension * dimension,
std::vector< IntVar * > spans,
std::vector< IntVar * > total_slacks )

For every vehicle of the routing model:

  • if total_slacks[vehicle] is not nullptr, constrains it to be the sum of slacks on that vehicle, that is, dimension->CumulVar(end) - dimension->CumulVar(start) - sum_{node in path of vehicle} dimension->FixedTransitVar(node).
  • if spans[vehicle] is not nullptr, constrains it to be dimension->CumulVar(end) - dimension->CumulVar(start) This does stronger propagation than a decomposition, and takes breaks into account.

Definition at line 629 of file routing_constraints.cc.

◆ MakePathStateFilter()

LocalSearchFilter * operations_research::MakePathStateFilter ( Solver * solver,
std::unique_ptr< PathState > path_state,
const std::vector< IntVar * > & nexts )

Make a filter that takes ownership of a PathState and synchronizes it with solver events. The solver represents a graph with array of variables 'nexts'. Solver events are embodied by Assignment* deltas, that are translated to node changes during Relax(), committed during Synchronize(), and reverted on Revert().

Definition at line 3087 of file local_search.cc.

◆ MakePerturbationDecisionBuilder()

DecisionBuilder * operations_research::MakePerturbationDecisionBuilder ( const RoutingSearchParameters & parameters,
RoutingModel * model,
const Assignment * assignment,
std::function< bool()> stop_search,
LocalSearchFilterManager * filter_manager )

Returns a DecisionBuilder implementing a perturbation step of an Iterated Local Search approach.

Definition at line 250 of file routing_ils.cc.

◆ MakePickupDeliveryFilter()

IntVarLocalSearchFilter * operations_research::MakePickupDeliveryFilter ( const RoutingModel & routing_model,
const std::vector< PickupDeliveryPair > & pairs,
const std::vector< RoutingModel::PickupAndDeliveryPolicy > & vehicle_policies )

Returns a filter enforcing pickup and delivery constraints for the given pair of nodes and given policies.

Definition at line 2449 of file routing_filters.cc.

◆ MakeResourceAssignmentFilter()

LocalSearchFilter * operations_research::MakeResourceAssignmentFilter ( LocalDimensionCumulOptimizer * optimizer,
LocalDimensionCumulOptimizer * mp_optimizer,
bool propagate_own_objective_value,
bool filter_objective_cost )

Returns a filter checking the feasibility and cost of the resource assignment.

Definition at line 2983 of file routing_filters.cc.

◆ MakeResourceConstraint()

Constraint * operations_research::MakeResourceConstraint ( const RoutingModel::ResourceGroup * resource_group,
const std::vector< IntVar * > * vehicle_resource_vars,
RoutingModel * model )

Definition at line 266 of file routing_constraints.cc.

◆ MakeRestoreDimensionValuesForUnchangedRoutes()

DecisionBuilder * operations_research::MakeRestoreDimensionValuesForUnchangedRoutes ( RoutingModel * model)

A decision builder that monitors solutions, and tries to fix dimension variables whose route did not change in the candidate solution. Dimension variables are Cumul, Slack and break variables of all dimensions. The user must make sure that those variables will be always be fixed at solution, typically by composing another DecisionBuilder after this one. If this DecisionBuilder returns a non-nullptr value at some node of the search tree, it will always return nullptr in the subtree of that node. Moreover, the decision will be a simultaneous assignment of the dimension variables of unchanged routes on the left branch, and an empty decision on the right branch.

Definition at line 805 of file routing_decision_builders.cc.

◆ MakeRuinAndRecreateDecisionBuilder()

DecisionBuilder * operations_research::MakeRuinAndRecreateDecisionBuilder ( const RoutingSearchParameters & parameters,
RoutingModel * model,
const Assignment * assignment,
std::function< bool()> stop_search,
LocalSearchFilterManager * filter_manager )

Definition at line 235 of file routing_ils.cc.

◆ MakeSetCumulsFromGlobalDimensionCosts()

DecisionBuilder * operations_research::MakeSetCumulsFromGlobalDimensionCosts ( Solver * solver,
GlobalDimensionCumulOptimizer * global_optimizer,
GlobalDimensionCumulOptimizer * global_mp_optimizer,
SearchMonitor * monitor,
bool optimize_and_pack,
std::vector< RoutingModel::RouteDimensionTravelInfo > dimension_travel_info_per_route )

Variant based on global optimizers, handling all routes together.

Definition at line 637 of file routing_decision_builders.cc.

◆ MakeSetCumulsFromLocalDimensionCosts()

DecisionBuilder * operations_research::MakeSetCumulsFromLocalDimensionCosts ( Solver * solver,
LocalDimensionCumulOptimizer * lp_optimizer,
LocalDimensionCumulOptimizer * mp_optimizer,
bool optimize_and_pack = false,
std::vector< RoutingModel::RouteDimensionTravelInfo > dimension_travel_info_per_route = {} )

Functions returning decision builders which try to instantiate dimension cumul variables using scheduling optimizers. Variant based on local optimizers, for which each route is handled separately.

Definition at line 472 of file routing_decision_builders.cc.

◆ MakeSetValuesFromTargets()

DecisionBuilder * operations_research::MakeSetValuesFromTargets ( Solver * solver,
std::vector< IntVar * > variables,
std::vector< int64_t > targets )

A decision builder which tries to assign values to variables as close as possible to target values first.

Definition at line 101 of file routing_decision_builders.cc.

◆ MakeSweepDecisionBuilder()

DecisionBuilder * operations_research::MakeSweepDecisionBuilder ( RoutingModel * model,
bool check_assignment )

Returns a DecisionBuilder building a first solution based on the Sweep heuristic. Mostly suitable when cost is proportional to distance.

Definition at line 4774 of file routing_search.cc.

◆ MakeTypeRegulationsFilter()

IntVarLocalSearchFilter * operations_research::MakeTypeRegulationsFilter ( const RoutingModel & routing_model)

Returns a filter ensuring type regulation constraints are enforced.

Definition at line 813 of file routing_filters.cc.

◆ MakeVehicleAmortizedCostFilter()

IntVarLocalSearchFilter * operations_research::MakeVehicleAmortizedCostFilter ( const RoutingModel & routing_model)

Returns a filter computing vehicle amortized costs.

Definition at line 664 of file routing_filters.cc.

◆ MakeVehicleBreaksFilter()

IntVarLocalSearchFilter * operations_research::MakeVehicleBreaksFilter ( const RoutingModel & routing_model,
const RoutingDimension & dimension )

Definition at line 1081 of file routing_breaks.cc.

◆ MakeVehicleVarFilter()

IntVarLocalSearchFilter * operations_research::MakeVehicleVarFilter ( const RoutingModel & routing_model)

Returns a filter checking that vehicle variable domains are respected.

Definition at line 2527 of file routing_filters.cc.

◆ MaximizeLinearAssignment()

void operations_research::MaximizeLinearAssignment ( absl::Span< const std::vector< double > > cost,
absl::flat_hash_map< int, int > * direct_assignment,
absl::flat_hash_map< int, int > * reverse_assignment )

See IMPORTANT NOTE at the top of the file.

Definition at line 673 of file hungarian.cc.

◆ MaxVarArray()

int64_t operations_research::MaxVarArray ( const std::vector< IntVar * > & vars)
inline

The std::max<int64_t> is needed for compilation on MSVC.

Definition at line 3311 of file constraint_solveri.h.

◆ MemoryUsage()

std::string operations_research::MemoryUsage ( )

Returns the current thread's total memory usage in an human-readable string.

Definition at line 31 of file stats.cc.

◆ MergeConstraintHandlerResults()

GScipCallbackResult operations_research::MergeConstraintHandlerResults ( GScipCallbackResult result1,
GScipCallbackResult result2,
ConstraintHandlerCallbackType callback_type )

Returns the GScipCallbackResult with larger priority, see ConstraintHandlerResultPriority().

Definition at line 296 of file gscip_constraint_handler.cc.

◆ MergeMPConstraintProtoExceptTerms()

void operations_research::MergeMPConstraintProtoExceptTerms ( const MPConstraintProto & from,
MPConstraintProto * to )

Partially merges a MPConstraintProto onto another, skipping only the repeated fields "var_index" and "coefficients". This is used within FindErrorInMPModelDeltaProto. See the unit test MergeMPConstraintProtoExceptTermsTest that explains why we need this.

Definition at line 940 of file model_validator.cc.

◆ MinimizeLinearAssignment()

void operations_research::MinimizeLinearAssignment ( absl::Span< const std::vector< double > > cost,
absl::flat_hash_map< int, int > * direct_assignment,
absl::flat_hash_map< int, int > * reverse_assignment )

See IMPORTANT NOTE at the top of the file.

Definition at line 655 of file hungarian.cc.

◆ MinVarArray()

int64_t operations_research::MinVarArray ( const std::vector< IntVar * > & vars)
inline

The std::min<int64_t> is needed for compilation on MSVC.

Definition at line 3321 of file constraint_solveri.h.

◆ mix()

static void operations_research::mix ( uint64_t & a,
uint64_t & b,
uint64_t & c )
inlinestatic

64 bit version.

Definition at line 29 of file hash.h.

◆ MostSignificantBitPosition32() [1/2]

int operations_research::MostSignificantBitPosition32 ( const uint32_t * bitset,
uint32_t start,
uint32_t end )

◆ MostSignificantBitPosition32() [2/2]

int operations_research::MostSignificantBitPosition32 ( uint32_t n)
inline

Definition at line 277 of file bitset.h.

◆ MostSignificantBitPosition32Default()

int operations_research::MostSignificantBitPosition32Default ( uint32_t n)
inline

Definition at line 253 of file bitset.h.

◆ MostSignificantBitPosition64() [1/2]

int64_t operations_research::MostSignificantBitPosition64 ( const uint64_t * bitset,
uint64_t start,
uint64_t end )

Returns the last bit set in bitset between min_bit and start.

◆ MostSignificantBitPosition64() [2/2]

int operations_research::MostSignificantBitPosition64 ( uint64_t n)
inline

Definition at line 235 of file bitset.h.

◆ MostSignificantBitPosition64Default()

int operations_research::MostSignificantBitPosition64Default ( uint64_t n)
inline

Returns the most significant bit position in n.

Definition at line 207 of file bitset.h.

◆ MPModelRequestLoggingInfo()

std::string operations_research::MPModelRequestLoggingInfo ( const MPModelRequest & request)

Gives some brief (a few lines, at most) human-readable information about the given request, suitable for debug logging.

Definition at line 48 of file solve_mp_model.cc.

◆ MPSolverResponseStatusIsRpcError()

bool operations_research::MPSolverResponseStatusIsRpcError ( MPSolverResponseStatus status)

Whether the given MPSolverResponseStatus (of a solve) would yield an RPC error when happening on the linear solver stubby server, see ./linear_solver_service.proto.

Note
RPC errors forbid to carry a response to the client, who can only see the RPC error itself (error code + error message).

Cases that don't yield an RPC error when they happen on the server.

Cases that should never happen with the linear solver server. We prefer to consider those as "not RPC errors".

Cases that yield an RPC error when they happen on the server.

Definition at line 1922 of file linear_solver.cc.

◆ MPSolverToGlopConstraintStatus()

glop::ConstraintStatus operations_research::MPSolverToGlopConstraintStatus ( MPSolver::BasisStatus s)

Definition at line 108 of file glop_utils.cc.

◆ MPSolverToGlopVariableStatus()

glop::VariableStatus operations_research::MPSolverToGlopVariableStatus ( MPSolver::BasisStatus s)

Definition at line 74 of file glop_utils.cc.

◆ MPSolverToXpressBasisStatus()

static int operations_research::MPSolverToXpressBasisStatus ( MPSolver::BasisStatus mpsolver_basis_status)
static

Transform MPSolver basis status to XPRESS status.

Definition at line 1264 of file xpress_interface.cc.

◆ MultiDijkstra()

template<class DistanceType , class Graph , class ArcLengthFunctor , class SettledNodeCallbackType >
std::vector< absl::flat_hash_map< int, DistanceAndParentArc< DistanceType > > > operations_research::MultiDijkstra ( const Graph & graph,
ArcLengthFunctor arc_length_functor,
const std::vector< std::vector< int > > & source_sets,
SettledNodeCallbackType settled_node_callback )

Runs multiple Dijkstra searches simultaneously on the same graph, in a single thread. All the Dijkstras share the same priority queue: their search radius will grow "simulatenously".

Moreover, each individual Dijkstra search can have several nodes as its "source", and the stopping criterion for each Dijkstra search is highly customizable: the user controls it via a "settled node callback", called every time a node is settled. See the API below.

The Dijkstra are sparse: the global space complexity will be linear in the number of search states explored. Ditto for the time complexity, with an additional logarithmic factor caused by the priority queue.

This class has many similarities with BoundedDijkstraWrapper from ./bounded_dijkstra.h but adds the overhead of tracking the source index for every search state, and of the sparse (but slower) node hash maps.

Arguments:

  • "graph": the graph. The Graph class must support the interface of ortools/graph/graph.h: OutgoingArcs(), Head(), Tail().
  • "arc_length_functor": we will call arc_length_functor(a) on every arc "a" explored, where "a" is cast to an int. It should return the arc's length, which is statically cast to DistanceType.
  • "source_sets" contains the sources. Each source is itself a set of nodes.
  • "settled_node_callback" will be called every time we settled a node, with 3 arguments (node, source index, distance of node from that source). If it returns true, the Dijkstra search from that source will stop.

Returns the list of Dijkstra search: for each source #s, the element #s of the returned vector will map every node explored in the Dijkstra from source #s to its distance and parent arc.

Initialize the return data structure and the priority queue.

Main Dijkstra loop.

Dijkstra optimization: ignore states that don't correspond to the optimal (such states have been preceded by better states in the queue order, without being deleted since priority_queue doesn't have erase()).

Initialize the return data structure and the priority queue.

Main Dijkstra loop.

Dijkstra optimization: ignore states that don't correspond to the optimal (such states have been preceded by better states in the queue order, without being deleted since priority_queue doesn't have erase()).

Definition at line 126 of file multi_dijkstra.h.

◆ NChooseK()

absl::StatusOr< int64_t > operations_research::NChooseK ( int64_t n,
int64_t k )

Returns the number of ways to choose k elements among n, ignoring the order, i.e., the binomial coefficient (n, k). This is like std::exp(MathUtil::LogCombinations(n, k)), but with perfect accuracy, and returning an error iff the result would overflow an int64_t or if an argument is invalid (i.e., n < 0, k < 0, or k > n).

NOTE(user): If performance ever matters, we could simply precompute and store all (N choose K) that don't overflow, there aren't that many of them: only a few tens of thousands, after removing simple cases like k ≤ 5.

Definition at line 120 of file n_choose_k.cc.

◆ NodePathImpliedBy()

template<typename GraphType >
std::vector< typename GraphType::NodeIndex > operations_research::NodePathImpliedBy ( absl::Span< const typename GraphType::ArcIndex > arc_path,
const GraphType & graph )

Implementations.

Todo
(b/332475804): If ArcPathTo and/or NodePathTo functions become bottlenecks: (1) have the class preallocate a buffer of size num_nodes (2) assign into an index rather than with push_back (3) return by absl::Span (or return a copy) with known size.

Definition at line 298 of file dag_shortest_path.h.

◆ One()

int64_t operations_research::One ( )
inline

This method returns 1.

Definition at line 3362 of file constraint_solver.h.

◆ OneBit32()

uint32_t operations_research::OneBit32 ( int pos)
inline

Definition at line 43 of file bitset.h.

◆ OneBit64()

uint64_t operations_research::OneBit64 ( int pos)
inline

Returns a word with only bit pos set.

Definition at line 42 of file bitset.h.

◆ OneRange32()

uint32_t operations_research::OneRange32 ( uint32_t s,
uint32_t e )
inline

Definition at line 296 of file bitset.h.

◆ OneRange64()

uint64_t operations_research::OneRange64 ( uint64_t s,
uint64_t e )
inline

Returns a word with bits from s to e set.

Definition at line 289 of file bitset.h.

◆ operator*() [1/2]

LinearExpr operations_research::operator* ( double lhs,
LinearExpr rhs )

Definition at line 168 of file linear_expr.cc.

◆ operator*() [2/2]

LinearExpr operations_research::operator* ( LinearExpr lhs,
double rhs )

Definition at line 160 of file linear_expr.cc.

◆ operator+()

LinearExpr operations_research::operator+ ( LinearExpr lhs,
const LinearExpr & rhs )

NOTE(user): in the ops below, the non-"const LinearExpr&" are intentional. We need to create a new LinearExpr for the result, so we lose nothing by passing one argument by value, mutating it, and then returning it. In particular, this allows (with move semantics and RVO) an optimized evaluation of expressions such as a + b + c + d (see http://en.cppreference.com/w/cpp/language/operators).

Definition at line 152 of file linear_expr.cc.

◆ operator-()

LinearExpr operations_research::operator- ( LinearExpr lhs,
const LinearExpr & rhs )

Definition at line 156 of file linear_expr.cc.

◆ operator/()

LinearExpr operations_research::operator/ ( LinearExpr lhs,
double rhs )

Definition at line 164 of file linear_expr.cc.

◆ operator<<() [1/13]

std::ostream & operations_research::operator<< ( std::ostream & os,
MPSolver::OptimizationProblemType optimization_problem_type )
inline

Definition at line 997 of file linear_solver.h.

◆ operator<<() [2/13]

std::ostream & operations_research::operator<< ( std::ostream & os,
MPSolver::ResultStatus status )
inline

Definition at line 1003 of file linear_solver.h.

◆ operator<<() [3/13]

template<typename StrongIndexName >
std::ostream & operations_research::operator<< ( std::ostream & os,
StrongIndex< StrongIndexName > arg )

– NON-MEMBER STREAM OPERATORS -------------------------------------------— We provide the << operator, primarily for logging purposes. Currently, there seems to be no need for an >> operator.

Definition at line 250 of file strong_integers.h.

◆ operator<<() [4/13]

template<typename StrongIntegerName >
std::ostream & operations_research::operator<< ( std::ostream & os,
StrongInt64< StrongIntegerName > arg )

Definition at line 261 of file strong_integers.h.

◆ operator<<() [5/13]

std::ostream & operations_research::operator<< ( std::ostream & out,
const Assignment & assignment )

Definition at line 1021 of file assignment.cc.

◆ operator<<() [6/13]

std::ostream & operations_research::operator<< ( std::ostream & out,
const BaseObject *const o )

Definition at line 2488 of file constraint_solver.cc.

◆ operator<<() [7/13]

std::ostream & operations_research::operator<< ( std::ostream & out,
const ClosedInterval & interval )

Definition at line 109 of file sorted_interval_list.cc.

◆ operator<<() [8/13]

std::ostream & operations_research::operator<< ( std::ostream & out,
const Domain & domain )

Definition at line 118 of file sorted_interval_list.cc.

◆ operator<<() [9/13]

std::ostream & operations_research::operator<< ( std::ostream & out,
const RoundTripDoubleFormat & format )

Definition at line 110 of file fp_roundtrip_conv.cc.

◆ operator<<() [10/13]

std::ostream & operations_research::operator<< ( std::ostream & out,
const Solver *const s )

---------------— Useful Operators ---------------—

Definition at line 2483 of file constraint_solver.cc.

◆ operator<<() [11/13]

std::ostream & operations_research::operator<< ( std::ostream & out,
const std::vector< ClosedInterval > & intervals )

Definition at line 113 of file sorted_interval_list.cc.

◆ operator<<() [12/13]

template<class DistanceType >
std::ostream & operations_research::operator<< ( std::ostream & out,
DistanceAndParentArc< DistanceType > distance_and_parent_arc )

Implementation of the function templates

Definition at line 116 of file multi_dijkstra.h.

◆ operator<<() [13/13]

std::ostream & operations_research::operator<< ( std::ostream & stream,
const LinearExpr & linear_expr )

Definition at line 147 of file linear_expr.cc.

◆ operator<=()

LinearRange operations_research::operator<= ( const LinearExpr & lhs,
const LinearExpr & rhs )

Definition at line 183 of file linear_expr.cc.

◆ operator==()

LinearRange operations_research::operator== ( const LinearExpr & lhs,
const LinearExpr & rhs )

Definition at line 186 of file linear_expr.cc.

◆ operator>=()

LinearRange operations_research::operator>= ( const LinearExpr & lhs,
const LinearExpr & rhs )

Definition at line 189 of file linear_expr.cc.

◆ optimizermsg()

void XPRS_CC operations_research::optimizermsg ( XPRSprob prob,
void * data,
const char * sMsg,
int nLen,
int nMsgLvl )

Definition at line 2179 of file xpress_interface.cc.

◆ OrToolsMajorVersion()

int operations_research::OrToolsMajorVersion ( )

Definition at line 22 of file version.cc.

◆ OrToolsMinorVersion()

int operations_research::OrToolsMinorVersion ( )

Definition at line 24 of file version.cc.

◆ OrToolsPatchVersion()

int operations_research::OrToolsPatchVersion ( )

Definition at line 26 of file version.cc.

◆ OrToolsVersionString()

std::string operations_research::OrToolsVersionString ( )

Definition at line 28 of file version.cc.

◆ ParameterDebugString() [1/2]

template<class P >
std::string operations_research::ParameterDebugString ( P * param)

Support limited to pointers to classes which define DebugString().

Definition at line 542 of file constraint_solveri.h.

◆ ParameterDebugString() [2/2]

template<class P >
std::string operations_research::ParameterDebugString ( P param)

Definition at line 536 of file constraint_solveri.h.

◆ ParseAndSolve()

void operations_research::ParseAndSolve ( const std::string & filename,
absl::string_view solver,
const std::string & params )
Todo
(user): Move naming code to parser.

Build optimization model.

Definition at line 41 of file vector_bin_packing_main.cc.

◆ ParseSolFile() [1/2]

absl::StatusOr< glop::DenseRow > operations_research::ParseSolFile ( absl::string_view file_name,
const glop::LinearProgram & model )

Parse a solution to model from a file.

Definition at line 35 of file sol_reader.cc.

◆ ParseSolFile() [2/2]

absl::StatusOr< MPSolutionResponse > operations_research::ParseSolFile ( absl::string_view file_name,
const MPModelProto & model )

Definition at line 41 of file sol_reader.cc.

◆ ParseSolString() [1/2]

absl::StatusOr< glop::DenseRow > operations_research::ParseSolString ( const std::string & solution,
const glop::LinearProgram & model )

Parse a solution to model from a string.

Remove the comments.

Definition at line 47 of file sol_reader.cc.

◆ ParseSolString() [2/2]

absl::StatusOr< MPSolutionResponse > operations_research::ParseSolString ( const std::string & solution,
const MPModelProto & model )

Remove the comments.

Definition at line 104 of file sol_reader.cc.

◆ ParseTextProtoForFlag()

bool operations_research::ParseTextProtoForFlag ( absl::string_view text,
google::protobuf::Message * message_out,
std::string * error_out )

Tries to parse text as a text format proto. On a success, stores the result in message_out and returns true, otherwise, returns false with an explanation in error_out.

Note
this API is optimized for implementing AbslParseFlag(). The error message will be multiline and is designed to be easily read when printed.

Definition at line 82 of file parse_proto.cc.

◆ PdlpSolveProto()

absl::StatusOr< MPSolutionResponse > operations_research::PdlpSolveProto ( LazyMutableCopy< MPModelRequest > request,
bool relax_integer_variables = false,
const std::atomic< bool > * interrupt_solve = nullptr )

Uses pdlp::PrimalDualHybridGradient to solve the problem specified by the MPModelRequest. Users of this interface should be aware of the size limitations of MPModelProto (see, e.g., large_linear_program.proto).

If possible, std::move the request into this function call so that its memory can be reclaimed early.

The optional interrupt_solve can be used to interrupt the solve early. The solver will periodically check its value and stop if it holds true.

If relax_integer_variables is true, integrality constraints are relaxed before solving. If false, integrality constraints result in an error. The solver_specific_info field in the MPSolutionResponse contains a serialized SolveLog.

Returns an error if the conversion from MPModelProto to pdlp::QuadraticProgram fails. The lack of an error does not imply success. Check the SolveLog's termination_reason for more refined status details.

We can now clear the request and optional_model.

PDLP's statuses don't map very cleanly to MPSolver statuses. Do the best we can for now.

variable_value and dual_value are supposed to be set iff 'status' is OPTIMAL or FEASIBLE. However, we set them in all cases.

QpFromMpModelProto converts maximization problems to minimization problems for PDLP by negating the objective and setting objective_scaling_factor to -1. This maintains the same set of primal solutions. Dual solutions need to be negated if objective_scaling_factor is -1.

Definition at line 36 of file pdlp_proto_solver.cc.

◆ PiecewiseLinearFormulationToSlopeAndYIntercept()

std::vector< SlopeAndYIntercept > operations_research::PiecewiseLinearFormulationToSlopeAndYIntercept ( const RoutingModel::RouteDimensionTravelInfo::TransitionInfo::PiecewiseLinearFormulation & pwl_function,
int index_start = 0,
int index_end = -1 )

Given a PiecewiseLinearFormulation, returns a vector of slope and y-intercept corresponding to each segment. Only the segments in [index_start, index_end[ will be considered.

Definition at line 1282 of file routing_lp_scheduling.cc.

◆ PortableDeleteFile()

absl::Status operations_research::PortableDeleteFile ( absl::string_view file_name)

Definition at line 78 of file file.cc.

◆ PortableFileGetContents()

absl::Status operations_research::PortableFileGetContents ( absl::string_view file_name,
std::string * output )

Definition at line 45 of file file.cc.

◆ PortableFileSetContents()

absl::Status operations_research::PortableFileSetContents ( absl::string_view file_name,
absl::string_view content )

Definition at line 35 of file file.cc.

◆ PortableTemporaryFile()

bool operations_research::PortableTemporaryFile ( const char * directory_prefix,
std::string * filename_out )

Returns true if successful. Outputs temp file to filename.

Definition at line 55 of file file.cc.

◆ PosIntDivDown()

int64_t operations_research::PosIntDivDown ( int64_t e,
int64_t v )
inline

Definition at line 3345 of file constraint_solveri.h.

◆ PosIntDivUp()

int64_t operations_research::PosIntDivUp ( int64_t e,
int64_t v )
inline

Definition at line 3340 of file constraint_solveri.h.

◆ printError()

void operations_research::printError ( const XPRSprob & mLp,
int line )

Definition at line 137 of file xpress_interface.cc.

◆ PrintStatistic()

template<typename T >
void operations_research::PrintStatistic ( absl::string_view name,
T value,
RoutingOutputFormat format )

Prints a formatted solution or solver statistic according to the given format.

Definition at line 290 of file solution_serializer.h.

◆ printXpressBanner()

void operations_research::printXpressBanner ( bool error)

clang-format on

Definition at line 169 of file environment.cc.

◆ ProbablyRunningInsideUnitTest()

bool operations_research::ProbablyRunningInsideUnitTest ( )
inline

Definition at line 22 of file testing_utils.h.

◆ ProtobufDebugString()

template<class P >
std::string operations_research::ProtobufDebugString ( const P & message)

Definition at line 32 of file proto_utils.h.

◆ ProtobufParseTextProtoForFlag()

template<typename ProtoType >
bool operations_research::ProtobufParseTextProtoForFlag ( absl::string_view text,
ProtoType * message_out,
std::string * error_out )

Tries to parse text as a text format proto. On a success, stores the result in message_out and returns true, otherwise, returns false with an explanation in error_out.

When compiled with lite protos, any nonempty text will result in an error, as lite protos do not support parsing from text format.

Note
this API is optimized for implementing AbslParseFlag(). The error message will be multiline and is designed to be easily read when printed.

Definition at line 86 of file proto_utils.h.

◆ ProtobufShortDebugString()

template<class P >
std::string operations_research::ProtobufShortDebugString ( const P & message)

Definition at line 41 of file proto_utils.h.

◆ ProtobufTextFormatMergeFromString()

template<typename ProtoType >
bool operations_research::ProtobufTextFormatMergeFromString ( absl::string_view proto_text_string,
ProtoType * proto )

Definition at line 66 of file proto_utils.h.

◆ ProtobufTextFormatPrintToStringForFlag() [1/2]

std::string operations_research::ProtobufTextFormatPrintToStringForFlag ( const google::protobuf::Message & proto)

Prints the input proto to a string on a single line in a format compatible with ProtobufParseTextProtoForFlag().

TextFormat may add an empty space at the end of the string (e.g. "cpu: 3.5 "), likely because it always add a space after each field; we simply remove it here.

Definition at line 26 of file proto_utils.cc.

◆ ProtobufTextFormatPrintToStringForFlag() [2/2]

std::string operations_research::ProtobufTextFormatPrintToStringForFlag ( const google::protobuf::MessageLite & proto)

Prints an error message when compiling with lite protos.

Definition at line 39 of file proto_utils.cc.

◆ ProtoEnumToString()

template<typename ProtoEnumType >
std::string operations_research::ProtoEnumToString ( ProtoEnumType enum_value)

Definition at line 50 of file proto_utils.h.

◆ RadixSort()

template<typename T >
void operations_research::RadixSort ( absl::Span< T > values)

Sorts an array of int, double, or other numeric types. Up to ~10x faster than std::sort() when size ≥ 8k: go/radix-sort-bench. See file-level comment.

Todo
(user): Expose an API that takes the "max value" as argument, for users who want to take advantage of that knowledge to reduce the number of passes.

Definition at line 247 of file radix_sort.h.

◆ RadixSortTpl()

template<typename T , int radix_width, int num_passes>
void operations_research::RadixSortTpl ( absl::Span< T > values)

The internal template that does all the work.

ADVANCED USAGE: For power users who know which radix_width or num_passes they need, possibly differing from the canonical values used by RadixSort().

Internally we assume our values are unsigned integers. This works for both signed integers and IEEE754 floating-point types, with various twists for negative numbers. In particular, two nonnegative floats compare exactly as their unsigned integer bitcast do.

NOTE(user): We could support sizes > kint32max if needed. We use uint32_t for sizes, instead of size_t, to spare memory for the large radix widths. We could use uint64_t for sizes > 4G, but until we need it, just using uint32_t is simpler. Using smaller types (uint16_t or uint8_t) for smaller sizes was noticeably slower.

Main Radix/Count-sort counters. Radix sort normally uses several passes, but to speed things up, we compute all radix counters for all passes at once in a single initial sweep over the data.

count[] is actually a 2-dimensional array [num_passes][1 << radix_width], flattened for performance and in a vector<> because it can be too big for the stack.

Perform the radix count all at once, in 'parallel' (the CPU should be able to parallelize the inner loop).

Convert the counts into offsets via a cumulative sum.

This inner loop should be parallelizable by the CPU.

FIRST-TIME READER: Skip this section, which is only for signed integers: you can go back to it at the end.

If T is signed, and if there were any negative numbers, we'll need to account for that. For floating-point types, we do that at the end of this function. For integer types, fortunately, it's easy and fast to do it now: negative numbers were treated as top-half values in the last radix pass. We can poll the most significant count[] bucket corresponding to the min negative number, immediately see if there were any negative numbers, and patch the last count[] offsets in that case. Number of bits of the radix in the last pass. E.g. if U is 32 bits,

Todo
: remove the if constexpr so that compilation catches the bad cases.

There are some negative values, and they're sorted last instead of first, since we considered them as unsigned so far. E.g., with bytes: 00000000, ..., 01111111, 10000000, ..., 11111111. Fixing that is easy: we take the 10000000..11111111 chunks and shift it before all the 00000000..01111111 ones.

Shift non-negatives by +num_negative_values...

... and negatives by -num_nonnegative_values.

Perform the radix sort, using a temporary buffer.

FIRST-TIME READER: Skip this section, which is only for negative floats. We fix mis-sorted negative floating-point numbers here.

Negative floating-point numbers are sorted exactly in the reverse order. Unlike for integers, we need to std::reverse() them, and also shift them back before the positive ones.

If we swapped an odd number of times, we're lucky: we don't need to make an extra copy.

Todo
(user): See if this is faster than memcpy + std::reverse().

We can't move + reverse in-place, so we need the temporary buffer. First, we copy all negative numbers to the temporary buffer.

Then we shift the nonnegative.

Todo
(user): See if memcpy everything + memcpy here is faster than memmove().

If there were negative floats, we've done our work and are done. Else we still may need to move the data from the temp buffer to 'values'.

If we swapped an odd number of times, copy tmp[] onto values[].

Internally we assume our values are unsigned integers. This works for both signed integers and IEEE754 floating-point types, with various twists for negative numbers. In particular, two nonnegative floats compare exactly as their unsigned integer bitcast do.

NOTE(user): We could support sizes > kint32max if needed. We use uint32_t for sizes, instead of size_t, to spare memory for the large radix widths. We could use uint64_t for sizes > 4G, but until we need it, just using uint32_t is simpler. Using smaller types (uint16_t or uint8_t) for smaller sizes was noticeably slower.

Main Radix/Count-sort counters. Radix sort normally uses several passes, but to speed things up, we compute all radix counters for all passes at once in a single initial sweep over the data.

count[] is actually a 2-dimensional array [num_passes][1 << radix_width], flattened for performance and in a vector<> because it can be too big for the stack.

Perform the radix count all at once, in 'parallel' (the CPU should be able to parallelize the inner loop).

Convert the counts into offsets via a cumulative sum.

This inner loop should be parallelizable by the CPU.

FIRST-TIME READER: Skip this section, which is only for signed integers: you can go back to it at the end.

If T is signed, and if there were any negative numbers, we'll need to account for that. For floating-point types, we do that at the end of this function. For integer types, fortunately, it's easy and fast to do it now: negative numbers were treated as top-half values in the last radix pass. We can poll the most significant count[] bucket corresponding to the min negative number, immediately see if there were any negative numbers, and patch the last count[] offsets in that case. Number of bits of the radix in the last pass. E.g. if U is 32 bits,

Todo
: remove the if constexpr so that compilation catches the bad cases.

There are some negative values, and they're sorted last instead of first, since we considered them as unsigned so far. E.g., with bytes: 00000000, ..., 01111111, 10000000, ..., 11111111. Fixing that is easy: we take the 10000000..11111111 chunks and shift it before all the 00000000..01111111 ones.

Shift non-negatives by +num_negative_values...

... and negatives by -num_nonnegative_values.

Perform the radix sort, using a temporary buffer.

FIRST-TIME READER: Skip this section, which is only for negative floats. We fix mis-sorted negative floating-point numbers here.

Negative floating-point numbers are sorted exactly in the reverse order. Unlike for integers, we need to std::reverse() them, and also shift them back before the positive ones.

If we swapped an odd number of times, we're lucky: we don't need to make an extra copy.

Todo
(user): See if this is faster than memcpy + std::reverse().

We can't move + reverse in-place, so we need the temporary buffer. First, we copy all negative numbers to the temporary buffer.

Then we shift the nonnegative.

Todo
(user): See if memcpy everything + memcpy here is faster than memmove().

If there were negative floats, we've done our work and are done. Else we still may need to move the data from the temp buffer to 'values'.

If we swapped an odd number of times, copy tmp[] onto values[].

Definition at line 92 of file radix_sort.h.

◆ RangeConvexMinimum() [1/2]

template<class Point , class Value >
std::pair< Point, Value > operations_research::RangeConvexMinimum ( Point begin,
Point end,
absl::FunctionRef< Value(Point)> f )

Searches in the range [begin, end), where Point supports basic arithmetic.

Starts by splitting interval in two with two queries and getting some info. Note the current min will be outside the interval.

Note
we exclude before_mid from the range.

Starts by splitting interval in two with two queries and getting some info. Note the current min will be outside the interval.

Note
we exclude before_mid from the range.

Definition at line 237 of file binary_search.h.

◆ RangeConvexMinimum() [2/2]

template<class Point , class Value >
std::pair< Point, Value > operations_research::RangeConvexMinimum ( std::pair< Point, Value > current_min,
Point begin,
Point end,
absl::FunctionRef< Value(Point)> f )

If the midpoint is no better than our current minimum, then the global min must lie between our midpoint and our current min.

v < current_min.second, we cannot decide, so we use a second value close to v like in the initial step.

If the midpoint is no better than our current minimum, then the global min must lie between our midpoint and our current min.

v < current_min.second, we cannot decide, so we use a second value close to v like in the initial step.

Definition at line 270 of file binary_search.h.

◆ RationalApproximation()

Fraction operations_research::RationalApproximation ( const double x,
const double precision )

Computes a rational approximation numerator/denominator for value x using a continued fraction algorithm. The absolute difference between the output fraction and the input "x" will not exceed "precision".

Computes a rational approximation numerator/denominator for value x using a continued fraction algorithm. The absolute difference between the output fraction and the input "x" will not exceed "precision".

Todo
(user): make a parameterized template with integer and floating-point type parameters.

All computations are made on long doubles to guarantee the maximum precision for the approximations. This way, the approximations when Fractional is float or double are as accurate as possible.

If there was an overflow, we prefer returning a not-so-good approximation rather than something that is completely wrong.

Definition at line 27 of file rational_approximation.cc.

◆ ReadAllRecordsOrDie() [1/2]

template<typename Proto >
std::vector< Proto > operations_research::ReadAllRecordsOrDie ( absl::string_view filename)

Reads all records in Proto format in 'file'. Silently does nothing if the file is empty. Dies if the file doesn't exist or contains something else than protos encoded in RecordIO format.

Definition at line 117 of file file_util.h.

◆ ReadAllRecordsOrDie() [2/2]

template<typename Proto >
std::vector< Proto > operations_research::ReadAllRecordsOrDie ( File * file)

Definition at line 121 of file file_util.h.

◆ ReadBeasleySetCoverProblem()

SetCoverModel operations_research::ReadBeasleySetCoverProblem ( absl::string_view filename)

Readers for set covering problems at http://people.brunel.ac.uk/~mastjjb/jeb/orlib/scpinfo.html All the instances have either the Beasley or the rail format. There is currently NO error handling, as the files are in a limited number.

Todo
(user): add proper error handling.

Also, note that the indices in the files, when mentioned, start from 1, while SetCoverModel starts from 0, The translation is done at read time. Reads a rail set cover problem create by Beasley and returns a SetCoverModel. The format of all of these 80 data files is: number of rows (m), number of columns (n) for each column j, (j=1,...,n): the cost of the column c(j) for each row i (i=1,...,m): the number of columns which cover row i followed by a list of the columns which cover row i

Definition at line 93 of file set_cover_reader.cc.

◆ ReadFile()

absl::Status operations_research::ReadFile ( absl::string_view file_name,
CapacityPlanningInstance * request )

implicit.

Definition at line 33 of file dow_parser.cc.

◆ ReadFileToProto() [1/2]

template<typename Proto >
absl::StatusOr< Proto > operations_research::ReadFileToProto ( absl::string_view filename,
bool allow_partial = false )

Definition at line 51 of file file_util.h.

◆ ReadFileToProto() [2/2]

absl::Status operations_research::ReadFileToProto ( absl::string_view filename,
google::protobuf::Message * proto,
bool allow_partial = false )

Reads a proto from a file. Supports the following formats: binary, text, JSON, all of those optionally gzipped. Returns errors as expected: filesystem error, parsing errors, or type error: maybe it was a valid JSON, text proto, or binary proto, but not of the right proto message (this is not an exact science, but the heuristics used should work well in practice).

Parameters
allow_partialIf true, unset required fields don't cause errors. This boolean doesn't work for JSON inputs.

Definition at line 53 of file file_util.cc.

◆ ReadFileToString()

absl::StatusOr< std::string > operations_research::ReadFileToString ( absl::string_view filename)

Reads a file, optionally gzipped, to a string.

Try decompressing it.

Definition at line 42 of file file_util.cc.

◆ ReadOneRecordOrDie()

template<typename Proto >
Proto operations_research::ReadOneRecordOrDie ( absl::string_view filename)

Reads one record from file, which must be in RecordIO binary proto format. Dies if the file can't be read, doesn't contain exactly one record, or contains something else than the expected proto in RecordIO format.

Definition at line 129 of file file_util.h.

◆ readParameter()

bool operations_research::readParameter ( XPRSprob const & prob,
std::string const & name,
std::string const & value )

Apply the specified name=value setting to prob.

We cannot set empty parameters.

Figure out the type of the control.

Depending on the type, parse the text in value and apply it.

Note
string parameters are not supported at the moment since we don't want to deal with potential encoding or escaping issues.

Definition at line 59 of file xpress_interface.cc.

◆ ReadQapProblemOrDie()

QapProblem operations_research::ReadQapProblemOrDie ( absl::string_view filepath)
Todo
(user): Unit test cases when the function dies, or return (and test) a status instead.

Reads a QAP problem from file in a format used in QAPLIB. See anjos.mgi.polymtl.ca/qaplib/ for more context. The format is "n W D", where n is the number of factories/locations, and W and D are weight and distance matrices, respectively. Both W and D are square matrices of size N x N. Each entry of the matrices must parse as double (we CHECK if it does). Multiple spaces, or '
' are disregarded. For example:

2

0 2 3 0

0 2 1 0

defines a problem with two factories and two locations. There are 2 units of supply flowing from factory 0 to factory 1, and 3 units of supply flowing from factory 1 to 0. The distance from location 0 to location 1 is equal to 2, and the distance from location 1 to 0 is equal to 1.

Definition at line 30 of file qap_reader.cc.

◆ ReadRailSetCoverProblem()

SetCoverModel operations_research::ReadRailSetCoverProblem ( absl::string_view filename)

Reads a rail set cover problem and returns a SetCoverModel. The format of these test problems is: number of rows (m), number of columns (n) for each column j (j=1,...,n): the cost of the column, the number of rows that it covers followed by a list of the rows that it covers.

Definition at line 115 of file set_cover_reader.cc.

◆ RealDebugString()

template<class Container , class Element >
void operations_research::RealDebugString ( const Container & container,
std::string *const out )

Definition at line 614 of file assignment.cc.

◆ RealLoad()

template<class Var , class Element , class Proto , class Container >
void operations_research::RealLoad ( const AssignmentProto & assignment_proto,
Container *const container,
int(AssignmentProto::* GetSize )() const,
const Proto &(AssignmentProto::* GetElem )(int) const )

Definition at line 505 of file assignment.cc.

◆ RealSave()

template<class Var , class Element , class Proto , class Container >
void operations_research::RealSave ( AssignmentProto *const assignment_proto,
const Container & container,
Proto *(AssignmentProto::* Add )() )

Definition at line 578 of file assignment.cc.

◆ RegisterConstraintHandler() [1/2]

template<typename Constraint >
void operations_research::RegisterConstraintHandler ( ScipConstraintHandler< Constraint > * handler,
SCIP * scip )

handler is not owned but held.

◆ RegisterConstraintHandler() [2/2]

template<typename ConstraintData >
void operations_research::RegisterConstraintHandler ( ScipConstraintHandler< ConstraintData > * handler,
SCIP * scip )

Definition at line 251 of file scip_callback.h.

◆ RegisterDemon()

void operations_research::RegisterDemon ( Solver *const solver,
Demon *const demon,
DemonProfiler *const monitor )

--— Exported Methods for Unit Tests --—

Definition at line 465 of file demon_profiler.cc.

◆ RestoreBoolValue()

void operations_research::RestoreBoolValue ( IntVar * var)
extern

--— Trail --—

Object are explicitly copied using the copy ctor instead of passing and storing a pointer. As objects are small, copying is much faster than allocating (around 35% on a complete solve).

Definition at line 6412 of file expressions.cc.

◆ ReturnCodeString()

std::string operations_research::ReturnCodeString ( int rc)

Formats the return code of glp_intopt(), glp_simplex(), glp_exact() and glp_interior() to a string.

Definition at line 66 of file glpk_formatters.cc.

◆ RootedTreeFromGraph() [1/2]

template<typename Graph >
absl::StatusOr< RootedTree< typename Graph::NodeIndex > > operations_research::RootedTreeFromGraph ( const typename Graph::NodeIndex root,
const Graph & graph,
std::vector< typename Graph::NodeIndex > *const topological_order,
std::vector< typename Graph::NodeIndex > *const depths )
Note
this will also catch nodes with self loops.

Definition at line 746 of file rooted_tree.h.

◆ RootedTreeFromGraph() [2/2]

template<typename Graph >
absl::StatusOr< RootedTree< typename Graph::NodeType > > operations_research::RootedTreeFromGraph ( typename Graph::NodeType root,
const Graph & graph,
std::vector< typename Graph::NodeType > * topological_order = nullptr,
std::vector< typename Graph::NodeType > * depths = nullptr )

Graph API Converts an adjacency list representation of an undirected tree into a rooted tree.

Graph must meet the API defined in ortools/graph/graph.h, e.g., StaticGraph or ListGraph. Note that these are directed graph APIs, so they must have both forward and backward arcs for each edge in the tree.

Graph must be a tree when viewed as an undirected graph.

If topological_order is not null, it is set to a vector with one entry for each node giving a topological ordering over the nodes of the graph, with the root first.

If depths is not null, it is set to a vector with one entry for each node, giving the depth in the tree of that node (the root has depth zero).

◆ RoutingOutputFormatFromString()

RoutingOutputFormat operations_research::RoutingOutputFormatFromString ( std::string_view format)

Parses a user-provided description of the output format. Expected inputs look like (without quotes): "tsplib", "cvrplib", "carplib". Unrecognized strings are parsed as kNone.

Definition at line 30 of file solution_serializer.cc.

◆ RunSeparation()

ScipSeparationResult operations_research::RunSeparation ( internal::ScipCallbackRunner * runner,
const ScipConstraintHandlerContext & context,
absl::Span< SCIP_CONS * > constraints,
bool is_integral )

If any violated lazy constraint is found: returns kLazyConstraintAdded, else if any violated cutting plane is found: returns kCuttingPlaneAdded, else: returns kDidNotFind

Two code paths, one for cuts, one for lazy constraints. Cuts first:

NOTE(user): the coefficients don't come out sorted. I don't think this matters.

Todo
(user): when infeasible is true, it better to have the scip return status be cutoff instead of cutting plane added (e.g. see cs/scip/src/scip/cons_knapsack.c). However, as we use SCIPaddRow(), it isn't clear this will even happen.

NOTE(user): if we have already found a violated lazy constraint, we want to return kLazyConstraintAdded, not kCuttingPlaneAdded, see function contract.

Lazy constraint path:

NOTE(user): the coefficients don't come out sorted. I don't think this matters.

Todo
(user): Maybe it is better to expose more of these options, potentially through user_suggested_constraint.

Definition at line 118 of file scip_callback.cc.

◆ RunWorker()

void operations_research::RunWorker ( void * data)

Definition at line 23 of file threadpool.cc.

◆ SafeAddInto()

template<typename IntegerType >
bool operations_research::SafeAddInto ( IntegerType a,
IntegerType * b )

Performs *b += a and returns false iff the addition overflow or underflow. This function only works for typed integer type (IntType<>).

Definition at line 133 of file saturated_arithmetic.h.

◆ SafeProtoConstDownCast()

template<class Proto >
absl::StatusOr< const Proto * > operations_research::SafeProtoConstDownCast ( const google::protobuf::Message * proto)

Definition at line 63 of file proto_tools.h.

◆ SafeProtoDownCast()

template<class Proto >
absl::StatusOr< Proto * > operations_research::SafeProtoDownCast ( google::protobuf::Message * proto)

Implementation of function templates.

Casts a generic google::protobuf::Message* to a specific proto type, or returns an InvalidArgumentError if it doesn't seem to be of the right type. Comes in non-const and const versions. NOTE(user): You should rather use DynamicCastToGenerated() from message.h if you don't need the fancy error message or the absl::Status.

Definition at line 50 of file proto_tools.h.

◆ SatSolveProto()

MPSolutionResponse operations_research::SatSolveProto ( LazyMutableCopy< MPModelRequest > request,
std::atomic< bool > * interrupt_solve = nullptr,
std::function< void(const std::string &)> logging_callback = nullptr,
std::function< void(const MPSolution &)> solution_callback = nullptr )

Solve the input MIP model with the SAT solver.

If possible, std::move the request into this function call to avoid a copy.

If you need to change the solver parameters, please use the EncodeParametersAsString() function to set the request's solver_specific_parameters field.

The optional interrupt_solve can be used to interrupt the solve early. It must only be set to true, never reset to false. It is also used internally by the solver that will set it to true for its own internal logic. As a consequence the caller should ignore the stored value and should not use the same atomic for different concurrent calls.

The optional logging_callback will be called when the SAT parameter log_search_progress is set to true. Passing a callback will disable the default logging to INFO. Note though that by default the SAT parameter log_to_stdout is true so even with a callback, the logs will appear on stdout too unless log_to_stdout is set to false. The enable_internal_solver_output in the request will act as the SAT parameter log_search_progress.

The optional solution_callback will be called on each intermediate solution found by the solver. The solver may call solution_callback from multiple threads, but it will ensure that at most one thread executes solution_callback at a time.

Todo
(user): We do not support all the parameters here. In particular the logs before the solver is called will not be appended to the response. Fix that, and remove code duplication for the logger config. One way should be to not touch/configure anything if the logger is already created while calling SolveCpModel() and call a common config function from here or from inside Solve()?

Set it now so that it can be overwritten by the solver specific parameters.

See EncodeSatParametersAsString() documentation.

Validate parameters.

Reconfigure the logger in case the solver_specific_parameters overwrite its configuration. Note that the invalid parameter message will be logged before that though according to request.enable_internal_solver_output().

Model validation and delta handling.

Note
the ExtractValidMPModelInPlaceOrPopulateResponseStatus() can also close trivial model (empty or trivially infeasible). So this is not always the MODEL_INVALID status.

The logging is only needed for our benchmark script, so we use UNKNOWN here, but we could log the proper status instead.

We will presolve directly on the MPModelProto, so get a copy or transfer ownership from the LazyMutableCopy<MPModelProto>().

The request is no longer needed after this. Important: we need to copy the model above before clearing this.

We start by some extra validation since our code do not accept any kind of input.

This is good to do before any presolve.

Coefficients really close to zero can cause issues. We remove them right away according to our parameters.

Note(user): the LP presolvers API is a bit weird and keep a reference to the given GlopParameters, so we need to make sure it outlive them.

Continue with the solve.

Todo
(user): We put the INFEASIBLE_OR_UNBOUNBED case here since there is no return status that exactly matches it.

This is needed for our benchmark scripts.

We need to do that before the automatic detection of integers.

Abort if one only want to solve pure-IP model and we don't have one.

Copy and scale the hint if there is one.

To handle weird hint input values, we cap any large value to +/- mip_max_bound() which is also the min/max value of any variable once scaled.

We no longer need the mp_model after this, reclaime its memory.

Configure model.

Postsolve the bound shift and scaling.

Solve.

Convert the response.

Todo
(user): Implement the row and column status.

Copy and postsolve any additional solutions.

Todo
(user): Remove the postsolve hack of copying to a response.

If the scaling factor is unset/zero, it is assumed to be one.

Definition at line 160 of file sat_proto_solver.cc.

◆ SatSolverVersion()

std::string operations_research::SatSolverVersion ( )

Returns a string that describes the version of the CP-SAT solver.

Definition at line 493 of file sat_proto_solver.cc.

◆ ScipSolveProto()

absl::StatusOr< MPSolutionResponse > operations_research::ScipSolveProto ( LazyMutableCopy< MPModelRequest > request)

Note, here we do not override any of SCIP default parameters. This behavior differs from MPSolver::Solve() which sets the feasibility tolerance to 1e-7, and the gap limit to 0.0001 (whereas SCIP defaults are 1e-6 and 0, respectively, and they are being used here).

Release all created pointers.

Default clock type. We use wall clock time because getting CPU user seconds involves calling times() which is very expensive. NOTE(user): Also, time limit based on CPU user seconds is NOT thread safe. We observed that different instances of SCIP running concurrently in different threads consume the time limit together. E.g., 2 threads running SCIP with time limit 10s each will both terminate after ~5s.

These extra arrays are used by quadratic constraints.

can't make 'scip_solution' const, as SCIPxxx does not offer const parameter functions.

NOTE(user): As of SCIP 7.0.1, getting the pointer to all solutions is as fast as getting the pointer to the best solution. See scip/src/scip/scip_sol.c?l=2264&rcl=322332899.

To be consistent with the other solvers.

NOTE(user): After looking at the SCIP code on 2019-06-14, it seems that this will mostly happen for INFEASIBLE problems in practice. Since most (all?) users shouldn't have their application behave very differently upon INFEASIBLE or UNBOUNDED, the potential error that we are making here seems reasonable (and not worth a LOG, unless in debug mode).

Definition at line 692 of file scip_proto_solver.cc.

◆ SetAssignmentFromAssignment()

void operations_research::SetAssignmentFromAssignment ( Assignment * target_assignment,
const std::vector< IntVar * > & target_vars,
const Assignment * source_assignment,
const std::vector< IntVar * > & source_vars )

NOLINT.

Given a "source_assignment", clears the "target_assignment" and adds all IntVars in "target_vars", with the values of the variables set according to the corresponding values of "source_vars" in "source_assignment". source_vars and target_vars must have the same number of elements. The source and target assignments can belong to different Solvers.

Definition at line 948 of file assignment.cc.

◆ SetBit32()

void operations_research::SetBit32 ( uint32_t *const bitset,
uint32_t pos )
inline

Definition at line 361 of file bitset.h.

◆ SetBit64()

void operations_research::SetBit64 ( uint64_t *const bitset,
uint64_t pos )
inline

Sets the bit pos to true in bitset.

Definition at line 358 of file bitset.h.

◆ SetIsEqual()

Constraint * operations_research::SetIsEqual ( IntVar *const var,
absl::Span< const int64_t > values,
const std::vector< IntVar * > & vars )

Definition at line 6397 of file expressions.cc.

◆ SetIsGreaterOrEqual()

Constraint * operations_research::SetIsGreaterOrEqual ( IntVar *const var,
absl::Span< const int64_t > values,
const std::vector< IntVar * > & vars )

Definition at line 6404 of file expressions.cc.

◆ setobjoffset()

int operations_research::setobjoffset ( const XPRSprob & mLp,
double value )
Todo
detect xpress version

Definition at line 182 of file xpress_interface.cc.

◆ SetSolverSpecificParameters() [1/2]

absl::Status operations_research::SetSolverSpecificParameters ( absl::string_view parameters,
GRBenv * gurobi )

Set parameters specified in the string. The format of the string is a series of tokens separated by either '
' or by ',' characters. Any token whose first character is a '#' or has zero length is skipped. Comment tokens (i.e. those starting with #) can contain ',' characters. Any other token has the form: parameter_name(separator)value where (separator) is either '=' or ' '. A valid string can look-like: "#\n# Gurobi-specific parameters, still part of the comment\n\nThreads=1\nPresolve 2,SolutionLimit=100" This function will process each and every token, even if an intermediate token is unrecognized.

Empty lines are simply ignored.

Comment tokens end at the next new-line, or the end of the string. The first character must be '#'

If one parameter fails, we keep processing the list of parameters.

Definition at line 232 of file gurobi_proto_solver.cc.

◆ SetSolverSpecificParameters() [2/2]

absl::Status operations_research::SetSolverSpecificParameters ( const std::string & parameters,
Highs & highs )

Comment tokens end at the next new-line, or the end of the string. The first character must be '#'

If one parameter fails, we keep processing the list of parameters.

Comment tokens end at the next new-line, or the end of the string. The first character must be '#'

If one parameter fails, we keep processing the list of parameters.

Definition at line 266 of file highs_proto_solver.cc.

◆ SetupGlpkEnvAutomaticDeletion()

void operations_research::SetupGlpkEnvAutomaticDeletion ( )

Setups a thread local that will call glp_free_env() when the calling thread exits. This method is safe to be called multiple times on the same thread and is thread-safe.

This function needs to be called on any thread where glp_create_prob() is called since Glpk automatically creates an environment on each thread if it does not already exist but does not have any code to free it. Thus it leaks.

The GlpkEnvDeleter will be created at most once per thread where the function is called and its destructor will be called at the exit of this thread.

Definition at line 35 of file glpk_env_deleter.cc.

◆ ShortestPathsOnDag()

PathWithLength operations_research::ShortestPathsOnDag ( int num_nodes,
absl::Span< const ArcWithLength > arcs_with_length,
int source,
int destination )

Returns {+inf, {}, {}} if there is no path of finite length from the source to the destination. Dies if arcs_with_length has a cycle.

Definition at line 84 of file dag_shortest_path.cc.

◆ SimpleOneToOneShortestPath()

template<typename DistanceType >
std::pair< DistanceType, std::vector< int > > operations_research::SimpleOneToOneShortestPath ( int source,
int destination,
absl::Span< const int > tails,
absl::Span< const int > heads,
absl::Span< const DistanceType > lengths,
DistanceType limit = std::numeric_limits<DistanceType>::max() )

Computes a shortest path from source to destination in a weighted directed graph, specified as an arc list.

This function also demonstrates how to use the more feature rich BoundedDijkstraWrapper (defined below) in the simple case, see the implementation at the bottom of this file.

We take a sparse directed input graph with nodes indexed in [0, num_nodes). Each arcs goes from a tail node to a head node (tail -> head) and must have a NON-NEGATIVE length. Self-arc or duplicate arcs are supported. This is provided as 3 parallel vectors of the same size. Note that we validate the input consistency with checks.

If your graph is undirected, you can easily transform it by adding two arcs (a -> b and b -> a) for each edge (a <-> b).

This returns a pair (path length, node-path from source to destination) corresponding to a shortest path. Both source and destination will be included in the path.

If destination is not reachable from source, or if the shortest path length is >= limit we will return {limit, {}}. As a consequence any arc length >= limit is the same as no arc. The code is also overflow-safe and will behave correctly if the limit is int64max or infinity.

Example usage.

Compute the number of nodes.

This is not necessary, but is a good practice to allocate the graph size in one go. We also do some basic validation.

The number of arcs.

Build the graph. Note that this permutes arc indices for speed, but we don't care here since we will return a node path.

Negative length can cause the algo to loop forever and/or use a lot of memory. So it should be validated.

Compute a shortest path. This should work for both float/double or integer distances.

No path exists, or shortest_distance >= limit.

A path exist, returns it.

Compute the number of nodes.

This is not necessary, but is a good practice to allocate the graph size in one go. We also do some basic validation.

The number of arcs.

Build the graph. Note that this permutes arc indices for speed, but we don't care here since we will return a node path.

Negative length can cause the algo to loop forever and/or use a lot of memory. So it should be validated.

Compute a shortest path. This should work for both float/double or integer distances.

No path exists, or shortest_distance >= limit.

A path exist, returns it.

Definition at line 635 of file bounded_dijkstra.h.

◆ SlopeAndYInterceptToConvexityRegions()

std::vector< bool > operations_research::SlopeAndYInterceptToConvexityRegions ( const std::vector< SlopeAndYIntercept > & slope_and_y_intercept)

Converts a vector of SlopeAndYIntercept to a vector of convexity regions. Convexity regions are defined such that, all segment in a convexity region form a convex function. The boolean in the vector is set to true if the segment associated to it starts a new convexity region. Therefore, a convex function would yield {true, false, false, ...} and a concave function would yield {true, true, true, ...}.

Definition at line 1267 of file routing_lp_scheduling.cc.

◆ solution()

Select next search node to expand Select next item_i to add this new search node to the search Generate a new search node where item_i is not in the knapsack Check validity of this new partial operations_research::solution ( using propagators)

◆ SolutionStatusString()

std::string operations_research::SolutionStatusString ( const int status)

Formats a solution status (GLP_OPT,...).

Definition at line 30 of file glpk_formatters.cc.

◆ SolveMaxFlow()

void operations_research::SolveMaxFlow ( const FlowModelProto & flow_model,
double * loading_time,
double * solving_time )

Loads a FlowModelProto proto into the MaxFlow class and solves it.

Compute the number of nodes.

Build the graph.

Find source & sink.

Create the max flow instance and set the arc capacities.

Definition at line 222 of file solve_flow_model.cc.

◆ SolveMinCostFlow()

void operations_research::SolveMinCostFlow ( const FlowModelProto & flow_model,
double * loading_time,
double * solving_time )

Loads a FlowModelProto proto into the MinCostFlow class and solves it.

Compute the number of nodes.

Build the graph.

Definition at line 177 of file solve_flow_model.cc.

◆ SolveModelWithSat()

bool operations_research::SolveModelWithSat ( RoutingModel * model,
const RoutingSearchParameters & search_parameters,
const Assignment * initial_solution,
Assignment * solution )

Solves a RoutingModel using the CP-SAT solver. Returns false if no solution was found.

Todo
(user): Check that performance is acceptable.
Todo
(user): Check that performance is acceptable.

Definition at line 1140 of file routing_sat.cc.

◆ SolveMPModel()

MPSolutionResponse operations_research::SolveMPModel ( LazyMutableCopy< MPModelRequest > request,
const SolveInterrupter * interrupter )
Todo
(b/311704821): this function should not delegate to MPSolver, also true for the functions below.

Solves the model encoded by a MPModelRequest protocol buffer and returns the solution encoded as a MPSolutionResponse.

LazyMutableCopy<> accept both 'const MPModelRequest&' and 'MPModelRequest&&' prefer to call this with the std::move() version if you no longer need the request. It will allows to reclaim the request memory as soon as it is converted to one of the solver internal data representation.

If interrupter is non-null, one can call interrupter->Interrupt() to stop the solver earlier. Interruption is only supported if SolverTypeSupportsInterruption() returns true for the requested solver. Passing a non-null pointer with any other solver type immediately returns an MPSOLVER_INCOMPATIBLE_OPTIONS error.

Definition at line 29 of file solve_mp_model.cc.

◆ SolverTypeIsMip() [1/2]

bool operations_research::SolverTypeIsMip ( MPModelRequest::SolverType solver_type)

There is a homonymous version taking a MPSolver::OptimizationProblemType.

Definition at line 85 of file linear_solver.cc.

◆ SolverTypeIsMip() [2/2]

bool operations_research::SolverTypeIsMip ( MPSolver::OptimizationProblemType solver_type)
inline

Definition at line 990 of file linear_solver.h.

◆ SolverTypeSupportsInterruption()

bool operations_research::SolverTypeSupportsInterruption ( const MPModelRequest::SolverType solver)

Definition at line 44 of file solve_mp_model.cc.

◆ splitMyString()

template<class Container >
void operations_research::splitMyString ( const std::string & str,
Container & cont,
char delim = ' ' )
Todo
useless ?

Definition at line 2101 of file xpress_interface.cc.

◆ stringToCharPtr()

const char * operations_research::stringToCharPtr ( std::string & var)

Definition at line 2109 of file xpress_interface.cc.

◆ StringToProto()

absl::Status operations_research::StringToProto ( absl::string_view data,
google::protobuf::Message * proto,
bool allow_partial )

Exactly like ReadFileToProto(), but directly from the contents.

Try decompressing it.

Try binary format first, then text format, then JSON, then proto3 JSON, then give up. For some of those, like binary format and proto3 JSON, we perform additional checks to verify that we have the right proto: it can happen to try to read a proto of type Foo as a proto of type Bar, by mistake, and we'd rather have this function fail rather than silently accept it, because the proto parser is too lenient with unknown fields. We don't require ByteSizeLong(parsed) == input.size(), because it may be the case that the proto version changed and some fields are dropped. We just fail when the difference is too large.

NOTE(user): When using ParseFromString() from a generic google::protobuf::Message, like we do here, all fields are stored, even if they are unknown in the underlying proto type. Unless we explicitly discard those 'unknown fields' here, our call to ByteSizeLong() will still count the unknown payload.

We convert the 0-indexed line to 1-indexed.

NOTE(user): We protect against the JSON proto3 parser being very lenient and easily accepting any JSON as a valid JSON for our proto: if the parsed proto's size is too small compared to the JSON, we probably parsed a JSON that wasn't representing a valid proto.

Definition at line 62 of file file_util.cc.

◆ STRONG_TYPE_ARITHMETIC_OP() [1/11]

operations_research::STRONG_TYPE_ARITHMETIC_OP ( StrongIndex ,
int ,
%  )

◆ STRONG_TYPE_ARITHMETIC_OP() [2/11]

operations_research::STRONG_TYPE_ARITHMETIC_OP ( StrongIndex ,
int ,
*  )

◆ STRONG_TYPE_ARITHMETIC_OP() [3/11]

operations_research::STRONG_TYPE_ARITHMETIC_OP ( StrongIndex ,
int ,
-  )

◆ STRONG_TYPE_ARITHMETIC_OP() [4/11]

operations_research::STRONG_TYPE_ARITHMETIC_OP ( StrongIndex ,
int ,
+  )

◆ STRONG_TYPE_ARITHMETIC_OP() [5/11]

operations_research::STRONG_TYPE_ARITHMETIC_OP ( StrongInt64 ,
int64_t ,
%  )

◆ STRONG_TYPE_ARITHMETIC_OP() [6/11]

operations_research::STRONG_TYPE_ARITHMETIC_OP ( StrongInt64 ,
int64_t ,
*  )

◆ STRONG_TYPE_ARITHMETIC_OP() [7/11]

operations_research::STRONG_TYPE_ARITHMETIC_OP ( StrongInt64 ,
int64_t ,
-  )

◆ STRONG_TYPE_ARITHMETIC_OP() [8/11]

operations_research::STRONG_TYPE_ARITHMETIC_OP ( StrongInt64 ,
int64_t  )

◆ STRONG_TYPE_ARITHMETIC_OP() [9/11]

operations_research::STRONG_TYPE_ARITHMETIC_OP ( StrongInt64 ,
int64_t ,
+  )

◆ STRONG_TYPE_ARITHMETIC_OP() [10/11]

operations_research::STRONG_TYPE_ARITHMETIC_OP ( StrongInt64 ,
int64_t ,
/  )

◆ STRONG_TYPE_ARITHMETIC_OP() [11/11]

operations_research::STRONG_TYPE_ARITHMETIC_OP ( StrongInt64 ,
int64_t ,
<<  )

◆ STRONG_TYPE_COMPARISON_OP() [1/8]

operations_research::STRONG_TYPE_COMPARISON_OP ( StrongIndex ,
int ,
!  )

◆ STRONG_TYPE_COMPARISON_OP() [2/8]

operations_research::STRONG_TYPE_COMPARISON_OP ( StrongIndex ,
int ,
>=  )

◆ STRONG_TYPE_COMPARISON_OP() [3/8]

operations_research::STRONG_TYPE_COMPARISON_OP ( StrongIndex ,
int ,
<=  )

◆ STRONG_TYPE_COMPARISON_OP() [4/8]

operations_research::STRONG_TYPE_COMPARISON_OP ( StrongIndex ,
int  )

◆ STRONG_TYPE_COMPARISON_OP() [5/8]

operations_research::STRONG_TYPE_COMPARISON_OP ( StrongInt64 ,
int64_t ,
!  )

◆ STRONG_TYPE_COMPARISON_OP() [6/8]

operations_research::STRONG_TYPE_COMPARISON_OP ( StrongInt64 ,
int64_t ,
>=  )

◆ STRONG_TYPE_COMPARISON_OP() [7/8]

operations_research::STRONG_TYPE_COMPARISON_OP ( StrongInt64 ,
int64_t ,
<=  )

◆ STRONG_TYPE_COMPARISON_OP() [8/8]

operations_research::STRONG_TYPE_COMPARISON_OP ( StrongInt64 ,
int64_t  )

◆ strtoint32()

int32_t operations_research::strtoint32 ( absl::string_view word)

Definition at line 26 of file strtoint.cc.

◆ strtoint64()

int64_t operations_research::strtoint64 ( absl::string_view word)

Definition at line 32 of file strtoint.cc.

◆ SubHadOverflow()

bool operations_research::SubHadOverflow ( int64_t x,
int64_t y,
int64_t diff )
inline

This is the same reasoning as for AddHadOverflow. We have x = diff + y. The formula is the same, with 'x' and diff exchanged.

Definition at line 107 of file saturated_arithmetic.h.

◆ SubOverflows()

int64_t operations_research::SubOverflows ( int64_t x,
int64_t y )
inline

Definition at line 126 of file saturated_arithmetic.h.

◆ SumOfKMaxValueInDomain()

int64_t operations_research::SumOfKMaxValueInDomain ( const Domain & domain,
int k )

Returns the sum of largest k values in the domain.

Definition at line 729 of file sorted_interval_list.cc.

◆ SumOfKMinValueInDomain()

int64_t operations_research::SumOfKMinValueInDomain ( const Domain & domain,
int k )

Returns the sum of smallest k values in the domain.

Definition at line 715 of file sorted_interval_list.cc.

◆ ToInt64Vector()

std::vector< int64_t > operations_research::ToInt64Vector ( const std::vector< int > & input)

--— Vector manipulations --—

Definition at line 829 of file utilities.cc.

◆ TopologicalOrderIsValid()

template<class GraphType >
absl::Status operations_research::TopologicalOrderIsValid ( const GraphType & graph,
absl::Span< const typename GraphType::NodeIndex > topological_order )

Definition at line 327 of file dag_shortest_path.h.

◆ ToString() [1/2]

std::string operations_research::ToString ( MPCallbackEvent event)

Definition at line 23 of file linear_solver_callback.cc.

◆ ToString() [2/2]

absl::string_view operations_research::ToString ( MPSolver::OptimizationProblemType optimization_problem_type)

Definition at line 627 of file linear_solver.cc.

◆ TruncateAndQuoteGLPKName()

std::string operations_research::TruncateAndQuoteGLPKName ( std::string_view original_name)

Returns a name which size is < kMaxGLPKNameLen and that does not contain control characters (as define by iscntrl()) (escaped using \xHH sequences).

We use \ for escape sequences; thus we must escape it too.

Simply insert non-control characters (that are not the escape character above).

Escape control characters.

Definition at line 111 of file glpk_formatters.cc.

◆ TwoBitsFromPos64()

uint64_t operations_research::TwoBitsFromPos64 ( uint64_t pos)
inline

Returns a mask with the bits pos % 64 and (pos ^ 1) % 64 sets.

Definition at line 406 of file bitset.h.

◆ TwosComplementAddition()

int64_t operations_research::TwosComplementAddition ( int64_t x,
int64_t y )
inline

-------— Overflow utility functions -------—

Implement two's complement addition and subtraction on int64s.

The C and C++ standards specify that the overflow of signed integers is undefined. This is because of the different possible representations that may be used for signed integers (one's complement, two's complement, sign and magnitude). Such overflows are detected by Address Sanitizer with -fsanitize=signed-integer-overflow.

Simple, portable overflow detection on current machines relies on these two functions. For example, if the sign of the sum of two positive integers is negative, there has been an overflow.

Note
the static assert will break if the code is compiled on machines which do not use two's complement.

Definition at line 82 of file saturated_arithmetic.h.

◆ TwosComplementSubtraction()

int64_t operations_research::TwosComplementSubtraction ( int64_t x,
int64_t y )
inline

Definition at line 89 of file saturated_arithmetic.h.

◆ UnsafeLeastSignificantBitPosition32()

int32_t operations_research::UnsafeLeastSignificantBitPosition32 ( const uint32_t * bitset,
uint32_t start,
uint32_t end )

◆ UnsafeLeastSignificantBitPosition64()

int64_t operations_research::UnsafeLeastSignificantBitPosition64 ( const uint64_t * bitset,
uint64_t start,
uint64_t end )

Unsafe versions of the functions above where respectively end and start are supposed to be set.

◆ UnsafeMostSignificantBitPosition32()

int32_t operations_research::UnsafeMostSignificantBitPosition32 ( const uint32_t * bitset,
uint32_t start,
uint32_t end )

◆ UnsafeMostSignificantBitPosition64()

int64_t operations_research::UnsafeMostSignificantBitPosition64 ( const uint64_t * bitset,
uint64_t start,
uint64_t end )

◆ VariablesToString()

std::string operations_research::VariablesToString ( absl::flat_hash_map< std::string, std::pair< sat::IntegerVariableProto, int > > & variables,
absl::flat_hash_map< std::string, std::vector< int > > & variable_instances,
absl::flat_hash_map< std::string, absl::flat_hash_set< std::string > > & variable_childs,
const sat::CpSolverResponse & response_,
absl::string_view variable,
std::string prefix = "" )

Childs

Definition at line 3065 of file routing_lp_scheduling.cc.

◆ VariableToString()

std::string operations_research::VariableToString ( std::pair< sat::IntegerVariableProto, int > & variable_pair,
const sat::CpSolverResponse & response_ )

Definition at line 3013 of file routing_lp_scheduling.cc.

◆ VectorSum()

float operations_research::VectorSum ( absl::Span< const float > values)
inline

Computes the sum of values without assuming anything.

Definition at line 37 of file vector_sum.h.

◆ WriteModelToMpsFile()

absl::Status operations_research::WriteModelToMpsFile ( absl::string_view filename,
const MPModelProto & model,
const MPModelExportOptions & options = MPModelExportOptions() )

Write the current model (variables, constraints, objective) to a file in MPS file format, using the "free" MPS format.

See ExportModelAsMpsFormat().

Definition at line 251 of file model_exporter.cc.

◆ WriteProtoToFile()

absl::Status operations_research::WriteProtoToFile ( absl::string_view filename,
const google::protobuf::Message & proto,
ProtoWriteFormat proto_write_format,
bool gzipped = false,
bool append_extension_to_file_name = true )

Writes a proto to a file. Supports the following formats: binary, text, JSON, all of those optionally gzipped. If 'proto_write_format' is kProtoBinary, ".bin" is appended to file_name. If 'proto_write_format' is kJson or kCanonicalJson, ".json" is appended to file_name. If 'gzipped' is true, ".gz" is appended to file_name.

Definition at line 142 of file file_util.cc.

◆ WriteRecordsOrDie()

template<typename Proto >
void operations_research::WriteRecordsOrDie ( absl::string_view filename,
const std::vector< Proto > & protos )

Writes all records in Proto format to 'file'. Dies if it is unable to open the file or write to it.

Definition at line 138 of file file_util.h.

◆ XpressBasisStatusesFrom()

std::vector< int > operations_research::XpressBasisStatusesFrom ( const std::vector< MPSolver::BasisStatus > & statuses)

Definition at line 1712 of file xpress_interface.cc.

◆ XpressDynamicLibraryPotentialPaths()

std::vector< std::string > operations_research::XpressDynamicLibraryPotentialPaths ( )

Look for libraries pointed by XPRESSDIR first.

Search for canonical places.

Definition at line 180 of file environment.cc.

◆ XpressIntSolCallbackImpl()

void XPRS_CC operations_research::XpressIntSolCallbackImpl ( XPRSprob cbprob,
void * cbdata )

This is the call-back called by XPRESS when it finds a new MIP solution NOTE(user): This function must have this exact API, because we are passing it to XPRESS as a callback.

nothing to do

nothing to do

Definition at line 2228 of file xpress_interface.cc.

◆ XpressIsCorrectlyInstalled()

bool operations_research::XpressIsCorrectlyInstalled ( )
extern

Definition at line 359 of file environment.cc.

◆ XPressSolveProto()

MPSolutionResponse operations_research::XPressSolveProto ( LazyMutableCopy< MPModelRequest > request)

Solves the input request.

◆ XpressToMPSolverBasisStatus()

static MPSolver::BasisStatus operations_research::XpressToMPSolverBasisStatus ( int xpress_basis_status)
static

Transform XPRESS basis status to MPSolver basis status.

Transform a XPRESS basis status to an MPSolver basis status.

Definition at line 1247 of file xpress_interface.cc.

◆ YenKShortestPaths()

template<class GraphType >
KShortestPaths operations_research::YenKShortestPaths ( const GraphType & graph,
const std::vector< PathDistance > & arc_lengths,
NodeIndex source,
NodeIndex destination,
unsigned k )

Computes up to k shortest paths from the node source to the node destination in the given directed graph. The paths are guaranteed not to have loops.

Hypotheses on input (which are not checked at runtime):

  • No multigraphs (more than one edge or a pair of nodes). The behavior is undefined otherwise.
  • The arc_lengths are supposed to be nonnegative. The behavior is undefined otherwise.
    Todo
    (user): relax to "no negative-weight cycles" (no Dijkstra).

This function uses Yen's algorithm, which guarantees to find the first k shortest paths in O(k n (m + n log n)) for n nodes and m edges. This algorithm is an implementation of the idea of detours.

Yen, Jin Y. "Finding the k Shortest Loopless Paths in a Network". Management Science. 17 (11): 712–716, 1971. https://doi.org/10.1287%2Fmnsc.17.11.712

Todo
(user): Yen's algorithm can work with negative weights, but Dijkstra cannot.

Yen, Jin Y. "Finding the k Shortest Loopless Paths in a Network". Management Science. 17 (11): 712–716, 1971. https://doi.org/10.1287%2Fmnsc.17.11.712

Yen's notations:

  • Source node: (1).
  • Destination node: (N).
  • Path from (1) to (j): (1) - (i) - ... - (j).
  • Cost for following the arc from (i) to (j), potentially negative: d_ij.
  • k-th shortest path: A^k == (1) - (2^k) - (3^k) - ... - (Q_k^k) - (N).
  • Deviation from A^k-1 at (i): A_i^k. This is the shortest path from (1) to (N) that is identical to A^k-1 from (1) to (i^k-1), then different from all the first k-1 shortest paths {A^1, A^2, ..., A^k-1}.
  • Root of A_i^k: R_i^k. This is the first subpath of A_i^k that coincides with A^k-1, i.e. A_i^k until i^k-1.
  • Spur of A_i^k: S_i^k. This is the last subpart of A_i^k with only one node coinciding with A_i^k, (i^k-1), i.e. A_i^k from i^k-1 onwards.

Example graph, paths from A to H (more classical notations): C - D / / \ A - B / G - H \ / / E - F Source node: A. Destination node: H. Three paths from A to H, say they are ordered from the cheapest to the most expensive:

  • 1st path: A - B - C - D - G - H
  • 2nd path: A - B - E - F - G - H
  • 3rd path: A - B - E - D - G - H To start with, Yen's algorithm uses the shortest path: A^1 = A - B - C - D - G - H To compute the second path A^2, compute a detour around A^1. Consider the iteration where B is the spur node.
  • Spur node: 2^1 = B.
  • Root of A^1_2: R_1^2 = A - B (including the spur node 2^1 = B).
  • Spur path S_1^2 starts at the spur node 2^1 = B. There are two possible spur paths, the cheapest being: S_1^2 = B - E - F - G - H

First step: compute the shortest path.

Generate variant paths.

One path has already been generated (the shortest one). Only k-1 more paths need to be generated.

Generate variant paths from the last shortest path.

Todo
(user): think about adding parallelism for this loop to improve running times. This is not a priority as long as the algorithm is faster than the one in shortest_paths.h.

Consider the part of the last shortest path up to and excluding the spur node. If spur_node_position == 0, this span only contains the source node.

Simplify the graph to have different paths using infinite lengths: copy the weights, set some of them to infinity. There is no need to restore the graph to its previous state in this case.

This trick is used in the original article (it's old-fashioned), but not in Wikipedia's pseudocode (it prefers mutating the graph, which is harder to do without copying the whole graph structure). Copying the whole graph might be quite expensive, especially as it is not useful for long (computing one shortest path).

Check among the previous paths: if part of the path coincides with the first few nodes up to the spur node (included), forbid this part of the path in the search for the next shortest path. More precisely, in that case, avoid the arc from the spur node to the next node in the path.

Ensure that the path computed from the new weights is loopless by "removing" the nodes of the root path from the graph (by tweaking the weights, again). The previous operation only disallows the arc from the spur node (at the end of the root path) to the next node in the previously found paths.

Generate a new candidate path from the spur node to the destination without using the forbidden arcs.

Node unreachable after some arcs are forbidden.

Ensure there is an edge between the end of the root path and the beginning of the spur path (knowing that both subpaths coincide at the spur node).

Ensure the forbidden arc is not present in any previously generated path.

Assemble the new path.

Ensure the assembled path is loopless, i.e. no node is repeated.

Ensure the new path is not one of the previously known ones. This operation is required, as there are two sources of paths from the source to the destination:

  • paths, the list of paths that is output by the function: there is no possible duplicate due to arc_lengths_for_detour, where edges that might generate a duplicate path are forbidden.
  • variant_path_queue, the list of potential paths, ordered by their cost, with no impact on arc_lengths_for_detour.
    Todo
    (user): would it be faster to fingerprint the paths and filter by fingerprints? Due to the probability of error with fingerprints, still use this slow-but-exact code, but after filtering.

Add the shortest spur path ever found that has not yet been added. This can be a spur path that has just been generated or a previous one, if this iteration found no shorter one.

First step: compute the shortest path.

Generate variant paths.

One path has already been generated (the shortest one). Only k-1 more paths need to be generated.

Generate variant paths from the last shortest path.

Todo
(user): think about adding parallelism for this loop to improve running times. This is not a priority as long as the algorithm is faster than the one in shortest_paths.h.

Consider the part of the last shortest path up to and excluding the spur node. If spur_node_position == 0, this span only contains the source node.

Simplify the graph to have different paths using infinite lengths: copy the weights, set some of them to infinity. There is no need to restore the graph to its previous state in this case.

This trick is used in the original article (it's old-fashioned), but not in Wikipedia's pseudocode (it prefers mutating the graph, which is harder to do without copying the whole graph structure). Copying the whole graph might be quite expensive, especially as it is not useful for long (computing one shortest path).

Check among the previous paths: if part of the path coincides with the first few nodes up to the spur node (included), forbid this part of the path in the search for the next shortest path. More precisely, in that case, avoid the arc from the spur node to the next node in the path.

Ensure that the path computed from the new weights is loopless by "removing" the nodes of the root path from the graph (by tweaking the weights, again). The previous operation only disallows the arc from the spur node (at the end of the root path) to the next node in the previously found paths.

Generate a new candidate path from the spur node to the destination without using the forbidden arcs.

Node unreachable after some arcs are forbidden.

Ensure there is an edge between the end of the root path and the beginning of the spur path (knowing that both subpaths coincide at the spur node).

Ensure the forbidden arc is not present in any previously generated path.

Assemble the new path.

Ensure the assembled path is loopless, i.e. no node is repeated.

Ensure the new path is not one of the previously known ones. This operation is required, as there are two sources of paths from the source to the destination:

  • paths, the list of paths that is output by the function: there is no possible duplicate due to arc_lengths_for_detour, where edges that might generate a duplicate path are forbidden.
  • variant_path_queue, the list of potential paths, ordered by their cost, with no impact on arc_lengths_for_detour.
    Todo
    (user): would it be faster to fingerprint the paths and filter by fingerprints? Due to the probability of error with fingerprints, still use this slow-but-exact code, but after filtering.

Add the shortest spur path ever found that has not yet been added. This can be a spur path that has just been generated or a previous one, if this iteration found no shorter one.

Definition at line 269 of file k_shortest_paths.h.

◆ Zero()

int64_t operations_research::Zero ( )
inline

NOLINT.

This method returns 0. It is useful when 0 can be cast either as a pointer or as an integer value and thus lead to an ambiguous function call.

Definition at line 3359 of file constraint_solver.h.

Variable Documentation

◆ GRBaddconstr

std::function< int(GRBmodel *model, int numnz, int *cind, double *cval, char sense, double rhs, const char *constrname)> operations_research::GRBaddconstr = nullptr

Definition at line 144 of file environment.cc.

◆ GRBaddconstrs

std::function< int(GRBmodel *model, int numconstrs, int numnz, int *cbeg, int *cind, double *cval, char *sense, double *rhs, char **constrnames)> operations_research::GRBaddconstrs = nullptr

Definition at line 148 of file environment.cc.

◆ GRBaddgenconstrAbs

std::function< int(GRBmodel *model, const char *name, int resvar, int argvar)> operations_research::GRBaddgenconstrAbs = nullptr

Definition at line 162 of file environment.cc.

◆ GRBaddgenconstrAnd

std::function< int(GRBmodel *model, const char *name, int resvar, int nvars, const int *vars)> operations_research::GRBaddgenconstrAnd = nullptr

Definition at line 165 of file environment.cc.

◆ GRBaddgenconstrIndicator

std::function< int(GRBmodel *model, const char *name, int binvar, int binval, int nvars, const int *vars, const double *vals, char sense, double rhs)> operations_research::GRBaddgenconstrIndicator = nullptr

Definition at line 172 of file environment.cc.

◆ GRBaddgenconstrMax

std::function< int(GRBmodel *model, const char *name, int resvar, int nvars, const int *vars, double constant)> operations_research::GRBaddgenconstrMax = nullptr

Definition at line 157 of file environment.cc.

◆ GRBaddgenconstrMin

std::function< int(GRBmodel *model, const char *name, int resvar, int nvars, const int *vars, double constant)> operations_research::GRBaddgenconstrMin = nullptr

Definition at line 160 of file environment.cc.

◆ GRBaddgenconstrOr

std::function< int(GRBmodel *model, const char *name, int resvar, int nvars, const int *vars)> operations_research::GRBaddgenconstrOr = nullptr

Definition at line 168 of file environment.cc.

◆ GRBaddqconstr

std::function< int(GRBmodel *model, int numlnz, int *lind, double *lval, int numqnz, int *qrow, int *qcol, double *qval, char sense, double rhs, const char *QCname)> operations_research::GRBaddqconstr = nullptr

Definition at line 176 of file environment.cc.

◆ GRBaddqpterms

std::function< int(GRBmodel *model, int numqnz, int *qrow, int *qcol, double *qval)> operations_research::GRBaddqpterms = nullptr

Definition at line 179 of file environment.cc.

◆ GRBaddrangeconstr

std::function< int(GRBmodel *model, int numnz, int *cind, double *cval, double lower, double upper, const char *constrname)> operations_research::GRBaddrangeconstr = nullptr

Definition at line 151 of file environment.cc.

◆ GRBaddsos

std::function< int(GRBmodel *model, int numsos, int nummembers, int *types, int *beg, int *ind, double *weight)> operations_research::GRBaddsos = nullptr

Definition at line 154 of file environment.cc.

◆ GRBaddvar

std::function< int(GRBmodel *model, int numnz, int *vind, double *vval, double obj, double lb, double ub, char vtype, const char *varname)> operations_research::GRBaddvar = nullptr

Definition at line 137 of file environment.cc.

◆ GRBaddvars

std::function< int(GRBmodel *model, int numvars, int numnz, int *vbeg, int *vind, double *vval, double *obj, double *lb, double *ub, char *vtype, char **varnames)> operations_research::GRBaddvars = nullptr

Definition at line 141 of file environment.cc.

◆ GRBcbcut

std::function< int(void *cbdata, int cutlen, const int *cutind, const double *cutval, char cutsense, double cutrhs)> operations_research::GRBcbcut = nullptr

Definition at line 120 of file environment.cc.

◆ GRBcbget

std::function< int(void *cbdata, int where, int what, void *resultP)> operations_research::GRBcbget
Initial value:
=
nullptr

Definition at line 114 of file environment.cc.

◆ GRBcblazy

std::function< int(void *cbdata, int lazylen, const int *lazyind, const double *lazyval, char lazysense, double lazyrhs)> operations_research::GRBcblazy = nullptr

Definition at line 123 of file environment.cc.

◆ GRBcbsolution

std::function< int(void *cbdata, const double *solution, double *objvalP)> operations_research::GRBcbsolution = nullptr

Definition at line 117 of file environment.cc.

◆ GRBchgcoeffs

std::function< int(GRBmodel *model, int cnt, int *cind, int *vind, double *val)> operations_research::GRBchgcoeffs = nullptr

Definition at line 188 of file environment.cc.

◆ GRBcomputeIIS

std::function< int(GRBmodel *model)> operations_research::GRBcomputeIIS = nullptr

Definition at line 128 of file environment.cc.

◆ GRBcopyparams

std::function< int(GRBenv *dest, GRBenv *src)> operations_research::GRBcopyparams = nullptr

Definition at line 223 of file environment.cc.

◆ GRBdelconstrs

std::function< int(GRBmodel *model, int len, int *ind)> operations_research::GRBdelconstrs = nullptr

Definition at line 181 of file environment.cc.

◆ GRBdelgenconstrs

std::function< int(GRBmodel *model, int len, int *ind)> operations_research::GRBdelgenconstrs
Initial value:
=
nullptr

Definition at line 183 of file environment.cc.

◆ GRBdelq

std::function< int(GRBmodel *model)> operations_research::GRBdelq = nullptr

Definition at line 186 of file environment.cc.

◆ GRBdelqconstrs

std::function< int(GRBmodel *model, int len, int *ind)> operations_research::GRBdelqconstrs = nullptr

Definition at line 185 of file environment.cc.

◆ GRBdelsos

std::function< int(GRBmodel *model, int len, int *ind)> operations_research::GRBdelsos = nullptr

Definition at line 182 of file environment.cc.

◆ GRBdelvars

std::function< int(GRBmodel *model, int len, int *ind)> operations_research::GRBdelvars = nullptr

Definition at line 180 of file environment.cc.

◆ GRBemptyenv

std::function< int(GRBenv **envP)> operations_research::GRBemptyenv = nullptr

Definition at line 225 of file environment.cc.

◆ GRBfreeenv

std::function< void(GRBenv *env)> operations_research::GRBfreeenv = nullptr

Definition at line 229 of file environment.cc.

◆ GRBfreemodel

std::function< int(GRBmodel *model)> operations_research::GRBfreemodel = nullptr

Definition at line 190 of file environment.cc.

◆ GRBgetcharattrarray

std::function< int(GRBmodel *model, const char *attrname, int first, int len, char *values)> operations_research::GRBgetcharattrarray = nullptr

Definition at line 81 of file environment.cc.

◆ GRBgetcharattrelement

std::function< int(GRBmodel *model, const char *attrname, int element, char *valueP)> operations_research::GRBgetcharattrelement = nullptr

Definition at line 75 of file environment.cc.

◆ GRBgetdblattr

std::function< int(GRBmodel *model, const char *attrname, double *valueP)> operations_research::GRBgetdblattr = nullptr

Definition at line 89 of file environment.cc.

◆ GRBgetdblattrarray

std::function< int(GRBmodel *model, const char *attrname, int first, int len, double *values)> operations_research::GRBgetdblattrarray = nullptr

Definition at line 100 of file environment.cc.

◆ GRBgetdblattrelement

std::function< int(GRBmodel *model, const char *attrname, int element, double *valueP)> operations_research::GRBgetdblattrelement = nullptr

Definition at line 94 of file environment.cc.

◆ GRBgetdblparam

std::function< int(GRBenv *env, const char *paramname, double *valueP)> operations_research::GRBgetdblparam = nullptr

Definition at line 199 of file environment.cc.

◆ GRBgetdblparaminfo

std::function< int(GRBenv *envP, const char *paramname, double *valueP, double *minP, double *maxP, double *defP)> operations_research::GRBgetdblparaminfo = nullptr

Definition at line 207 of file environment.cc.

◆ GRBgetenv

std::function< GRBenv *(GRBmodel *model)> operations_research::GRBgetenv = nullptr

Definition at line 228 of file environment.cc.

◆ GRBgeterrormsg

std::function< const char *(GRBenv *env)> operations_research::GRBgeterrormsg = nullptr

Definition at line 230 of file environment.cc.

◆ GRBgetintattr

std::function< int(GRBmodel *model, const char *attrname, int *valueP)> operations_research::GRBgetintattr = nullptr

Definition at line 55 of file environment.cc.

◆ GRBgetintattrarray

std::function< int(GRBmodel *model, const char *attrname, int first, int len, int *values)> operations_research::GRBgetintattrarray = nullptr

Definition at line 66 of file environment.cc.

◆ GRBgetintattrelement

std::function< int(GRBmodel *model, const char *attrname, int element, int *valueP)> operations_research::GRBgetintattrelement = nullptr

Definition at line 60 of file environment.cc.

◆ GRBgetintparam

std::function< int(GRBenv *env, const char *paramname, int *valueP)> operations_research::GRBgetintparam = nullptr

Definition at line 197 of file environment.cc.

◆ GRBgetintparaminfo

std::function< int(GRBenv *envP, const char *paramname, int *valueP, int *minP, int *maxP, int *defP)> operations_research::GRBgetintparaminfo = nullptr

Definition at line 204 of file environment.cc.

◆ GRBgetnumparams

std::function< int(GRBenv *envP)> operations_research::GRBgetnumparams = nullptr

Definition at line 224 of file environment.cc.

◆ GRBgetparamname

std::function< int(GRBenv *envP, int i, char **paramnameP)> operations_research::GRBgetparamname
Initial value:
=
nullptr

Definition at line 212 of file environment.cc.

◆ GRBgetparamtype

std::function< int(GRBenv *envP, const char *paramname)> operations_research::GRBgetparamtype
Initial value:
=
nullptr

Definition at line 210 of file environment.cc.

◆ GRBgetstrattr

std::function< int(GRBmodel *model, const char *attrname, char **valueP)> operations_research::GRBgetstrattr = nullptr

Definition at line 108 of file environment.cc.

◆ GRBgetstrparam

std::function< int(GRBenv *env, const char *paramname, char *valueP)> operations_research::GRBgetstrparam = nullptr

Definition at line 201 of file environment.cc.

◆ GRBgetstrparaminfo

std::function< int(GRBenv *envP, const char *paramname, char *valueP, char *defP)> operations_research::GRBgetstrparaminfo = nullptr

Definition at line 209 of file environment.cc.

◆ GRBgetvars

std::function< int(GRBmodel *model, int *numnzP, int *vbeg, int *vind, double *vval, int start, int len)> operations_research::GRBgetvars = nullptr

Definition at line 126 of file environment.cc.

◆ GRBisattravailable

std::function< int(GRBmodel *model, const char *attrname)> operations_research::GRBisattravailable
Initial value:
=
nullptr

Definition at line 52 of file environment.cc.

◆ GRBisqp

std::function< int(GRBenv **, const char *, const char *, const char *, int, const char *)> operations_research::GRBisqp = nullptr

This is the 'define' section.

This was generated with the parse_header.py script. See the comment at the top of the script.

Definition at line 51 of file environment.cc.

◆ GRBloadenv

std::function< int(GRBenv **envP, const char *logfilename)> operations_research::GRBloadenv = nullptr

Definition at line 226 of file environment.cc.

◆ GRBnewmodel

std::function< int(GRBenv *env, GRBmodel **modelP, const char *Pname, int numvars, double *obj, double *lb, double *ub, char *vtype, char **varnames)> operations_research::GRBnewmodel = nullptr

Definition at line 133 of file environment.cc.

◆ GRBoptimize

std::function< int(GRBmodel *model)> operations_research::GRBoptimize = nullptr

Definition at line 127 of file environment.cc.

◆ GRBplatform

std::function< char *(void)> operations_research::GRBplatform = nullptr

Definition at line 233 of file environment.cc.

◆ GRBresetparams

std::function< int(GRBenv *env)> operations_research::GRBresetparams = nullptr

Definition at line 222 of file environment.cc.

◆ GRBsetcallbackfunc

std::function< int(GRBmodel *model, int(GUROBI_STDCALL *cb)(CB_ARGS), void *usrdata)> operations_research::GRBsetcallbackfunc = nullptr

Definition at line 113 of file environment.cc.

◆ GRBsetcharattrarray

std::function< int(GRBmodel *model, const char *attrname, int first, int len, char *newvalues)> operations_research::GRBsetcharattrarray = nullptr

Definition at line 84 of file environment.cc.

◆ GRBsetcharattrelement

std::function< int(GRBmodel *model, const char *attrname, int element, char newvalue)> operations_research::GRBsetcharattrelement = nullptr

Definition at line 78 of file environment.cc.

◆ GRBsetcharattrlist

std::function< int(GRBmodel *model, const char *attrname, int len, int *ind, char *newvalues)> operations_research::GRBsetcharattrlist = nullptr

Definition at line 87 of file environment.cc.

◆ GRBsetdblattr

std::function< int(GRBmodel *model, const char *attrname, double newvalue)> operations_research::GRBsetdblattr = nullptr

Definition at line 91 of file environment.cc.

◆ GRBsetdblattrarray

std::function< int(GRBmodel *model, const char *attrname, int first, int len, double *newvalues)> operations_research::GRBsetdblattrarray = nullptr

Definition at line 103 of file environment.cc.

◆ GRBsetdblattrelement

std::function< int(GRBmodel *model, const char *attrname, int element, double newvalue)> operations_research::GRBsetdblattrelement = nullptr

Definition at line 97 of file environment.cc.

◆ GRBsetdblattrlist

std::function< int(GRBmodel *model, const char *attrname, int len, int *ind, double *newvalues)> operations_research::GRBsetdblattrlist = nullptr

Definition at line 106 of file environment.cc.

◆ GRBsetdblparam

std::function< int(GRBenv *env, const char *paramname, double value)> operations_research::GRBsetdblparam = nullptr

Definition at line 219 of file environment.cc.

◆ GRBsetintattr

std::function< int(GRBmodel *model, const char *attrname, int newvalue)> operations_research::GRBsetintattr = nullptr

Definition at line 57 of file environment.cc.

◆ GRBsetintattrarray

std::function< int(GRBmodel *model, const char *attrname, int first, int len, int *newvalues)> operations_research::GRBsetintattrarray = nullptr

Definition at line 69 of file environment.cc.

◆ GRBsetintattrelement

std::function< int(GRBmodel *model, const char *attrname, int element, int newvalue)> operations_research::GRBsetintattrelement = nullptr

Definition at line 63 of file environment.cc.

◆ GRBsetintattrlist

std::function< int(GRBmodel *model, const char *attrname, int len, int *ind, int *newvalues)> operations_research::GRBsetintattrlist = nullptr

Definition at line 72 of file environment.cc.

◆ GRBsetintparam

std::function< int(GRBenv *env, const char *paramname, int value)> operations_research::GRBsetintparam = nullptr

Definition at line 217 of file environment.cc.

◆ GRBsetobjectiven

std::function< int(GRBmodel *model, int index, int priority, double weight, double abstol, double reltol, const char *name, double constant, int lnz, int *lind, double *lval)> operations_research::GRBsetobjectiven = nullptr

Definition at line 195 of file environment.cc.

◆ GRBsetparam

std::function< int(GRBenv *env, const char *paramname, const char *value)> operations_research::GRBsetparam = nullptr

Definition at line 215 of file environment.cc.

◆ GRBsetstrattr

std::function< int(GRBmodel *model, const char *attrname, const char *newvalue)> operations_research::GRBsetstrattr = nullptr

Definition at line 110 of file environment.cc.

◆ GRBsetstrparam

std::function< int(GRBenv *env, const char *paramname, const char *value)> operations_research::GRBsetstrparam = nullptr

Definition at line 221 of file environment.cc.

◆ GRBstartenv

std::function< int(GRBenv *env)> operations_research::GRBstartenv = nullptr

Definition at line 227 of file environment.cc.

◆ GRBterminate

std::function< void(GRBmodel *model)> operations_research::GRBterminate = nullptr

Definition at line 191 of file environment.cc.

◆ GRBupdatemodel

std::function< int(GRBmodel *model)> operations_research::GRBupdatemodel = nullptr

Definition at line 189 of file environment.cc.

◆ GRBversion

std::function< void(int *majorP, int *minorP, int *technicalP)> operations_research::GRBversion
Initial value:
=
nullptr

Definition at line 231 of file environment.cc.

◆ GRBwrite

std::function< int(GRBmodel *model, const char *filename)> operations_research::GRBwrite = nullptr

Definition at line 129 of file environment.cc.

◆ kAllBits32

const uint32_t operations_research::kAllBits32 = 0xFFFFFFFFU
static

Definition at line 39 of file bitset.h.

◆ kAllBits64

const uint64_t operations_research::kAllBits64 = uint64_t{0xFFFFFFFFFFFFFFFF}
static

Basic bit operations.

Useful constants: word and double word will all bits set.

Definition at line 37 of file bitset.h.

◆ kAllBitsButLsb64

const uint64_t operations_research::kAllBitsButLsb64 = uint64_t{0xFFFFFFFFFFFFFFFE}
static

Definition at line 38 of file bitset.h.

◆ kAnyXsanEnabled

bool operations_research::kAnyXsanEnabled
inlineconstexpr
Initial value:
=
constexpr bool kAsanEnabled
constexpr bool kTsanEnabled
constexpr bool kMsanEnabled

Definition at line 24 of file testing_utils.h.

◆ kAsanEnabled

bool operations_research::kAsanEnabled = false
inlineconstexpr

Definition at line 19 of file testing_utils.h.

◆ kDefaultPrimalTolerance

double operations_research::kDefaultPrimalTolerance = 1e-07
constexpr

Definition at line 174 of file linear_solver.h.

◆ kDisconnectedPathDistance

const PathDistance operations_research::kDisconnectedPathDistance
Initial value:
=
std::numeric_limits<uint32_t>::max()

Definition at line 82 of file shortest_paths.h.

◆ kInfinity

double operations_research::kInfinity = std::numeric_limits<float>::infinity()
staticconstexpr

Definition at line 35 of file set_cover_heuristics.cc.

◆ kMaxGLPKNameLen

std::size_t operations_research::kMaxGLPKNameLen = 255
inlineconstexpr

The maximum length of GLPK's names for the problem, the variables and the constraints.

Definition at line 35 of file glpk_formatters.h.

◆ kMaxPossibleCost

Cost operations_research::kMaxPossibleCost = std::numeric_limits<Cost>::max()
staticconstexpr

Definition at line 34 of file set_cover_heuristics.cc.

◆ kMsanEnabled

bool operations_research::kMsanEnabled = false
inlineconstexpr

Definition at line 20 of file testing_utils.h.

◆ kOptimizationProblemTypeNames

NamedOptimizationProblemType operations_research::kOptimizationProblemTypeNames[]
constexpr
Initial value:
= {
{MPSolver::GLOP_LINEAR_PROGRAMMING, "glop"},
{MPSolver::CLP_LINEAR_PROGRAMMING, "clp"},
{MPSolver::GUROBI_LINEAR_PROGRAMMING, "gurobi_lp"},
{MPSolver::GLPK_LINEAR_PROGRAMMING, "glpk_lp"},
{MPSolver::HIGHS_LINEAR_PROGRAMMING, "highs_lp"},
{MPSolver::CPLEX_LINEAR_PROGRAMMING, "cplex_lp"},
{MPSolver::XPRESS_LINEAR_PROGRAMMING, "xpress_lp"},
{MPSolver::SCIP_MIXED_INTEGER_PROGRAMMING, "scip"},
{MPSolver::CBC_MIXED_INTEGER_PROGRAMMING, "cbc"},
{MPSolver::SAT_INTEGER_PROGRAMMING, "sat"},
{MPSolver::BOP_INTEGER_PROGRAMMING, "bop"},
{MPSolver::GUROBI_MIXED_INTEGER_PROGRAMMING, "gurobi"},
{MPSolver::GLPK_MIXED_INTEGER_PROGRAMMING, "glpk"},
{MPSolver::HIGHS_MIXED_INTEGER_PROGRAMMING, "highs"},
{MPSolver::PDLP_LINEAR_PROGRAMMING, "pdlp"},
{MPSolver::KNAPSACK_MIXED_INTEGER_PROGRAMMING, "knapsack"},
{MPSolver::CPLEX_MIXED_INTEGER_PROGRAMMING, "cplex"},
{MPSolver::XPRESS_MIXED_INTEGER_PROGRAMMING, "xpress"},
}

Definition at line 569 of file linear_solver.cc.

◆ kRoundTripTestNumber

double operations_research::kRoundTripTestNumber = 0.10000000000000002
inlineconstexpr

Number that can be used in unit tests to validate that RoundTripDoubleFormat is actually used by the underlying code.

This value has a unique shortest base-10 representation which is "0.10000000000000002": 0.10000000000000001 and 0.10000000000000003 respectively round to the two adjacent doubles, which shortest representations are "0.1" and "0.10000000000000003".

When printed with the default formatting of floating point numbers, this will be printed as "0.1".

The kRoundTripTestNumberStr constant can be used to test the output.

Definition at line 33 of file fp_roundtrip_conv_testing.h.

◆ kRoundTripTestNumberStr

absl::string_view operations_research::kRoundTripTestNumberStr
inlineconstexpr
Initial value:
=
"0.10000000000000002"

Definition at line 34 of file fp_roundtrip_conv_testing.h.

◆ kSetCoverAlignmentInBytes

int operations_research::kSetCoverAlignmentInBytes = 64
constexpr

SIMD operations require vectors to be aligned at 64-bytes on x86-64 processors as of 2024-05-03.

Todo
(user): improve the code to make it possible to use unaligned memory.

Definition at line 90 of file set_cover_model.h.

◆ kStdToCharsDoubleIsSupported

ABSL_CONST_INIT const bool operations_research::kStdToCharsDoubleIsSupported
Initial value:
=
std_to_chars_has_overload_v<double>

True if the plateform supports double to std::to_chars().

std::to_chars() for double is not yet supported on Emscripten, Android and iOS; they only implement std::to_chars() for integers.

Definition at line 107 of file fp_roundtrip_conv.cc.

◆ kTsanEnabled

bool operations_research::kTsanEnabled = false
inlineconstexpr

Definition at line 21 of file testing_utils.h.

◆ kUnassigned

const int operations_research::kUnassigned = -1
static

--— Routing model --—

Definition at line 361 of file routing.cc.

◆ XPRSaddcbintsol

std::function< int(XPRSprob prob, void(XPRS_CC *f_intsol)(XPRSprob cbprob, void *cbdata), void *p, int priority)> operations_research::XPRSaddcbintsol = nullptr

Definition at line 97 of file environment.cc.

◆ XPRSaddcbmessage

std::function< int(XPRSprob prob, void(XPRS_CC *f_message)(XPRSprob cbprob, void *cbdata, const char *msg, int msglen, int msgtype), void *p, int priority)> operations_research::XPRSaddcbmessage = nullptr

Definition at line 99 of file environment.cc.

◆ XPRSaddcols

std::function< int(XPRSprob prob, int ncols, int ncoefs, const double objcoef[], const int start[], const int rowind[], const double rowcoef[], const double lb[], const double ub[])> operations_research::XPRSaddcols = nullptr

Definition at line 74 of file environment.cc.

◆ XPRSaddmipsol

std::function< int(XPRSprob prob, int length, const double solval[], const int colind[], const char *name)> operations_research::XPRSaddmipsol = nullptr

Definition at line 88 of file environment.cc.

◆ XPRSaddnames

std::function< int(XPRSprob prob, int type, const char names[], int first, int last)> operations_research::XPRSaddnames = nullptr

Definition at line 75 of file environment.cc.

◆ XPRSaddrows

std::function< int(XPRSprob prob, int nrows, int ncoefs, const char rowtype[], const double rhs[], const double rng[], const int start[], const int colind[], const double rowcoef[])> operations_research::XPRSaddrows = nullptr

Definition at line 72 of file environment.cc.

◆ XPRSchgbounds

std::function< int(XPRSprob prob, int nbounds, const int colind[], const char bndtype[], const double bndval[])> operations_research::XPRSchgbounds = nullptr

Definition at line 87 of file environment.cc.

◆ XPRSchgcoef

std::function< int(XPRSprob prob, int row, int col, double coef)> operations_research::XPRSchgcoef = nullptr

Definition at line 92 of file environment.cc.

◆ XPRSchgcoltype

std::function< int(XPRSprob prob, int ncols, const int colind[], const char coltype[])> operations_research::XPRSchgcoltype = nullptr

Definition at line 78 of file environment.cc.

◆ XPRSchgmcoef

std::function< int(XPRSprob prob, int ncoefs, const int rowind[], const int colind[], const double rowcoef[])> operations_research::XPRSchgmcoef = nullptr

Definition at line 93 of file environment.cc.

◆ XPRSchgobj

std::function< int(XPRSprob prob, int ncols, const int colind[], const double objcoef[])> operations_research::XPRSchgobj = nullptr

Definition at line 91 of file environment.cc.

◆ XPRSchgobjsense

std::function< int(XPRSprob prob, int objsense)> operations_research::XPRSchgobjsense = nullptr

Definition at line 81 of file environment.cc.

◆ XPRSchgrhs

std::function< int(XPRSprob prob, int nrows, const int rowind[], const double rhs[])> operations_research::XPRSchgrhs = nullptr

Definition at line 94 of file environment.cc.

◆ XPRSchgrhsrange

std::function< int(XPRSprob prob, int nrows, const int rowind[], const double rng[])> operations_research::XPRSchgrhsrange = nullptr

Definition at line 95 of file environment.cc.

◆ XPRSchgrowtype

std::function< int(XPRSprob prob, int nrows, const int rowind[], const char rowtype[])> operations_research::XPRSchgrowtype = nullptr

Definition at line 96 of file environment.cc.

◆ XPRScreateprob

std::function< int(XPRSprob *p_prob)> operations_research::XPRScreateprob = nullptr

This is the 'define' section.

Let's not reformat for rest of the file. clang-format off This was generated with the parse_header_xpress.py script. See the comment at the top of the script.

Let's not reformat for rest of the file. clang-format off

Definition at line 43 of file environment.cc.

◆ XPRSdelcols

std::function< int(XPRSprob prob, int ncols, const int colind[])> operations_research::XPRSdelcols = nullptr

Definition at line 77 of file environment.cc.

◆ XPRSdelrows

std::function< int(XPRSprob prob, int nrows, const int rowind[])> operations_research::XPRSdelrows = nullptr

Definition at line 73 of file environment.cc.

◆ XPRSdestroyprob

std::function< int(XPRSprob prob)> operations_research::XPRSdestroyprob = nullptr

Definition at line 44 of file environment.cc.

◆ XPRSfree

std::function< int(void)> operations_research::XPRSfree = nullptr

Definition at line 46 of file environment.cc.

◆ XPRSgetbanner

std::function< int(char *banner)> operations_research::XPRSgetbanner = nullptr

Definition at line 49 of file environment.cc.

◆ XPRSgetbasis

std::function< int(XPRSprob prob, int rowstat[], int colstat[])> operations_research::XPRSgetbasis = nullptr

Definition at line 83 of file environment.cc.

◆ XPRSgetcoef

std::function< int(XPRSprob prob, int row, int col, double *p_coef)> operations_research::XPRSgetcoef = nullptr

Definition at line 71 of file environment.cc.

◆ XPRSgetcoltype

std::function< int(XPRSprob prob, char coltype[], int first, int last)> operations_research::XPRSgetcoltype = nullptr

Definition at line 86 of file environment.cc.

◆ XPRSgetcontrolinfo

std::function< int(XPRSprob prob, const char *name, int *p_id, int *p_type)> operations_research::XPRSgetcontrolinfo = nullptr

Definition at line 63 of file environment.cc.

◆ XPRSgetdblattrib

std::function< int(XPRSprob prob, int attrib, double *p_value)> operations_research::XPRSgetdblattrib = nullptr

Definition at line 62 of file environment.cc.

◆ XPRSgetdblcontrol

std::function< int(XPRSprob prob, int control, double *p_value)> operations_research::XPRSgetdblcontrol = nullptr

Definition at line 59 of file environment.cc.

◆ XPRSgetintattrib

std::function< int(XPRSprob prob, int attrib, int *p_value)> operations_research::XPRSgetintattrib = nullptr

Definition at line 61 of file environment.cc.

◆ XPRSgetintcontrol

std::function< int(XPRSprob prob, int control, int *p_value)> operations_research::XPRSgetintcontrol = nullptr

Definition at line 57 of file environment.cc.

◆ XPRSgetintcontrol64

std::function< int(XPRSprob prob, int control, XPRSint64 *p_value)> operations_research::XPRSgetintcontrol64 = nullptr

Definition at line 58 of file environment.cc.

◆ XPRSgetlasterror

std::function< int(XPRSprob prob, char *errmsg)> operations_research::XPRSgetlasterror = nullptr

Definition at line 82 of file environment.cc.

◆ XPRSgetlb

std::function< int(XPRSprob prob, double lb[], int first, int last)> operations_research::XPRSgetlb = nullptr

Definition at line 69 of file environment.cc.

◆ XPRSgetlicerrmsg

std::function< int(char *buffer, int maxbytes)> operations_research::XPRSgetlicerrmsg = nullptr

Definition at line 47 of file environment.cc.

◆ XPRSgetlpsol

std::function< int(XPRSprob prob, double x[], double slack[], double duals[], double djs[])> operations_research::XPRSgetlpsol = nullptr

Definition at line 89 of file environment.cc.

◆ XPRSgetmipsol

std::function< int(XPRSprob prob, double x[], double slack[])> operations_research::XPRSgetmipsol = nullptr

Definition at line 90 of file environment.cc.

◆ XPRSgetnames

std::function< int(XPRSprob prob, int type, char names[], int first, int last)> operations_research::XPRSgetnames = nullptr

Definition at line 76 of file environment.cc.

◆ XPRSgetobj

std::function< int(XPRSprob prob, double objcoef[], int first, int last)> operations_research::XPRSgetobj = nullptr

Definition at line 66 of file environment.cc.

◆ XPRSgetrhs

std::function< int(XPRSprob prob, double rhs[], int first, int last)> operations_research::XPRSgetrhs = nullptr

Definition at line 67 of file environment.cc.

◆ XPRSgetrhsrange

std::function< int(XPRSprob prob, double rng[], int first, int last)> operations_research::XPRSgetrhsrange = nullptr

Definition at line 68 of file environment.cc.

◆ XPRSgetrowtype

std::function< int(XPRSprob prob, char rowtype[], int first, int last)> operations_research::XPRSgetrowtype = nullptr

Definition at line 85 of file environment.cc.

◆ XPRSgetstringcontrol

std::function< int(XPRSprob prob, int control, char *value, int maxbytes, int *p_nbytes)> operations_research::XPRSgetstringcontrol = nullptr

Definition at line 60 of file environment.cc.

◆ XPRSgetub

std::function< int(XPRSprob prob, double ub[], int first, int last)> operations_research::XPRSgetub = nullptr

Definition at line 70 of file environment.cc.

◆ XPRSgetversion

std::function< int(char *version)> operations_research::XPRSgetversion = nullptr

Definition at line 50 of file environment.cc.

◆ XPRSinit

std::function< int(const char *path)> operations_research::XPRSinit = nullptr

Definition at line 45 of file environment.cc.

◆ XPRSinterrupt

std::function< int(XPRSprob prob, int reason)> operations_research::XPRSinterrupt = nullptr

Definition at line 52 of file environment.cc.

◆ XPRSlicense

std::function< int(int *p_i, char *p_c)> operations_research::XPRSlicense = nullptr

Definition at line 48 of file environment.cc.

◆ XPRSloadbasis

std::function< int(XPRSprob prob, const int rowstat[], const int colstat[])> operations_research::XPRSloadbasis = nullptr

Definition at line 79 of file environment.cc.

◆ XPRSloadlp

std::function< int(XPRSprob prob, const char *probname, int ncols, int nrows, const char rowtype[], const double rhs[], const double rng[], const double objcoef[], const int start[], const int collen[], const int rowind[], const double rowcoef[], const double lb[], const double ub[])> operations_research::XPRSloadlp = nullptr

Definition at line 64 of file environment.cc.

◆ XPRSloadlp64

std::function< int(XPRSprob prob, const char *probname, int ncols, int nrows, const char rowtype[], const double rhs[], const double rng[], const double objcoef[], const XPRSint64 start[], const int collen[], const int rowind[], const double rowcoef[], const double lb[], const double ub[])> operations_research::XPRSloadlp64 = nullptr

Definition at line 65 of file environment.cc.

◆ XPRSlpoptimize

std::function< int(XPRSprob prob, const char *flags)> operations_research::XPRSlpoptimize = nullptr

Definition at line 100 of file environment.cc.

◆ XPRSmipoptimize

std::function< int(XPRSprob prob, const char *flags)> operations_research::XPRSmipoptimize = nullptr

Definition at line 101 of file environment.cc.

◆ XPRSpostsolve

std::function< int(XPRSprob prob)> operations_research::XPRSpostsolve = nullptr

Definition at line 80 of file environment.cc.

◆ XPRSremovecbintsol

std::function< int(XPRSprob prob, void(XPRS_CC *f_intsol)(XPRSprob cbprob, void *cbdata), void *p)> operations_research::XPRSremovecbintsol = nullptr

Definition at line 98 of file environment.cc.

◆ XPRSsetdblcontrol

std::function< int(XPRSprob prob, int control, double value)> operations_research::XPRSsetdblcontrol = nullptr

Definition at line 55 of file environment.cc.

◆ XPRSsetdefaultcontrol

std::function< int(XPRSprob prob, int control)> operations_research::XPRSsetdefaultcontrol = nullptr

Definition at line 51 of file environment.cc.

◆ XPRSsetintcontrol

std::function< int(XPRSprob prob, int control, int value)> operations_research::XPRSsetintcontrol = nullptr

Definition at line 53 of file environment.cc.

◆ XPRSsetintcontrol64

std::function< int(XPRSprob prob, int control, XPRSint64 value)> operations_research::XPRSsetintcontrol64 = nullptr

Definition at line 54 of file environment.cc.

◆ XPRSsetstrcontrol

std::function< int(XPRSprob prob, int control, const char *value)> operations_research::XPRSsetstrcontrol = nullptr

Definition at line 56 of file environment.cc.

◆ XPRSwriteprob

std::function< int(XPRSprob prob, const char *filename, const char *flags)> operations_research::XPRSwriteprob = nullptr

Definition at line 84 of file environment.cc.