canonize: Construct the canonical design matrix A = [C | S; M | Q] for...

View source: R/utils.R

canonizeR Documentation

Construct the canonical design matrix A = [C | S; M | Q] for CLSP.

Description

This method assembles the constraint matrix A from user-supplied or internally generated components — C, S, M, and Q — and assigns the corresponding right-hand side vector b. It is a required pre-step before solving a Convex Least Squares Programming (CLSP) problem.

Usage

canonize(
  object,
  problem = "",
  C = NULL,
  S = NULL,
  M = NULL,
  Q = NULL,
  b = NULL,
  m = NULL,
  p = NULL,
  i = 1L,
  j = 1L,
  zero_diagonal = FALSE
)

Arguments

object

An object of class "clsp".

problem

Character, optional. Structural template for matrix construction. One of:

  • 'ap' or 'tm': allocation or tabular matrix problem.

  • 'cmls' or 'rp': constrained modular least squares or RP-type.

  • '' or other: General CLSP problems (user-defined C and/or M).

C, S, M

Numeric matrix or NULL. Blocks of the constraint matrix A = [C | S; M | Q]. If C and/or M are provided, the matrix A is constructed accordingly. If both are NULL and A is not yet defined, an error is raised.

Q

Numeric matrix or NULL. Externally supplied residual slack matrix used to adjust inequality constraints in M. Required only when r > 1. Encodes the sign pattern of residuals from the previous iteration and is used to construct the [C | S; M | Q] canonical form. Defaults to a conformable zero matrix on the first iteration.

b

Numeric vector or NULL. Right-hand side vector. Must have as many rows as A. Required.

m, p

Integer or NULL. Dimensions of X \in \mathbb{R}^{m \times p}, relevant for allocation problems ('ap').

i, j

Integer, default = 1. Grouping sizes for row and column sum constraints in AP problems.

zero_diagonal

Logical, default = FALSE. If TRUE, enforces structural zero diagonals via identity truncation.

Details

Depending on the specified problem type, it can generate allocation, tabular matrix, or modular constraints and enforce optional diagonal exclusions. All missing blocks are padded to ensure conformability.

Value

An updated object of class "clsp".

Attributes Set

A

Numeric matrix. Canonical design matrix constructed from (C, S, M, Q).

C_idx

Integer vector of length 2 indicating the size of the C block.

b

Numeric vector. Conformable right-hand side vector.


rclsp documentation built on Feb. 19, 2026, 5:07 p.m.