| Total Complexity | 1 |
| Total Lines | 36 |
| Duplicated Lines | 0 % |
| 1 | """ |
||
| 12 | class LeastSquaresSolver(solvers.Solver): |
||
| 13 | |||
| 14 | def solve(self, basis_kwargs, boundary_points, coefs_array, nodes, problem, |
||
| 15 | **solver_options): |
||
| 16 | """ |
||
| 17 | Solve a boundary value problem using the collocation method. |
||
| 18 | |||
| 19 | Parameters |
||
| 20 | ---------- |
||
| 21 | basis_kwargs : dict |
||
| 22 | Dictionary of keyword arguments used to build basis functions. |
||
| 23 | coefs_array : numpy.ndarray |
||
| 24 | Array of coefficients for basis functions defining the initial |
||
| 25 | condition. |
||
| 26 | problem : bvp.TwoPointBVPLike |
||
| 27 | A two-point boundary value problem (BVP) to solve. |
||
| 28 | solver_options : dict |
||
| 29 | Dictionary of options to pass to the non-linear equation solver. |
||
| 30 | |||
| 31 | Return |
||
| 32 | ------ |
||
| 33 | solution: solutions.SolutionLike |
||
| 34 | An instance of the SolutionLike class representing the solution to |
||
| 35 | the two-point boundary value problem (BVP) |
||
| 36 | |||
| 37 | Notes |
||
| 38 | ----- |
||
| 39 | |||
| 40 | """ |
||
| 41 | result = optimize.leastsq(self._compute_residuals, |
||
| 42 | x0=coefs_array, |
||
| 43 | args=(basis_kwargs, boundary_points, nodes, problem), |
||
| 44 | **solver_options) |
||
| 45 | solution = self._solution_factory(basis_kwargs, result[0], nodes, |
||
| 46 | problem, result) |
||
| 47 | return solution |
||
| 48 |