algebraicElimination

Method of mdss.

Eliminate algebraic variables and their equality equations from an mdss model while preserving the implicit multilinear structure.

Source: src/model/@mdss/algebraicElimination.m

Syntax

reducedSystem = algebraicElimination(sys)
reducedSystem = algebraicElimination(sys, analysisPoints)
reducedSystem = algebraicElimination(sys, analysisPoints, Name, Value)

Description

algebraicElimination removes algebraic variables and their corresponding equality equations from an mdss model, wherever doing so keeps the model multilinear (no variable ends up squared). The result is an equivalent, smaller model in the same CP-tensor representation. Variables listed in analysisPoints are protected and never eliminated.

Two convenience guards are on by default and can leave more variables unreduced than analysisPoints alone: ProtectInequalities protects every algebraic variable that appears on an inequality/switching row, and GuardBlockGrowth skips any elimination that would grow a row of the cyclic core (so small blocks do not fuse into one large implicit loop).

Input arguments

Argument Description
sys The mdss model to reduce (CP-tensor backed).
analysisPoints Algebraic-variable indices to protect from elimination. Default [].

Name-value arguments

Name Default Description
ProtectInequalities true Never eliminate an algebraic variable that appears on an inequality/switching row.
GuardBlockGrowth true Skip any elimination that grows a row of the cyclic core.
debug false Print elimination progress and matrix sizes.

Output arguments

Output Description
reducedSystem The reduced mdss model, equivalent to sys.

Overview

The algebraic elimination algorithm removes algebraic variables and their corresponding equality equations from an mdss model, while preserving the implicit multilinear (CP-tensor) structure. The model is represented in a CP-tensor format:

model=kϕ(:,k)isupp(F(:,k))xi \text{model} = \sum_k \phi(:,k) \cdot \prod_{i \in \text{supp}(F(:,k))} x_i

where each column kk of the structure matrix FF encodes which variables appear in that monomial term (its support), and the corresponding column kk of the parameter matrix ϕ\phi encodes the coefficient per equation.

Two local functions implement the core logic: checkReducability determines whether a variable can safely be eliminated, and reduction performs the actual elimination.


checkReducability

Purpose

Determines whether substituting varIdx (using eqIdx) into all other equations in eqOthers preserves multilinearity — i.e. no variable ends up appearing twice in any term after substitution.

Mathematical Derivation

The substitution produces new terms by pairing each column kk from the other equations with each column mm from eqIdx. For each pair (k,m)(k, m), the contribution to equation ii is:

reducable(i)=kmϕeq(m)ϕothers(i,k)S(k,m)D(k,m) \text{reducable}(i) = \sum_k \sum_m \phi_\text{eq}(m) \cdot \phi_\text{others}(i,k) \cdot S(k,m) \cdot D(k,m)

where the two factor matrices are defined as:

Scalar factor S(k,m)S(k,m) — encodes that exactly one of (k,m)(k, m) must involve varIdx for a valid substitution term to arise:

S(k,m)=(1|Fvar(k)|)Fvar(m)Fvar(k)(1|Fvar(m)|) S(k,m) = (1 - |F_\text{var}(k)|) \cdot F_\text{var}(m) - F_\text{var}(k) \cdot (1 - |F_\text{var}(m)|)

Dot product D(k,m)D(k,m) — captures whether columns kk and mm share any active variable rows:

D(k,m)=Fothers(:,k)Fothers(:,m) D(k,m) = F_\text{others}(:,k)^\top \cdot F_\text{others}(:,m)

D(k,m)0D(k,m) \neq 0 means that after substitution, some variable would appear in both column kk and column mm, creating a squared variable — a multilinearity violation.

Vectorised Form

The double sum over (k,m)(k, m) is a matrix triple product:

reducable=Φothersneq×ncols(SD)ncols×ncolsϕeqncols×1 \text{reducable} = \underbrace{\Phi_\text{others}}_{n_\text{eq} \times n_\text{cols}} \cdot \underbrace{(S \odot D)}_{n_\text{cols} \times n_\text{cols}} \cdot \underbrace{\phi_\text{eq}^\top}_{n_\text{cols} \times 1}

This replaces the original entry-by-entry double loop with three BLAS matrix operations.

Result

If reducable is the zero vector, no multilinearity violation occurs and the variable is safe to eliminate:

isReducable=𝚊𝚕𝚕(reducable=0) \text{isReducable} = \texttt{all}(\text{reducable} = 0)


reduction

Purpose

Performs the actual algebraic substitution: eliminates varIdx from all equations by expressing it via eqIdx and substituting into eqOthers. Returns updated structure and parameter matrices with one fewer variable and one fewer equation.

Step 1 — Sign normalisation

The sign of eqIdx is normalised so that the coefficient of varIdx is positive. This makes the substitution direction unambiguous — varIdx is always expressed as a function of the other terms in eqIdx, not the negative.

Step 2 — Column classification

Two sets of columns are identified:

Step 3 — Base output construction

The base output matrices are built by:

  1. Zeroing out the eqOthers rows in the parameter matrix — they will be replaced by substituted terms
  2. Removing the eqIdx row entirely — it is consumed by the substitution
  3. Removing columns in colsContainingVar — they are absorbed into the eliminated variable

What remains are the monomial terms unaffected by this substitution.

Step 4 — Substitution loop

For each pair of columns (k,m)(k, m) from the restricted matrices, the new monomial term arising from the substitution has:

Coefficient per equation ii:

ϕnew(i)=ϕbar(i,k)ϕeq(m)S(k,m) \phi_\text{new}(i) = \phi_\text{bar}(i,k) \cdot \phi_\text{eq}(m) \cdot S(k,m)

where S(k,m)S(k,m) is the same scalar factor as in checkReducability.

Variable support — union of the supports of columns kk and mm:

Fnew=F(:,k)+F(:,m) F_\text{new} = F(:,k) + F(:,m)

Multiple pairs (k,m)(k, m) may produce the same monomial support FnewF_\text{new}. These are like terms whose coefficients are summed into the same output column.

Step 5 — Like-term collection via numeric hash map

Identifying like terms requires checking whether FnewF_\text{new} already exists as a column in the growing output matrix. A naive comparison scans all existing columns — O(n) per lookup.

Instead, each column is projected onto a fixed random probe vector to obtain a scalar fingerprint:

hc=probeF(:,c) h_c = \text{probe}^\top \cdot F(:,c)

Two identical columns always produce the same scalar. Two different columns produce the same scalar only with negligible probability (floating-point collision on a random projection). A MATLAB dictionary keyed on those (plain-double) fingerprints then provides O(1) lookup:

Step 6 — Row normalisation

Each equation row is scaled so its largest absolute coefficient is 1:

ϕnew(i,:)ϕnew(i,:)maxk|ϕnew(i,k)| \phi_\text{new}(i,:) \leftarrow \frac{\phi_\text{new}(i,:)}{\max_k |\phi_\text{new}(i,k)|}

This keeps the representation numerically consistent across successive reductions.

See also

mdss · trivialReduction · determineParallizedSolvingOrder


MyToolbox Documentation | Generated automatically by CI/CD pipeline