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_;
A simple class to enforce both an elapsed time limit and a deterministic time limit in the same threa...
AddSlackVariablesPreprocessor(const AddSlackVariablesPreprocessor &)=delete
AddSlackVariablesPreprocessor(const GlopParameters *parameters)
bool Run(LinearProgram *lp) final
void RecoverSolution(ProblemSolution *solution) const final
AddSlackVariablesPreprocessor & operator=(const AddSlackVariablesPreprocessor &)=delete
~AddSlackVariablesPreprocessor() final
ColumnDeletionHelper(const ColumnDeletionHelper &)=delete
bool IsColumnMarked(ColIndex col) const
void MarkColumnForDeletionWithState(ColIndex col, Fractional value, VariableStatus status)
void MarkColumnForDeletion(ColIndex col)
const DenseBooleanRow & GetMarkedColumns() const
ColumnDeletionHelper & operator=(const ColumnDeletionHelper &)=delete
const DenseRow & GetStoredValue() const
void RestoreDeletedColumns(ProblemSolution *solution) const
const SparseColumn & SavedOrEmptyColumn(ColIndex col) const
void SaveColumnIfNotAlreadyDone(ColIndex col, const SparseColumn &column)
void SaveColumn(ColIndex col, const SparseColumn &column)
const SparseColumn & SavedColumn(ColIndex col) const
~DoubletonEqualityRowPreprocessor() final
DoubletonEqualityRowPreprocessor(const DoubletonEqualityRowPreprocessor &)=delete
bool Run(LinearProgram *lp) final
void RecoverSolution(ProblemSolution *solution) const final
DoubletonEqualityRowPreprocessor(const GlopParameters *parameters)
DoubletonEqualityRowPreprocessor & operator=(const DoubletonEqualityRowPreprocessor &)=delete
bool Run(LinearProgram *lp) final
void RecoverSolution(ProblemSolution *solution) const final
DoubletonFreeColumnPreprocessor & operator=(const DoubletonFreeColumnPreprocessor &)=delete
~DoubletonFreeColumnPreprocessor() final
DoubletonFreeColumnPreprocessor(const DoubletonFreeColumnPreprocessor &)=delete
DoubletonFreeColumnPreprocessor(const GlopParameters *parameters)
DualizerPreprocessor(const DualizerPreprocessor &)=delete
~DualizerPreprocessor() final
bool Run(LinearProgram *lp) final
void RecoverSolution(ProblemSolution *solution) const final
ProblemStatus ChangeStatusToDualStatus(ProblemStatus status) const
void UseInMipContext() final
DualizerPreprocessor(const GlopParameters *parameters)
DualizerPreprocessor & operator=(const DualizerPreprocessor &)=delete
EmptyColumnPreprocessor(const GlopParameters *parameters)
~EmptyColumnPreprocessor() final
bool Run(LinearProgram *lp) final
void RecoverSolution(ProblemSolution *solution) const final
EmptyColumnPreprocessor(const EmptyColumnPreprocessor &)=delete
EmptyColumnPreprocessor & operator=(const EmptyColumnPreprocessor &)=delete
EmptyConstraintPreprocessor & operator=(const EmptyConstraintPreprocessor &)=delete
~EmptyConstraintPreprocessor() final
bool Run(LinearProgram *lp) final
void RecoverSolution(ProblemSolution *solution) const final
EmptyConstraintPreprocessor(const EmptyConstraintPreprocessor &)=delete
EmptyConstraintPreprocessor(const GlopParameters *parameters)
FixedVariablePreprocessor(const FixedVariablePreprocessor &)=delete
~FixedVariablePreprocessor() final
bool Run(LinearProgram *lp) final
void RecoverSolution(ProblemSolution *solution) const final
FixedVariablePreprocessor & operator=(const FixedVariablePreprocessor &)=delete
FixedVariablePreprocessor(const GlopParameters *parameters)
ForcingAndImpliedFreeConstraintPreprocessor(const GlopParameters *parameters)
ForcingAndImpliedFreeConstraintPreprocessor(const ForcingAndImpliedFreeConstraintPreprocessor &)=delete
bool Run(LinearProgram *lp) final
void RecoverSolution(ProblemSolution *solution) const final
ForcingAndImpliedFreeConstraintPreprocessor & operator=(const ForcingAndImpliedFreeConstraintPreprocessor &)=delete
~ForcingAndImpliedFreeConstraintPreprocessor() final
bool Run(LinearProgram *lp) final
FreeConstraintPreprocessor(const FreeConstraintPreprocessor &)=delete
void RecoverSolution(ProblemSolution *solution) const final
~FreeConstraintPreprocessor() final
FreeConstraintPreprocessor(const GlopParameters *parameters)
FreeConstraintPreprocessor & operator=(const FreeConstraintPreprocessor &)=delete
double preprocessor_zero_tolerance() const
double solution_feasibility_tolerance() const
bool Run(LinearProgram *lp) final
ImpliedFreePreprocessor(const ImpliedFreePreprocessor &)=delete
void RecoverSolution(ProblemSolution *solution) const final
ImpliedFreePreprocessor(const GlopParameters *parameters)
~ImpliedFreePreprocessor() final
ImpliedFreePreprocessor & operator=(const ImpliedFreePreprocessor &)=delete
void RecoverSolution(ProblemSolution *solution) const override
MainLpPreprocessor(const MainLpPreprocessor &)=delete
MainLpPreprocessor(const GlopParameters *parameters)
bool Run(LinearProgram *lp) final
void DestructiveRecoverSolution(ProblemSolution *solution)
MainLpPreprocessor & operator=(const MainLpPreprocessor &)=delete
~MainLpPreprocessor() override
ProblemStatus status() const
virtual void RecoverSolution(ProblemSolution *solution) const =0
bool IsSmallerWithinPreprocessorZeroTolerance(Fractional a, Fractional b) const
Preprocessor(const GlopParameters *parameters)
const GlopParameters & parameters_
Preprocessor & operator=(const Preprocessor &)=delete
Preprocessor(const Preprocessor &)=delete
std::unique_ptr< TimeLimit > infinite_time_limit_
virtual void UseInMipContext()
virtual bool Run(LinearProgram *lp)=0
void SetTimeLimit(TimeLimit *time_limit)
bool IsSmallerWithinFeasibilityTolerance(Fractional a, Fractional b) const
ProportionalColumnPreprocessor & operator=(const ProportionalColumnPreprocessor &)=delete
ProportionalColumnPreprocessor(const ProportionalColumnPreprocessor &)=delete
ProportionalColumnPreprocessor(const GlopParameters *parameters)
bool Run(LinearProgram *lp) final
void RecoverSolution(ProblemSolution *solution) const final
void UseInMipContext() final
~ProportionalColumnPreprocessor() final
~ProportionalRowPreprocessor() final
bool Run(LinearProgram *lp) final
ProportionalRowPreprocessor(const GlopParameters *parameters)
void RecoverSolution(ProblemSolution *solution) const final
ProportionalRowPreprocessor & operator=(const ProportionalRowPreprocessor &)=delete
ProportionalRowPreprocessor(const ProportionalRowPreprocessor &)=delete
RemoveNearZeroEntriesPreprocessor & operator=(const RemoveNearZeroEntriesPreprocessor &)=delete
bool Run(LinearProgram *lp) final
void RecoverSolution(ProblemSolution *solution) const final
RemoveNearZeroEntriesPreprocessor(const GlopParameters *parameters)
~RemoveNearZeroEntriesPreprocessor() final
RemoveNearZeroEntriesPreprocessor(const RemoveNearZeroEntriesPreprocessor &)=delete
void MarkRowForDeletion(RowIndex row)
void UnmarkRow(RowIndex row)
void RestoreDeletedRows(ProblemSolution *solution) const
const DenseBooleanColumn & GetMarkedRows() const
RowDeletionHelper & operator=(const RowDeletionHelper &)=delete
bool IsRowMarked(RowIndex row) const
RowDeletionHelper(const RowDeletionHelper &)=delete
bool Run(LinearProgram *lp) final
void RecoverSolution(ProblemSolution *solution) const final
ScalingPreprocessor & operator=(const ScalingPreprocessor &)=delete
void UseInMipContext() final
ScalingPreprocessor(const ScalingPreprocessor &)=delete
~ScalingPreprocessor() final
ScalingPreprocessor(const GlopParameters *parameters)
const DenseRow & offsets() const
ShiftVariableBoundsPreprocessor(const GlopParameters *parameters)
bool Run(LinearProgram *lp) final
void RecoverSolution(ProblemSolution *solution) const final
ShiftVariableBoundsPreprocessor(const ShiftVariableBoundsPreprocessor &)=delete
~ShiftVariableBoundsPreprocessor() final
ShiftVariableBoundsPreprocessor & operator=(const ShiftVariableBoundsPreprocessor &)=delete
~SingletonColumnSignPreprocessor() final
bool Run(LinearProgram *lp) final
void RecoverSolution(ProblemSolution *solution) const final
SingletonColumnSignPreprocessor(const GlopParameters *parameters)
SingletonColumnSignPreprocessor & operator=(const SingletonColumnSignPreprocessor &)=delete
SingletonColumnSignPreprocessor(const SingletonColumnSignPreprocessor &)=delete
SingletonPreprocessor(const SingletonPreprocessor &)=delete
~SingletonPreprocessor() final
bool Run(LinearProgram *lp) final
void RecoverSolution(ProblemSolution *solution) const final
SingletonPreprocessor & operator=(const SingletonPreprocessor &)=delete
SingletonPreprocessor(const GlopParameters *parameters)
void Undo(const GlopParameters ¶meters, const SparseColumn &saved_column, const SparseColumn &saved_row, ProblemSolution *solution) const
SingletonUndo(OperationType type, const LinearProgram &lp, MatrixEntry e, ConstraintStatus status)
const MatrixEntry & Entry() const
@ ZERO_COST_SINGLETON_COLUMN
@ MAKE_CONSTRAINT_AN_EQUALITY
@ SINGLETON_COLUMN_IN_EQUALITY
ToMinimizationPreprocessor & operator=(const ToMinimizationPreprocessor &)=delete
ToMinimizationPreprocessor(const ToMinimizationPreprocessor &)=delete
bool Run(LinearProgram *lp) final
void RecoverSolution(ProblemSolution *solution) const final
ToMinimizationPreprocessor(const GlopParameters *parameters)
~ToMinimizationPreprocessor() final
void RemoveZeroCostUnconstrainedVariable(ColIndex col, Fractional target_bound, LinearProgram *lp)
UnconstrainedVariablePreprocessor & operator=(const UnconstrainedVariablePreprocessor &)=delete
bool Run(LinearProgram *lp) final
UnconstrainedVariablePreprocessor(const GlopParameters *parameters)
void RecoverSolution(ProblemSolution *solution) const final
UnconstrainedVariablePreprocessor(const UnconstrainedVariablePreprocessor &)=delete
~UnconstrainedVariablePreprocessor() final
ModelSharedTimeLimit * time_limit
void FixConstraintWithFixedStatuses(const DenseColumn &row_lower_bounds, const DenseColumn &row_upper_bounds, ProblemSolution *solution)
StrictITIVector< RowIndex, Fractional > DenseColumn
Collection of objects used to extend the Constraint Solver library.
bool IsSmallerWithinTolerance(FloatType x, FloatType y, FloatType tolerance)
ColChoiceAndStatus(ColChoice c, VariableStatus s, Fractional v)
MatrixEntry(RowIndex _row, ColIndex _col, Fractional _coeff)