21 #ifndef OR_TOOLS_GLOP_PREPROCESSOR_H_ 22 #define OR_TOOLS_GLOP_PREPROCESSOR_H_ 124 void RunAndPushIfRelevant(std::unique_ptr<Preprocessor> preprocessor,
129 std::vector<std::unique_ptr<Preprocessor>> preprocessors_;
136 EntryIndex initial_num_entries_;
137 RowIndex initial_num_rows_;
138 ColIndex initial_num_cols_;
164 absl::flat_hash_map<ColIndex, int> saved_columns_index_;
168 std::deque<SparseColumn> saved_columns_;
196 return col < is_column_deleted_.
size() && is_column_deleted_[
col];
251 return row < is_row_deleted_.
size() && is_row_deleted_[
row];
349 bool lp_is_maximization_problem_;
398 const MatrixEntry&
Entry()
const {
return e_; }
415 bool is_maximization_;
445 MatrixEntry GetSingletonColumnMatrixEntry(ColIndex
col,
447 MatrixEntry GetSingletonRowMatrixEntry(RowIndex
row,
457 void UpdateConstraintBoundsWithVariableBounds(MatrixEntry e,
462 bool IntegerSingletonColumnIsRemovable(
const MatrixEntry& matrix_entry,
468 void DeleteZeroCostSingletonColumn(
const SparseMatrix& matrix_transpose,
488 bool MakeConstraintAnEqualityIfPossible(
const SparseMatrix& matrix_transpose,
494 void DeleteSingletonColumnInEquality(
const SparseMatrix& matrix_transpose,
499 std::vector<SingletonUndo> undo_stack_;
570 bool lp_is_maximization_problem_;
675 RowIndex
row[NUM_ROWS];
679 SparseColumn deleted_row_as_column;
682 std::vector<RestoreInfo> restore_stack_;
683 RowDeletionHelper row_deletion_helper_;
830 std::vector<ColIndex> changed_columns_;
856 NUM_DOUBLETON_COLS = 2,
858 static ColChoice OtherColChoice(ColChoice x) {
859 return x == DELETED ? MODIFIED : DELETED;
862 ColumnDeletionHelper column_deletion_helper_;
863 RowDeletionHelper row_deletion_helper_;
872 ColIndex
col[NUM_DOUBLETON_COLS];
876 Fractional objective_coefficient[NUM_DOUBLETON_COLS];
891 ColChoiceAndStatus bound_backtracking_at_lower_bound;
892 ColChoiceAndStatus bound_backtracking_at_upper_bound;
894 void SwapDeletedAndModifiedVariableRestoreInfo(RestoreInfo* r);
896 std::vector<RestoreInfo> restore_stack_;
918 ProblemSolution* solution);
938 LOG(
FATAL) <<
"In the presence of integer variables, " 939 <<
"there is no notion of a dual problem.";
949 RowIndex primal_num_rows_;
950 ColIndex primal_num_cols_;
951 bool primal_is_maximization_problem_;
1082 ColIndex first_slack_col_;
1088 #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
void SetLogger(SolverLogger *logger)
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