improve glop numerical precision

This commit is contained in:
Laurent Perron
2020-10-01 18:07:45 +02:00
parent b16c0289a1
commit 54929db482
4 changed files with 13 additions and 14 deletions

View File

@@ -246,7 +246,7 @@ Status BasisFactorization::MiddleProductFormUpdate(
const ColIndex left_index =
left_pool_mapping_[RowToColIndex(leaving_variable_row)];
if (right_index == kInvalidCol || left_index == kInvalidCol) {
VLOG(0) << "One update vector is missing!!!";
LOG(INFO) << "One update vector is missing!!!";
return ForceRefactorization();
}

View File

@@ -2026,10 +2026,9 @@ void RevisedSimplex::DualPhaseIUpdatePriceOnReducedCostChange(
for (ColIndex col : cols) {
const Fractional reduced_cost = reduced_costs[col];
const Fractional sign =
(can_increase.IsSet(col) && reduced_cost < -tolerance)
? 1.0
: (can_decrease.IsSet(col) && reduced_cost > tolerance) ? -1.0
: 0.0;
(can_increase.IsSet(col) && reduced_cost < -tolerance) ? 1.0
: (can_decrease.IsSet(col) && reduced_cost > tolerance) ? -1.0
: 0.0;
if (sign != dual_infeasibility_improvement_direction_[col]) {
if (sign == 0.0) {
--num_dual_infeasible_positions_;
@@ -2275,9 +2274,9 @@ Status RevisedSimplex::UpdateAndPivot(ColIndex entering_col,
const VariableStatus leaving_variable_status =
lower_bound_[leaving_col] == upper_bound_[leaving_col]
? VariableStatus::FIXED_VALUE
: target_bound == lower_bound_[leaving_col]
? VariableStatus::AT_LOWER_BOUND
: VariableStatus::AT_UPPER_BOUND;
: target_bound == lower_bound_[leaving_col]
? VariableStatus::AT_LOWER_BOUND
: VariableStatus::AT_UPPER_BOUND;
if (variable_values_.Get(leaving_col) != target_bound) {
ratio_test_stats_.bound_shift.Add(variable_values_.Get(leaving_col) -
target_bound);

View File

@@ -227,8 +227,8 @@ RowIndex LinearProgram::FindOrCreateConstraint(
}
}
void LinearProgram::SetVariableName(ColIndex col, const std::string& name) {
variable_names_[col] = name;
void LinearProgram::SetVariableName(ColIndex col, absl::string_view name) {
variable_names_[col] = std::string(name);
}
void LinearProgram::SetVariableType(ColIndex col, VariableType type) {
@@ -240,8 +240,8 @@ void LinearProgram::SetVariableType(ColIndex col, VariableType type) {
}
}
void LinearProgram::SetConstraintName(RowIndex row, const std::string& name) {
constraint_names_[row] = name;
void LinearProgram::SetConstraintName(RowIndex row, absl::string_view name) {
constraint_names_[row] = std::string(name);
}
void LinearProgram::SetVariableBounds(ColIndex col, Fractional lower_bound,

View File

@@ -108,8 +108,8 @@ class LinearProgram {
// FindOrCreate{Variable|Constraint}().
// TODO(user): Add PopulateIdsFromNames() so names added via
// Set{Variable|Constraint}Name() can be found.
void SetVariableName(ColIndex col, const std::string& name);
void SetConstraintName(RowIndex row, const std::string& name);
void SetVariableName(ColIndex col, absl::string_view name);
void SetConstraintName(RowIndex row, absl::string_view name);
// Set the type of the variable.
void SetVariableType(ColIndex col, VariableType type);