Muscat.LinAlg.ConstraintsHolder module¶
- class Ainsworth[source]¶
Bases:
object
Method from https://doi.org/10.1016/S0045-7825(01)00236-5 Because the CleanConstraint(C) matrix is orthonormal then C.dot(C.T) = I this make the P Q R expression simpler
- class ConstraintsHolder[source]¶
Bases:
object
Constrained linear problem: Class to store and to enforce constraints for a quadratic system of the form:
minimize 1/2 u.K.u - u.f subject to: A.u = b
This class can store, and manipulate the system Au=b and enforce the constraints by different methods (penalization, substitution, lagrange multiplier)
the first set of function is used to fill this class with the system Au=b:
NextEquation must be called after the call of a set of : AddFactor, AddConstant One per constraint
AddEquationSparse, AddEquation, AddEquationsFromIJV to add a full constraint at once
Compact will clean (zeros, and duplicated) entries
- CleanEmptyColumns(mat)[source]¶
Function to clean empty columns for a matrix,
- this function returns:
res : a sparse matrix with only non zero columns of mat (the last column is always present, event if it is full of zeros) usedDofs : the indices of the columns prensent in res
- GetCleanConstraintBase(purePython=False)[source]¶
This function compute the QR decomposition of the augmented system [A|b] Il will use the self.tol value to detect redundant constraints (rank revealing)
- this functions returns:
res : a parse matrix q’ with only the relevant part of the QR decomposition. Q’ constraint only the non zero columns of [A|b] and always the last column (the b) usedDofs : the indices of the columns present in Q
- option:
purePython: to force scipy for computing the QR decomposition
- Residual(u: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) Tuple[ndarray, ndarray] [source]¶
Recover A.u and b
- Parameters:
u (ArrayLike) – Vector of unknowns
- Returns:
se result of
- Return type:
Tuple[np.ndarray,np.ndarray]
- ToSparse()[source]¶
Function to convert to the constraints system Ax=B to a sparse matrix
- this function returns:
res : a sparse matrix of [A’|B] , A’ has only the non zero columns of A
usedDofs : the indices of the columns present in A’