Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
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 |
Typedefs | |
typedef KnapsackItem * | KnapsackItemPtr |
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, ArcIndex > | StarGraph |
typedef ForwardEbertGraph< NodeIndex, ArcIndex > | ForwardStarGraph |
typedef ForwardStaticGraph< NodeIndex, ArcIndex > | ForwardStarStaticGraph |
typedef ZVector< NodeIndex > | NodeIndexArray |
typedef ZVector< ArcIndex > | ArcIndexArray |
typedef ZVector< FlowQuantity > | QuantityArray |
typedef ZVector< CostValue > | CostArray |
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 |
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 --— | |
DemonProfiler * | BuildDemonProfiler (Solver *solver) |
void | DeleteDemonProfiler (DemonProfiler *monitor) |
void | InstallLocalSearchProfiler (LocalSearchProfiler *monitor) |
LocalSearchProfiler * | BuildLocalSearchProfiler (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) |
PropagationMonitor * | BuildTrace (Solver *s) |
LocalSearchMonitor * | BuildLocalSearchMonitorPrimary (Solver *s) |
ModelCache * | BuildModelCache (Solver *solver) |
PropagationMonitor * | BuildPrintTrace (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 > | |
LocalSearchOperator * | 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. | |
template<class T > | |
LocalSearchOperator * | 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) |
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 --— | |
LocalSearchFilter * | MakePathStateFilter (Solver *solver, std::unique_ptr< PathState > path_state, const std::vector< IntVar * > &nexts) |
LocalSearchFilter * | MakeDimensionFilter (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 --— | |
Constraint * | SetIsEqual (IntVar *const var, absl::Span< const int64_t > values, const std::vector< IntVar * > &vars) |
Constraint * | SetIsGreaterOrEqual (IntVar *const var, absl::Span< const int64_t > values, const std::vector< IntVar * > &vars) |
IntExpr * | BuildStartExpr (IntervalVar *var) |
--— Expression builders ---— | |
IntExpr * | BuildDurationExpr (IntervalVar *var) |
IntExpr * | BuildEndExpr (IntervalVar *var) |
IntExpr * | BuildSafeStartExpr (IntervalVar *var, int64_t unperformed_value) |
IntExpr * | BuildSafeDurationExpr (IntervalVar *var, int64_t unperformed_value) |
IntExpr * | BuildSafeEndExpr (IntervalVar *var, int64_t unperformed_value) |
std::unique_ptr< BinCapacities > | MakeBinCapacities (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) |
IntVarLocalSearchFilter * | MakeVehicleBreaksFilter (const RoutingModel &routing_model, const RoutingDimension &dimension) |
Constraint * | MakeDifferentFromValues (Solver *solver, IntVar *var, std::vector< int64_t > values) |
Constraint * | MakeResourceConstraint (const RoutingModel::ResourceGroup *resource_group, const std::vector< IntVar * > *vehicle_resource_vars, RoutingModel *model) |
Constraint * | MakePathSpansAndTotalSlacks (const RoutingDimension *dimension, std::vector< IntVar * > spans, std::vector< IntVar * > total_slacks) |
DecisionBuilder * | MakeSetValuesFromTargets (Solver *solver, std::vector< IntVar * > variables, std::vector< int64_t > targets) |
DecisionBuilder * | MakeSetCumulsFromLocalDimensionCosts (Solver *solver, LocalDimensionCumulOptimizer *lp_optimizer, LocalDimensionCumulOptimizer *mp_optimizer, bool optimize_and_pack, std::vector< RoutingModel::RouteDimensionTravelInfo > dimension_travel_info_per_route) |
DecisionBuilder * | MakeSetCumulsFromGlobalDimensionCosts (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. | |
DecisionBuilder * | MakeRestoreDimensionValuesForUnchangedRoutes (RoutingModel *model) |
IntVarLocalSearchFilter * | MakeMaxActiveVehiclesFilter (const RoutingModel &routing_model) |
Returns a filter ensuring that max active vehicles constraints are enforced. | |
IntVarLocalSearchFilter * | MakeNodeDisjunctionFilter (const RoutingModel &routing_model, bool filter_cost) |
Returns a filter ensuring that node disjunction constraints are enforced. | |
IntVarLocalSearchFilter * | MakeVehicleAmortizedCostFilter (const RoutingModel &routing_model) |
Returns a filter computing vehicle amortized costs. | |
IntVarLocalSearchFilter * | MakeTypeRegulationsFilter (const RoutingModel &routing_model) |
Returns a filter ensuring type regulation constraints are enforced. | |
IntVarLocalSearchFilter * | 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. | |
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 ¶meters, bool filter_objective_cost, bool use_chain_cumul_filter, std::vector< LocalSearchFilterManager::FilterEvent > *filters) |
IntVarLocalSearchFilter * | MakePickupDeliveryFilter (const RoutingModel &routing_model, const std::vector< PickupDeliveryPair > &pairs, const std::vector< RoutingModel::PickupAndDeliveryPolicy > &vehicle_policies) |
IntVarLocalSearchFilter * | MakeVehicleVarFilter (const RoutingModel &routing_model) |
Returns a filter checking that vehicle variable domains are respected. | |
IntVarLocalSearchFilter * | MakeCumulBoundsPropagatorFilter (const RoutingDimension &dimension) |
Returns a filter handling dimension cumul bounds. | |
IntVarLocalSearchFilter * | MakeGlobalLPCumulFilter (GlobalDimensionCumulOptimizer *optimizer, GlobalDimensionCumulOptimizer *mp_optimizer, bool filter_objective_cost) |
Returns a filter checking global linear constraints and costs. | |
LocalSearchFilter * | MakeResourceAssignmentFilter (LocalDimensionCumulOptimizer *optimizer, LocalDimensionCumulOptimizer *mp_optimizer, bool propagate_own_objective_value, bool filter_objective_cost) |
IntVarLocalSearchFilter * | MakeCPFeasibilityFilter (RoutingModel *routing_model) |
Returns a filter checking the current solution using CP propagation. | |
LocalSearchFilter * | MakePathEnergyCostFilter (Solver *solver, std::unique_ptr< PathEnergyCostChecker > checker, absl::string_view dimension_name) |
DecisionBuilder * | MakeRuinAndRecreateDecisionBuilder (const RoutingSearchParameters ¶meters, RoutingModel *model, const Assignment *assignment, std::function< bool()> stop_search, LocalSearchFilterManager *filter_manager) |
DecisionBuilder * | MakePerturbationDecisionBuilder (const RoutingSearchParameters ¶meters, RoutingModel *model, const Assignment *assignment, std::function< bool()> stop_search, LocalSearchFilterManager *filter_manager) |
std::unique_ptr< NeighborAcceptanceCriterion > | MakeNeighborAcceptanceCriterion (const RoutingSearchParameters ¶meters) |
Returns a neighbor acceptance criterion based on the given parameters. | |
std::vector< bool > | SlopeAndYInterceptToConvexityRegions (const std::vector< SlopeAndYIntercept > &slope_and_y_intercept) |
std::vector< SlopeAndYIntercept > | PiecewiseLinearFormulationToSlopeAndYIntercept (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) |
DecisionBuilder * | MakeSweepDecisionBuilder (RoutingModel *model, bool check_assignment) |
DecisionBuilder * | MakeAllUnperformed (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< PathWithLength > | KShortestPathsOnDag (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< NodeIndex > | BuildEulerianPathFromNode (const Graph &graph, NodeIndex root) |
template<typename NodeIndex , typename Graph > | |
std::vector< NodeIndex > | BuildEulerianTourFromNode (const Graph &graph, NodeIndex root, bool assume_connectivity=true) |
template<typename Graph > | |
std::vector< typename Graph::NodeIndex > | BuildEulerianTour (const Graph &graph, bool assume_connectivity=true) |
template<typename Graph > | |
std::vector< typename Graph::NodeIndex > | BuildEulerianPath (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::ArcIndex > | BuildKruskalMinimumSpanningTreeFromSortedArcs (const Graph &graph, absl::Span< const typename Graph::ArcIndex > sorted_arcs) |
template<typename Graph , typename ArcComparator > | |
std::vector< typename Graph::ArcIndex > | BuildKruskalMinimumSpanningTree (const Graph &graph, const ArcComparator &arc_comparator) |
template<typename Graph , typename ArcValue > | |
std::vector< typename Graph::ArcIndex > | BuildPrimMinimumSpanningTree (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 ¶meters) |
bool | GScipTimeLimitSet (const GScipParameters ¶meters) |
void | GScipSetMaxNumThreads (int num_threads, GScipParameters *parameters) |
CHECK fails if num_threads < 1. | |
int | GScipMaxNumThreads (const GScipParameters ¶meters) |
Returns 1 if the number of threads it not specified. | |
bool | GScipMaxNumThreadsSet (const GScipParameters ¶meters) |
void | GScipSetLogLevel (GScipParameters *parameters, int log_level) |
int | GScipLogLevel (const GScipParameters ¶meters) |
bool | GScipLogLevelSet (const GScipParameters ¶meters) |
void | GScipSetOutputEnabled (GScipParameters *parameters, bool output_enabled) |
Sets the log level to 4 if enabled, 0 if disabled (see above). | |
bool | GScipOutputEnabled (const GScipParameters ¶meters) |
Checks if the log level is equal to zero. | |
bool | GScipOutputEnabledSet (const GScipParameters ¶meters) |
void | GScipSetRandomSeed (GScipParameters *parameters, int random_seed) |
int | GScipRandomSeed (const GScipParameters ¶meters) |
Returns -1 if unset. | |
bool | GScipRandomSeedSet (const GScipParameters ¶meters) |
void | GScipSetCatchCtrlC (bool catch_ctrl_c, GScipParameters *parameters) |
Sets the misc/catchctrlc property. | |
bool | GScipCatchCtrlC (const GScipParameters ¶meters) |
bool | GScipCatchCtrlCSet (const GScipParameters ¶meters) |
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) |
MPSolverInterface * | BuildBopInterface (MPSolver *const solver) |
Register BOP in the global linear solver factory. | |
MPSolverInterface * | BuildCBCInterface (MPSolver *const solver) |
MPSolverInterface * | BuildCLPInterface (MPSolver *const solver) |
MPSolverInterface * | BuildCplexInterface (bool mip, MPSolver *const solver) |
MPSolverInterface * | BuildGLOPInterface (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. | |
MPSolverInterface * | BuildGLPKInterface (bool mip, MPSolver *const solver) |
MPSolverInterface * | BuildGurobiInterface (bool mip, MPSolver *const solver) |
MPSolverInterface * | BuildHighsInterface (bool mip, MPSolver *const solver) |
Register PDLP in the global linear solver factory. | |
MPSolverInterface * | BuildKnapsackInterface (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. | |
MPSolverInterface * | BuildPdlpInterface (MPSolver *const solver) |
Register PDLP in the global linear solver factory. | |
MPSolverInterface * | BuildSatInterface (MPSolver *const solver) |
Register Sat in the global linear solver factory. | |
MPSolverInterface * | BuildSCIPInterface (MPSolver *const solver) |
MPSolverInterface * | BuildXpressInterface (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 ¶meters, 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 ¶meters) |
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::DenseRow > | ParseSolFile (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::DenseRow > | ParseSolString (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 ¶ms) |
::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) |
RangeIntToIntFunction * | MakeBareIntToIntFunction (std::function< int64_t(int64_t)> f) |
RangeIntToIntFunction * | MakeCachedIntToIntFunction (const std::function< int64_t(int64_t)> &f, int64_t domain_start, int64_t domain_end) |
RangeMinMaxIndexFunction * | MakeCachedRangeMinMaxIndexFunction (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 > | |
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 > | |
H | AbslHashValue (H h, const StrongIndex< StrongIndexName > &i) |
– ABSL HASHING SUPPORT --------------------------------------------------— | |
template<typename StrongIntegerName , typename H > | |
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 > | |
Demon * | MakeConstraintDemon0 (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 > | |
Demon * | MakeConstraintDemon1 (Solver *const s, T *const ct, void(T::*method)(P), const std::string &name, P param1) |
template<class T , class P , class Q > | |
Demon * | MakeConstraintDemon2 (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 > | |
Demon * | MakeConstraintDemon3 (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 > | |
Demon * | MakeDelayedConstraintDemon0 (Solver *const s, T *const ct, void(T::*method)(), const std::string &name) |
template<class T , class P > | |
Demon * | MakeDelayedConstraintDemon1 (Solver *const s, T *const ct, void(T::*method)(P), const std::string &name, P param1) |
template<class T , class P , class Q > | |
Demon * | MakeDelayedConstraintDemon2 (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 |
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
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
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.
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
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
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.
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
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.
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
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:
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
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
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
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
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
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.
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
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
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
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:
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
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.
Sweep heuristic
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
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).
(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
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
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
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
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
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:
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
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
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
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).
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
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
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.
The EbertGraph implementation has the following benefits:
The EbertGraph implementation differs from the implementation described in [Ebert 1987] in the following respects:
The ForwardEbertGraph representation is like the EbertGraph case described above, with the following modifications:
The ForwardStaticGraph representation is restricted yet farther than ForwardEbertGraph, with the benefit that it provides higher performance to those applications that can use it.
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
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:
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
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
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)).
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)
The advantage of the Held and Karp formulation is that it enables:
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
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.
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
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:
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)).
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.
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
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:
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.
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
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
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.
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
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
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
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
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
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.
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
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.
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
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
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
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:
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
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
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
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
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
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
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
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
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:
The utilities implemented by SparseVectorView<T> include:
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
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) { ///<
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.
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
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
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}});
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:
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
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
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
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:
3*x + 2*y + 5
.2*x
. It is used as an intermediate in the arithmetic operations that builds linear expressions.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
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)
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
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
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
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:
(b/180024054): add tests for:
(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
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 parameters are under-tested:
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
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.
(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
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:
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
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
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
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
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
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:
The format of the data is the following:
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
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
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
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:
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
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
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:
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
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
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
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
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
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.
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
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.
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
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
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
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
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:
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
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
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
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
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:
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
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:
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
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
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.
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
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
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.
(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
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
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
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:
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
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
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
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.
using operations_research::AlignedAllocator |
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.
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.
using operations_research::ArcId = SubDagComputer::ArcId |
Definition at line 4032 of file local_search.cc.
typedef int32_t operations_research::ArcIndex |
Definition at line 200 of file ebert_graph.h.
Definition at line 207 of file ebert_graph.h.
using operations_research::BaseInt = int |
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.
using operations_research::ColumnEntryRange = util_intops::StrongIntRange<ColumnEntryIndex> |
Definition at line 85 of file set_cover_model.h.
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.
Definition at line 92 of file set_cover_model.h.
Definition at line 209 of file ebert_graph.h.
typedef BlossomGraph::CostValue operations_research::CostValue = BlossomGraph::CostValue |
Definition at line 202 of file ebert_graph.h.
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.
Definition at line 93 of file set_cover_model.h.
Definition at line 100 of file set_cover_model.h.
using operations_research::ElementRange = util_intops::StrongIntRange<ElementIndex> |
Definition at line 84 of file set_cover_model.h.
Definition at line 109 of file set_cover_model.h.
typedef int64_t operations_research::FlowQuantity |
Definition at line 201 of file ebert_graph.h.
Definition at line 204 of file ebert_graph.h.
Definition at line 205 of file ebert_graph.h.
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.
Type of graph to use.
Definition at line 174 of file solve_flow_model.cc.
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.
typedef ZVector<int16_t> operations_research::Int16ZVector |
typedef ZVector<int32_t> operations_research::Int32ZVector |
typedef ZVector<int64_t> operations_research::Int64ZVector |
typedef ZVector<int8_t> operations_research::Int8ZVector |
Definition at line 108 of file set_cover_model.h.
Definition at line 335 of file knapsack_solver.h.
using operations_research::NodeId = SubDagComputer::NodeId |
Definition at line 3986 of file local_search.cc.
typedef RoutingIndexManager::NodeIndex operations_research::NodeIndex = BlossomGraph::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.
Definition at line 206 of file ebert_graph.h.
typedef uint32_t operations_research::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.
typedef int operations_research::PathNodeIndex |
Definition at line 449 of file hamiltonian_path.h.
Definition at line 208 of file ebert_graph.h.
using operations_research::random_engine_t = std::mt19937_64 |
Definition at line 23 of file random_engine.h.
typedef std::function<int64_t(RoutingNodeIndex, RoutingNodeIndex)> operations_research::RoutingNodeEvaluator2 |
Definition at line 30 of file cvrptw_lib.h.
typedef std::function<int64_t(int64_t)> operations_research::RoutingTransitCallback1 |
Definition at line 50 of file routing_types.h.
typedef std::function<int64_t(int64_t, int64_t)> operations_research::RoutingTransitCallback2 |
Definition at line 51 of file routing_types.h.
Definition at line 103 of file set_cover_model.h.
using operations_research::SparseColumnView = util_intops::StrongVector<SubsetIndex, SparseColumn> |
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.
Definition at line 105 of file set_cover_model.h.
using operations_research::SparseRowView = util_intops::StrongVector<ElementIndex, SparseRow> |
Definition at line 117 of file set_cover_model.h.
Definition at line 203 of file ebert_graph.h.
using operations_research::StrictVector = glop::StrictITIVector<IndexType, ValueType> |
Definition at line 43 of file set_cover_mip.cc.
Definition at line 95 of file set_cover_model.h.
using operations_research::SubsetBoolVector = util_intops::StrongVector<SubsetIndex, bool> |
Definition at line 119 of file set_cover_model.h.
Definition at line 98 of file set_cover_model.h.
using operations_research::SubsetRange = util_intops::StrongIntRange<SubsetIndex> |
Definition at line 83 of file set_cover_model.h.
Definition at line 111 of file set_cover_model.h.
typedef ZVector<uint16_t> operations_research::UInt16ZVector |
typedef ZVector<uint32_t> operations_research::UInt32ZVector |
typedef ZVector<uint64_t> operations_research::UInt64ZVector |
typedef ZVector<uint8_t> operations_research::UInt8ZVector |
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.
using operations_research::value_type_t = typename std::iterator_traits<Iterator>::value_type |
using operations_research::VariableDomainId = LocalSearchState::VariableDomainId |
Definition at line 3867 of file local_search.cc.
|
strong |
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. |
|
strong |
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. |
|
strong |
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.
Definition at line 462 of file gscip_constraint_handler.h.
Enumerator | |
---|---|
CALLBACK_EXCEPTION |
Definition at line 199 of file xpress_interface.cc.
|
strong |
Definition at line 157 of file routing_lp_scheduling.h.
|
strong |
Equivalent to type_result.h in SCIP.
Definition at line 23 of file gscip_callback_result.h.
|
strong |
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.
|
strong |
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.
Definition at line 34 of file linear_solver_callback.h.
|
strong |
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.
|
strong |
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.
|
strong |
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.
|
strong |
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.
|
strong |
Enumerator | |
---|---|
kLazyConstraintAdded | |
kCuttingPlaneAdded | |
kDidNotFind |
Definition at line 95 of file scip_callback.cc.
|
strong |
Enumerator | |
---|---|
SCIP | |
SAT | |
GUROBI | |
GLOP | |
PDLP |
Definition at line 22 of file set_cover_mip.h.
Definition at line 144 of file model_builder_helper.h.
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.
Enumerator | |
---|---|
XPRS_AT_LOWER | |
XPRS_BASIC | |
XPRS_AT_UPPER | |
XPRS_FREE_SUPER |
Definition at line 206 of file xpress_interface.cc.
H operations_research::AbslHashValue | ( | H | h, |
const StrongIndex< StrongIndexName > & | i ) |
– ABSL HASHING SUPPORT --------------------------------------------------—
Definition at line 338 of file strong_integers.h.
H operations_research::AbslHashValue | ( | H | h, |
const StrongInt64< StrongIntegerName > & | i ) |
Definition at line 343 of file strong_integers.h.
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.
void operations_research::AbslStringify | ( | Sink & | sink, |
StrongIndex< T... > | arg ) |
Definition at line 256 of file strong_integers.h.
void operations_research::AbslStringify | ( | Sink & | sink, |
StrongInt64< T... > | arg ) |
Definition at line 267 of file strong_integers.h.
|
inline |
Definition at line 1013 of file linear_solver.h.
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.
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.
void operations_research::AcceptUncheckedNeighbor | ( | Search * | search | ) |
Definition at line 1386 of file constraint_solver.cc.
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.
|
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.
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.
|
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.
Definition at line 122 of file saturated_arithmetic.h.
|
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.
|
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.
|
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.
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.
Definition at line 2169 of file routing_filters.cc.
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.
void operations_research::AppendTasksFromIntervals | ( | const std::vector< IntervalVar * > & | intervals, |
DisjunctivePropagator::Tasks * | tasks ) |
Definition at line 694 of file routing_breaks.cc.
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.
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:
We need to copy the hint because LinearProgramToMPModelProto() loose it.
These presolve might change the problem size.
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.
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.
|
inline |
Definition at line 3284 of file constraint_solveri.h.
|
inline |
Definition at line 3275 of file constraint_solveri.h.
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.
|
inline |
Returns true if all variables are assigned to 'value'.
Definition at line 3302 of file constraint_solveri.h.
bool operations_research::AreAllGreaterOrEqual | ( | const std::vector< T > & | values, |
const T & | value ) |
Definition at line 3205 of file constraint_solveri.h.
bool operations_research::AreAllLessOrEqual | ( | const std::vector< T > & | values, |
const T & | value ) |
Definition at line 3215 of file constraint_solveri.h.
bool operations_research::AreAllNegative | ( | const std::vector< T > & | values | ) |
Definition at line 3230 of file constraint_solveri.h.
bool operations_research::AreAllNull | ( | const std::vector< T > & | values | ) |
Definition at line 3200 of file constraint_solveri.h.
bool operations_research::AreAllOnes | ( | const std::vector< T > & | values | ) |
Definition at line 3195 of file constraint_solveri.h.
bool operations_research::AreAllPositive | ( | const std::vector< T > & | values | ) |
Definition at line 3225 of file constraint_solveri.h.
bool operations_research::AreAllStrictlyNegative | ( | const std::vector< T > & | values | ) |
Definition at line 3240 of file constraint_solveri.h.
bool operations_research::AreAllStrictlyPositive | ( | const std::vector< T > & | values | ) |
Definition at line 3235 of file constraint_solveri.h.
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.
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.
|
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:
|
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.
|
inline |
Convenience versions of the above that take a string argument.
Definition at line 56 of file strtoint.h.
|
inline |
Definition at line 57 of file strtoint.h.
operations_research::FirstSolutionStrategy::Value operations_research::AutomaticFirstSolutionStrategy | ( | bool | has_pickup_deliveries, |
bool | has_node_precedences, | ||
bool | has_single_vehicle_node ) |
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.
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.
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); });
Ideally, f is a monotonic boolean function, such that:
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:
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.
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.
|
inline |
|
inline |
uint32_t operations_research::BitCountRange32 | ( | const uint32_t * | bitset, |
uint32_t | start, | ||
uint32_t | end ) |
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.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
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.
|
inline |
|
inline |
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.
MPSolverInterface * operations_research::BuildCBCInterface | ( | MPSolver *const | solver | ) |
Definition at line 533 of file cbc_interface.cc.
MPSolverInterface * operations_research::BuildCLPInterface | ( | MPSolver *const | solver | ) |
Definition at line 625 of file clp_interface.cc.
MPSolverInterface * operations_research::BuildCplexInterface | ( | bool | mip, |
MPSolver *const | solver ) |
Definition at line 1286 of file cplex_interface.cc.
|
extern |
Definition at line 445 of file demon_profiler.cc.
IntExpr * operations_research::BuildDurationExpr | ( | IntervalVar * | var | ) |
Definition at line 171 of file sched_expr.cc.
IntExpr * operations_research::BuildEndExpr | ( | IntervalVar * | var | ) |
Definition at line 181 of file sched_expr.cc.
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.
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.
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.
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.
MPSolverInterface * operations_research::BuildGLOPInterface | ( | MPSolver *const | solver | ) |
Register GLOP in the global linear solver factory.
Definition at line 441 of file glop_interface.cc.
MPSolverInterface * operations_research::BuildGLPKInterface | ( | bool | mip, |
MPSolver *const | solver ) |
Definition at line 964 of file glpk_interface.cc.
MPSolverInterface * operations_research::BuildGurobiInterface | ( | bool | mip, |
MPSolver *const | solver ) |
Definition at line 1403 of file gurobi_interface.cc.
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.
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.
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.
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)).
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.
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.
|
extern |
Definition at line 3227 of file constraint_solver.cc.
|
extern |
Definition at line 4582 of file local_search.cc.
|
extern |
Definition at line 846 of file model_cache.cc.
|
extern |
Register PDLP in the global linear solver factory.
Definition at line 314 of file pdlp_interface.cc.
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.
|
extern |
IntExpr * operations_research::BuildSafeDurationExpr | ( | IntervalVar * | var, |
int64_t | unperformed_value ) |
Definition at line 196 of file sched_expr.cc.
IntExpr * operations_research::BuildSafeEndExpr | ( | IntervalVar * | var, |
int64_t | unperformed_value ) |
Definition at line 201 of file sched_expr.cc.
IntExpr * operations_research::BuildSafeStartExpr | ( | IntervalVar * | var, |
int64_t | unperformed_value ) |
Definition at line 191 of file sched_expr.cc.
|
extern |
Register Sat in the global linear solver factory.
Definition at line 275 of file sat_interface.cc.
|
extern |
Definition at line 1155 of file scip_interface.cc.
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.
|
extern |
Definition at line 3151 of file constraint_solver.cc.
|
extern |
Definition at line 2096 of file xpress_interface.cc.
|
inline |
Definition at line 61 of file saturated_arithmetic.h.
|
inline |
Definition at line 292 of file saturated_arithmetic.h.
|
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.
|
inline |
Definition at line 302 of file saturated_arithmetic.h.
|
inline |
Note(user): -kint64min != kint64max, but kint64max == ~kint64min.
Definition at line 59 of file saturated_arithmetic.h.
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.
|
inline |
Definition at line 314 of file saturated_arithmetic.h.
|
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.
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.
|
inline |
Definition at line 304 of file saturated_arithmetic.h.
|
inline |
Definition at line 238 of file saturated_arithmetic.h.
|
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.
int64_t operations_research::CeilRatio | ( | int64_t | value, |
int64_t | positive_coeff ) |
Definition at line 95 of file sorted_interval_list.cc.
void operations_research::CheckNodeIsValid | ( | typename GraphType::NodeIndex | node, |
const GraphType & | graph ) |
Definition at line 315 of file dag_shortest_path.h.
BaseAssignVariables::Mode operations_research::ChooseMode | ( | Solver::IntValueStrategy | val_str | ) |
|
extern |
---------------— Queue class ---------------—
--— API --—
Definition at line 6391 of file expressions.cc.
|
inline |
|
inline |
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.
Actually sample sampled_subset.
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.
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.
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.
Definition at line 560 of file set_cover_heuristics.cc.
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.
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.
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.
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:
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.
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.
|
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.
|
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.
|
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.
|
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):
Definition at line 88 of file glpk_computational_form.h.
|
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
SCIP_RESULT operations_research::ConvertGScipCallbackResult | ( | const GScipCallbackResult | result | ) |
Definition at line 20 of file gscip_callback_result.cc.
|
inline |
Some SolveWithProto() returns a StatusOr<MPModelResponse>, this utility just convert bad absl::StatusOr to a proper error in MPModelResponse.
Definition at line 41 of file proto_utils.h.
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.
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
Definition at line 314 of file binary_search.h.
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.
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.
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.
|
inline |
Definition at line 178 of file constraint_solver.h.
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.
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.
const GScipConstraintOptions & operations_research::DefaultGScipConstraintOptions | ( | ) |
const GScipVariableOptions & operations_research::DefaultGScipVariableOptions | ( | ) |
std::string operations_research::DefaultPhaseStatString | ( | DecisionBuilder * | db | ) |
-------— API -------—
Definition at line 1121 of file default_search.cc.
RoutingModelParameters operations_research::DefaultRoutingModelParameters | ( | ) |
Definition at line 41 of file routing_parameters.cc.
RoutingSearchParameters operations_research::DefaultRoutingSearchParameters | ( | ) |
static
Definition at line 214 of file routing_parameters.cc.
RoutingSearchParameters operations_research::DefaultSecondaryRoutingSearchParameters | ( | ) |
Definition at line 220 of file routing_parameters.cc.
operations_research::DEFINE_INT_TYPE | ( | RoutingCostClassIndex | , |
int | ) |
operations_research::DEFINE_INT_TYPE | ( | RoutingDimensionIndex | , |
int | ) |
operations_research::DEFINE_INT_TYPE | ( | RoutingDisjunctionIndex | , |
int | ) |
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.
operations_research::DEFINE_INT_TYPE | ( | RoutingResourceClassIndex | , |
int | ) |
operations_research::DEFINE_INT_TYPE | ( | RoutingVehicleClassIndex | , |
int | ) |
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.
operations_research::DEFINE_STRONG_INT_TYPE | ( | ElementIndex | , |
BaseInt | ) |
Element index.
operations_research::DEFINE_STRONG_INT_TYPE | ( | RowEntryIndex | , |
BaseInt | ) |
operations_research::DEFINE_STRONG_INT_TYPE | ( | SubsetIndex | , |
BaseInt | ) |
We make heavy use of strong typing to avoid obvious mistakes. Subset index.
|
extern |
Definition at line 453 of file demon_profiler.cc.
|
extern |
Definition at line 4589 of file local_search.cc.
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.
void operations_research::DemonProfilerBeginInitialPropagation | ( | DemonProfiler *const | monitor, |
Constraint *const | constraint ) |
Definition at line 488 of file demon_profiler.cc.
void operations_research::DemonProfilerEndInitialPropagation | ( | DemonProfiler *const | monitor, |
Constraint *const | constraint ) |
Definition at line 493 of file demon_profiler.cc.
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.
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.
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.
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.
std::string operations_research::DomainToString | ( | const ::google::protobuf::RepeatedField< int64_t > * | domain | ) |
Definition at line 2981 of file routing_lp_scheduling.cc.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
void operations_research::fast_scalbn_inplace | ( | double & | mutable_value, |
int | exponent ) |
Definition at line 242 of file fp_utils.cc.
uint64_t operations_research::fasthash64 | ( | const void * | buf, |
size_t | len, | ||
uint64_t | seed ) |
void operations_research::FillPathEvaluation | ( | const std::vector< int64_t > & | path, |
const RoutingModel::TransitCallback2 & | evaluator, | ||
std::vector< int64_t > * | values ) |
Definition at line 6095 of file routing.cc.
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.
|
inline |
Definition at line 3331 of file constraint_solveri.h.
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.
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.
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.
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.
accept_trivially_infeasible_bounds | If 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.
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.
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.
std::string operations_research::FindFeasibilityErrorInSolutionHint | ( | const MPModelProto & | model, |
double | tolerance ) |
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.
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.
Definition at line 120 of file routing_utils.cc.
void operations_research::FixFlagsAndEnvironmentForSwig | ( | ) |
Definition at line 29 of file logging.cc.
int64_t operations_research::FloorRatio | ( | int64_t | value, |
int64_t | positive_coeff ) |
Definition at line 102 of file sorted_interval_list.cc.
|
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.
std::string operations_research::FormatStatistic | ( | absl::string_view | name, |
T | value, | ||
RoutingOutputFormat | format ) |
Formats a solution or solver statistic according to the given format.
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.
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.
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.
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):
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 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.
Definition at line 197 of file fp_utils.cc.
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.
void operations_research::GetGraphNodesFromGraph | ( | const GraphType & | graph, |
std::vector< typename GraphType::NodeIndex > * | nodes ) |
Definition at line 171 of file shortest_paths.h.
absl::StatusOr< GRBenv * > operations_research::GetGurobiEnv | ( | ) |
Definition at line 453 of file environment.cc.
std::vector< int > operations_research::GetInversePermutation | ( | absl::Span< const int > | permutation | ) |
Definition at line 92 of file dag_constrained_shortest_path.cc.
int operations_research::getitcnt | ( | const XPRSprob & | mLp | ) |
Definition at line 170 of file xpress_interface.cc.
|
static |
Definition at line 507 of file xpress_interface.cc.
|
static |
Definition at line 829 of file xpress_interface.cc.
|
static |
Definition at line 592 of file xpress_interface.cc.
|
static |
Definition at line 492 of file xpress_interface.cc.
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(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.
int operations_research::getnodecnt | ( | const XPRSprob & | mLp | ) |
Definition at line 176 of file xpress_interface.cc.
int operations_research::getnumcols | ( | const XPRSprob & | mLp | ) |
Definition at line 158 of file xpress_interface.cc.
int operations_research::getnumrows | ( | const XPRSprob & | mLp | ) |
Definition at line 164 of file xpress_interface.cc.
int64_t operations_research::GetProcessMemoryUsage | ( | ) |
GetProcessMemoryUsage.
Returns the memory usage of the process.
Definition at line 88 of file sysinfo.cc.
int32_t operations_research::GetSeed | ( | bool | deterministic | ) |
Random seed generator.
Definition at line 35 of file cvrptw_lib.cc.
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.
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.
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.
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.
MPSolver::BasisStatus operations_research::GlopToMPSolverConstraintStatus | ( | glop::ConstraintStatus | s | ) |
Definition at line 91 of file glop_utils.cc.
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.
Definition at line 18 of file glop_utils.cc.
MPSolver::BasisStatus operations_research::GlopToMPSolverVariableStatus | ( | glop::VariableStatus | s | ) |
Definition at line 57 of file glop_utils.cc.
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.
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 = "" ) |
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.
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.
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.
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.
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.
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.
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.
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.
GScipLinearExpr operations_research::GScipDifference | ( | GScipLinearExpr | left, |
const GScipLinearExpr & | right ) |
Returns left - right.
Definition at line 43 of file gscip_ext.cc.
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.
int operations_research::GScipLogLevel | ( | const GScipParameters & | parameters | ) |
Definition at line 88 of file gscip_parameters.cc.
bool operations_research::GScipLogLevelSet | ( | const GScipParameters & | parameters | ) |
Definition at line 93 of file gscip_parameters.cc.
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.
bool operations_research::GScipMaxNumThreadsSet | ( | const GScipParameters & | parameters | ) |
Definition at line 77 of file gscip_parameters.cc.
GScipLinearExpr operations_research::GScipNegate | ( | GScipLinearExpr | expr | ) |
Returns -expr.
Definition at line 52 of file gscip_ext.cc.
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.
bool operations_research::GScipOutputEnabledSet | ( | const GScipParameters & | parameters | ) |
Definition at line 109 of file gscip_parameters.cc.
int operations_research::GScipRandomSeed | ( | const GScipParameters & | parameters | ) |
Returns -1 if unset.
Definition at line 119 of file gscip_parameters.cc.
bool operations_research::GScipRandomSeedSet | ( | const GScipParameters & | parameters | ) |
Definition at line 126 of file gscip_parameters.cc.
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.
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.
void operations_research::GScipSetMaxNumThreads | ( | int | num_threads, |
GScipParameters * | parameters ) |
CHECK fails if num_threads < 1.
Definition at line 64 of file gscip_parameters.cc.
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.
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.
void operations_research::GScipSetTimeLimit | ( | absl::Duration | time_limit, |
GScipParameters * | parameters ) |
Definition at line 36 of file gscip_parameters.cc.
absl::Duration operations_research::GScipTimeLimit | ( | const GScipParameters & | parameters | ) |
Definition at line 45 of file gscip_parameters.cc.
bool operations_research::GScipTimeLimitSet | ( | const GScipParameters & | parameters | ) |
Definition at line 60 of file gscip_parameters.cc.
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.
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.
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.
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.
|
inline |
Definition at line 273 of file constraint_solveri.h.
uint64_t operations_research::Hash1 | ( | const std::vector< T * > & | ptrs | ) |
Definition at line 263 of file constraint_solveri.h.
|
inline |
Definition at line 251 of file constraint_solveri.h.
|
inline |
Definition at line 247 of file constraint_solveri.h.
|
inline |
Definition at line 236 of file constraint_solveri.h.
|
inline |
Hash functions
value = (value << 21) - value - 1;
value * 265
value * 21
Definition at line 225 of file constraint_solveri.h.
|
inline |
Definition at line 253 of file constraint_solveri.h.
absl::StatusOr< MPSolutionResponse > operations_research::HighsSolveProto | ( | LazyMutableCopy< MPModelRequest > | request | ) |
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.
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.
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.
bool operations_research::InputContainsNan | ( | absl::Span< const std::vector< double > > | input | ) |
Definition at line 643 of file hungarian.cc.
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.
|
extern |
--— Forward Declarations and Profiling Support --—
--— Exported Functions --—
Definition at line 443 of file demon_profiler.cc.
|
extern |
Definition at line 4578 of file local_search.cc.
std::string operations_research::Int64ToStr | ( | int64_t | number | ) |
Definition at line 2975 of file routing_lp_scheduling.cc.
Definition at line 965 of file constraint_solver.cc.
|
inline |
Returns alpha * x + (1 - alpha) * y.
Definition at line 246 of file fp_utils.h.
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.
|
inline |
|
inline |
bool operations_research::IntervalsAreSortedAndNonAdjacent | ( | absl::Span< const ClosedInterval > | intervals | ) |
Returns true iff we have:
First test make sure that intervals[i - 1].end + 1 will not overflow.
Definition at line 40 of file sorted_interval_list.cc.
|
inline |
|
inline |
|
inline |
Returns true when ptr
is aligned to alignment_bytes
bytes.
Definition at line 64 of file aligned_memory.h.
bool operations_research::IsArrayBoolean | ( | const std::vector< T > & | values | ) |
Definition at line 3185 of file constraint_solveri.h.
bool operations_research::IsArrayConstant | ( | const std::vector< T > & | values, |
const T & | value ) |
Definition at line 3175 of file constraint_solveri.h.
bool operations_research::IsArrayInRange | ( | const std::vector< IntVar * > & | vars, |
T | range_min, | ||
T | range_max ) |
Definition at line 3265 of file constraint_solveri.h.
|
inline |
|
inline |
bool operations_research::IsEmptyRange32 | ( | const uint32_t * | bitset, |
uint32_t | start, | ||
uint32_t | end ) |
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.
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.
bool operations_research::IsIncreasing | ( | const std::vector< T > & | values | ) |
Definition at line 3255 of file constraint_solveri.h.
bool operations_research::IsIncreasingContiguous | ( | const std::vector< T > & | values | ) |
Definition at line 3245 of file constraint_solveri.h.
|
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.
|
inline |
Definition at line 113 of file fp_utils.h.
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.
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.
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.
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.
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.
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.
void operations_research::KeepAbslSymbols | ( | ) |
Definition at line 37 of file logging.cc.
|
constexpr |
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.
int operations_research::LeastSignificantBitPosition32 | ( | const uint32_t * | bitset, |
uint32_t | start, | ||
uint32_t | end ) |
|
inline |
|
inline |
|
inline |
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.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
absl::Status operations_research::LegacyScipSetSolverSpecificParameters | ( | absl::string_view | parameters, |
SCIP * | scip ) |
Definition at line 35 of file legacy_scip_params.cc.
bool operations_research::LinearConstraintIsViolated | ( | const ScipConstraintHandlerContext & | context, |
const LinearRange & | constraint ) |
Definition at line 101 of file scip_callback.cc.
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.
Definition at line 418 of file environment.cc.
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.
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.
Definition at line 221 of file environment.cc.
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.
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.
tmp_mask | For 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.
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.
void operations_research::log_full_license_error | ( | int | code, |
const std::string & | xpress_lib_dir ) |
Definition at line 343 of file environment.cc.
void operations_research::log_message_about_XPRSinit_argument | ( | ) |
Definition at line 354 of file environment.cc.
DecisionBuilder * operations_research::MakeAllUnperformed | ( | RoutingModel * | model | ) |
Returns a DecisionBuilder making all nodes unperformed.
Definition at line 4808 of file routing_search.cc.
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.
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.
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.
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.
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.
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.
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.
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.
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.
IntVarLocalSearchFilter * operations_research::MakeCumulBoundsPropagatorFilter | ( | const RoutingDimension & | dimension | ) |
Returns a filter handling dimension cumul bounds.
Definition at line 2585 of file routing_filters.cc.
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.
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.
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.
Constraint * operations_research::MakeDifferentFromValues | ( | Solver * | solver, |
IntVar * | var, | ||
std::vector< int64_t > | values ) |
Definition at line 59 of file routing_constraints.cc.
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:
Definition at line 3400 of file local_search.cc.
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.
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.
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 ) |
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.
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.
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.
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.
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.
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.
Constraint * operations_research::MakePathSpansAndTotalSlacks | ( | const RoutingDimension * | dimension, |
std::vector< IntVar * > | spans, | ||
std::vector< IntVar * > | total_slacks ) |
For every vehicle of the routing model:
Definition at line 629 of file routing_constraints.cc.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
IntVarLocalSearchFilter * operations_research::MakeVehicleAmortizedCostFilter | ( | const RoutingModel & | routing_model | ) |
Returns a filter computing vehicle amortized costs.
Definition at line 664 of file routing_filters.cc.
IntVarLocalSearchFilter * operations_research::MakeVehicleBreaksFilter | ( | const RoutingModel & | routing_model, |
const RoutingDimension & | dimension ) |
Definition at line 1081 of file routing_breaks.cc.
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.
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.
|
inline |
The std::max<int64_t> is needed for compilation on MSVC.
Definition at line 3311 of file constraint_solveri.h.
std::string operations_research::MemoryUsage | ( | ) |
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.
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.
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.
|
inline |
The std::min<int64_t> is needed for compilation on MSVC.
Definition at line 3321 of file constraint_solveri.h.
|
inlinestatic |
int operations_research::MostSignificantBitPosition32 | ( | const uint32_t * | bitset, |
uint32_t | start, | ||
uint32_t | end ) |
|
inline |
|
inline |
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.
|
inline |
|
inline |
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.
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.
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.
glop::ConstraintStatus operations_research::MPSolverToGlopConstraintStatus | ( | MPSolver::BasisStatus | s | ) |
Definition at line 108 of file glop_utils.cc.
glop::VariableStatus operations_research::MPSolverToGlopVariableStatus | ( | MPSolver::BasisStatus | s | ) |
Definition at line 74 of file glop_utils.cc.
|
static |
Transform MPSolver basis status to XPRESS status.
Definition at line 1264 of file xpress_interface.cc.
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:
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.
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.
std::vector< typename GraphType::NodeIndex > operations_research::NodePathImpliedBy | ( | absl::Span< const typename GraphType::ArcIndex > | arc_path, |
const GraphType & | graph ) |
Implementations.
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.
|
inline |
This method returns 1.
Definition at line 3362 of file constraint_solver.h.
|
inline |
|
inline |
|
inline |
LinearExpr operations_research::operator* | ( | double | lhs, |
LinearExpr | rhs ) |
Definition at line 168 of file linear_expr.cc.
LinearExpr operations_research::operator* | ( | LinearExpr | lhs, |
double | rhs ) |
Definition at line 160 of file linear_expr.cc.
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.
LinearExpr operations_research::operator- | ( | LinearExpr | lhs, |
const LinearExpr & | rhs ) |
Definition at line 156 of file linear_expr.cc.
LinearExpr operations_research::operator/ | ( | LinearExpr | lhs, |
double | rhs ) |
Definition at line 164 of file linear_expr.cc.
|
inline |
Definition at line 997 of file linear_solver.h.
|
inline |
Definition at line 1003 of file linear_solver.h.
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.
std::ostream & operations_research::operator<< | ( | std::ostream & | os, |
StrongInt64< StrongIntegerName > | arg ) |
Definition at line 261 of file strong_integers.h.
std::ostream & operations_research::operator<< | ( | std::ostream & | out, |
const Assignment & | assignment ) |
Definition at line 1021 of file assignment.cc.
std::ostream & operations_research::operator<< | ( | std::ostream & | out, |
const BaseObject *const | o ) |
Definition at line 2488 of file constraint_solver.cc.
std::ostream & operations_research::operator<< | ( | std::ostream & | out, |
const ClosedInterval & | interval ) |
Definition at line 109 of file sorted_interval_list.cc.
std::ostream & operations_research::operator<< | ( | std::ostream & | out, |
const Domain & | domain ) |
Definition at line 118 of file sorted_interval_list.cc.
std::ostream & operations_research::operator<< | ( | std::ostream & | out, |
const RoundTripDoubleFormat & | format ) |
Definition at line 110 of file fp_roundtrip_conv.cc.
std::ostream & operations_research::operator<< | ( | std::ostream & | out, |
const Solver *const | s ) |
---------------— Useful Operators ---------------—
Definition at line 2483 of file constraint_solver.cc.
std::ostream & operations_research::operator<< | ( | std::ostream & | out, |
const std::vector< ClosedInterval > & | intervals ) |
Definition at line 113 of file sorted_interval_list.cc.
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.
std::ostream & operations_research::operator<< | ( | std::ostream & | stream, |
const LinearExpr & | linear_expr ) |
Definition at line 147 of file linear_expr.cc.
LinearRange operations_research::operator<= | ( | const LinearExpr & | lhs, |
const LinearExpr & | rhs ) |
Definition at line 183 of file linear_expr.cc.
LinearRange operations_research::operator== | ( | const LinearExpr & | lhs, |
const LinearExpr & | rhs ) |
Definition at line 186 of file linear_expr.cc.
LinearRange operations_research::operator>= | ( | const LinearExpr & | lhs, |
const LinearExpr & | rhs ) |
Definition at line 189 of file linear_expr.cc.
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.
int operations_research::OrToolsMajorVersion | ( | ) |
Definition at line 22 of file version.cc.
int operations_research::OrToolsMinorVersion | ( | ) |
Definition at line 24 of file version.cc.
int operations_research::OrToolsPatchVersion | ( | ) |
Definition at line 26 of file version.cc.
std::string operations_research::OrToolsVersionString | ( | ) |
Definition at line 28 of file version.cc.
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.
std::string operations_research::ParameterDebugString | ( | P | param | ) |
Definition at line 536 of file constraint_solveri.h.
void operations_research::ParseAndSolve | ( | const std::string & | filename, |
absl::string_view | solver, | ||
const std::string & | params ) |
Build optimization model.
Definition at line 41 of file vector_bin_packing_main.cc.
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.
absl::StatusOr< MPSolutionResponse > operations_research::ParseSolFile | ( | absl::string_view | file_name, |
const MPModelProto & | model ) |
Definition at line 41 of file sol_reader.cc.
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.
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.
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
.
Definition at line 82 of file parse_proto.cc.
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.
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.
absl::Status operations_research::PortableDeleteFile | ( | absl::string_view | file_name | ) |
absl::Status operations_research::PortableFileGetContents | ( | absl::string_view | file_name, |
std::string * | output ) |
absl::Status operations_research::PortableFileSetContents | ( | absl::string_view | file_name, |
absl::string_view | content ) |
bool operations_research::PortableTemporaryFile | ( | const char * | directory_prefix, |
std::string * | filename_out ) |
|
inline |
Definition at line 3345 of file constraint_solveri.h.
|
inline |
Definition at line 3340 of file constraint_solveri.h.
void operations_research::printError | ( | const XPRSprob & | mLp, |
int | line ) |
Definition at line 137 of file xpress_interface.cc.
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.
void operations_research::printXpressBanner | ( | bool | error | ) |
clang-format on
Definition at line 169 of file environment.cc.
|
inline |
Definition at line 22 of file testing_utils.h.
std::string operations_research::ProtobufDebugString | ( | const P & | message | ) |
Definition at line 32 of file proto_utils.h.
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.
Definition at line 86 of file proto_utils.h.
std::string operations_research::ProtobufShortDebugString | ( | const P & | message | ) |
Definition at line 41 of file proto_utils.h.
bool operations_research::ProtobufTextFormatMergeFromString | ( | absl::string_view | proto_text_string, |
ProtoType * | proto ) |
Definition at line 66 of file proto_utils.h.
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.
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.
std::string operations_research::ProtoEnumToString | ( | ProtoEnumType | enum_value | ) |
Definition at line 50 of file proto_utils.h.
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.
Definition at line 247 of file radix_sort.h.
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,
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.
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.
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,
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.
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.
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.
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.
Starts by splitting interval in two with two queries and getting some info. Note the current min will be outside the interval.
Definition at line 237 of file binary_search.h.
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.
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".
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.
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.
std::vector< Proto > operations_research::ReadAllRecordsOrDie | ( | File * | file | ) |
Definition at line 121 of file file_util.h.
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.
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.
absl::Status operations_research::ReadFile | ( | absl::string_view | file_name, |
CapacityPlanningInstance * | request ) |
implicit.
Definition at line 33 of file dow_parser.cc.
absl::StatusOr< Proto > operations_research::ReadFileToProto | ( | absl::string_view | filename, |
bool | allow_partial = false ) |
Definition at line 51 of file file_util.h.
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).
allow_partial | If 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.
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.
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.
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.
Definition at line 59 of file xpress_interface.cc.
QapProblem operations_research::ReadQapProblemOrDie | ( | absl::string_view | filepath | ) |
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.
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.
void operations_research::RealDebugString | ( | const Container & | container, |
std::string *const | out ) |
Definition at line 614 of file assignment.cc.
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.
void operations_research::RealSave | ( | AssignmentProto *const | assignment_proto, |
const Container & | container, | ||
Proto *(AssignmentProto::* | Add )() ) |
Definition at line 578 of file assignment.cc.
void operations_research::RegisterConstraintHandler | ( | ScipConstraintHandler< Constraint > * | handler, |
SCIP * | scip ) |
handler is not owned but held.
void operations_research::RegisterConstraintHandler | ( | ScipConstraintHandler< ConstraintData > * | handler, |
SCIP * | scip ) |
Definition at line 251 of file scip_callback.h.
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.
|
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.
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.
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 ) |
Definition at line 746 of file rooted_tree.h.
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).
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.
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.
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.
Definition at line 118 of file scip_callback.cc.
void operations_research::RunWorker | ( | void * | data | ) |
Definition at line 23 of file threadpool.cc.
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.
absl::StatusOr< const Proto * > operations_research::SafeProtoConstDownCast | ( | const google::protobuf::Message * | proto | ) |
Definition at line 63 of file proto_tools.h.
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.
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.
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.
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.
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.
Copy and postsolve any additional solutions.
If the scaling factor is unset/zero, it is assumed to be one.
Definition at line 160 of file sat_proto_solver.cc.
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.
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.
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.
|
inline |
|
inline |
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.
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.
int operations_research::setobjoffset | ( | const XPRSprob & | mLp, |
double | value ) |
Definition at line 182 of file xpress_interface.cc.
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.
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.
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.
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.
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.
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.
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 | ) |
std::string operations_research::SolutionStatusString | ( | const int | status | ) |
Formats a solution status (GLP_OPT,...).
Definition at line 30 of file glpk_formatters.cc.
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.
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.
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.
Definition at line 1140 of file routing_sat.cc.
MPSolutionResponse operations_research::SolveMPModel | ( | LazyMutableCopy< MPModelRequest > | request, |
const SolveInterrupter * | interrupter ) |
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.
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.
|
inline |
Definition at line 990 of file linear_solver.h.
bool operations_research::SolverTypeSupportsInterruption | ( | const MPModelRequest::SolverType | solver | ) |
Definition at line 44 of file solve_mp_model.cc.
void operations_research::splitMyString | ( | const std::string & | str, |
Container & | cont, | ||
char | delim = ' ' ) |
Definition at line 2101 of file xpress_interface.cc.
const char * operations_research::stringToCharPtr | ( | std::string & | var | ) |
Definition at line 2109 of file xpress_interface.cc.
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.
operations_research::STRONG_TYPE_ARITHMETIC_OP | ( | StrongIndex | , |
int | , | ||
% | ) |
operations_research::STRONG_TYPE_ARITHMETIC_OP | ( | StrongIndex | , |
int | , | ||
* | ) |
operations_research::STRONG_TYPE_ARITHMETIC_OP | ( | StrongIndex | , |
int | , | ||
- | ) |
operations_research::STRONG_TYPE_ARITHMETIC_OP | ( | StrongIndex | , |
int | , | ||
+ | ) |
operations_research::STRONG_TYPE_ARITHMETIC_OP | ( | StrongInt64 | , |
int64_t | , | ||
% | ) |
operations_research::STRONG_TYPE_ARITHMETIC_OP | ( | StrongInt64 | , |
int64_t | , | ||
* | ) |
operations_research::STRONG_TYPE_ARITHMETIC_OP | ( | StrongInt64 | , |
int64_t | , | ||
- | ) |
operations_research::STRONG_TYPE_ARITHMETIC_OP | ( | StrongInt64 | , |
int64_t | ) |
operations_research::STRONG_TYPE_ARITHMETIC_OP | ( | StrongInt64 | , |
int64_t | , | ||
+ | ) |
operations_research::STRONG_TYPE_ARITHMETIC_OP | ( | StrongInt64 | , |
int64_t | , | ||
/ | ) |
operations_research::STRONG_TYPE_ARITHMETIC_OP | ( | StrongInt64 | , |
int64_t | , | ||
<< | ) |
operations_research::STRONG_TYPE_COMPARISON_OP | ( | StrongIndex | , |
int | , | ||
! | ) |
operations_research::STRONG_TYPE_COMPARISON_OP | ( | StrongIndex | , |
int | , | ||
>= | ) |
operations_research::STRONG_TYPE_COMPARISON_OP | ( | StrongIndex | , |
int | , | ||
<= | ) |
operations_research::STRONG_TYPE_COMPARISON_OP | ( | StrongIndex | , |
int | ) |
operations_research::STRONG_TYPE_COMPARISON_OP | ( | StrongInt64 | , |
int64_t | , | ||
! | ) |
operations_research::STRONG_TYPE_COMPARISON_OP | ( | StrongInt64 | , |
int64_t | , | ||
>= | ) |
operations_research::STRONG_TYPE_COMPARISON_OP | ( | StrongInt64 | , |
int64_t | , | ||
<= | ) |
operations_research::STRONG_TYPE_COMPARISON_OP | ( | StrongInt64 | , |
int64_t | ) |
int32_t operations_research::strtoint32 | ( | absl::string_view | word | ) |
Definition at line 26 of file strtoint.cc.
int64_t operations_research::strtoint64 | ( | absl::string_view | word | ) |
Definition at line 32 of file strtoint.cc.
|
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.
|
inline |
Definition at line 126 of file saturated_arithmetic.h.
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.
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.
std::vector< int64_t > operations_research::ToInt64Vector | ( | const std::vector< int > & | input | ) |
--— Vector manipulations --—
Definition at line 829 of file utilities.cc.
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.
std::string operations_research::ToString | ( | MPCallbackEvent | event | ) |
Definition at line 23 of file linear_solver_callback.cc.
absl::string_view operations_research::ToString | ( | MPSolver::OptimizationProblemType | optimization_problem_type | ) |
Definition at line 627 of file linear_solver.cc.
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.
|
inline |
|
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.
Definition at line 82 of file saturated_arithmetic.h.
|
inline |
Definition at line 89 of file saturated_arithmetic.h.
int32_t operations_research::UnsafeLeastSignificantBitPosition32 | ( | const uint32_t * | bitset, |
uint32_t | start, | ||
uint32_t | end ) |
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.
int32_t operations_research::UnsafeMostSignificantBitPosition32 | ( | const uint32_t * | bitset, |
uint32_t | start, | ||
uint32_t | end ) |
int64_t operations_research::UnsafeMostSignificantBitPosition64 | ( | const uint64_t * | bitset, |
uint64_t | start, | ||
uint64_t | end ) |
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.
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.
|
inline |
Computes the sum of values
without assuming anything.
Definition at line 37 of file vector_sum.h.
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.
Definition at line 251 of file model_exporter.cc.
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.
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.
std::vector< int > operations_research::XpressBasisStatusesFrom | ( | const std::vector< MPSolver::BasisStatus > & | statuses | ) |
Definition at line 1712 of file xpress_interface.cc.
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.
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.
|
extern |
Definition at line 359 of file environment.cc.
MPSolutionResponse operations_research::XPressSolveProto | ( | LazyMutableCopy< MPModelRequest > | request | ) |
Solves the input request.
|
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.
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):
arc_lengths
are supposed to be nonnegative. The behavior is undefined otherwise. 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
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:
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:
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.
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
. 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.
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
. 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.
|
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.
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.
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.
std::function< int(GRBmodel *model, const char *name, int resvar, int argvar)> operations_research::GRBaddgenconstrAbs = nullptr |
Definition at line 162 of file environment.cc.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
std::function< int(void *cbdata, int where, int what, void *resultP)> operations_research::GRBcbget |
Definition at line 114 of file environment.cc.
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.
std::function< int(void *cbdata, const double *solution, double *objvalP)> operations_research::GRBcbsolution = nullptr |
Definition at line 117 of file environment.cc.
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.
Definition at line 128 of file environment.cc.
Definition at line 223 of file environment.cc.
std::function< int(GRBmodel *model, int len, int *ind)> operations_research::GRBdelconstrs = nullptr |
Definition at line 181 of file environment.cc.
Definition at line 183 of file environment.cc.
Definition at line 186 of file environment.cc.
std::function< int(GRBmodel *model, int len, int *ind)> operations_research::GRBdelqconstrs = nullptr |
Definition at line 185 of file environment.cc.
Definition at line 182 of file environment.cc.
Definition at line 180 of file environment.cc.
std::function< int(GRBenv **envP)> operations_research::GRBemptyenv = nullptr |
Definition at line 225 of file environment.cc.
std::function< void(GRBenv *env)> operations_research::GRBfreeenv = nullptr |
Definition at line 229 of file environment.cc.
Definition at line 190 of file environment.cc.
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.
std::function< int(GRBmodel *model, const char *attrname, int element, char *valueP)> operations_research::GRBgetcharattrelement = nullptr |
Definition at line 75 of file environment.cc.
std::function< int(GRBmodel *model, const char *attrname, double *valueP)> operations_research::GRBgetdblattr = nullptr |
Definition at line 89 of file environment.cc.
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.
std::function< int(GRBmodel *model, const char *attrname, int element, double *valueP)> operations_research::GRBgetdblattrelement = nullptr |
Definition at line 94 of file environment.cc.
std::function< int(GRBenv *env, const char *paramname, double *valueP)> operations_research::GRBgetdblparam = nullptr |
Definition at line 199 of file environment.cc.
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.
Definition at line 228 of file environment.cc.
std::function< const char *(GRBenv *env)> operations_research::GRBgeterrormsg = nullptr |
Definition at line 230 of file environment.cc.
std::function< int(GRBmodel *model, const char *attrname, int *valueP)> operations_research::GRBgetintattr = nullptr |
Definition at line 55 of file environment.cc.
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.
std::function< int(GRBmodel *model, const char *attrname, int element, int *valueP)> operations_research::GRBgetintattrelement = nullptr |
Definition at line 60 of file environment.cc.
std::function< int(GRBenv *env, const char *paramname, int *valueP)> operations_research::GRBgetintparam = nullptr |
Definition at line 197 of file environment.cc.
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.
std::function< int(GRBenv *envP)> operations_research::GRBgetnumparams = nullptr |
Definition at line 224 of file environment.cc.
std::function< int(GRBenv *envP, int i, char **paramnameP)> operations_research::GRBgetparamname |
Definition at line 212 of file environment.cc.
std::function< int(GRBenv *envP, const char *paramname)> operations_research::GRBgetparamtype |
Definition at line 210 of file environment.cc.
std::function< int(GRBmodel *model, const char *attrname, char **valueP)> operations_research::GRBgetstrattr = nullptr |
Definition at line 108 of file environment.cc.
std::function< int(GRBenv *env, const char *paramname, char *valueP)> operations_research::GRBgetstrparam = nullptr |
Definition at line 201 of file environment.cc.
std::function< int(GRBenv *envP, const char *paramname, char *valueP, char *defP)> operations_research::GRBgetstrparaminfo = nullptr |
Definition at line 209 of file environment.cc.
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.
Definition at line 52 of file environment.cc.
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.
std::function< int(GRBenv **envP, const char *logfilename)> operations_research::GRBloadenv = nullptr |
Definition at line 226 of file environment.cc.
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.
Definition at line 127 of file environment.cc.
std::function< char *(void)> operations_research::GRBplatform = nullptr |
Definition at line 233 of file environment.cc.
std::function< int(GRBenv *env)> operations_research::GRBresetparams = nullptr |
Definition at line 222 of file environment.cc.
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.
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.
std::function< int(GRBmodel *model, const char *attrname, int element, char newvalue)> operations_research::GRBsetcharattrelement = nullptr |
Definition at line 78 of file environment.cc.
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.
std::function< int(GRBmodel *model, const char *attrname, double newvalue)> operations_research::GRBsetdblattr = nullptr |
Definition at line 91 of file environment.cc.
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.
std::function< int(GRBmodel *model, const char *attrname, int element, double newvalue)> operations_research::GRBsetdblattrelement = nullptr |
Definition at line 97 of file environment.cc.
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.
std::function< int(GRBenv *env, const char *paramname, double value)> operations_research::GRBsetdblparam = nullptr |
Definition at line 219 of file environment.cc.
std::function< int(GRBmodel *model, const char *attrname, int newvalue)> operations_research::GRBsetintattr = nullptr |
Definition at line 57 of file environment.cc.
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.
std::function< int(GRBmodel *model, const char *attrname, int element, int newvalue)> operations_research::GRBsetintattrelement = nullptr |
Definition at line 63 of file environment.cc.
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.
std::function< int(GRBenv *env, const char *paramname, int value)> operations_research::GRBsetintparam = nullptr |
Definition at line 217 of file environment.cc.
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.
std::function< int(GRBenv *env, const char *paramname, const char *value)> operations_research::GRBsetparam = nullptr |
Definition at line 215 of file environment.cc.
std::function< int(GRBmodel *model, const char *attrname, const char *newvalue)> operations_research::GRBsetstrattr = nullptr |
Definition at line 110 of file environment.cc.
std::function< int(GRBenv *env, const char *paramname, const char *value)> operations_research::GRBsetstrparam = nullptr |
Definition at line 221 of file environment.cc.
std::function< int(GRBenv *env)> operations_research::GRBstartenv = nullptr |
Definition at line 227 of file environment.cc.
Definition at line 191 of file environment.cc.
Definition at line 189 of file environment.cc.
std::function< void(int *majorP, int *minorP, int *technicalP)> operations_research::GRBversion |
Definition at line 231 of file environment.cc.
Definition at line 129 of file environment.cc.
|
static |
|
static |
|
static |
|
inlineconstexpr |
Definition at line 24 of file testing_utils.h.
|
inlineconstexpr |
Definition at line 19 of file testing_utils.h.
|
constexpr |
Definition at line 174 of file linear_solver.h.
const PathDistance operations_research::kDisconnectedPathDistance |
Definition at line 82 of file shortest_paths.h.
|
staticconstexpr |
Definition at line 35 of file set_cover_heuristics.cc.
|
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.
Definition at line 34 of file set_cover_heuristics.cc.
|
inlineconstexpr |
Definition at line 20 of file testing_utils.h.
|
constexpr |
Definition at line 569 of file linear_solver.cc.
|
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.
|
inlineconstexpr |
Definition at line 34 of file fp_roundtrip_conv_testing.h.
|
constexpr |
SIMD operations require vectors to be aligned at 64-bytes on x86-64 processors as of 2024-05-03.
Definition at line 90 of file set_cover_model.h.
ABSL_CONST_INIT const bool operations_research::kStdToCharsDoubleIsSupported |
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.
|
inlineconstexpr |
Definition at line 21 of file testing_utils.h.
|
static |
--— Routing model --—
Definition at line 361 of file routing.cc.
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.
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.
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.
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.
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.
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.
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.
std::function< int(XPRSprob prob, int row, int col, double coef)> operations_research::XPRSchgcoef = nullptr |
Definition at line 92 of file environment.cc.
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.
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.
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.
std::function< int(XPRSprob prob, int objsense)> operations_research::XPRSchgobjsense = nullptr |
Definition at line 81 of file environment.cc.
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.
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.
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.
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.
std::function< int(XPRSprob prob, int ncols, const int colind[])> operations_research::XPRSdelcols = nullptr |
Definition at line 77 of file environment.cc.
std::function< int(XPRSprob prob, int nrows, const int rowind[])> operations_research::XPRSdelrows = nullptr |
Definition at line 73 of file environment.cc.
std::function< int(XPRSprob prob)> operations_research::XPRSdestroyprob = nullptr |
Definition at line 44 of file environment.cc.
std::function< int(void)> operations_research::XPRSfree = nullptr |
Definition at line 46 of file environment.cc.
std::function< int(char *banner)> operations_research::XPRSgetbanner = nullptr |
Definition at line 49 of file environment.cc.
std::function< int(XPRSprob prob, int rowstat[], int colstat[])> operations_research::XPRSgetbasis = nullptr |
Definition at line 83 of file environment.cc.
std::function< int(XPRSprob prob, int row, int col, double *p_coef)> operations_research::XPRSgetcoef = nullptr |
Definition at line 71 of file environment.cc.
std::function< int(XPRSprob prob, char coltype[], int first, int last)> operations_research::XPRSgetcoltype = nullptr |
Definition at line 86 of file environment.cc.
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.
std::function< int(XPRSprob prob, int attrib, double *p_value)> operations_research::XPRSgetdblattrib = nullptr |
Definition at line 62 of file environment.cc.
std::function< int(XPRSprob prob, int control, double *p_value)> operations_research::XPRSgetdblcontrol = nullptr |
Definition at line 59 of file environment.cc.
std::function< int(XPRSprob prob, int attrib, int *p_value)> operations_research::XPRSgetintattrib = nullptr |
Definition at line 61 of file environment.cc.
std::function< int(XPRSprob prob, int control, int *p_value)> operations_research::XPRSgetintcontrol = nullptr |
Definition at line 57 of file environment.cc.
std::function< int(XPRSprob prob, int control, XPRSint64 *p_value)> operations_research::XPRSgetintcontrol64 = nullptr |
Definition at line 58 of file environment.cc.
std::function< int(XPRSprob prob, char *errmsg)> operations_research::XPRSgetlasterror = nullptr |
Definition at line 82 of file environment.cc.
std::function< int(XPRSprob prob, double lb[], int first, int last)> operations_research::XPRSgetlb = nullptr |
Definition at line 69 of file environment.cc.
std::function< int(char *buffer, int maxbytes)> operations_research::XPRSgetlicerrmsg = nullptr |
Definition at line 47 of file environment.cc.
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.
std::function< int(XPRSprob prob, double x[], double slack[])> operations_research::XPRSgetmipsol = nullptr |
Definition at line 90 of file environment.cc.
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.
std::function< int(XPRSprob prob, double objcoef[], int first, int last)> operations_research::XPRSgetobj = nullptr |
Definition at line 66 of file environment.cc.
std::function< int(XPRSprob prob, double rhs[], int first, int last)> operations_research::XPRSgetrhs = nullptr |
Definition at line 67 of file environment.cc.
std::function< int(XPRSprob prob, double rng[], int first, int last)> operations_research::XPRSgetrhsrange = nullptr |
Definition at line 68 of file environment.cc.
std::function< int(XPRSprob prob, char rowtype[], int first, int last)> operations_research::XPRSgetrowtype = nullptr |
Definition at line 85 of file environment.cc.
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.
std::function< int(XPRSprob prob, double ub[], int first, int last)> operations_research::XPRSgetub = nullptr |
Definition at line 70 of file environment.cc.
std::function< int(char *version)> operations_research::XPRSgetversion = nullptr |
Definition at line 50 of file environment.cc.
std::function< int(const char *path)> operations_research::XPRSinit = nullptr |
Definition at line 45 of file environment.cc.
std::function< int(XPRSprob prob, int reason)> operations_research::XPRSinterrupt = nullptr |
Definition at line 52 of file environment.cc.
std::function< int(int *p_i, char *p_c)> operations_research::XPRSlicense = nullptr |
Definition at line 48 of file environment.cc.
std::function< int(XPRSprob prob, const int rowstat[], const int colstat[])> operations_research::XPRSloadbasis = nullptr |
Definition at line 79 of file environment.cc.
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.
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.
std::function< int(XPRSprob prob, const char *flags)> operations_research::XPRSlpoptimize = nullptr |
Definition at line 100 of file environment.cc.
std::function< int(XPRSprob prob, const char *flags)> operations_research::XPRSmipoptimize = nullptr |
Definition at line 101 of file environment.cc.
std::function< int(XPRSprob prob)> operations_research::XPRSpostsolve = nullptr |
Definition at line 80 of file environment.cc.
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.
std::function< int(XPRSprob prob, int control, double value)> operations_research::XPRSsetdblcontrol = nullptr |
Definition at line 55 of file environment.cc.
std::function< int(XPRSprob prob, int control)> operations_research::XPRSsetdefaultcontrol = nullptr |
Definition at line 51 of file environment.cc.
std::function< int(XPRSprob prob, int control, int value)> operations_research::XPRSsetintcontrol = nullptr |
Definition at line 53 of file environment.cc.
std::function< int(XPRSprob prob, int control, XPRSint64 value)> operations_research::XPRSsetintcontrol64 = nullptr |
Definition at line 54 of file environment.cc.
std::function< int(XPRSprob prob, int control, const char *value)> operations_research::XPRSsetstrcontrol = nullptr |
Definition at line 56 of file environment.cc.
std::function< int(XPRSprob prob, const char *filename, const char *flags)> operations_research::XPRSwriteprob = nullptr |
Definition at line 84 of file environment.cc.