Skip to content

Commit

Permalink
st: Fixup export from google3
Browse files Browse the repository at this point in the history
  • Loading branch information
Mizux committed Oct 7, 2024
1 parent 205e2d9 commit c41dbb8
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 19 deletions.
27 changes: 27 additions & 0 deletions ortools/base/parse_text_proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#ifndef OR_TOOLS_BASE_PARSE_TEXT_PROTO_H_
#define OR_TOOLS_BASE_PARSE_TEXT_PROTO_H_

#include <string_view>

#include "absl/log/absl_check.h"
#include "google/protobuf/message.h"
#include "google/protobuf/text_format.h"
Expand All @@ -32,6 +34,31 @@ T ParseTextOrDie(const std::string& input) {
return result;
}

namespace text_proto_internal {

class ParseProtoHelper {
public:
explicit ParseProtoHelper(std::string_view asciipb) : asciipb_(asciipb) {}
template <class T>
operator T() { // NOLINT(runtime/explicit)
T result;
const bool ok = ::google::protobuf::TextFormat::TextFormat::ParseFromString(
asciipb_, &result);
CHECK(ok) << "Failed to parse text proto: " << asciipb_;
return result;
}

private:
const std::string asciipb_;
};

} // namespace text_proto_internal

text_proto_internal::ParseProtoHelper ParseTextProtoOrDie(
std::string_view input) {
return text_proto_internal::ParseProtoHelper(input);
}

} // namespace google::protobuf::contrib::parse_proto

#endif // OR_TOOLS_BASE_PARSE_TEXT_PROTO_H_
3 changes: 2 additions & 1 deletion ortools/sat/cp_model_expand.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1768,7 +1768,8 @@ void CompressAndExpandPositiveTable(ConstraintProto* ct,
}
}

VLOG(2) << "Table compression" << " var=" << vars.size()
VLOG(2) << "Table compression"
<< " var=" << vars.size()
<< " cost=" << domain_sizes.size() - vars.size()
<< " tuples= " << num_tuples_before_compression << " -> "
<< num_tuples_after_first_compression << " -> "
Expand Down
4 changes: 2 additions & 2 deletions ortools/sat/cp_model_lns.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1726,8 +1726,8 @@ Neighborhood DecompositionGraphNeighborhoodGenerator::Generate(
VLOG(2) << "#relaxed " << relaxed_variables.size() << " #zero_score "
<< num_zero_score << " max_width " << max_width
<< " (size,min_width)_after_100 (" << size_at_min_width_after_100
<< "," << min_width_after_100 << ") " << " final_width "
<< pq.Size();
<< "," << min_width_after_100 << ") "
<< " final_width " << pq.Size();
}

return helper_.RelaxGivenVariables(initial_solution, relaxed_variables);
Expand Down
3 changes: 2 additions & 1 deletion ortools/sat/feasibility_jump.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ bool JumpTable::JumpIsUpToDate(int var) const {
if (abs(score - scores_[var]) / std::max(abs(score), 1.0) > 1e-2) {
score_ok = false;
LOG(ERROR) << "Incorrect score for var " << var << ": " << scores_[var]
<< " (should be " << score << ") " << " delta = " << delta;
<< " (should be " << score << ") "
<< " delta = " << delta;
}
return delta == deltas_[var] && score_ok;
}
Expand Down
3 changes: 2 additions & 1 deletion ortools/sat/linear_constraint_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,8 @@ bool LinearConstraintManager::AddCut(LinearConstraint ct, std::string type_name,

// Only add cut with sufficient efficacy.
if (violation / l2_norm < 1e-4) {
VLOG(3) << "BAD Cut '" << type_name << "'" << " size=" << ct.num_terms
VLOG(3) << "BAD Cut '" << type_name << "'"
<< " size=" << ct.num_terms
<< " max_magnitude=" << ComputeInfinityNorm(ct)
<< " norm=" << l2_norm << " violation=" << violation
<< " eff=" << violation / l2_norm << " " << extra_info;
Expand Down
4 changes: 2 additions & 2 deletions ortools/sat/lp_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1507,8 +1507,8 @@ bool ConvertBinaryMPModelProtoToBooleanProblem(const MPModelProto& mp_model,
// Abort if the variable is not binary.
if (!is_binary) {
LOG(WARNING) << "The variable #" << var_id << " with name "
<< mp_var.name() << " is not binary. " << "lb: " << lb
<< " ub: " << ub;
<< mp_var.name() << " is not binary. "
<< "lb: " << lb << " ub: " << ub;
return false;
}
}
Expand Down
5 changes: 3 additions & 2 deletions ortools/sat/precedences.cc
Original file line number Diff line number Diff line change
Expand Up @@ -647,8 +647,9 @@ void PrecedencesPropagator::AddArc(
// A self-arc is either plain SAT or plain UNSAT or it forces something on
// the given offset_var or presence_literal_index. In any case it could be
// presolved in something more efficient.
VLOG(1) << "Self arc! This could be presolved. " << "var:" << tail
<< " offset:" << offset << " offset_var:" << offset_var
VLOG(1) << "Self arc! This could be presolved. "
<< "var:" << tail << " offset:" << offset
<< " offset_var:" << offset_var
<< " conditioned_by:" << presence_literals;
}

Expand Down
5 changes: 3 additions & 2 deletions ortools/sat/probing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -890,8 +890,9 @@ bool FailedLiteralProbingRound(ProbingOptions options, Model* model) {
const bool limit_reached = time_limit->LimitReached() ||
time_limit->GetElapsedDeterministicTime() > limit;
LOG_IF(INFO, options.log_info)
<< "Probing. " << " num_probed: " << num_probed << " num_fixed: +"
<< num_newly_fixed << " (" << num_fixed << "/" << num_variables << ")"
<< "Probing. "
<< " num_probed: " << num_probed << " num_fixed: +" << num_newly_fixed
<< " (" << num_fixed << "/" << num_variables << ")"
<< " explicit_fix:" << num_explicit_fix
<< " num_conflicts:" << num_conflicts
<< " new_binary_clauses: " << num_new_binary
Expand Down
5 changes: 3 additions & 2 deletions ortools/sat/sat_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -625,8 +625,9 @@ inline bool SatPropagator::PropagatePreconditionsAreSatisfied(
if (propagation_trail_index_ < trail.Index() &&
trail.Info(trail[propagation_trail_index_].Variable()).level !=
trail.CurrentDecisionLevel()) {
LOG(INFO) << "Issue in '" << name_ << "':" << " propagation_trail_index_="
<< propagation_trail_index_ << " trail_.Index()=" << trail.Index()
LOG(INFO) << "Issue in '" << name_ << "':"
<< " propagation_trail_index_=" << propagation_trail_index_
<< " trail_.Index()=" << trail.Index()
<< " level_at_propagation_index="
<< trail.Info(trail[propagation_trail_index_].Variable()).level
<< " current_decision_level=" << trail.CurrentDecisionLevel();
Expand Down
7 changes: 4 additions & 3 deletions ortools/sat/sat_inprocessing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -704,8 +704,8 @@ bool StampingSimplifier::ComputeStampsForNextRound(bool log_info) {

// TODO(user): compute some dtime, it is always zero currently.
time_limit_->AdvanceDeterministicTime(dtime_);
LOG_IF(INFO, log_info) << "Prestamping." << " num_fixed: " << num_fixed_
<< " dtime: " << dtime_
LOG_IF(INFO, log_info) << "Prestamping."
<< " num_fixed: " << num_fixed_ << " dtime: " << dtime_
<< " wtime: " << wall_timer.Get();
return true;
}
Expand Down Expand Up @@ -1259,7 +1259,8 @@ bool BoundedVariableElimination::DoOneRound(bool log_info) {
dtime_ += 1e-8 * num_inspected_literals_;
time_limit_->AdvanceDeterministicTime(dtime_);
log_info |= VLOG_IS_ON(1);
LOG_IF(INFO, log_info) << "BVE." << " num_fixed: "
LOG_IF(INFO, log_info) << "BVE."
<< " num_fixed: "
<< trail_->Index() - saved_trail_index
<< " num_simplified_literals: " << num_simplifications_
<< " num_blocked_clauses_: " << num_blocked_clauses_
Expand Down
4 changes: 2 additions & 2 deletions ortools/sat/var_domination.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1304,8 +1304,8 @@ void ScanModelForDominanceDetection(PresolveContext& context,
}
}
if (num_unconstrained_refs == 0 && num_dominated_refs == 0) return;
VLOG(1) << "Dominance:" << " num_unconstrained_refs="
<< num_unconstrained_refs
VLOG(1) << "Dominance:"
<< " num_unconstrained_refs=" << num_unconstrained_refs
<< " num_dominated_refs=" << num_dominated_refs
<< " num_dominance_relations=" << num_dominance_relations;
}
Expand Down
2 changes: 1 addition & 1 deletion ortools/sat/work_assignment_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

#include "absl/strings/string_view.h"
#include "gtest/gtest.h"
#include "net/proto2/contrib/parse_proto/parse_text_proto.h"
#include "ortools/base/gmock.h"
#include "ortools/base/parse_text_proto.h"
#include "ortools/sat/cp_model.h"
#include "ortools/sat/cp_model.pb.h"
#include "ortools/sat/cp_model_checker.h"
Expand Down

0 comments on commit c41dbb8

Please sign in to comment.