Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move LeastSquaresSolver' to its own module.
- Loading branch information
1 parent
9f7a14f
commit cd856bd
Showing
3 changed files
with
49 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
""" | ||
Solvers for over-identified systems. | ||
@author : davidrpugh | ||
""" | ||
from scipy import optimize | ||
|
||
from . import solvers | ||
|
||
|
||
class LeastSquaresSolver(solvers.Solver): | ||
|
||
def solve(self, basis_kwargs, boundary_points, coefs_array, nodes, problem, | ||
**solver_options): | ||
""" | ||
Solve a boundary value problem using the collocation method. | ||
Parameters | ||
---------- | ||
basis_kwargs : dict | ||
Dictionary of keyword arguments used to build basis functions. | ||
coefs_array : numpy.ndarray | ||
Array of coefficients for basis functions defining the initial | ||
condition. | ||
problem : bvp.TwoPointBVPLike | ||
A two-point boundary value problem (BVP) to solve. | ||
solver_options : dict | ||
Dictionary of options to pass to the non-linear equation solver. | ||
Return | ||
------ | ||
solution: solutions.SolutionLike | ||
An instance of the SolutionLike class representing the solution to | ||
the two-point boundary value problem (BVP) | ||
Notes | ||
----- | ||
""" | ||
result = optimize.leastsq(self._compute_residuals, | ||
x0=coefs_array, | ||
args=(basis_kwargs, boundary_points, nodes, problem), | ||
**solver_options) | ||
solution = self._solution_factory(basis_kwargs, result[0], nodes, | ||
problem, result) | ||
return solution |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters