141 const GlopParameters&
GetParameters()
const {
return parameters_; }
191 return dual_edge_norms_.GetEdgeSquaredNorms();
195 return variables_info_.GetNotBasicBitRow();
217 ColIndex
GetBasis(RowIndex row)
const;
220 return update_row_.ComputeAndGetUnitRowLeftInverse(row);
261 transpose_was_changed_ =
true;
262 return &transposed_matrix_;
265 return variables_info_.MutableLowerBounds();
268 return variables_info_.MutableUpperBounds();
278 total(
"total", this),
279 normal(
"normal", this),
280 bound_flip(
"bound_flip", this),
281 refactorize(
"refactorize", this),
282 degenerate(
"degenerate", this),
283 num_dual_flips(
"num_dual_flips", this),
284 degenerate_run_size(
"degenerate_run_size", this) {}
294 struct RatioTestStats :
public StatsGroup {
297 bound_shift(
"bound_shift", this),
298 abs_used_pivot(
"abs_used_pivot", this),
299 abs_tested_pivot(
"abs_tested_pivot", this),
300 abs_skipped_pivot(
"abs_skipped_pivot", this),
301 direction_density(
"direction_density", this),
302 leaving_choices(
"leaving_choices", this),
303 num_perfect_ties(
"num_perfect_ties", this) {}
304 DoubleDistribution bound_shift;
305 DoubleDistribution abs_used_pivot;
306 DoubleDistribution abs_tested_pivot;
307 DoubleDistribution abs_skipped_pivot;
308 RatioDistribution direction_density;
309 IntegerDistribution leaving_choices;
310 IntegerDistribution num_perfect_ties;
313 enum class Phase { FEASIBILITY, OPTIMIZATION, PUSH };
315 enum class RefactorizationReason {
325 ABSL_MUST_USE_RESULT Status SolveInternal(
double start_time,
bool maximize,
334 void PropagateParameters();
348 std::string GetPrettySolverStats()
const;
352 std::string SimpleVariableInfo(ColIndex col)
const;
355 void DisplayIterationInfo(
bool primal, RefactorizationReason reason =
356 RefactorizationReason::DEFAULT);
359 void DisplayErrors();
362 void DisplayInfoOnVariables()
const;
365 void DisplayVariableBounds();
381 void DisplayRevisedSimplexDebugInfo();
384 void DisplayProblem();
393 Fractional ComputeInitialProblemObjectiveValue()
const;
397 void SetVariableNames();
403 void SetNonBasicVariableStatusAndDeriveValue(ColIndex col,
409 bool BasisIsConsistent()
const;
414 void UpdateBasis(ColIndex entering_col, RowIndex basis_row,
424 bool InitializeMatrixAndTestIfUnchanged(
const LinearProgram& lp,
425 bool lp_is_in_equation_form,
426 bool* only_change_is_new_rows,
427 bool* only_change_is_new_cols,
428 ColIndex* num_new_cols);
432 bool OldBoundsAreUnchangedAndNewVariablesHaveOneBoundAtZero(
433 const LinearProgram& lp,
bool lp_is_in_equation_form,
434 ColIndex num_new_cols);
437 bool InitializeObjectiveAndTestIfUnchanged(
const LinearProgram& lp);
440 void InitializeObjectiveLimit();
444 ABSL_MUST_USE_RESULT Status CreateInitialBasis();
448 ABSL_MUST_USE_RESULT Status
452 ABSL_MUST_USE_RESULT Status Initialize(
const LinearProgram& lp);
453 ABSL_MUST_USE_RESULT Status FinishInitialization(
bool solve_from_scratch);
459 void DisplayBasicVariableStatistics();
468 RowIndex ComputeNumberOfEmptyRows();
472 ColIndex ComputeNumberOfEmptyColumns();
477 int ComputeNumberOfSuperBasicVariables()
const;
489 void CorrectErrorsOnVariableValues();
492 void ComputeVariableValuesError();
497 void ComputeDirection(ColIndex col);
500 Fractional ComputeDirectionError(ColIndex col);
507 template <
bool is_entering_reduced_cost_positive>
509 const DenseRow& upper_bounds, RowIndex row)
const;
515 template <
bool is_entering_reduced_cost_positive>
516 Fractional ComputeHarrisRatioAndLeavingCandidates(
524 Status ChooseLeavingVariableRow(ColIndex entering_col,
526 RowIndex* leaving_row,
535 void PrimalPhaseIChooseLeavingVariableRow(ColIndex entering_col,
538 RowIndex* leaving_row,
550 ABSL_MUST_USE_RESULT Status DualChooseLeavingVariableRow(
551 RowIndex* leaving_row,
Fractional* cost_variation,
559 void DualPhaseIUpdatePrice(RowIndex leaving_row, ColIndex entering_col);
563 template <
bool use_dense_update = false>
569 template <
typename Cols>
570 void DualPhaseIUpdatePriceOnReducedCostChange(
const Cols& cols);
579 ABSL_MUST_USE_RESULT Status DualPhaseIChooseLeavingVariableRow(
580 RowIndex* leaving_row,
Fractional* cost_variation,
591 template <
typename BoxedVariableCols>
592 void MakeBoxedVariableDualFeasible(
const BoxedVariableCols& cols,
593 bool update_basic_values);
597 Fractional ComputeStepToMoveBasicVariableToBound(RowIndex leaving_row,
601 bool TestPivot(ColIndex entering_col, RowIndex leaving_row);
612 ABSL_MUST_USE_RESULT Status UpdateAndPivot(ColIndex entering_col,
613 RowIndex leaving_row,
617 void DisplayAllStats();
626 Status RefactorizeBasisIfNeeded(
bool* refactorize);
629 ABSL_MUST_USE_RESULT Status PrimalMinimize(TimeLimit*
time_limit);
632 ABSL_MUST_USE_RESULT Status DualMinimize(
bool feasibility_phase,
640 ABSL_MUST_USE_RESULT Status PrimalPush(TimeLimit*
time_limit);
650 ABSL_MUST_USE_RESULT Status Polish(TimeLimit*
time_limit);
655 ColIndex SlackColIndex(RowIndex row)
const;
662 void AdvanceDeterministicTime(TimeLimit*
time_limit);
668 RowIndex num_rows_ = RowIndex(0);
671 ColIndex num_cols_ = ColIndex(0);
676 ColIndex first_slack_col_ = ColIndex(0);
683 CompactSparseMatrix compact_matrix_;
686 CompactSparseMatrix transposed_matrix_;
711 DenseRow dual_infeasibility_improvement_direction_;
712 int num_dual_infeasible_positions_;
715 ScatteredColumn initially_all_zero_scratchpad_;
724 StrictITIVector<ColIndex, std::string> variable_name_;
727 RefactorizationReason last_refactorization_reason_;
735 DenseRow solution_dual_ray_row_combination_;
736 BasisState solution_state_;
737 bool solution_state_has_been_set_externally_;
743 bool transpose_was_changed_ =
false;
749 ScatteredColumn direction_;
759 absl::BitGen absl_random_;
762 absl::BitGenRef random_;
765 SolverLogger default_logger_;
766 SolverLogger* logger_ = &default_logger_;
769 BasisFactorization basis_factorization_;
772 VariablesInfo variables_info_;
773 PrimalEdgeNorms primal_edge_norms_;
774 DualEdgeNorms dual_edge_norms_;
775 DynamicMaximum<RowIndex> dual_prices_;
776 VariableValues variable_values_;
777 UpdateRow update_row_;
779 EnteringVariable entering_variable_;
780 PrimalPrices primal_prices_;
787 std::vector<ColIndex> bound_flip_candidates_;
790 uint64_t num_iterations_ = 0;
793 uint64_t num_feasibility_iterations_ = 0;
796 uint64_t num_optimization_iterations_ = 0;
799 uint64_t num_push_iterations_ = 0;
802 int64_t num_update_price_operations_ = 0;
805 double total_time_ = 0.0;
808 double feasibility_time_ = 0.0;
811 double optimization_time_ = 0.0;
814 double push_time_ = 0.0;
818 double last_deterministic_time_update_ = 0.0;
821 IterationStats iteration_stats_;
823 mutable RatioTestStats ratio_test_stats_;
827 mutable StatsGroup function_stats_;
835 GlopParameters parameters_;
836 GlopParameters initial_parameters_;
840 LuFactorization test_lu_;
843 int num_consecutive_degenerate_iterations_;
846 Phase phase_ = Phase::FEASIBILITY;
853 bool objective_limit_reached_;
862 std::vector<RowIndex> equivalent_leaving_choices_;