convexengineering / gpfit

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

Example t_ex6_1.py issue #17

Closed mjburton11 closed 8 years ago

mjburton11 commented 8 years ago

Here the current issue with t_ex6_1. Probably due to missed update with gpfit

In [2]: %run gpfit/tests/t_e
gpfit/tests/t_ex6_1.py  gpfit/tests/t_ex6_3.py  

In [2]: %run gpfit/tests/t_ex6_1.py
1 = (0.95/w**0.0961) * (u_1)**0.0161
    + (0.996/w**0.165) * (u_1)**-0.0958
    + (0.975/w**0.112) * (u_1)**-0.0166
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/Users/mjburton11/Documents/SuperUROP/gpfit/gpfit/tests/t_ex6_1.py in <module>()
      3 from gpfit.fit import fit
      4 
----> 5 class t_ex6_1_ISMA(unittest.TestCase):
      6     '''
      7     ISMA unit tests based on example 6.1 from GPfit paper

/Users/mjburton11/Documents/SuperUROP/gpfit/gpfit/tests/t_ex6_1.py in t_ex6_1_ISMA()
     14     K = 3
     15 
---> 16     cstrt, rms_error = fit(x, y, K, "ISMA")
     17 
     18     def test_rms_error(self):

/Users/mjburton11/Documents/SuperUROP/gpfit/gpfit/fit.py in fit(xdata, ydata, K, ftype, varNames)
    110         # ISMA returns a constraint of the form 1 >= c1*u1^exp1*u2^exp2*w^(-alpha) + ....
    111         posy  = Posynomial(exps, cs)
--> 112         cstrt = Constraint(posy,1)
    113 
    114         # # If only one term, automatically make an equality constraint

/Users/mjburton11/Documents/SuperUROP/gpkit/gpkit/nomials.pyc in __init__(self, left, right, oper_ge)
    572         self.left, self.right = (pgt, plt) if oper_ge else (plt, pgt)
    573 
--> 574         p = plt / pgt
    575 
    576         if isinstance(p.cs, Quantity):

TypeError: unsupported operand type(s) for /: 'Monomial' and 'Posynomial'
mjburton11 commented 8 years ago

See #18. Should fix the problem.

whoburg commented 8 years ago

:+1:

mjburton11 commented 8 years ago

21 Fixed this problem.