Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
#include <reduced_costs.h>
Public Member Functions | |
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. | |
ReducedCosts (const ReducedCosts &)=delete | |
This type is neither copyable nor movable. | |
ReducedCosts & | operator= (const ReducedCosts &)=delete |
bool | NeedsBasisRefactorization () const |
Fractional | TestEnteringReducedCostPrecision (ColIndex entering_col, const ScatteredColumn &direction) |
Fractional | ComputeMaximumDualResidual () |
Fractional | ComputeMaximumDualInfeasibility () |
Fractional | ComputeSumOfDualInfeasibilities () |
Fractional | ComputeMaximumDualInfeasibilityOnNonBoxedVariables () |
void | UpdateBeforeBasisPivot (ColIndex entering_col, RowIndex leaving_row, const ScatteredColumn &direction, UpdateRow *update_row) |
void | SetNonBasicVariableCostToZero (ColIndex col, Fractional *current_cost) |
void | SetParameters (const GlopParameters ¶meters) |
Sets the pricing parameters. This does not change the pricing rule. | |
bool | AreReducedCostsPrecise () |
bool | AreReducedCostsRecomputed () |
void | MakeReducedCostsPrecise () |
void | PerturbCosts () |
void | ShiftCostIfNeeded (bool increasing_rc_is_needed, ColIndex col) |
bool | HasCostShift () const |
bool | StepIsDualDegenerate (bool increasing_rc_is_needed, ColIndex col) |
void | ClearAndRemoveCostShifts () |
void | ResetForNewObjective () |
Invalidates all internal structure that depends on the objective function. | |
void | UpdateDataOnBasisPermutation () |
Invalidates the data that depends on the order of the column in basis_. | |
DenseRow::ConstView | GetReducedCosts () |
DenseRow::ConstView | GetFullReducedCosts () |
const DenseColumn & | GetDualValues () |
Returns the dual values associated to the current basis. | |
std::string | StatString () const |
Stats related functions. | |
Fractional | GetDualFeasibilityTolerance () const |
Returns the current dual feasibility tolerance. | |
bool | IsValidPrimalEnteringCandidate (ColIndex col) const |
Does basic checking of an entering candidate. | |
const DenseRow & | GetCostPerturbations () const |
Visible for testing. | |
double | DeterministicTime () const |
The deterministic time used by this class. | |
void | AddRecomputationWatcher (bool *watcher) |
Maintains the reduced costs of the non-basic variables and some related quantities.
Terminology:
Definition at line 53 of file reduced_costs.h.
operations_research::glop::ReducedCosts::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.
Definition at line 43 of file reduced_costs.cc.
|
delete |
This type is neither copyable nor movable.
|
inline |
Registers a boolean that will be set to true each time the reduced costs are or will be recomputed. This allows anyone that depends on this to know that it cannot just assume an incremental changes and needs to updates its data. Important: UpdateBeforeBasisPivot() will not trigger this.
Definition at line 202 of file reduced_costs.h.
|
inline |
Returns true if the current reduced costs are computed with maximum precision.
Definition at line 115 of file reduced_costs.h.
|
inline |
Returns true if the current reduced costs where just recomputed or will be on the next call to GetReducedCosts().
Definition at line 119 of file reduced_costs.h.
void operations_research::glop::ReducedCosts::ClearAndRemoveCostShifts | ( | ) |
Removes any cost shift and cost perturbation. This also lazily forces a recomputation of all the derived quantities. This effectively resets the class to its initial state.
Definition at line 317 of file reduced_costs.cc.
Fractional operations_research::glop::ReducedCosts::ComputeMaximumDualInfeasibility | ( | ) |
Trigger a recomputation if needed so that reduced_costs_ is valid.
Definition at line 125 of file reduced_costs.cc.
Fractional operations_research::glop::ReducedCosts::ComputeMaximumDualInfeasibilityOnNonBoxedVariables | ( | ) |
Same as ComputeMaximumDualInfeasibility() but ignore boxed variables. Because we can always switch bounds of boxed variables, if this is under the dual tolerance, then we can easily have a dual feasible solution and do not need to run a dual phase I algorithm.
Trigger a recomputation if needed so that reduced_costs_ is valid.
Definition at line 145 of file reduced_costs.cc.
Fractional operations_research::glop::ReducedCosts::ComputeMaximumDualResidual | ( | ) |
Computes the current dual residual and infeasibility. Note that these functions are not really fast (many scalar products will be computed) and shouldn't be called at each iteration.
These function will compute the reduced costs if needed. ComputeMaximumDualResidual() also needs ComputeBasicObjectiveLeftInverse() and do not depends on reduced costs.
Definition at line 110 of file reduced_costs.cc.
Fractional operations_research::glop::ReducedCosts::ComputeSumOfDualInfeasibilities | ( | ) |
Trigger a recomputation if needed so that reduced_costs_ is valid.
Definition at line 167 of file reduced_costs.cc.
|
inline |
The deterministic time used by this class.
Definition at line 196 of file reduced_costs.h.
|
inline |
Visible for testing.
Definition at line 193 of file reduced_costs.h.
|
inline |
Returns the current dual feasibility tolerance.
Definition at line 185 of file reduced_costs.h.
const DenseColumn & operations_research::glop::ReducedCosts::GetDualValues | ( | ) |
Returns the dual values associated to the current basis.
Definition at line 346 of file reduced_costs.cc.
DenseRow::ConstView operations_research::glop::ReducedCosts::GetFullReducedCosts | ( | ) |
Same as GetReducedCosts() but trigger a recomputation if not already done to have access to the reduced costs on all positions, not just the relevant one.
Definition at line 327 of file reduced_costs.cc.
DenseRow::ConstView operations_research::glop::ReducedCosts::GetReducedCosts | ( | ) |
Returns the current reduced costs. If AreReducedCostsPrecise() is true, then for basic columns, this gives the error between 'c_B' and 'y.B' and for non-basic columns, this is the classic reduced cost. If it is false, then this is defined only for the columns in variables_info_.GetIsRelevantBitRow().
Definition at line 335 of file reduced_costs.cc.
|
inline |
Returns true if ShiftCostIfNeeded() was applied since the last ClearAndRemoveCostShifts().
Definition at line 149 of file reduced_costs.h.
bool operations_research::glop::ReducedCosts::IsValidPrimalEnteringCandidate | ( | ColIndex | col | ) | const |
Does basic checking of an entering candidate.
Definition at line 505 of file reduced_costs.cc.
void operations_research::glop::ReducedCosts::MakeReducedCostsPrecise | ( | ) |
Makes sure the next time the reduced cost are needed, they will be recomputed with maximum precision (i.e. from scratch with a basis refactorization first).
Definition at line 232 of file reduced_costs.cc.
bool operations_research::glop::ReducedCosts::NeedsBasisRefactorization | ( | ) | const |
If this is true, then the caller must re-factorize the basis before the next call to GetReducedCosts().
Definition at line 68 of file reduced_costs.cc.
|
delete |
void operations_research::glop::ReducedCosts::PerturbCosts | ( | ) |
Randomly perturb the costs. Both Koberstein and Huangfu recommend doing that before the dual simplex starts in their Phd thesis.
The perturbation follows what is explained in Huangfu Q (2013) "High performance simplex solver", Ph.D, dissertation, University of Edinburgh, section 3.2.3, page 58.
The perturbation direction is such that a dual-feasible solution stays feasible. This is important.
Here we don't necessarily maintain the dual-feasibility of a dual feasible solution, however we can always shift the variable to its other bound (because it is boxed) to restore dual-feasiblity. This is done by MakeBoxedVariableDualFeasible() at the end of the dual phase-I algorithm.
Definition at line 240 of file reduced_costs.cc.
void operations_research::glop::ReducedCosts::ResetForNewObjective | ( | ) |
Invalidates all internal structure that depends on the objective function.
Definition at line 218 of file reduced_costs.cc.
void operations_research::glop::ReducedCosts::SetNonBasicVariableCostToZero | ( | ColIndex | col, |
Fractional * | current_cost ) |
Sets the cost of the given non-basic variable to zero and updates its reduced cost. Note that changing the cost of a non-basic variable only impacts its reduced cost and not the one of any other variables. The current_cost pointer must be equal to the address of objective[col] where objective is the DenseRow passed at construction.
Definition at line 206 of file reduced_costs.cc.
void operations_research::glop::ReducedCosts::SetParameters | ( | const GlopParameters & | parameters | ) |
Sets the pricing parameters. This does not change the pricing rule.
Definition at line 214 of file reduced_costs.cc.
void operations_research::glop::ReducedCosts::ShiftCostIfNeeded | ( | bool | increasing_rc_is_needed, |
ColIndex | col ) |
Shifts the cost of the given non-basic column such that its current reduced cost becomes 0.0. Actually, this shifts the cost a bit more according to the positive_direction parameter.
This is explained in Koberstein's thesis (section 6.2.2.3) and helps on degenerate problems. As of july 2013, this allowed to pass dano3mip and dbic1 without cycling forever. Note that contrary to what is explained in the thesis, we do not shift any other variable costs. If any becomes infeasible, it will be selected and shifted in subsequent iterations.
We always want a minimum step size, so if we have a negative step or a step that is really small, we will shift the cost of the given column.
Definition at line 291 of file reduced_costs.cc.
|
inline |
Stats related functions.
Definition at line 182 of file reduced_costs.h.
bool operations_research::glop::ReducedCosts::StepIsDualDegenerate | ( | bool | increasing_rc_is_needed, |
ColIndex | col ) |
Returns true if this step direction make the given column even more infeasible. This is just used for reporting stats.
Definition at line 310 of file reduced_costs.cc.
Fractional operations_research::glop::ReducedCosts::TestEnteringReducedCostPrecision | ( | ColIndex | entering_col, |
const ScatteredColumn & | direction ) |
Checks the precision of the entering variable choice now that the direction is computed. Returns its precise version. This will also trigger a reduced cost recomputation if it was deemed too imprecise.
Update the reduced cost of the entering variable with the precise version.
At this point, we have an entering variable that will move the objective in the good direction. We check the precision of the reduced cost and edges norm, but even if they are imprecise, we finish this pivot and will recompute them during the next call to ChooseEnteringColumn().
Estimate the accuracy of the reduced costs using the entering variable.
Definition at line 72 of file reduced_costs.cc.
void operations_research::glop::ReducedCosts::UpdateBeforeBasisPivot | ( | ColIndex | entering_col, |
RowIndex | leaving_row, | ||
const ScatteredColumn & | direction, | ||
UpdateRow * | update_row ) |
Updates any internal data BEFORE the given simplex pivot is applied to B.
If we are recomputing everything when requested, no need to update.
Definition at line 186 of file reduced_costs.cc.
void operations_research::glop::ReducedCosts::UpdateDataOnBasisPermutation | ( | ) |
Invalidates the data that depends on the order of the column in basis_.
Definition at line 226 of file reduced_costs.cc.