Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
sparse_containers.proto
Go to the documentation of this file.
1// Copyright 2010-2024 Google LLC
2// Licensed under the Apache License, Version 2.0 (the "License");
3// you may not use this file except in compliance with the License.
4// You may obtain a copy of the License at
5//
6// http://www.apache.org/licenses/LICENSE-2.0
7//
8// Unless required by applicable law or agreed to in writing, software
9// distributed under the License is distributed on an "AS IS" BASIS,
10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11// See the License for the specific language governing permissions and
12// limitations under the License.
13
14// Data structures used throughout MathOpt to model sparse vectors and matrices.
15
16syntax = "proto3";
17
18package operations_research.service.v1.mathopt;
19
20option java_multiple_files = true;
21option java_package = "com.google.ortools.service.v1.mathopt";
22option csharp_namespace = "Google.OrTools.Service";
23
24// A sparse representation of a vector of doubles.
25message SparseDoubleVectorProto {
26 // Must be sorted (in increasing ordering) with all elements distinct.
27 repeated int64 ids = 1;
28 // Must have equal length to ids. May not contain NaN.
29 repeated double values = 2;
30}
31
32// A sparse representation of a vector of bools.
33message SparseBoolVectorProto {
34 // Should be sorted (in increasing ordering) with all elements distinct.
35 repeated int64 ids = 1;
36 // Must have equal length to ids.
37 repeated bool values = 2;
38}
39
40// A sparse representation of a vector of ints.
41message SparseInt32VectorProto {
42 // Should be sorted (in increasing ordering) with all elements distinct.
43 repeated int64 ids = 1;
44 // Must have equal length to ids.
45 repeated int32 values = 2;
46}
47
48// This message allows to query/set specific parts of a SparseXxxxVector.
49// The default behavior is not to filter out anything.
50// A common usage is to query only parts of solutions (only non-zero values,
51// and/or just a hand-picked set of variable values).
52message SparseVectorFilterProto {
53 // For SparseBoolVectorProto "zero" is `false`.
54 bool skip_zero_values = 1;
55 // When true, return only the values corresponding to the IDs listed in
56 // filtered_ids.
57 bool filter_by_ids = 2;
58 // The list of IDs to use when filter_by_ids is true. Must be empty when
59 // filter_by_ids is false.
60 // NOTE: if this is empty, and filter_by_ids is true, you are saying that
61 // you do not want any information in the result.
62 repeated int64 filtered_ids = 3;
63}
64
65// A sparse representation of a matrix of doubles.
66//
67// The matrix is stored as triples of row id, column id, and coefficient. These
68// three vectors must be of equal length. For all i, the tuple (row_ids[i],
69// column_ids[i]) should be distinct. Entries must be in row major order.
70message SparseDoubleMatrixProto {
71 repeated int64 row_ids = 1;
72 repeated int64 column_ids = 2;
73 // May not contain NaN.
74 repeated double coefficients = 3;
75}
76
77// A sparse representation of a linear expression (a weighted sum of variables,
78// plus a constant offset).
79message LinearExpressionProto {
80 // Ids of variables. Must be sorted (in increasing ordering) with all elements
81 // distinct.
82 repeated int64 ids = 1;
83 // Must have equal length to ids. Values must be finite may not be NaN.
84 repeated double coefficients = 2;
85 // Must be finite and may not be NaN.
86 double offset = 3;
87}