Closed abe-mart closed 4 years ago
I fixed the bug with APM v0.9.2 that is updated in Github for Windows and will be updated on the next release cycle. You can use the new local EXE now by updating your distribution at: Python37\Lib\site-packages\gekko\bin
New Local Executable https://github.com/BYU-PRISM/GEKKO/blob/master/gekko/bin/apm.exe
ChangeLog https://github.com/BYU-PRISM/GEKKO/blob/master/CHANGELOG.md
I also added some new features (smoothing factor, order of fit) to gekko.py:
Generate a 2D Bspline with continuous first and seconds derivatives
from 1-D arrays of x_data and y_data coordinates (in strictly ascending order)
and 2-D z data of size (x.size,y.size). GEKKO variables x, y and z are
linked with function z=f(x,y) where the function f is a bspline.
Usage: m.bspline(x,y,z,x_data,y_data,z_data,data=True,kx=3,ky=3,sf=None)
Inputs:
x,y = independent Gekko parameters or variables as predictors for z
z = dependent Gekko variable with z = f(x,y)
If data is True (default) then the bspline is built from data
x_data = 1D list or array of x values, size (nx)
y_data = 1D list or array of y values, size (ny)
z_data = 2D list or matrix of z values, size (nx,ny)
If data is False then the bspline knots and coefficients are loaded
x_data = 1D list or array of x knots, size (nx)
y_data = 1D list or array of y knots, size (ny)
z_data = 2D list or matrix of c coefficients, size (nx-kx-1)*(ny-ky-1)
kx = degree of spline in x-direction, default=3
ky = degree of spline in y-direction, default=3
sf = smooth factor (sf), only for data=True
sf controls the tradeoff between smoothness and closeness of fit
if sf is small, the approximation may follow too much signal noise
if sf is large, the approximation does not follow the general trend
a proper sf depends on the data and level of noise
when sf is None a default value of nx*ny*(0.1)**2 is used
where 0.1 is the approximate statistical error of each point
the sf is only used when constructing the bspline (data=True)
Outputs:
None
I've run into a problem with the bspline function in data=True mode. The existing test coverage is only for cases where x and y are the same size. Inputting x and y matrices that are not the same shape gives an error. This is on Linux.
Case 1: x and y are equal sizes. Solves succesfully
Case 2: x is larger than y
Case 3: y is larger than x