ortools/sat/cp_model_presolve.cc
void AddImplication(int lhs, int rhs, CpModelProto* proto,
                    absl::flat_hash_map<int, int>* ref_to_bool_and) {
  if (ref_to_bool_and->contains(lhs)) {
    const int ct_index = (*ref_to_bool_and)[lhs];
    proto->mutable_constraints(ct_index)->mutable_bool_and()->add_literals(rhs);
  } else if (ref_to_bool_and->contains(NegatedRef(rhs))) {
    const int ct_index = (*ref_to_bool_and)[NegatedRef(rhs)];
    proto->mutable_constraints(ct_index)->mutable_bool_and()->add_literals(
        NegatedRef(lhs));
  } else {
    (*ref_to_bool_and)[lhs] = proto->constraints_size();
    ConstraintProto* ct = proto->add_constraints();
    ct->add_enforcement_literal(lhs);
    ct->mutable_bool_and()->add_literals(rhs);
  }
}
// Add the constraint (lhs => rhs) to the given proto. The hash map lhs ->
// bool_and constraint index is used to merge implications with the same lhs.
Add the constraint (lhs => rhs) to the given proto. The hash map lhs ->
bool_and constraint index is used to merge implications with the same lhs.
Add the constraint ( lhs = > rhs ) to the given proto . The hash map lhs - > bool_and constraint index is used to merge implications with the same lhs .
void AddImplication(int lhs, int rhs, CpModelProto* proto,
                    absl::flat_hash_map<int, int>* ref_to_bool_and) {
  if (ref_to_bool_and->contains(lhs)) {
    const int ct_index = (*ref_to_bool_and)[lhs];
    proto->mutable_constraints(ct_index)->mutable_bool_and()->add_literals(rhs);
  } else if (ref_to_bool_and->contains(NegatedRef(rhs))) {
    const int ct_index = (*ref_to_bool_and)[NegatedRef(rhs)];
    proto->mutable_constraints(ct_index)->mutable_bool_and()->add_literals(
        NegatedRef(lhs));
  } else {
    (*ref_to_bool_and)[lhs] = proto->constraints_size();
    ConstraintProto* ct = proto->add_constraints();
    ct->add_enforcement_literal(lhs);
    ct->mutable_bool_and()->add_literals(rhs);
  }
}
void AddImplication ( int lhs , int rhs , CpModelProto * proto , absl :: flat_hash_map < int , int > * ref_to_bool_and ) { if ( ref_to_bool_and -> contains ( lhs ) ) { const int ct_index = ( * ref_to_bool_and ) [ lhs ] ; proto -> mutable_constraints ( ct_index ) -> mutable_bool_and ( ) -> add_literals ( rhs ) ; } else if ( ref_to_bool_and -> contains ( NegatedRef ( rhs ) ) ) { const int ct_index = ( * ref_to_bool_and ) [ NegatedRef ( rhs ) ] ; proto -> mutable_constraints ( ct_index ) -> mutable_bool_and ( ) -> add_literals ( NegatedRef ( lhs ) ) ; } else { ( * ref_to_bool_and ) [ lhs ] = proto -> constraints_size ( ) ; ConstraintProto * ct = proto -> add_constraints ( ) ; ct -> add_enforcement_literal ( lhs ) ; ct -> mutable_bool_and ( ) -> add_literals ( rhs ) ; } }
Add the constraint (lhs => rhs) to the given proto.
Add the constraint ( lhs = > rhs ) to the given proto .