convexengineering / gpfit

Fit posynomials to data
http://gpfit.readthedocs.io/en/latest/
MIT License
10 stars 7 forks source link

Ali and I are breaking the multi-dimensional fits #84

Closed 1ozturkbe closed 5 years ago

1ozturkbe commented 5 years ago

It seems to work for univariate fits, but not for multivariate ones. The code is here, under Code/frictionFactorFitting.py. When we run it, we get the following error:

In [23]: run frictionFactorFitting.py
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
C:\Users\Berk\Dropbox (MIT)\MIT Graduate School\code\EGPAnet\code\frictionFactorFitting.py in <module>()
     23
     24 K = 3
---> 25 cMA, errorMA = fit(xData, z, K, "MA")
     26 cSMA, errorSMA = fit(xData, z, K, "SMA")
     27 cISMA, errorISMA = fit(xData, z, K, "ISMA")

c:\users\berk\dropbox (mit)\mit graduate school\code\gpfit\gpfit\fit.pyc in fit(xdata, ydata, K, ftype)
     78             fitdata["ub%d" % i] = exp(max(xdata.T[i]))
     79
---> 80     params = get_params(ftype, K, xdata, ydata)
     81
     82     # A: exponent parameters, B: coefficient parameters

c:\users\berk\dropbox (mit)\mit graduate school\code\gpfit\gpfit\fit.pyc in get_params(ftype, K, xdata, ydata)
     23         return r, drdp
     24
---> 25     ba = ba_init(xdata, ydata.reshape(ydata.size, 1), K).flatten('F')
     26
     27     if ftype == "ISMA":

c:\users\berk\dropbox (mit)\mit graduate school\code\gpfit\gpfit\ba_init.pyc in ba_init(x, y, K)
     71             while matrix_rank(X[inds, :]) < dimx+1:
     72                 i = i+1
---> 73                 inds[sortdistind[i]] = 1
     74
     75             if options['bverbose']:

IndexError: index 1001 is out of bounds for axis 0 with size 1001

Tried a bunch of hacks, mostly to do with data structures, but nothing worked. Let us know if you have any ideas @bqpd, since the documentation is less than ideal.

1ozturkbe commented 5 years ago

btw, we left the code verbatim the same as Mike's solar fitting codes. This is why there is all kinds of weird operations on the arrays. So by extension, none of his codes work.

bqpd commented 5 years ago

Maybe look at the gplibrary drag polars? I think this may be something to do with the way your arrays are input...

On Mon, Sep 17, 2018 at 3:30 PM, Berk Ozturk notifications@github.com wrote:

It seems to work for univariate fits, but not for multivariate ones. The code is here https://github.com/1ozturkbe/EGPAnet, under Code/frictionFactorFitting.py. When we run it, we get the following error:

In [23]: run frictionFactorFitting.py---------------------------------------------------------------------------IndexError Traceback (most recent call last) C:\Users\Berk\Dropbox (MIT)\MIT Graduate School\code\EGPAnet\code\frictionFactorFitting.py in () 23 24 K = 3---> 25 cMA, errorMA = fit(xData, z, K, "MA") 26 cSMA, errorSMA = fit(xData, z, K, "SMA") 27 cISMA, errorISMA = fit(xData, z, K, "ISMA")

c:\users\berk\dropbox (mit)\mit graduate school\code\gpfit\gpfit\fit.pyc in fit(xdata, ydata, K, ftype) 78 fitdata["ub%d" % i] = exp(max(xdata.T[i])) 79---> 80 params = get_params(ftype, K, xdata, ydata) 81 82 # A: exponent parameters, B: coefficient parameters

c:\users\berk\dropbox (mit)\mit graduate school\code\gpfit\gpfit\fit.pyc in get_params(ftype, K, xdata, ydata) 23 return r, drdp 24---> 25 ba = ba_init(xdata, ydata.reshape(ydata.size, 1), K).flatten('F') 26 27 if ftype == "ISMA":

c:\users\berk\dropbox (mit)\mit graduate school\code\gpfit\gpfit\ba_init.pyc in ba_init(x, y, K) 71 while matrix_rank(X[inds, :]) < dimx+1: 72 i = i+1---> 73 inds[sortdistind[i]] = 1 74 75 if options['bverbose']: IndexError: index 1001 is out of bounds for axis 0 with size 1001

Tried a bunch of hacks, mostly to do with data structures, but nothing worked. Let us know if you have any ideas @bqpd https://github.com/bqpd, since the documentation is s***.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/convexengineering/gpfit/issues/84, or mute the thread https://github.com/notifications/unsubscribe-auth/ABagGO0LO8_3VthHu4kuZGWilnF7qz2Kks5ub_hIgaJpZM4Wsj-_ .

bqpd commented 5 years ago

hmm, try running his codes to verify that

On Mon, Sep 17, 2018 at 3:32 PM, Berk Ozturk notifications@github.com wrote:

btw, we left the code verbatim the same as Mike's solar fitting codes. This is why there is all kinds of weird operations on the arrays. So by extension, none of his codes work.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/convexengineering/gpfit/issues/84#issuecomment-422141429, or mute the thread https://github.com/notifications/unsubscribe-auth/ABagGFa2kt2om_69SlKpxCnhF3HGV2geks5ub_jWgaJpZM4Wsj-_ .

bqpd commented 5 years ago

(or link to the file of his you based this on and I'll verify tonight)

On Mon, Sep 17, 2018 at 3:33 PM, Edward Burnell eburn@mit.edu wrote:

hmm, try running his codes to verify that

On Mon, Sep 17, 2018 at 3:32 PM, Berk Ozturk notifications@github.com wrote:

btw, we left the code verbatim the same as Mike's solar fitting codes. This is why there is all kinds of weird operations on the arrays. So by extension, none of his codes work.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/convexengineering/gpfit/issues/84#issuecomment-422141429, or mute the thread https://github.com/notifications/unsubscribe-auth/ABagGFa2kt2om_69SlKpxCnhF3HGV2geks5ub_jWgaJpZM4Wsj-_ .

bqpd commented 5 years ago

I'm pretty sure all those fits are tested in the model tests

On Mon, Sep 17, 2018 at 3:34 PM, Edward Burnell eburn@mit.edu wrote:

(or link to the file of his you based this on and I'll verify tonight)

On Mon, Sep 17, 2018 at 3:33 PM, Edward Burnell eburn@mit.edu wrote:

hmm, try running his codes to verify that

On Mon, Sep 17, 2018 at 3:32 PM, Berk Ozturk notifications@github.com wrote:

btw, we left the code verbatim the same as Mike's solar fitting codes. This is why there is all kinds of weird operations on the arrays. So by extension, none of his codes work.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/convexengineering/gpfit/issues/84#issuecomment-422141429, or mute the thread https://github.com/notifications/unsubscribe-auth/ABagGFa2kt2om_69SlKpxCnhF3HGV2geks5ub_jWgaJpZM4Wsj-_ .

1ozturkbe commented 5 years ago

For starters, the data required for the fit in gplibrary\gpkitmodels\GP\aircraft\wing\jho1polars.py does not exist (it requires a "jho1.ncrit09.Re%dk.pol" file), making it impossible to confirm if it actually works.

bqpd commented 5 years ago

oh dang. @mjburton11, could you take a look?

On Mon, Sep 17, 2018 at 3:42 PM, Berk Ozturk notifications@github.com wrote:

For starters, the data required for the fit in gplibrary\gpkitmodels\GP\aircraft\wing\jho1polars.py does not exist (it requires a "jho1.ncrit09.Re%dk.pol" file), making it impossible to confirm if it actually works.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/convexengineering/gpfit/issues/84#issuecomment-422144337, or mute the thread https://github.com/notifications/unsubscribe-auth/ABagGAQnGa9Xo-XEQDiEmQD-IJYepvmFks5ub_sQgaJpZM4Wsj-_ .

1ozturkbe commented 5 years ago

Ali confirmed that the fits in gassolar (at least in tailpolars) don't have any data. I will check if the SPaircraft fits work.

1ozturkbe commented 5 years ago

One good news is that Martin's fits in the SPaircraft repo work...

1ozturkbe commented 5 years ago

Alright, I think we have figured out the issue. We didn't realize that you have to meshgrid in the number of dimensions of the independent variables. That is non-obvious from the documentation, but makes a lot of sense.

bqpd commented 5 years ago

yupyup, that's one of the proposed new interfaces in the most recent gpkit issue on this

On Mon, Sep 17, 2018, 16:02 Berk Ozturk notifications@github.com wrote:

Alright, I think we have figured out the issue. We didn't realize that you have to meshgrid in the number of dimensions of the independent variables. That is non-obvious from the documentation, but makes a lot of sense.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/convexengineering/gpfit/issues/84#issuecomment-422150744, or mute the thread https://github.com/notifications/unsubscribe-auth/ABagGHFFCp3sY0YU0E8PmsfF-Kx2VmsFks5ub_-zgaJpZM4Wsj-_ .

1ozturkbe commented 5 years ago

Well, that was annoying but necessary. This underlines the need to merge gpfit into gpkit and document.