14#ifndef OR_TOOLS_GLOP_REDUCED_COSTS_H_
15#define OR_TOOLS_GLOP_REDUCED_COSTS_H_
20#include "absl/random/bit_gen_ref.h"
60 absl::BitGenRef random);
70 void SetRandom(absl::BitGenRef random) { random_ = random; }
122 return recompute_reduced_costs_ || are_reduced_costs_recomputed_;
184 std::string
StatString()
const {
return stats_.StatString(); }
188 return dual_feasibility_tolerance_;
211 basic_objective_left_inverse_density(
212 "basic_objective_left_inverse_density", this),
213 reduced_costs_accuracy(
"reduced_costs_accuracy", this),
214 cost_shift(
"cost_shift", this) {}
222 void ComputeBasicObjective();
223 void ComputeReducedCosts();
224 void ComputeBasicObjectiveLeftInverse();
230 void UpdateReducedCosts(ColIndex entering_col, ColIndex leaving_col,
232 UpdateRow* update_row);
235 void UpdateBasicObjective(ColIndex entering_col, RowIndex leaving_row);
238 void SetRecomputeReducedCostsAndNotifyWatchers();
241 const CompactSparseMatrix& matrix_;
244 const VariablesInfo& variables_info_;
245 const BasisFactorization& basis_factorization_;
246 absl::BitGenRef random_;
249 GlopParameters parameters_;
250 mutable Stats stats_;
253 bool must_refactorize_basis_;
254 bool recompute_basic_objective_left_inverse_;
255 bool recompute_basic_objective_;
256 bool recompute_reduced_costs_;
259 bool are_reduced_costs_precise_;
260 bool are_reduced_costs_recomputed_;
262 bool has_cost_shift_ =
false;
284 ScatteredRow basic_objective_left_inverse_;
293 std::vector<bool*> watchers_;
295 double deterministic_time_ = 0.0;
312 void SetRandom(absl::BitGenRef random) { prices_.SetRandom(random); }
336 template <
bool from_clean_state,
typename ColumnsToUpdate>
337 void UpdateEnteringCandidates(
const ColumnsToUpdate& cols);
339 bool recompute_ =
true;
Statistic on the distribution of a sequence of doubles.
Statistic on the distribution of a sequence of ratios, displayed as %.
Base class to print a nice summary of a group of statistics.
void RecomputePriceAt(ColIndex col)
Triggers a recomputation of the price at the given column only.
void SetRandom(absl::BitGenRef random)
void ForceRecomputation()
void SetAndDebugCheckThatColumnIsDualFeasible(ColIndex col)
void UpdateBeforeBasisPivot(ColIndex entering_col, UpdateRow *update_row)
PrimalPrices(absl::BitGenRef random, const VariablesInfo &variables_info, PrimalEdgeNorms *primal_edge_norms, ReducedCosts *reduced_costs)
ColIndex GetBestEnteringColumn()
ReducedCosts(const ReducedCosts &)=delete
This type is neither copyable nor movable.
ReducedCosts & operator=(const ReducedCosts &)=delete
std::string StatString() const
Stats related functions.
void SetRandom(absl::BitGenRef random)
void SetNonBasicVariableCostToZero(ColIndex col, Fractional *current_cost)
Fractional ComputeMaximumDualInfeasibilityOnNonBoxedVariables()
Fractional ComputeMaximumDualInfeasibility()
Fractional GetDualFeasibilityTolerance() const
Returns the current dual feasibility tolerance.
void SetParameters(const GlopParameters ¶meters)
Sets the pricing parameters. This does not change the pricing rule.
bool StepIsDualDegenerate(bool increasing_rc_is_needed, ColIndex col)
bool NeedsBasisRefactorization() const
Fractional ComputeMaximumDualResidual()
Fractional TestEnteringReducedCostPrecision(ColIndex entering_col, const ScatteredColumn &direction)
bool HasCostShift() const
bool IsValidPrimalEnteringCandidate(ColIndex col) const
Does basic checking of an entering candidate.
void UpdateDataOnBasisPermutation()
Invalidates the data that depends on the order of the column in basis_.
bool AreReducedCostsPrecise()
void ClearAndRemoveCostShifts()
ReducedCosts(const CompactSparseMatrix &matrix_, const DenseRow &objective, const RowToColMapping &basis, const VariablesInfo &variables_info, const BasisFactorization &basis_factorization, absl::BitGenRef random)
Takes references to the linear program data we need.
const DenseColumn & GetDualValues()
Returns the dual values associated to the current basis.
const DenseRow & GetCostPerturbations() const
Visible for testing.
void AddRecomputationWatcher(bool *watcher)
void ShiftCostIfNeeded(bool increasing_rc_is_needed, ColIndex col)
bool AreReducedCostsRecomputed()
double DeterministicTime() const
The deterministic time used by this class.
void UpdateBeforeBasisPivot(ColIndex entering_col, RowIndex leaving_row, const ScatteredColumn &direction, UpdateRow *update_row)
DenseRow::ConstView GetFullReducedCosts()
DenseRow::ConstView GetReducedCosts()
void MakeReducedCostsPrecise()
Fractional ComputeSumOfDualInfeasibilities()
void ResetForNewObjective()
Invalidates all internal structure that depends on the objective function.
StrictITISpan< ColIndex, const Fractional > ConstView
StrictITIVector< RowIndex, ColIndex > RowToColMapping
StrictITIVector< RowIndex, Fractional > DenseColumn
Column-vector types. Column-vector types are indexed by a row index.
StrictITIVector< ColIndex, Fractional > DenseRow
Row-vector types. Row-vector types are indexed by a column index.
In SWIG mode, we don't want anything besides these top-level includes.