bw2calc.least_squares ===================== .. py:module:: bw2calc.least_squares Classes ------- .. autoapisummary:: bw2calc.least_squares.LeastSquaresLCA Module Contents --------------- .. py:class:: LeastSquaresLCA(demand, method=None, weighting=None, normalization=None, database_filepath=None, log_config=None, presamples=None, seed=None, override_presamples_seed=False) Bases: :py:obj:`bw2calc.lca.LCA` .. autoapi-inheritance-diagram:: bw2calc.least_squares.LeastSquaresLCA :parts: 1 :private-bases: Solve overdetermined technosphere matrix with more products than activities using least-squares approximation. See also: * `Multioutput processes in LCA `_ * `LSMR in SciPy `_ * `Another least-squares algorithm in SciPy `_ Create a new LCA calculation. :param \* *demand*: The demand or functional unit. Needs to be a dictionary to indicate amounts, e.g. ``{("my database", "my process"): 2.5}``. :type \* *demand*: dict :param \* *method*: LCIA Method tuple, e.g. ``("My", "great", "LCIA", "method")``. Can be omitted if only interested in calculating the life cycle inventory. :type \* *method*: tuple, optional :returns: A new LCA object .. py:method:: decompose_technosphere() :abstractmethod: Factorize the technosphere matrix into lower and upper triangular matrices, :math:`A=LU`. Does not solve the linear system :math:`Ax=B`. Doesn't return anything, but creates ``self.solver``. .. warning:: Incorrect results could occur if a technosphere matrix was factorized, and then a new technosphere matrix was constructed, as ``self.solver`` would still be the factorized older technosphere matrix. You are responsible for deleting ``self.solver`` when doing these types of advanced calculations. .. py:method:: solve_linear_system(solver=lsmr) Master solution function for linear system :math:`Ax=B`. To most numerical analysts, matrix inversion is a sin. -- Nicolas Higham, Accuracy and Stability of Numerical Algorithms, Society for Industrial and Applied Mathematics, Philadelphia, PA, USA, 2002, p. 260. We use `UMFpack `_, which is a very fast solver for sparse matrices. If the technosphere matrix has already been factorized, then the decomposed technosphere (``self.solver``) is reused. Otherwise the calculation is redone completely.