14#ifndef ORTOOLS_GLOP_REDUCED_COSTS_H_
15#define ORTOOLS_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;
StrictITISpan< ColIndex, const Fractional > ConstView
void RecomputePriceAt(ColIndex col)
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
ReducedCosts & operator=(const ReducedCosts &)=delete
std::string StatString() const
void SetRandom(absl::BitGenRef random)
void SetNonBasicVariableCostToZero(ColIndex col, Fractional *current_cost)
Fractional ComputeMaximumDualInfeasibilityOnNonBoxedVariables()
Fractional ComputeMaximumDualInfeasibility()
Fractional GetDualFeasibilityTolerance() const
void SetParameters(const GlopParameters ¶meters)
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
void UpdateDataOnBasisPermutation()
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)
const DenseColumn & GetDualValues()
const DenseRow & GetCostPerturbations() const
void AddRecomputationWatcher(bool *watcher)
void ShiftCostIfNeeded(bool increasing_rc_is_needed, ColIndex col)
bool AreReducedCostsRecomputed()
double DeterministicTime() const
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()
StrictITIVector< RowIndex, ColIndex > RowToColMapping
StrictITIVector< RowIndex, Fractional > DenseColumn
StrictITIVector< ColIndex, Fractional > DenseRow