ommx.v1.quadratic_pb2

Classes

Quadratic

Quadratic function as a COO-style sparse matrix and linear sparse vector.

Module Contents

class ommx.v1.quadratic_pb2.Quadratic(*, rows: collections.abc.Iterable[int] | None = ..., columns: collections.abc.Iterable[int] | None = ..., values: collections.abc.Iterable[float] | None = ..., linear: ommx.v1.linear_pb2.Linear | None = ...)

Quadratic function as a COO-style sparse matrix and linear sparse vector.

COOrdinate format, also known as triplet format, is a way to represent sparse matrices as a list of non-zero elements. It consists of three lists: the row indices, the column indices, and the values of the non-zero elements with following constraints:

  • Entries and coordinates sorted by row, then column.

  • There are no duplicate entries (i.e. duplicate (i,j) locations)

  • Data arrays MAY have explicit zeros.

Note that this matrix is not assured to be symmetric nor upper triangular. For example, a quadratic function x1^2 + x2^2 + 2x1*x2 can be represented as:

  • { rows: [0, 0, 1], columns: [0, 1, 1], values: [1, 2, 1] }, i.e. an upper triangular matrix [[1, 2], [0, 1]

  • { rows: [0, 0, 1, 1], columns: [0, 1, 0, 1], values: [1, 1, 1, 1] }, i.e. a symmetric matrix [[1, 1], [1, 1]]

or even a non-symmetric, non-trianglar matrix as x1^2 + 3x1*x2 - x2*x1 + x2^2:

  • { rows: [0, 0, 1, 1], columns: [0, 1, 0, 1], values: [1, 3, -1, 1] }, i.e. a non-symmetric matrix [[1, 3], [-1, 1]]

ClearField(field_name: Literal['_linear', b'_linear', 'columns', b'columns', 'linear', b'linear', 'rows', b'rows', 'values', b'values']) None
HasField(field_name: Literal['_linear', b'_linear', 'linear', b'linear']) bool
WhichOneof(oneof_group: Literal['_linear', b'_linear']) Literal['linear'] | None
COLUMNS_FIELD_NUMBER: int
LINEAR_FIELD_NUMBER: int
ROWS_FIELD_NUMBER: int
VALUES_FIELD_NUMBER: int
property columns: google.protobuf.internal.containers.RepeatedScalarFieldContainer[int]
property linear: ommx.v1.linear_pb2.Linear
property rows: google.protobuf.internal.containers.RepeatedScalarFieldContainer[int]
property values: google.protobuf.internal.containers.RepeatedScalarFieldContainer[float]