23#ifndef ORTOOLS_LP_DATA_LP_DATA_H_
24#define ORTOOLS_LP_DATA_LP_DATA_H_
33#include "absl/container/flat_hash_map.h"
34#include "absl/container/flat_hash_set.h"
35#include "absl/log/check.h"
36#include "absl/strings/string_view.h"
82 const std::string&
name()
const {
return name_; }
93 const std::string&
name);
223 return constraint_lower_bounds_;
226 return constraint_upper_bounds_;
231 return objective_coefficients_;
237 return variable_lower_bounds_;
240 return variable_upper_bounds_;
245 return variable_types_;
269 return objective_scaling_factor_;
311 std::string
Dump()
const;
462 bool detect_integer_constraints_for_slack);
551 DCHECK(matrix_.IsCleanedUp());
552 columns_are_known_to_be_clean_ =
true;
561 return &constraint_lower_bounds_;
564 return &constraint_upper_bounds_;
573 void UpdateAllIntegerVariableLists()
const;
577 std::string ProblemStatFormatter(absl::string_view format)
const;
581 std::string NonZeroStatFormatter(absl::string_view format)
const;
584 void ResizeRowsIfNeeded(RowIndex row);
589 void PopulateNameObjectiveAndVariablesFromLinearProgram(
615 mutable std::vector<ColIndex> integer_variables_list_;
618 mutable std::vector<ColIndex> binary_variables_list_;
622 mutable std::vector<ColIndex> non_binary_variables_list_;
625 absl::flat_hash_map<std::string, ColIndex> variable_table_;
628 absl::flat_hash_map<std::string, RowIndex> constraint_table_;
641 mutable bool columns_are_known_to_be_clean_;
644 mutable bool transpose_matrix_is_consistent_;
648 mutable bool integer_variables_list_is_consistent_;
655 ColIndex first_slack_variable_;
658 bool dcheck_bounds_ =
true;
668struct ProblemSolution {
705 if (std::isnan(lower_bound))
return false;
706 if (std::isnan(upper_bound))
return false;
709 if (lower_bound > upper_bound)
return false;
GlopParameters_ScalingAlgorithm ScalingAlgorithm
GlopParameters_CostScalingAlgorithm CostScalingAlgorithm
void SetName(absl::string_view name)
bool BoundsOfIntegerConstraintsAreInteger(Fractional tolerance) const
std::string GetDimensionString() const
const DenseRow & objective_coefficients() const
void SetConstraintName(RowIndex row, absl::string_view name)
const std::vector< ColIndex > & NonBinaryVariablesList() const
StrictITIVector< ColIndex, VariableType > variable_types() const
std::string GetPrettyNonZeroStats() const
void NotifyThatColumnsAreClean()
void DeleteColumns(const DenseBooleanRow &columns_to_delete)
void RemoveNearZeroEntries(Fractional threshold)
bool BoundsOfIntegerVariablesAreInteger(Fractional tolerance) const
void ComputeSlackVariableValues(DenseRow *solution) const
bool IsValid(Fractional max_valid_magnitude=kInfinity) const
Fractional GetObjectiveCoefficientForMinimizationVersion(ColIndex col) const
void PopulateFromPermutedLinearProgram(const LinearProgram &lp, const RowPermutation &row_permutation, const ColumnPermutation &col_permutation)
void PopulateFromLinearProgramVariables(const LinearProgram &linear_program)
bool SolutionIsInteger(const DenseRow &solution, Fractional absolute_tolerance) const
void SetObjectiveOffset(Fractional objective_offset)
std::string GetConstraintName(RowIndex row) const
DenseColumn * mutable_constraint_upper_bounds()
void SetObjectiveCoefficient(ColIndex col, Fractional value)
bool SolutionIsLPFeasible(const DenseRow &solution, Fractional absolute_tolerance) const
std::string GetPrettyProblemStats() const
void Scale(SparseMatrixScaler *scaler)
const std::string & name() const
bool SolutionIsWithinVariableBounds(const DenseRow &solution, Fractional absolute_tolerance) const
Fractional RemoveObjectiveScalingAndOffset(Fractional value) const
void SetObjectiveScalingFactor(Fractional objective_scaling_factor)
bool IsInEquationForm() const
const DenseColumn & constraint_lower_bounds() const
const SparseMatrix & GetTransposeSparseMatrix() const
void AddSlackVariablesWhereNecessary(bool detect_integer_constraints)
void ClearTransposeMatrix()
const DenseRow & variable_lower_bounds() const
void SetVariableBounds(ColIndex col, Fractional lower_bound, Fractional upper_bound)
ColIndex GetSlackVariable(RowIndex row) const
const std::vector< ColIndex > & BinaryVariablesList() const
EntryIndex num_entries() const
DenseColumn * mutable_constraint_lower_bounds()
SparseMatrix * GetMutableTransposeSparseMatrix()
void DeleteSlackVariables()
bool IsMaximizationProblem() const
SparseColumn * GetMutableSparseColumn(ColIndex col)
const SparseMatrix & GetSparseMatrix() const
void AddConstraintsWithSlackVariables(const SparseMatrix &coefficients, const DenseColumn &left_hand_sides, const DenseColumn &right_hand_sides, const StrictITIVector< RowIndex, std::string > &names, bool detect_integer_constraints_for_slack)
const std::vector< ColIndex > & IntegerVariablesList() const
std::string GetProblemStats() const
bool IsVariableBinary(ColIndex col) const
Fractional ScaleObjective(GlopParameters::CostScalingAlgorithm method)
void Swap(LinearProgram *linear_program)
void DeleteRows(const DenseBooleanColumn &rows_to_delete)
void SetVariableType(ColIndex col, VariableType type)
ColIndex FindOrCreateVariable(absl::string_view variable_id)
std::string DumpSolution(const DenseRow &variable_values) const
bool SolutionIsMIPFeasible(const DenseRow &solution, Fractional absolute_tolerance) const
void SetConstraintBounds(RowIndex row, Fractional lower_bound, Fractional upper_bound)
void SetCoefficient(RowIndex row, ColIndex col, Fractional value)
void UseTransposeMatrixAsReference()
std::string GetVariableName(ColIndex col) const
LinearProgram(const LinearProgram &)=delete
const DenseRow & variable_upper_bounds() const
void AddConstraints(const SparseMatrix &coefficients, const DenseColumn &left_hand_sides, const DenseColumn &right_hand_sides, const StrictITIVector< RowIndex, std::string > &names)
void SetVariableName(ColIndex col, absl::string_view name)
ColIndex CreateNewSlackVariable(bool is_integer_slack_variable, Fractional lower_bound, Fractional upper_bound, const std::string &name)
VariableType GetVariableType(ColIndex col) const
const DenseColumn & constraint_upper_bounds() const
std::string GetNonZeroStats() const
RowIndex CreateNewConstraint()
const SparseColumn & GetSparseColumn(ColIndex col) const
bool IsVariableInteger(ColIndex col) const
void PopulateFromLinearProgram(const LinearProgram &linear_program)
bool UpdateVariableBoundsToIntersection(const DenseRow &variable_lower_bounds, const DenseRow &variable_upper_bounds)
LinearProgram & operator=(const LinearProgram &)=delete
void SetDcheckBounds(bool dcheck_bounds)
Fractional objective_scaling_factor() const
Fractional ApplyObjectiveScalingAndOffset(Fractional value) const
ColIndex num_variables() const
ColIndex GetFirstSlackVariable() const
std::string GetObjectiveStatsString() const
ColIndex CreateNewVariable()
Fractional objective_offset() const
RowIndex num_constraints() const
std::string GetBoundsStatsString() const
RowIndex FindOrCreateConstraint(absl::string_view constraint_id)
void PopulateFromDual(const LinearProgram &dual, RowToColMapping *duplicated_rows)
void SetMaximizationProblem(bool maximize)
StrictITIVector< RowIndex, ColIndex > RowToColMapping
bool AreBoundsValid(Fractional lower_bound, Fractional upper_bound)
StrictITIVector< RowIndex, bool > DenseBooleanColumn
Permutation< ColIndex > ColumnPermutation
StrictITIVector< RowIndex, ConstraintStatus > ConstraintStatusColumn
Permutation< RowIndex > RowPermutation
StrictITIVector< ColIndex, VariableStatus > VariableStatusRow
constexpr Fractional kInfinity
StrictITIVector< RowIndex, Fractional > DenseColumn
StrictITIVector< ColIndex, Fractional > DenseRow
StrictITIVector< ColIndex, bool > DenseBooleanRow
Select next search node to expand Select next item_i to add this new search node to the search Generate a new search node where item_i is not in the knapsack Check validity of this new partial solution(using propagators) - If valid
ConstraintStatusColumn constraint_statuses
std::string DebugString() const
VariableStatusRow variable_statuses
ProblemSolution(RowIndex num_rows, ColIndex num_cols)