14#ifndef OR_TOOLS_GLOP_REDUCED_COSTS_H_
15#define OR_TOOLS_GLOP_REDUCED_COSTS_H_
20#include "absl/random/bit_gen_ref.h"
22#include "ortools/glop/parameters.pb.h"
60 absl::BitGenRef random);
120 return recompute_reduced_costs_ || are_reduced_costs_recomputed_;
186 return dual_feasibility_tolerance_;
209 basic_objective_left_inverse_density(
210 "basic_objective_left_inverse_density", this),
211 reduced_costs_accuracy(
"reduced_costs_accuracy", this),
212 cost_shift(
"cost_shift", this) {}
220 void ComputeBasicObjective();
221 void ComputeReducedCosts();
222 void ComputeBasicObjectiveLeftInverse();
228 void UpdateReducedCosts(ColIndex entering_col, ColIndex leaving_col,
230 UpdateRow* update_row);
233 void UpdateBasicObjective(ColIndex entering_col, RowIndex leaving_row);
236 void SetRecomputeReducedCostsAndNotifyWatchers();
239 const CompactSparseMatrix& matrix_;
242 const VariablesInfo& variables_info_;
243 const BasisFactorization& basis_factorization_;
244 absl::BitGenRef random_;
247 GlopParameters parameters_;
248 mutable Stats stats_;
251 bool must_refactorize_basis_;
252 bool recompute_basic_objective_left_inverse_;
253 bool recompute_basic_objective_;
254 bool recompute_reduced_costs_;
257 bool are_reduced_costs_precise_;
258 bool are_reduced_costs_recomputed_;
260 bool has_cost_shift_ =
false;
282 ScatteredRow basic_objective_left_inverse_;
291 std::vector<bool*> watchers_;
293 double deterministic_time_ = 0.0;
332 template <
bool from_clean_state,
typename ColumnsToUpdate>
333 void UpdateEnteringCandidates(
const ColumnsToUpdate& cols);
335 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.
std::string StatString() const
void RecomputePriceAt(ColIndex col)
Triggers a recomputation of the price at the given column only.
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 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.
StrictITIVector< RowIndex, ColIndex > RowToColMapping
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.