Click or drag to resize

ConstrainedLinearFit Class

Constrained linear least-squares fit via SVD, using an IConstraintsProjector to enforce equality and inequality constraints on the parameter vector. The method iterates: 1. Project current beta onto the feasible set → learn which parameters are fixed/constrained at this point. 2. Solve the reduced unconstrained LS (SVD) for the remaining free parameters only. 3. Project the new beta back; repeat until convergence. For pure equality constraints this converges in one outer iteration. Inequality constraints may need a few iterations (active-set style).
Inheritance Hierarchy
SystemObject
  Altaxo.Calc.RegressionConstrainedLinearFit

Namespace: Altaxo.Calc.Regression
Assembly: AltaxoCore (in AltaxoCore.dll) Version: 4.8.3618.0 (4.8.3618.0)
Syntax
C#
public static class ConstrainedLinearFit

The ConstrainedLinearFit type exposes the following members.

Methods
 NameDescription
Public methodStatic memberFit Fits beta such that A*beta ≈ y subject to the constraints encoded in projector.
Top
Remarks

Usage example:

// Equality: beta[0] + beta[1] = 1.0 var A_eq = Matrix<double>.Build.DenseOfArray(new double[,] { { 1, 1, 0 } }); var b_eq = Vector<double>.Build.Dense(new double[] { 1.0 }); // Inequality: beta[2] >= 0 → -beta[2] <= 0 var C_ineq = Matrix<double>.Build.DenseOfArray(new double[,] { { 0, 0, -1 } }); var d_ineq = Vector<double>.Build.Dense(new double[] { 0.0 }); var projector = new LinearConstraintsProjector(A_eq, b_eq, C_ineq, d_ineq); // Design matrix and observations var A = Matrix<double>.Build.DenseOfArray(new double[,] { { 1, 0, 1 }, { 0, 1, 1 }, { 1, 1, 0 }, { 1, 0, 0 }, }); var y = Vector<double>.Build.Dense(new double[] { 1.5, 0.8, 1.0, 0.3 }); var beta = ConstrainedLinearFit.Fit(A, y, projector); // beta[0] + beta[1] == 1.0 ✓ // beta[2] >= 0 ✓
See Also