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

Sample code fails with TypeError #29

Open
JSchoeck opened this issue Oct 6, 2022 · 1 comment
Open

Sample code fails with TypeError #29

JSchoeck opened this issue Oct 6, 2022 · 1 comment

Comments

@JSchoeck
Copy link

JSchoeck commented Oct 6, 2022

The sample code from the readme fails on my Python 3.10.5 install.

result = bb.minimize(f=fun, # given function
    domain=[[-5, 5], [-5, 5]], # ranges of each parameter
    budget=20, # total number of function calls available
    batch=4 # number of calls that will be evaluated in parallel
)
print(result["best_x"])
print(result["best_f"])

Leads to:

INFO     evaluating batch 1/5 (samples 1..4/20) 10-06 10:54:00
INFO     evaluating batch 2/5 (samples 5..8/20) 10-06 10:54:04
INFO     evaluating batch 3/5 (samples 9..12/20) 10-06 10:54:09
Traceback (most recent call last):
  File "Optimierung_Logistikkosten_BlackBox.py", line 273, in <module>
    main()
  File "Optimierung_Logistikkosten_BlackBox.py", line 208, in main
    result = bb.minimize(f=fun, # given function
  File "\blackbox\blackbox.py", line 86, in minimize
    v1 = compute_volume_unit_ball(d)
  File "\blackbox\blackbox.py", line 165, in compute_volume_unit_ball
    v1 = np.pi ** (d / 2) / np.math.factorial(d / 2)
TypeError: 'float' object cannot be interpreted as an integer

Note that I have redacted the path information.

@paulknysh
Copy link
Owner

@JSchoeck thanks, I actually didn't know it errors (seems like in Python 3.10 and above), thought it's just a warning.

Do you want to open a small PR with a fix? (if not, I can do that)

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

2 participants