19#include "absl/container/flat_hash_set.h"
20#include "absl/status/statusor.h"
31 if (
proto.filter_by_ids()) {
32 absl::flat_hash_set<Variable> filtered;
33 for (
const int64_t
id :
proto.filtered_ids()) {
34 if (!
model.has_variable(
id)) {
36 <<
"cannot create MapFilter<Variable> from proto, variable id: "
37 <<
id <<
" not in model";
39 filtered.insert(
model.variable(
id));
49 proto.skip_zero_values()};
50 if (
proto.filter_by_ids()) {
51 absl::flat_hash_set<LinearConstraint> filtered;
52 for (
const int64_t
id :
proto.filtered_ids()) {
53 if (!
model.has_linear_constraint(
id)) {
55 <<
"cannot create MapFilter<LinearConstraint> from proto, "
56 "linear constraint id: "
57 <<
id <<
" not in model";
59 filtered.insert(
model.linear_constraint(
id));
66absl::StatusOr<MapFilter<QuadraticConstraint>>
68 const SparseVectorFilterProto&
proto) {
70 proto.skip_zero_values()};
71 if (
proto.filter_by_ids()) {
72 absl::flat_hash_set<QuadraticConstraint> filtered;
73 for (
const int64_t
id :
proto.filtered_ids()) {
74 if (!
model.has_quadratic_constraint(
id)) {
76 <<
"cannot create MapFilter<QuadraticConstraint> from proto, "
77 "quadratic constraint id: "
78 <<
id <<
" not in model";
80 filtered.insert(
model.quadratic_constraint(
id));
CpModelProto proto
The output proto.
An object oriented wrapper for quadratic constraints in ModelStorage.
absl::StatusOr< MapFilter< LinearConstraint > > LinearConstraintFilterFromProto(const Model &model, const SparseVectorFilterProto &proto)
absl::StatusOr< MapFilter< QuadraticConstraint > > QuadraticConstraintFilterFromProto(const Model &model, const SparseVectorFilterProto &proto)
absl::StatusOr< MapFilter< Variable > > VariableFilterFromProto(const Model &model, const SparseVectorFilterProto &proto)
StatusBuilder InvalidArgumentErrorBuilder()
std::optional< absl::flat_hash_set< KeyType > > filtered_keys