14 #ifndef OR_TOOLS_CONSTRAINT_SOLVER_ROUTING_LP_SCHEDULING_H_ 15 #define OR_TOOLS_CONSTRAINT_SOLVER_ROUTING_LP_SCHEDULING_H_ 18 #include "ortools/glop/lp_solver.h" 31 visited_pickup_index_for_pair_(
39 const std::function<int64(int64)>& next_accessor,
40 glop::LinearProgram* linear_program,
41 glop::LPSolver* lp_solver,
42 std::vector<int64>* cumul_values, int64* cost,
43 int64* transit_cost,
bool clear_lp =
true);
45 bool Optimize(
const std::function<int64(int64)>& next_accessor,
46 glop::LinearProgram* linear_program, glop::LPSolver* lp_solver,
47 std::vector<int64>* cumul_values, int64* cost,
48 int64* transit_cost,
bool clear_lp =
true);
51 glop::LinearProgram* linear_program,
52 glop::LPSolver* lp_solver,
53 std::vector<int64>* cumul_values);
56 int vehicle,
const std::function<int64(int64)>& next_accessor,
57 glop::LinearProgram* linear_program, glop::LPSolver* lp_solver,
58 std::vector<int64>* cumul_values);
65 void InitOptimizer(glop::LinearProgram* linear_program);
71 bool SetRouteCumulConstraints(
72 int vehicle,
const std::function<int64(int64)>& next_accessor,
73 int64 cumul_offset,
bool optimize_costs,
74 glop::LinearProgram* linear_program, int64* route_transit_cost,
75 int64* route_cost_offset);
83 void SetGlobalConstraints(
bool optimize_costs,
84 glop::LinearProgram* linear_program);
86 bool FinalizeAndSolve(glop::LinearProgram* linear_program,
87 glop::LPSolver* lp_solver);
89 void SetCumulValuesFromLP(
const std::vector<glop::ColIndex>& cumul_variables,
90 int64 offset,
const glop::LPSolver& lp_solver,
91 std::vector<int64>* cumul_values);
99 bool PackRoutes(std::vector<int>
vehicles,
100 glop::LinearProgram* linear_program,
101 glop::LPSolver* lp_solver);
104 std::vector<glop::ColIndex> current_route_cumul_variables_;
105 std::vector<glop::ColIndex> index_to_cumul_variable_;
106 glop::ColIndex max_end_cumul_;
107 glop::ColIndex min_start_cumul_;
108 std::vector<int64> visited_pickup_index_for_pair_;
125 const std::function<int64(int64)>& next_accessor,
126 int64* optimal_cost);
131 int vehicle,
const std::function<int64(int64)>& next_accessor,
132 int64* optimal_cost_without_transits);
139 const std::function<int64(int64)>& next_accessor,
140 std::vector<int64>* optimal_cumuls);
146 int vehicle,
const std::function<int64(int64)>& next_accessor,
147 std::vector<int64>* packed_cumuls);
154 std::vector<std::unique_ptr<glop::LPSolver>> lp_solver_;
155 std::vector<std::unique_ptr<glop::LinearProgram>> linear_program_;
168 const std::function<int64(int64)>& next_accessor,
169 int64* optimal_cost_without_transits);
174 bool ComputeCumuls(
const std::function<int64(int64)>& next_accessor,
175 std::vector<int64>* optimal_cumuls);
179 bool IsFeasible(
const std::function<int64(int64)>& next_accessor);
185 std::vector<int64>* packed_cumuls);
192 glop::LPSolver lp_solver_;
193 glop::LinearProgram linear_program_;
199 #endif // OR_TOOLS_CONSTRAINT_SOLVER_ROUTING_LP_SCHEDULING_H_ bool ComputePackedCumuls(const std::function< int64(int64)> &next_accessor, std::vector< int64 > *packed_cumuls)
Similar to ComputeCumuls, but also tries to pack the cumul values on all routes, such that the cost r...
int vehicles() const
Returns the number of vehicle routes in the model.
LocalDimensionCumulOptimizer(const RoutingDimension *dimension)
const RoutingDimension * dimension() const
bool ComputeRouteCumuls(int vehicle, const std::function< int64(int64)> &next_accessor, std::vector< int64 > *optimal_cumuls)
If feasible, computes the optimal cumul values of the route performed by a vehicle,...
bool ComputePackedRouteCumuls(int vehicle, const std::function< int64(int64)> &next_accessor, std::vector< int64 > *packed_cumuls)
Similar to ComputeRouteCumuls, but also tries to pack the cumul values on the route,...
bool Optimize(const std::function< int64(int64)> &next_accessor, glop::LinearProgram *linear_program, glop::LPSolver *lp_solver, std::vector< int64 > *cumul_values, int64 *cost, int64 *transit_cost, bool clear_lp=true)
bool OptimizeAndPack(const std::function< int64(int64)> &next_accessor, glop::LinearProgram *linear_program, glop::LPSolver *lp_solver, std::vector< int64 > *cumul_values)
const RoutingDimension * dimension() const
bool IsFeasible(const std::function< int64(int64)> &next_accessor)
Returns true iff the routes resulting from the next_accessor are feasible wrt the constraints on the ...
GlobalDimensionCumulOptimizer(const RoutingDimension *dimension)
bool OptimizeAndPackSingleRoute(int vehicle, const std::function< int64(int64)> &next_accessor, glop::LinearProgram *linear_program, glop::LPSolver *lp_solver, std::vector< int64 > *cumul_values)
Class used to compute optimal values for dimension cumuls of routes, minimizing cumul soft lower and ...
bool ComputeRouteCumulCostWithoutFixedTransits(int vehicle, const std::function< int64(int64)> &next_accessor, int64 *optimal_cost_without_transits)
Same as ComputeRouteCumulCost, but the cost computed does not contain the part of the vehicle span co...
bool ComputeRouteCumulCost(int vehicle, const std::function< int64(int64)> &next_accessor, int64 *optimal_cost)
If feasible, computes the optimal cost of the route performed by a vehicle, minimizing cumul soft low...
Classes to solve dimension cumul placement (aka scheduling) problems using linear programming.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in c...
bool ComputeCumulCostWithoutFixedTransits(const std::function< int64(int64)> &next_accessor, int64 *optimal_cost_without_transits)
If feasible, computes the optimal cost of the entire model with regards to the optimizer_core_'s dime...
*RoutingModel model(manager)
const RoutingDimension * dimension() const
DimensionCumulOptimizerCore(const RoutingDimension *dimension)
bool OptimizeSingleRoute(int vehicle, const std::function< int64(int64)> &next_accessor, glop::LinearProgram *linear_program, glop::LPSolver *lp_solver, std::vector< int64 > *cumul_values, int64 *cost, int64 *transit_cost, bool clear_lp=true)
In the OptimizeSingleRoute() and Optimize() methods, if both "cumul_values" and "cost" parameters are...
bool ComputeCumuls(const std::function< int64(int64)> &next_accessor, std::vector< int64 > *optimal_cumuls)
If feasible, computes the optimal cumul values, minimizing cumul soft lower/upper bound costs and veh...
friend class RoutingDimension