Coder Social home page Coder Social logo

blackbox's People

Contributors

celliern avatar lancastdw avatar lightash avatar paulknysh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

blackbox's Issues

Integer / categorical parameters

Is there a way to limit parameters to integers only? I'm currently rounding the parameter in the objective function, but this leads to the same value being evaluated multiple times.

Comparing to naive optimization

For a high dimensional problem, one naive approach is to calculate all the partial derivative in parallel then apply SGD or other algorithm. Have you compare this naive approach with your method, say in term of numbers of function calls and convergence rate.

TypeError: unsupported operand type(s) for /: 'NoneType' and 'float'

Thank you for providing this very useful toolbox!

When I try to use it for my optimization problem, it starts out quite well but it raises an error after having evaluated around half of the batches:

File "/Users/philipp/miniconda3/lib/python3.6/site-packages/black_box/blackbox.py", line 106, in search_min
  points[n+batch*i:n+batch*(i+1), -1] = list(e.map(f, list(map(cubetobox, points[n+batch*i:n+batch*(i+1), 0:-1]))))/fmax
TypeError: unsupported operand type(s) for /: 'NoneType' and 'float' 

It seems, that the map somehow returns a NoneType. I couldn't find the reason for it. Do you have any suggestions?

Unfortunately, I can not provide a MWE, since my cost-function is a very advanced black-box.
The function is called with:

fit_par = bb.search_min(f=cost_function, domain=bounds_list, budget=50, batch=4, resfile = 'bb_output.csv')

Tried this on a Linux and MacOs Machine.
I am working in a anaconda environment with
Python 3.7.9
black-box 1.0.2

Upon further investigation I discorvered, that there is a nan appearing at the last position of all the sublists in the points list. Could this be the problem and how could this have happened?

For completeness, my domain is

[[1000000000.0, 30000000000.0],
 [1000000000.0, 30000000000.0],
 [2e+18, 5e+18],
 [-1e-07, 3e-07],
 [10000.0, 100000.0],
 [-5000.0, 5000.0],
 [10000.0, 100000.0],
 [-5000.0, 5000.0]]

Cannot pass function arguments.

Hello Paul.

Is it possible to pass function arguments to the solver?
For example, my function is defined as:

def func(x,*parms):

And then with the scipy minimize I can pass the parameters with the args= argument:

minimize(func, Initial_Guesses, method = 'SLSQP', bounds = Bounds, args=Parms )

I looked at the code but did not see a way to pass this argument.
Thanks

Python typing support

Thanks for a great piece of code! Have you considered typing it?
That would make it easier to use and to improve on :)

Input an initial guess

Hello Paul,

Thank you for this nice piece of code ๐Ÿ‘
Is it possible to feed the algorithm with an initial guess ? Or can you think of some clues to implement this ?

Feature Suggestion: Load Past Results

So I have a really long running function, and as a result, I am exploring a broad range of parameter settings (n is large, m is 0). But if it turns out I am not happy with the exploratory performance of this sweep, then I would like to go back, use those results, and run again to explore points near the top performers (n = 0, m is large).

Sample code fails with TypeError

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.

LIcence

I would like to use Blackbox as a part of my reactive-transport modeling tool for calibration. How would you like me to cite you in my Github project?

Singularity matrix

Hi!

I have a hard function, that includes max and min and some conversions. I am getting the following error after few steps:

 File "/home/vzinoviev/ttf_DALI/training_toolbox/ssd_detector/blackbox_opt.py", line 124, in <module>
   main()
 File "/home/vzinoviev/ttf_DALI/training_toolbox/ssd_detector/blackbox_opt.py", line 113, in main
   resfile='output.csv')  # text file where results will be saved
 File "/home/vzinoviev/ttf_DALI/training_toolbox/ssd_detector/blackbox.py", line 123, in search
   fit = rbf(points, T)
 File "/home/vzinoviev/ttf_DALI/training_toolbox/ssd_detector/blackbox.py", line 212, in rbf
   sol = np.linalg.solve(M, v)
 File "/home/vzinoviev/ttf_DALI/venv/lib/python3.6/site-packages/numpy/linalg/linalg.py", line 390, in solve
   r = gufunc(a, b, signature=signature, extobj=extobj)
 File "/home/vzinoviev/ttf_DALI/venv/lib/python3.6/site-packages/numpy/linalg/linalg.py", line 89, in _raise_linalgerror_singular
   raise LinAlgError("Singular matrix")
numpy.linalg.linalg.LinAlgError: Singular matrix```

How to store set of parameters when optimization crashes?

Hello.
I am running some simulations and I am trying to optimize for some parameter. The simulation fails sometimes when I give a large value of m, n (say m=n=100) by giving an error related to a singular matrix. I want to find out for what parameters I am getting this singular matrix. Is there any way I can find the parameters for which the optimization is failing? It would work for me even if I can store all the parameters before optimization crashes due to a singular matrix error for a particular scenario. Thanks.

High dimensional optimization?

I replaced Monte Carlo (for minimizing fit) with a SLSQP method from scipy.optimize library. The code now should be able to handle high dimensional cases.

Let me know if there are any issues.

Parameters constraints

I'm looking for an adaptation of your method to allow joint constraints on parameters, not individually (i.e. range of value for each params).
For instance:
param1 + param2 + param3 <1
0<param1<1
0<param2<1
0<param3<1
I can constraint range values of param1, param2 and param3 in [0, 1] but not the sum ?

Thank you

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.