91 #ifndef OR_TOOLS_GLOP_REVISED_SIMPLEX_H_
92 #define OR_TOOLS_GLOP_REVISED_SIMPLEX_H_
98 #include "absl/random/bit_gen_ref.h"
236 void PropagateParameters();
250 std::string GetPrettySolverStats()
const;
254 std::string SimpleVariableInfo(ColIndex
col)
const;
257 void DisplayIterationInfo()
const;
260 void DisplayErrors()
const;
263 void DisplayInfoOnVariables()
const;
266 void DisplayVariableBounds();
282 void DisplayRevisedSimplexDebugInfo();
285 void DisplayProblem()
const;
294 Fractional ComputeInitialProblemObjectiveValue()
const;
298 void SetVariableNames();
304 void SetNonBasicVariableStatusAndDeriveValue(ColIndex
col,
310 bool BasisIsConsistent()
const;
315 void UpdateBasis(ColIndex entering_col, RowIndex basis_row,
325 bool InitializeMatrixAndTestIfUnchanged(
const LinearProgram& lp,
326 bool* only_change_is_new_rows,
327 bool* only_change_is_new_cols,
328 ColIndex* num_new_cols);
332 bool OldBoundsAreUnchangedAndNewVariablesHaveOneBoundAtZero(
336 bool InitializeObjectiveAndTestIfUnchanged(
const LinearProgram& lp);
343 ABSL_MUST_USE_RESULT
Status CreateInitialBasis();
347 ABSL_MUST_USE_RESULT
Status
357 void DisplayBasicVariableStatistics();
366 RowIndex ComputeNumberOfEmptyRows();
370 ColIndex ComputeNumberOfEmptyColumns();
382 void CorrectErrorsOnVariableValues();
385 void ComputeVariableValuesError();
390 void ComputeDirection(ColIndex
col);
400 template <
bool is_entering_reduced_cost_positive>
408 template <
bool is_entering_reduced_cost_positive>
409 Fractional ComputeHarrisRatioAndLeavingCandidates(
417 Status ChooseLeavingVariableRow(ColIndex entering_col,
419 RowIndex* leaving_row,
428 void PrimalPhaseIChooseLeavingVariableRow(ColIndex entering_col,
431 RowIndex* leaving_row,
443 ABSL_MUST_USE_RESULT
Status DualChooseLeavingVariableRow(
444 RowIndex* leaving_row,
Fractional* cost_variation,
452 void DualPhaseIUpdatePrice(RowIndex leaving_row, ColIndex entering_col);
456 template <
bool use_dense_update = false>
457 void OnDualPriceChange(
const DenseColumn& squared_norms, RowIndex
row,
462 template <
typename Cols>
463 void DualPhaseIUpdatePriceOnReducedCostChange(
const Cols& cols);
472 ABSL_MUST_USE_RESULT
Status DualPhaseIChooseLeavingVariableRow(
473 RowIndex* leaving_row,
Fractional* cost_variation,
484 template <
typename BoxedVariableCols>
485 void MakeBoxedVariableDualFeasible(
const BoxedVariableCols& cols,
486 bool update_basic_values);
490 Fractional ComputeStepToMoveBasicVariableToBound(RowIndex leaving_row,
494 bool TestPivot(ColIndex entering_col, RowIndex leaving_row);
505 ABSL_MUST_USE_RESULT
Status UpdateAndPivot(ColIndex entering_col,
506 RowIndex leaving_row,
510 void DisplayAllStats();
517 bool NeedsBasisRefactorization(
bool refactorize);
522 Status RefactorizeBasisIfNeeded(
bool* refactorize);
530 ABSL_MUST_USE_RESULT
Status DualMinimize(
bool feasibility_phase,
546 ColIndex SlackColIndex(RowIndex
row)
const;
567 ColIndex first_slack_col_;
602 DenseRow dual_infeasibility_improvement_direction_;
603 int num_dual_infeasible_positions_;
622 DenseRow solution_dual_ray_row_combination_;
624 bool solution_state_has_been_set_externally_;
628 bool notify_that_matrix_is_unchanged_ =
false;
645 absl::BitGen absl_random_;
647 absl::BitGenRef random_;
667 std::vector<ColIndex> bound_flip_candidates_;
670 uint64_t num_iterations_;
673 uint64_t num_feasibility_iterations_;
676 uint64_t num_optimization_iterations_;
679 int64_t num_update_price_operations_ = 0;
685 double feasibility_time_;
688 double optimization_time_;
692 double last_deterministic_time_update_;
698 total(
"total", this),
699 normal(
"normal", this),
700 bound_flip(
"bound_flip", this),
701 refactorize(
"refactorize", this),
702 degenerate(
"degenerate", this),
703 num_dual_flips(
"num_dual_flips", this),
704 degenerate_run_size(
"degenerate_run_size", this) {}
713 IterationStats iteration_stats_;
715 struct RatioTestStats :
public StatsGroup {
717 : StatsGroup(
"RatioTestStats"),
718 bound_shift(
"bound_shift", this),
719 abs_used_pivot(
"abs_used_pivot", this),
720 abs_tested_pivot(
"abs_tested_pivot", this),
721 abs_skipped_pivot(
"abs_skipped_pivot", this),
722 direction_density(
"direction_density", this),
723 leaving_choices(
"leaving_choices", this),
724 num_perfect_ties(
"num_perfect_ties", this) {}
725 DoubleDistribution bound_shift;
726 DoubleDistribution abs_used_pivot;
727 DoubleDistribution abs_tested_pivot;
728 DoubleDistribution abs_skipped_pivot;
729 RatioDistribution direction_density;
730 IntegerDistribution leaving_choices;
731 IntegerDistribution num_perfect_ties;
733 mutable RatioTestStats ratio_test_stats_;
737 mutable StatsGroup function_stats_;
745 GlopParameters parameters_;
746 GlopParameters initial_parameters_;
750 LuFactorization test_lu_;
753 int num_consecutive_degenerate_iterations_;
756 bool feasibility_phase_;
763 bool objective_limit_reached_;
766 SparseColumn leaving_candidates_;
772 std::vector<RowIndex> equivalent_leaving_choices_;
ParentType::const_iterator const_iterator
A simple class to enforce both an elapsed time limit and a deterministic time limit in the same threa...
RevisedSimplexDictionary(const DenseRow *col_scales, RevisedSimplex *revised_simplex)
ConstIterator end() const
ColIndex GetBasicColumnForRow(RowIndex r) const
RowMajorSparseMatrix::const_iterator ConstIterator
ConstIterator begin() const
SparseRow GetRow(RowIndex r) const
const GlopParameters & GetParameters() const
const DenseRow & GetDualRayRowCombination() const
Fractional GetVariableValue(ColIndex col) const
void SetIntegralityScale(ColIndex col, Fractional scale)
const DenseRow & GetReducedCosts() const
const DenseRow & GetPrimalRay() const
RowToColMapping GetBasisVector() const
bool objective_limit_reached() const
Fractional GetConstraintActivity(RowIndex row) const
VariableStatus GetVariableStatus(ColIndex col) const
Fractional GetReducedCost(ColIndex col) const
const DenseColumn & GetDualRay() const
ABSL_MUST_USE_RESULT Status Solve(const LinearProgram &lp, TimeLimit *time_limit)
ProblemStatus GetProblemStatus() const
Fractional GetObjectiveValue() const
RowMajorSparseMatrix ComputeDictionary(const DenseRow *column_scales)
Fractional GetDualValue(RowIndex row) const
void ClearIntegralityScales()
void NotifyThatMatrixIsUnchangedForNextSolve()
ConstraintStatus GetConstraintStatus(RowIndex row) const
void ComputeBasicVariablesForState(const LinearProgram &linear_program, const BasisState &state)
ColIndex GetProblemNumCols() const
void LoadStateForNextSolve(const BasisState &state)
RowIndex GetProblemNumRows() const
void ClearStateForNextSolve()
const BasisFactorization & GetBasisFactorization() const
int64_t GetNumberOfIterations() const
const BasisState & GetState() const
ColIndex GetBasis(RowIndex row) const
void SetParameters(const GlopParameters ¶meters)
double DeterministicTime() const
const ScatteredRow & GetUnitRowLeftInverse(RowIndex row)
const ScatteredRow & ComputeAndGetUnitRowLeftInverse(RowIndex leaving_row)
SharedTimeLimit * time_limit
StrictITIVector< ColIndex, Fractional > DenseRow
Collection of objects used to extend the Constraint Solver library.
std::mt19937 random_engine_t
std::vector< double > lower_bounds
std::vector< double > upper_bounds