21 #ifndef OR_TOOLS_GLOP_PREPROCESSOR_H_ 22 #define OR_TOOLS_GLOP_PREPROCESSOR_H_ 121 void RunAndPushIfRelevant(std::unique_ptr<Preprocessor> preprocessor,
126 std::vector<std::unique_ptr<Preprocessor>> preprocessors_;
129 EntryIndex initial_num_entries_;
130 RowIndex initial_num_rows_;
131 ColIndex initial_num_cols_;
157 absl::flat_hash_map<ColIndex, int> saved_columns_index_;
161 std::deque<SparseColumn> saved_columns_;
189 return col < is_column_deleted_.
size() && is_column_deleted_[
col];
244 return row < is_row_deleted_.
size() && is_row_deleted_[
row];
342 bool lp_is_maximization_problem_;
391 const MatrixEntry&
Entry()
const {
return e_; }
408 bool is_maximization_;
438 MatrixEntry GetSingletonColumnMatrixEntry(ColIndex
col,
440 MatrixEntry GetSingletonRowMatrixEntry(RowIndex
row,
450 void UpdateConstraintBoundsWithVariableBounds(MatrixEntry e,
455 bool IntegerSingletonColumnIsRemovable(
const MatrixEntry& matrix_entry,
461 void DeleteZeroCostSingletonColumn(
const SparseMatrix& matrix_transpose,
481 bool MakeConstraintAnEqualityIfPossible(
const SparseMatrix& matrix_transpose,
487 void DeleteSingletonColumnInEquality(
const SparseMatrix& matrix_transpose,
492 std::vector<SingletonUndo> undo_stack_;
563 bool lp_is_maximization_problem_;
668 RowIndex
row[NUM_ROWS];
672 SparseColumn deleted_row_as_column;
675 std::vector<RestoreInfo> restore_stack_;
676 RowDeletionHelper row_deletion_helper_;
823 std::vector<ColIndex> changed_columns_;
849 NUM_DOUBLETON_COLS = 2,
851 static ColChoice OtherColChoice(ColChoice x) {
852 return x == DELETED ? MODIFIED : DELETED;
855 ColumnDeletionHelper column_deletion_helper_;
856 RowDeletionHelper row_deletion_helper_;
865 ColIndex
col[NUM_DOUBLETON_COLS];
869 Fractional objective_coefficient[NUM_DOUBLETON_COLS];
884 ColChoiceAndStatus bound_backtracking_at_lower_bound;
885 ColChoiceAndStatus bound_backtracking_at_upper_bound;
887 void SwapDeletedAndModifiedVariableRestoreInfo(RestoreInfo* r);
889 std::vector<RestoreInfo> restore_stack_;
911 ProblemSolution* solution);
931 LOG(
FATAL) <<
"In the presence of integer variables, " 932 <<
"there is no notion of a dual problem.";
942 RowIndex primal_num_rows_;
943 ColIndex primal_num_cols_;
944 bool primal_is_maximization_problem_;
1075 ColIndex first_slack_col_;
1081 #endif // OR_TOOLS_GLOP_PREPROCESSOR_H_ virtual void RecoverSolution(ProblemSolution *solution) const =0
~DoubletonFreeColumnPreprocessor() final
~SingletonColumnSignPreprocessor() final
ProportionalColumnPreprocessor(const GlopParameters *parameters)
A simple class to enforce both an elapsed time limit and a deterministic time limit in the same threa...
DualizerPreprocessor & operator=(const DualizerPreprocessor &)=delete
bool Run(LinearProgram *lp) final
void RecoverSolution(ProblemSolution *solution) const final
ColumnDeletionHelper & operator=(const ColumnDeletionHelper &)=delete
double preprocessor_zero_tolerance() const
RemoveNearZeroEntriesPreprocessor & operator=(const RemoveNearZeroEntriesPreprocessor &)=delete
SingletonColumnSignPreprocessor & operator=(const SingletonColumnSignPreprocessor &)=delete
FixedVariablePreprocessor(const GlopParameters *parameters)
void RecoverSolution(ProblemSolution *solution) const final
FixedVariablePreprocessor & operator=(const FixedVariablePreprocessor &)=delete
void RecoverSolution(ProblemSolution *solution) const final
void RemoveZeroCostUnconstrainedVariable(ColIndex col, Fractional target_bound, LinearProgram *lp)
ToMinimizationPreprocessor(const GlopParameters *parameters)
bool Run(LinearProgram *lp) final
FreeConstraintPreprocessor & operator=(const FreeConstraintPreprocessor &)=delete
ShiftVariableBoundsPreprocessor & operator=(const ShiftVariableBoundsPreprocessor &)=delete
ModelSharedTimeLimit * time_limit
ForcingAndImpliedFreeConstraintPreprocessor & operator=(const ForcingAndImpliedFreeConstraintPreprocessor &)=delete
Preprocessor & operator=(const Preprocessor &)=delete
const DenseBooleanRow & GetMarkedColumns() const
ShiftVariableBoundsPreprocessor(const GlopParameters *parameters)
bool IsSmallerWithinTolerance(FloatType x, FloatType y, FloatType tolerance)
bool Run(LinearProgram *lp) final
bool IsColumnMarked(ColIndex col) const
DoubletonFreeColumnPreprocessor & operator=(const DoubletonFreeColumnPreprocessor &)=delete
DoubletonEqualityRowPreprocessor & operator=(const DoubletonEqualityRowPreprocessor &)=delete
~AddSlackVariablesPreprocessor() final
~ToMinimizationPreprocessor() final
const DenseRow & GetStoredValue() const
~DoubletonEqualityRowPreprocessor() final
bool Run(LinearProgram *lp) final
~ShiftVariableBoundsPreprocessor() final
ScalingPreprocessor(const GlopParameters *parameters)
bool Run(LinearProgram *lp) final
void RecoverSolution(ProblemSolution *solution) const final
double solution_feasibility_tolerance() const
bool Run(LinearProgram *lp) final
~ProportionalRowPreprocessor() final
SingletonUndo(OperationType type, const LinearProgram &lp, MatrixEntry e, ConstraintStatus status)
SingletonColumnSignPreprocessor(const GlopParameters *parameters)
UnconstrainedVariablePreprocessor & operator=(const UnconstrainedVariablePreprocessor &)=delete
void RecoverSolution(ProblemSolution *solution) const final
DoubletonFreeColumnPreprocessor(const GlopParameters *parameters)
bool Run(LinearProgram *lp) final
~EmptyConstraintPreprocessor() final
ProportionalRowPreprocessor(const GlopParameters *parameters)
void RecoverSolution(ProblemSolution *solution) const final
DualizerPreprocessor(const GlopParameters *parameters)
~EmptyColumnPreprocessor() final
MainLpPreprocessor(const GlopParameters *parameters)
virtual void UseInMipContext()
ProblemStatus status() const
~FixedVariablePreprocessor() final
bool Run(LinearProgram *lp) final
bool Run(LinearProgram *lp) final
MatrixEntry(RowIndex _row, ColIndex _col, Fractional _coeff)
void RecoverSolution(ProblemSolution *solution) const final
StrictITIVector< RowIndex, Fractional > DenseColumn
bool Run(LinearProgram *lp) final
EmptyConstraintPreprocessor(const GlopParameters *parameters)
bool Run(LinearProgram *lp) final
bool Run(LinearProgram *lp) final
EmptyConstraintPreprocessor & operator=(const EmptyConstraintPreprocessor &)=delete
bool Run(LinearProgram *lp) final
void SetTimeLimit(TimeLimit *time_limit)
ScalingPreprocessor & operator=(const ScalingPreprocessor &)=delete
EmptyColumnPreprocessor & operator=(const EmptyColumnPreprocessor &)=delete
void MarkColumnForDeletion(ColIndex col)
~FreeConstraintPreprocessor() final
std::unique_ptr< TimeLimit > infinite_time_limit_
void DestructiveRecoverSolution(ProblemSolution *solution)
ImpliedFreePreprocessor(const GlopParameters *parameters)
ForcingAndImpliedFreeConstraintPreprocessor(const GlopParameters *parameters)
const MatrixEntry & Entry() const
void RecoverSolution(ProblemSolution *solution) const final
bool IsRowMarked(RowIndex row) const
bool Run(LinearProgram *lp) final
MainLpPreprocessor & operator=(const MainLpPreprocessor &)=delete
void FixConstraintWithFixedStatuses(const DenseColumn &row_lower_bounds, const DenseColumn &row_upper_bounds, ProblemSolution *solution)
void RecoverSolution(ProblemSolution *solution) const final
virtual bool Run(LinearProgram *lp)=0
bool Run(LinearProgram *lp) final
FreeConstraintPreprocessor(const GlopParameters *parameters)
void UnmarkRow(RowIndex row)
~UnconstrainedVariablePreprocessor() final
SingletonPreprocessor & operator=(const SingletonPreprocessor &)=delete
UnconstrainedVariablePreprocessor(const GlopParameters *parameters)
~ProportionalColumnPreprocessor() final
void MarkColumnForDeletionWithState(ColIndex col, Fractional value, VariableStatus status)
RemoveNearZeroEntriesPreprocessor(const GlopParameters *parameters)
DoubletonEqualityRowPreprocessor(const GlopParameters *parameters)
void RecoverSolution(ProblemSolution *solution) const final
const SparseColumn & SavedColumn(ColIndex col) const
void RecoverSolution(ProblemSolution *solution) const final
~ImpliedFreePreprocessor() final
const DenseBooleanColumn & GetMarkedRows() const
void RecoverSolution(ProblemSolution *solution) const final
RowDeletionHelper & operator=(const RowDeletionHelper &)=delete
ProportionalRowPreprocessor & operator=(const ProportionalRowPreprocessor &)=delete
AddSlackVariablesPreprocessor(const GlopParameters *parameters)
bool Run(LinearProgram *lp) final
void RestoreDeletedRows(ProblemSolution *solution) const
Collection of objects used to extend the Constraint Solver library.
bool Run(LinearProgram *lp) final
ProblemStatus ChangeStatusToDualStatus(ProblemStatus status) const
~MainLpPreprocessor() override
SingletonPreprocessor(const GlopParameters *parameters)
ColChoiceAndStatus(ColChoice c, VariableStatus s, Fractional v)
AddSlackVariablesPreprocessor & operator=(const AddSlackVariablesPreprocessor &)=delete
const SparseColumn & SavedOrEmptyColumn(ColIndex col) const
void MarkRowForDeletion(RowIndex row)
ProportionalColumnPreprocessor & operator=(const ProportionalColumnPreprocessor &)=delete
~ScalingPreprocessor() final
bool IsSmallerWithinPreprocessorZeroTolerance(Fractional a, Fractional b) const
bool Run(LinearProgram *lp) final
~DualizerPreprocessor() final
void RecoverSolution(ProblemSolution *solution) const final
ToMinimizationPreprocessor & operator=(const ToMinimizationPreprocessor &)=delete
void UseInMipContext() final
void RecoverSolution(ProblemSolution *solution) const final
void RecoverSolution(ProblemSolution *solution) const override
void Undo(const GlopParameters ¶meters, const SparseColumn &saved_column, const SparseColumn &saved_row, ProblemSolution *solution) const
void RecoverSolution(ProblemSolution *solution) const final
bool Run(LinearProgram *lp) final
const DenseRow & offsets() const
ImpliedFreePreprocessor & operator=(const ImpliedFreePreprocessor &)=delete
void RecoverSolution(ProblemSolution *solution) const final
void UseInMipContext() final
void RecoverSolution(ProblemSolution *solution) const final
bool IsSmallerWithinFeasibilityTolerance(Fractional a, Fractional b) const
void RestoreDeletedColumns(ProblemSolution *solution) const
void SaveColumn(ColIndex col, const SparseColumn &column)
bool Run(LinearProgram *lp) final
void UseInMipContext() final
Preprocessor(const GlopParameters *parameters)
~ForcingAndImpliedFreeConstraintPreprocessor() final
const GlopParameters & parameters_
~SingletonPreprocessor() final
void SaveColumnIfNotAlreadyDone(ColIndex col, const SparseColumn &column)
~RemoveNearZeroEntriesPreprocessor() final
EmptyColumnPreprocessor(const GlopParameters *parameters)
void RecoverSolution(ProblemSolution *solution) const final
void RecoverSolution(ProblemSolution *solution) const final