Package com.polytechnik.utils
Class EliminateLinearConstraints_HomegrownLUFactorization
java.lang.Object
com.polytechnik.utils.EliminateLinearConstraints_HomegrownLUFactorization
Perform simplified version of
LU Factorization
by checking max pivot at rows and columns.
Expand
m=conditions.length
constraint equations, \( i=0\dots m-1 \)
for \(\mathbf{x}\) vector of the dimension n=conditions[i].length=nC*nX
.
$$ 0=\sum\limits_{j=0}^{n-1} x[j]*\mathrm{conditions}[i][j] $$
to the form
$$x[s]=\sum\limits_{j=0}^{n-1} x[j]*\mathrm{expansion}[i_s][j]$$
the \( \mathrm{expansion}[i\leq i_{s}][s]=0 \) thus the \( x[s] \)
can be eliminated by consequent application of the expansion
starting from the last one.
This allows to build a linear expansion
$$ x[j]=\sum\limits_{i=0}^{\mathrm{dimXnew}-1} M_{ji} V_i $$
of original \( \mathbf{x} \) of the dimension \(n\)
via reduced size \( \mathbf{V} \) of the dimension
\( n-\mathrm{rank}(\mathrm{conditions}) \).
The method fromXnewToXorigAsMatrix()
creates this \( M_{ji} \) matrix.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal int
New problem dimensiondimXnew=dimXorig-nEliminated
.final int
Original problem dimension.Eliminated variables.final int
The number of eliminated variables, equals to the rank ofconditions
matrix. -
Constructor Summary
ConstructorsConstructorDescriptionEliminateLinearConstraints_HomegrownLUFactorization
(int dimXorig, double[][] conditions, double condMaxToFail) Constructor. -
Method Summary
Modifier and TypeMethodDescriptiondouble[]
fromXnewToXorig
(double[] xnew) From new to old, recover previously eliminated components based on linear constraints.double[]
From new to old, recover components based on linear constraints, the result is presented as a matrix of dimXorig * dimXnew size.double[]
fromXorigToXnew
(double[] xorig) Discard some components.getByIndX
(int indX) Not a large size, does not worth a HashMap.(package private) static double[][]
getDegeneratedSample
(int nEq, int nX, Random r, double[][] eqs) static void
A unit test.(package private) static void
runMultiTest
(String name, int nTest, Random r, double eps) (package private) static void
(package private) static EliminateLinearConstraints_HomegrownLUFactorization
-
Field Details
-
dimXorig
public final int dimXorigOriginal problem dimension. -
nEliminated
public final int nEliminatedThe number of eliminated variables, equals to the rank ofconditions
matrix. -
dimXnew
public final int dimXnewNew problem dimensiondimXnew=dimXorig-nEliminated
. -
elim
Eliminated variables.
-
-
Constructor Details
-
EliminateLinearConstraints_HomegrownLUFactorization
public EliminateLinearConstraints_HomegrownLUFactorization(int dimXorig, double[][] conditions, double condMaxToFail) Constructor.- Parameters:
dimXorig
- Original problem dimension.conditions
- Linear constraints, a matrix of nEq x dimXorig. ObtainednEliminated
is the rank of this matrix.condMaxToFail
- Minimal value of maximal absolute element to decide the remaining constraints are degenerated and elimintation process should be stopped,1e-10
is a typical value.
-
-
Method Details
-
getByIndX
Not a large size, does not worth a HashMap. -
fromXorigToXnew
public double[] fromXorigToXnew(double[] xorig) Discard some components. -
fromXnewToXorig
public double[] fromXnewToXorig(double[] xnew) From new to old, recover previously eliminated components based on linear constraints. -
fromXnewToXorigAsMatrix
public double[] fromXnewToXorigAsMatrix()From new to old, recover components based on linear constraints, the result is presented as a matrix of dimXorig * dimXnew size. -
testOne
static EliminateLinearConstraints_HomegrownLUFactorization testOne(String name, int nX, double[][] eqs, Random r, double eps) -
getDegeneratedSample
-
testBasic
-
runMultiTest
-
main
A unit test.
-