24 #ifndef OR_TOOLS_LP_DATA_LP_DATA_H_
25 #define OR_TOOLS_LP_DATA_LP_DATA_H_
32 #include "absl/container/flat_hash_map.h"
33 #include "absl/container/flat_hash_set.h"
38 #include "ortools/glop/parameters.pb.h"
46 class SparseMatrixScaler;
74 const std::string&
name()
const {
return name_; }
85 const std::string&
name);
215 return constraint_lower_bounds_;
218 return constraint_upper_bounds_;
223 return objective_coefficients_;
229 return variable_lower_bounds_;
232 return variable_upper_bounds_;
237 return variable_types_;
261 return objective_scaling_factor_;
303 std::string
Dump()
const;
454 bool detect_integer_constraints_for_slack);
541 columns_are_known_to_be_clean_ =
true;
550 void UpdateAllIntegerVariableLists()
const;
554 std::string ProblemStatFormatter(
const absl::string_view format)
const;
558 std::string NonZeroStatFormatter(
const absl::string_view format)
const;
561 void ResizeRowsIfNeeded(RowIndex
row);
566 void PopulateNameObjectiveAndVariablesFromLinearProgram(
592 mutable std::vector<ColIndex> integer_variables_list_;
595 mutable std::vector<ColIndex> binary_variables_list_;
599 mutable std::vector<ColIndex> non_binary_variables_list_;
602 absl::flat_hash_map<std::string, ColIndex> variable_table_;
605 absl::flat_hash_map<std::string, RowIndex> constraint_table_;
618 mutable bool columns_are_known_to_be_clean_;
621 mutable bool transpose_matrix_is_consistent_;
625 mutable bool integer_variables_list_is_consistent_;
632 ColIndex first_slack_variable_;
635 bool dcheck_bounds_ =
true;
638 GlopParameters::ScalingAlgorithm scaling_method);
684 if (std::isnan(lower_bound))
return false;
685 if (std::isnan(upper_bound))
return false;
688 if (lower_bound > upper_bound)
return false;
#define DCHECK(condition)
SparseMatrix * GetMutableTransposeSparseMatrix()
std::string GetObjectiveStatsString() const
void SetObjectiveScalingFactor(Fractional objective_scaling_factor)
void PopulateFromPermutedLinearProgram(const LinearProgram &lp, const RowPermutation &row_permutation, const ColumnPermutation &col_permutation)
void SetVariableBounds(ColIndex col, Fractional lower_bound, Fractional upper_bound)
std::string GetVariableName(ColIndex col) const
void SetConstraintName(RowIndex row, absl::string_view name)
const SparseMatrix & GetTransposeSparseMatrix() const
bool SolutionIsWithinVariableBounds(const DenseRow &solution, Fractional absolute_tolerance) const
bool BoundsOfIntegerConstraintsAreInteger(Fractional tolerance) const
bool IsInEquationForm() const
void SetObjectiveOffset(Fractional objective_offset)
void PopulateFromLinearProgram(const LinearProgram &linear_program)
void Scale(SparseMatrixScaler *scaler)
std::string GetPrettyProblemStats() const
bool SolutionIsMIPFeasible(const DenseRow &solution, Fractional absolute_tolerance) const
void SetCoefficient(RowIndex row, ColIndex col, Fractional value)
std::string GetNonZeroStats() const
ColIndex GetFirstSlackVariable() const
const SparseMatrix & GetSparseMatrix() const
bool BoundsOfIntegerVariablesAreInteger(Fractional tolerance) const
void ClearTransposeMatrix()
void SetVariableName(ColIndex col, absl::string_view name)
std::string DumpSolution(const DenseRow &variable_values) const
ColIndex GetSlackVariable(RowIndex row) const
const DenseRow & variable_lower_bounds() const
ColIndex FindOrCreateVariable(const std::string &variable_id)
const DenseColumn & constraint_lower_bounds() const
std::string GetBoundsStatsString() const
Fractional ScaleObjective(GlopParameters::CostScalingAlgorithm method)
const std::vector< ColIndex > & BinaryVariablesList() const
const DenseRow & objective_coefficients() const
Fractional RemoveObjectiveScalingAndOffset(Fractional value) const
const std::vector< ColIndex > & IntegerVariablesList() const
Fractional GetObjectiveCoefficientForMinimizationVersion(ColIndex col) const
void SetConstraintBounds(RowIndex row, Fractional lower_bound, Fractional upper_bound)
ColIndex CreateNewVariable()
ColIndex CreateNewSlackVariable(bool is_integer_slack_variable, Fractional lower_bound, Fractional upper_bound, const std::string &name)
VariableType GetVariableType(ColIndex col) const
RowIndex FindOrCreateConstraint(const std::string &constraint_id)
void SetDcheckBounds(bool dcheck_bounds)
void Swap(LinearProgram *linear_program)
void AddConstraints(const SparseMatrix &coefficients, const DenseColumn &left_hand_sides, const DenseColumn &right_hand_sides, const StrictITIVector< RowIndex, std::string > &names)
std::string GetPrettyNonZeroStats() const
void SetVariableType(ColIndex col, VariableType type)
Fractional objective_offset() const
const std::vector< ColIndex > & NonBinaryVariablesList() const
bool SolutionIsInteger(const DenseRow &solution, Fractional absolute_tolerance) const
SparseColumn * GetMutableSparseColumn(ColIndex col)
std::string GetConstraintName(RowIndex row) const
void SetName(const std::string &name)
void UseTransposeMatrixAsReference()
void AddSlackVariablesWhereNecessary(bool detect_integer_constraints)
const DenseColumn & constraint_upper_bounds() const
void ComputeSlackVariableValues(DenseRow *solution) const
bool SolutionIsLPFeasible(const DenseRow &solution, Fractional absolute_tolerance) const
void NotifyThatColumnsAreClean()
bool IsVariableInteger(ColIndex col) const
void SetObjectiveCoefficient(ColIndex col, Fractional value)
bool IsVariableBinary(ColIndex col) const
Fractional ApplyObjectiveScalingAndOffset(Fractional value) const
void DeleteRows(const DenseBooleanColumn &rows_to_delete)
void DeleteColumns(const DenseBooleanRow &columns_to_delete)
bool IsMaximizationProblem() const
const DenseRow & variable_upper_bounds() const
std::string GetProblemStats() const
ColIndex num_variables() const
bool UpdateVariableBoundsToIntersection(const DenseRow &variable_lower_bounds, const DenseRow &variable_upper_bounds)
void PopulateFromDual(const LinearProgram &dual, RowToColMapping *duplicated_rows)
void DeleteSlackVariables()
const std::string & name() const
RowIndex CreateNewConstraint()
void PopulateFromLinearProgramVariables(const LinearProgram &linear_program)
std::string GetDimensionString() const
Fractional objective_scaling_factor() const
void SetMaximizationProblem(bool maximize)
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 StrictITIVector< ColIndex, VariableType > variable_types() const
const SparseColumn & GetSparseColumn(ColIndex col) const
EntryIndex num_entries() const
RowIndex num_constraints() const
ColIndex num_cols() const
RowIndex num_rows() const
EntryIndex num_entries() const
bool AreBoundsValid(Fractional lower_bound, Fractional upper_bound)
The vehicle routing library lets one model and solve generic vehicle routing problems ranging from th...
std::vector< double > coefficients
ProblemSolution(RowIndex num_rows, ColIndex num_cols)
std::string DebugString() const
VariableStatusRow variable_statuses
ConstraintStatusColumn constraint_statuses