Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error using the optimizer #2

Open
pranshrana opened this issue Mar 29, 2018 · 4 comments
Open

Error using the optimizer #2

pranshrana opened this issue Mar 29, 2018 · 4 comments

Comments

@pranshrana
Copy link

Hi, I just installed the constrNMPy library and was trying out the examples. But I get the following error:

C:\Users\User\Desktop\constrNMPy-master\constrNMPy\examples\beales.py
Traceback (most recent call last):
File "C:\Users\User\Desktop\constrNMPy-master\constrNMPy\examples\beales.py", line 18, in
res=cNM.constrNM(cNM.test_funcs.beales,x0,LB,UB,full_output=True)
File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\constrnmpy-0.1-py3.6.egg\constrNMPy\constrNMPy.py", line 60, in constrNM
if not ((x>LB[i] or LB[i]==None) and (x<UB[i] or UB[i]==None)):
TypeError: '<' not supported between instances of 'int' and 'NoneType'

What should I do?

@alexblaessle
Copy link
Owner

alexblaessle commented Apr 6, 2018 via email

@klankschap
Copy link

if not ((x>LB[i] or LB[i]==None) and (x<UB[i] or UB[i]==None)):

you cannot compare an int with a None, so if UB[i] is None, the comparison x < UB[i] will fail if x is an int.
As the expression is resolved from left to right, you could reorder the expression, placing the None check before the comparison

In [1]: a = 10
In [2]: b = None

In [3]: a < b

TypeError Traceback (most recent call last)
in ()
----> 1 a < b

TypeError: '<' not supported between instances of 'int' and 'NoneType'

In [4]: b is None or a < b
Out[4]: True

In [5]: a < b or b is None

TypeError Traceback (most recent call last)
in ()
----> 1 a < b or b is None

TypeError: '<' not supported between instances of 'int' and 'NoneType'

alexblaessle pushed a commit that referenced this issue Jun 5, 2018
There was a problem comparing Nones with numbers
when checking if the initial guess is within boundaries
in constrNM. Added an additional check for None. This should fix issue #2.
@alexblaessle
Copy link
Owner

I fixed the issue by introducing a primary check for None and then checking for boundaries. I hope this fixes the problem. Can you please report back if you still encounter the bug or not so I can close the issue?

@klankschap
Copy link

klankschap commented Jun 5, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants