{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {
    "Notes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The algorithm first computes the unconstrained least-squares solution by "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "numpy.linalg.lstsq",
              "reference": {
                "__type": "RefInfo",
                "__tag": 4000,
                "module": "numpy",
                "version": "*",
                "kind": "api",
                "path": "numpy.linalg:lstsq"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " or "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "scipy.sparse.linalg.lsmr",
              "reference": {
                "__type": "RefInfo",
                "__tag": 4000,
                "module": "scipy",
                "version": "*",
                "kind": "api",
                "path": "scipy.sparse.linalg._isolve.lsmr:lsmr"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " depending on "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "lsq_solver"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". This solution is returned as optimal if it lies within the bounds."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Method 'trf' runs the adaptation of the algorithm described in "
            },
            {
              "__type": "CitationReference",
              "__tag": 4063,
              "label": "STIR"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " for a linear least-squares problem. The iterations are essentially the same as in the nonlinear least-squares algorithm, but as the quadratic function model is always accurate, we don't need to track or modify the radius of a trust region. The line search (backtracking) is used as a safety net when a selected step does not decrease the cost function. Read more detailed description of the algorithm in "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "scipy.optimize.least_squares",
              "reference": {
                "__type": "RefInfo",
                "__tag": 4000,
                "module": "scipy",
                "version": "*",
                "kind": "api",
                "path": "scipy.optimize._lsq.least_squares:least_squares"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Method 'bvls' runs a Python implementation of the algorithm described in "
            },
            {
              "__type": "CitationReference",
              "__tag": 4063,
              "label": "BVLS"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". The algorithm maintains active and free sets of variables, on each iteration chooses a new variable to move from the active set to the free set and then solves the unconstrained least-squares problem on free variables. This algorithm is guaranteed to give an accurate solution eventually, but may require up to n iterations for a problem with n variables. Additionally, an ad-hoc initialization procedure is implemented, that determines which variables to set free or active initially. It takes some number of iterations before actual BVLS starts, but can significantly reduce the number of further iterations."
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Warns": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Raises": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Yields": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Methods": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Returns": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Parameters",
          "__tag": 4026,
          "children": [
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "",
              "annotation": "OptimizeResult with the following fields defined:",
              "desc": []
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "x",
              "annotation": "ndarray, shape (n,)",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Solution found."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "cost",
              "annotation": "float",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Value of the cost function at the solution."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "fun",
              "annotation": "ndarray, shape (m,)",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Vector of residuals at the solution."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "optimality",
              "annotation": "float",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "First-order optimality measure. The exact meaning depends on "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "method"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ", refer to the description of "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "tol"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " parameter."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "active_mask",
              "annotation": "ndarray of int, shape (n,)",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Each component shows whether a corresponding constraint is active (that is, whether a variable is at the bound):"
                    }
                  ]
                },
                {
                  "__type": "BulletList",
                  "__tag": 4053,
                  "ordered": false,
                  "start": 1,
                  "children": [
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "0a constraint is not active."
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "-1a lower bound is active."
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "1an upper bound is active."
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Might be somewhat arbitrary for the "
                    },
                    {
                      "__type": "CrossRef",
                      "__tag": 4002,
                      "value": "trf",
                      "reference": {
                        "__type": "LocalRef",
                        "__tag": 4022,
                        "kind": "module",
                        "path": "scipy.optimize._lsq.trf"
                      },
                      "kind": "module"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " method as it generates a sequence of strictly feasible iterates and active_mask is determined within a tolerance threshold."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "unbounded_sol",
              "annotation": "tuple",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Unbounded least squares solution tuple returned by the least squares solver (set with "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "lsq_solver"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " option). If "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "lsq_solver"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is not set or is set to "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "'exact'"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ", the tuple contains an ndarray of shape (n,) with the unbounded solution, an ndarray with the sum of squared residuals, an int with the rank of "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "A"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ", and an ndarray with the singular values of "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "A"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " (see NumPy's "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "linalg.lstsq"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " for more information). If "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "lsq_solver"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is set to "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "'lsmr'"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ", the tuple contains an ndarray of shape (n,) with the unbounded solution, an int with the exit code, an int with the number of iterations, and five floats with various norms and the condition number of "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "A"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " (see SciPy's "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "sparse.linalg.lsmr"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " for more information). This output can be useful for determining the convergence of the least squares solver, particularly the iterative "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "'lsmr'"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " solver. The unbounded least squares problem is to minimize "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "0.5 * ||A x - b||**2"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "nit",
              "annotation": "int",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Number of iterations. Zero if the unconstrained solution is optimal."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "status",
              "annotation": "int",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Reason for algorithm termination:"
                    }
                  ]
                },
                {
                  "__type": "BulletList",
                  "__tag": 4053,
                  "ordered": false,
                  "start": 1,
                  "children": [
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "-1the algorithm was not able to make progress on the last   iteration."
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "0the maximum number of iterations is exceeded."
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "1the first-order optimality measure is less than "
                            },
                            {
                              "__type": "ParamRef",
                              "__tag": 4071,
                              "name": "tol"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "."
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "2the relative change of the cost function is less than "
                            },
                            {
                              "__type": "ParamRef",
                              "__tag": 4071,
                              "name": "tol"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "."
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "3the unconstrained solution is optimal."
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "message",
              "annotation": "str",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Verbal description of the termination reason."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "success",
              "annotation": "bool",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "True if one of the convergence criteria is satisfied ("
                    },
                    {
                      "__type": "CrossRef",
                      "__tag": 4002,
                      "value": "status",
                      "reference": {
                        "__type": "RefInfo",
                        "__tag": 4000,
                        "module": null,
                        "version": null,
                        "kind": "local",
                        "path": "status"
                      },
                      "kind": "local"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " > 0)."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Solve a linear least-squares problem with bounds on the variables."
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Receives": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Warnings": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Attributes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Parameters": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Parameters",
          "__tag": 4026,
          "children": [
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "A",
              "annotation": "array_like, sparse array or LinearOperator, shape (m, n)",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Design matrix. Can be "
                    },
                    {
                      "__type": "CrossRef",
                      "__tag": 4002,
                      "value": "scipy.sparse.linalg.LinearOperator",
                      "reference": {
                        "__type": "RefInfo",
                        "__tag": 4000,
                        "module": "scipy",
                        "version": "*",
                        "kind": "api",
                        "path": "scipy.sparse.linalg._interface:LinearOperator"
                      },
                      "kind": "module"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "b",
              "annotation": "array_like, shape (m,)",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Target vector."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "bounds",
              "annotation": "2-tuple of array_like or `Bounds`, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Lower and upper bounds on parameters. Defaults to no bounds. There are two ways to specify the bounds:"
                    }
                  ]
                },
                {
                  "__type": "BulletList",
                  "__tag": 4053,
                  "ordered": false,
                  "start": 1,
                  "children": [
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "Instance of "
                            },
                            {
                              "__type": "CrossRef",
                              "__tag": 4002,
                              "value": "Bounds",
                              "reference": {
                                "__type": "LocalRef",
                                "__tag": 4022,
                                "kind": "module",
                                "path": "scipy.optimize._constraints:Bounds"
                              },
                              "kind": "module"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": " class."
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "2-tuple of array_like: Each element of the tuple must be either   an array with the length equal to the number of parameters, or a   scalar (in which case the bound is taken to be the same for all   parameters). Use "
                            },
                            {
                              "__type": "InlineCode",
                              "__tag": 4051,
                              "value": "np.inf"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": " with an appropriate sign to disable   bounds on all or some parameters."
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "method",
              "annotation": "'trf' or 'bvls', optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Method to perform minimization."
                    }
                  ]
                },
                {
                  "__type": "BulletList",
                  "__tag": 4053,
                  "ordered": false,
                  "start": 1,
                  "children": [
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "'trf'Trust Region Reflective algorithm adapted for a linear   least-squares problem. This is an interior-point-like method   and the required number of iterations is weakly correlated with   the number of variables."
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "'bvls'Bounded-variable least-squares algorithm. This is   an active set method, which requires the number of iterations   comparable to the number of variables. Can't be used when "
                            },
                            {
                              "__type": "ParamRef",
                              "__tag": 4071,
                              "name": "A"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": " is   sparse or LinearOperator."
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Default is 'trf'."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "tol",
              "annotation": "float, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Tolerance parameter. The algorithm terminates if a relative change of the cost function is less than "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "tol"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " on the last iteration. Additionally, the first-order optimality measure is considered:"
                    }
                  ]
                },
                {
                  "__type": "BulletList",
                  "__tag": 4053,
                  "ordered": false,
                  "start": 1,
                  "children": [
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "InlineCode",
                              "__tag": 4051,
                              "value": "method='trf'"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": " terminates if the uniform norm of the gradient,   scaled to account for the presence of the bounds, is less than   "
                            },
                            {
                              "__type": "ParamRef",
                              "__tag": 4071,
                              "name": "tol"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "."
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "InlineCode",
                              "__tag": 4051,
                              "value": "method='bvls'"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": " terminates if Karush-Kuhn-Tucker conditions   are satisfied within "
                            },
                            {
                              "__type": "ParamRef",
                              "__tag": 4071,
                              "name": "tol"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": " tolerance."
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "lsq_solver",
              "annotation": "{None, 'exact', 'lsmr'}, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Method of solving unbounded least-squares problems throughout iterations:"
                    }
                  ]
                },
                {
                  "__type": "BulletList",
                  "__tag": 4053,
                  "ordered": false,
                  "start": 1,
                  "children": [
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "'exact'Use dense QR or SVD decomposition approach. Can't be   used when "
                            },
                            {
                              "__type": "ParamRef",
                              "__tag": 4071,
                              "name": "A"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": " is sparse or LinearOperator."
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "'lsmr'Use "
                            },
                            {
                              "__type": "CrossRef",
                              "__tag": 4002,
                              "value": "scipy.sparse.linalg.lsmr",
                              "reference": {
                                "__type": "RefInfo",
                                "__tag": 4000,
                                "module": "scipy",
                                "version": "*",
                                "kind": "api",
                                "path": "scipy.sparse.linalg._isolve.lsmr:lsmr"
                              },
                              "kind": "module"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": " iterative procedure   which requires only matrix-vector product evaluations. Can't   be used with "
                            },
                            {
                              "__type": "InlineCode",
                              "__tag": 4051,
                              "value": "method='bvls'"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "."
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "If None (default), the solver is chosen based on type of "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "A"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "lsmr_tol",
              "annotation": "None, float or 'auto', optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Tolerance parameters 'atol' and 'btol' for "
                    },
                    {
                      "__type": "CrossRef",
                      "__tag": 4002,
                      "value": "scipy.sparse.linalg.lsmr",
                      "reference": {
                        "__type": "RefInfo",
                        "__tag": 4000,
                        "module": "scipy",
                        "version": "*",
                        "kind": "api",
                        "path": "scipy.sparse.linalg._isolve.lsmr:lsmr"
                      },
                      "kind": "module"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " If None (default), it is set to "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "1e-2 * tol"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ". If 'auto', the tolerance will be adjusted based on the optimality of the current iterate, which can speed up the optimization process, but is not always reliable."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "max_iter",
              "annotation": "None or int, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Maximum number of iterations before termination. If None (default), it is set to 100 for "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "method='trf'"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " or to the number of variables for "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "method='bvls'"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " (not counting iterations for 'bvls' initialization)."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "verbose",
              "annotation": "{0, 1, 2}, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Level of algorithm's verbosity:"
                    }
                  ]
                },
                {
                  "__type": "BulletList",
                  "__tag": 4053,
                  "ordered": false,
                  "start": 1,
                  "children": [
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "0work silently (default)."
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "1display a termination report."
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "2display progress during iterations."
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "lsmr_maxiter",
              "annotation": "None or int, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Maximum number of iterations for the lsmr least squares solver, if it is used (by setting "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "lsq_solver='lsmr'"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "). If None (default), it uses lsmr's default of "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "min(m, n)"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " where "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "m"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " and "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "n"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " are the number of rows and columns of "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "A"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ", respectively. Has no effect if "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "lsq_solver='exact'"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Extended Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Given an m-by-n design matrix A and a target vector b with m elements, "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "lsq_linear",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "module",
                "path": "scipy.optimize._lsq.lsq_linear:lsq_linear"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " solves the following optimization problem      "
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "minimize 0.5 * ||A x - b||**2\nsubject to lb <= x <= ub",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "This optimization problem is convex, hence a found minimum (if iterations have converged) is guaranteed to be global."
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Other Parameters": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    }
  },
  "_ordered_sections": [
    "Summary",
    "Extended Summary",
    "Parameters",
    "Attributes",
    "Methods",
    "Returns",
    "Yields",
    "Receives",
    "Other Parameters",
    "Raises",
    "Warns",
    "Warnings",
    "Notes"
  ],
  "item_file": "/scipy/optimize/_lsq/lsq_linear.py",
  "item_line": 37,
  "item_type": "function",
  "aliases": [
    "scipy.optimize.lsq_linear"
  ],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "In this example, a problem with a large sparse arrays and bounds on the\nvariables is solved.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "import numpy as np\nfrom scipy.sparse import random_array\nfrom scipy.optimize import lsq_linear\nrng = np.random.default_rng()\nm = 2000\nn = 1000\nA = random_array((m, n), density=1e-4, random_state=rng)\nb = rng.standard_normal(m)\nlb = rng.standard_normal(n)\nub = lb + 1\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "res = lsq_linear(A, b, bounds=(lb, ub), lsmr_tol='auto', verbose=1)\n",
        "execution_status": "failure"
      }
    ],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [
    {
      "__type": "SeeAlsoItem",
      "__tag": 4028,
      "name": {
        "__type": "CrossRef",
        "__tag": 4002,
        "value": "least_squares",
        "reference": {
          "__type": "LocalRef",
          "__tag": 4022,
          "kind": "module",
          "path": "scipy.optimize._lsq.least_squares:least_squares"
        },
        "kind": "module"
      },
      "descriptions": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Nonlinear least squares with bounds on the variables."
            }
          ]
        }
      ],
      "type": null
    },
    {
      "__type": "SeeAlsoItem",
      "__tag": 4028,
      "name": {
        "__type": "CrossRef",
        "__tag": 4002,
        "value": "nnls",
        "reference": {
          "__type": "RefInfo",
          "__tag": 4000,
          "module": "current-module",
          "version": "current-version",
          "kind": "to-resolve",
          "path": "nnls"
        },
        "kind": "module"
      },
      "descriptions": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Linear least squares with non-negativity constraint."
            }
          ]
        }
      ],
      "type": null
    }
  ],
  "signature": {
    "__type": "SignatureNode",
    "__tag": 4029,
    "kind": "function",
    "parameters": [
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "A",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "b",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "bounds",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "(-inf, inf)"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "method",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "trf"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "tol",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "1e-10"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "lsq_solver",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "None"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "lsmr_tol",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "None"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "max_iter",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "None"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "verbose",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "0"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "lsmr_maxiter",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "KEYWORD_ONLY",
        "default": "None"
      }
    ],
    "return_annotation": {
      "__type": "Empty",
      "__tag": 4031
    },
    "target_name": "lsq_linear"
  },
  "references": [
    ".. [STIR] M. A. Branch, T. F. Coleman, and Y. Li, \"A Subspace, Interior,",
    "          and Conjugate Gradient Method for Large-Scale Bound-Constrained",
    "          Minimization Problems,\" SIAM Journal on Scientific Computing,",
    "          Vol. 21, Number 1, pp 1-23, 1999.",
    ".. [BVLS] P. B. Start and R. L. Parker, \"Bounded-Variable Least-Squares:",
    "          an Algorithm and Applications\", Computational Statistics, 10,",
    "          129-141, 1995."
  ],
  "qa": "scipy.optimize._lsq.lsq_linear:lsq_linear",
  "arbitrary": [],
  "local_refs": [
    "A",
    "active_mask",
    "b",
    "bounds",
    "cost",
    "fun",
    "lsmr_maxiter",
    "lsmr_tol",
    "lsq_solver",
    "max_iter",
    "message",
    "method",
    "nit",
    "optimality",
    "status",
    "success",
    "tol",
    "unbounded_sol",
    "verbose",
    "x"
  ]
}