luinardi / hypermapper

Black-box Optimizer based on Bayesian Optimization
MIT License
155 stars 26 forks source link

ZeroDivisionError in CPU partition calculation #49

Closed noahsherrill closed 3 years ago

noahsherrill commented 3 years ago

I set up a simple problem and ran into a ZeroDivisionError. The configuration file is as follows:

{
  "application_name": "param_values_test",
  "optimization_objectives": ["value"],
  "optimization_iterations": 5,
  "input_parameters": {
    "param_1": {
      "parameter_type": "integer",
      "values": [4, 12],
      "parameter_default": 10
    }
  }
}

The code is as follows:

from hypermapper import optimizer

def test_function(parameters):
    return (6 - parameters["param_1"]) ** 2

if __name__ == "__main__":
    parameters_file_path = "param_values_test.json"
    optimizer.optimize(parameters_file_path, test_function)

The output is as follows:

Design of experiment phase, number of new doe samples = 9 .......
param_1,value,Timestamp
10,16,1
4,4,1
5,1,1
6,0,1
7,1,1
8,4,1
9,9,2
11,25,2
12,36,2

End of doe/resume phase, the number of evaluated configurations is: 10

Starting optimization iteration 1
Traceback (most recent call last):
  File "hypermapper_param_values_test.py", line 10, in <module>
    optimizer.optimize(parameters_file_path, test_function)
  File "/usr/local/lib/python3.6/site-packages/hypermapper/optimizer.py", line 125, in optimize
    config, black_box_function=black_box_function, profiling=profiling
  File "/usr/local/lib/python3.6/site-packages/hypermapper/bo.py", line 446, in main
    profiling,
  File "/usr/local/lib/python3.6/site-packages/hypermapper/random_scalarizations.py", line 541, in random_scalarizations
    profiling=profiling,
  File "/usr/local/lib/python3.6/site-packages/hypermapper/local_search.py", line 401, in local_search
    partitions_per_cpu * number_of_cpus
ZeroDivisionError: division by zero
noahsherrill commented 3 years ago

This was using HyperMapper Version 2.2.3.

arturluis commented 3 years ago

Hey @noahsherrill ,

Thanks for providing the json and .py files, I'll investigate what is causing this issue and get back to you.

hvarfner commented 3 years ago

@noahsherrill Thanks for the really simple way to recreate the error. Turns out we didn't know what to do when the number of CPUs surpassed the number of possible configurations.

noahsherrill commented 3 years ago

@hvarfner, I no longer see this error in HyperMapper Version 2.2.4. Thank you for the fix!