eyounx/ZOOpt

Optimization get stuck + "poss" fails + additional arguments

ntcnjdbxz opened this issue · 5 comments

Hi all,
1 - sometimes optimization just get stuck at some point and does not end (with dimension size < 50 - it's always the case). Don't know, maybe it is doing something, but after 10 minutes I just gave up (

2 - Moreover, 'poss' optimization fails with an error "AttributeError: 'NoneType' object has no attribute 'print_solution'" at different places.

3 - is there a way to pass additional arguments to objective function?

Best regards,
Oleg

Question 1

From your statement, I think there may be two possible reasons.

  1. The optimization runs normally but just doesn't find a better solution (High possibility).
    Set the parameter as follows so that zoopt will print the value of the best solution so far for each iteration. You can also manually print the function value in your customized objective function to see if the objective function is invoked.
parameter = Parameter(..., intermediate_result=True, intermediate_freq=1, ...)

If the objective function is invoked normally, the reason is just zoopt doesn't find a better solution in many iterations. If this is the case, try to increase the exploration rate. See https://zoopt.readthedocs.io/en/latest/ZOOpt/Practical-Parameter-Settings-and-fine-tuning-tricks.html#customize-a-stopping-criterion for more parameter tuning methods.

parameter = Parameter(..., exploration_rate = 0.2, ...)
  1. The optimization algorithm cannot find a new solution that is different from the solutions in the current population (In optimization, we first learn a classification model can then sample a new solution from the positive sample region.). If this is the case, zoopt will theoretically show warnings and return solutions early. Increasing 'uncertain_bits' and 'exploration_rate' in the definition of your parameter may help solve the problem. (Low probability)
parameter = Parameter(..., intermediate_result=True, intermediate_freq=1, ...)

Question 2

I've verified that the poss optimization example works properly. Could you please be more specific? It would help a lot if you can paste some code.

Question 3

If the additional arguments are not be optimized, yang has gives a solution in the email. Being more specific will help.

Thanks,
but it seems to get stuck. There is parameter "time-budget" which suppose to stop optimization and return best values so far. But either this parameter has been implemented wrong or it doesn't work (sometimes works sometimes doesn't.). According to the manual this value is in seconds. But in reality it's not. Even if I set "time-budget" - optimization does not stop (in the case of question 1), that's why I guess it gets stuck (not computing something). It happens very often. I run bunch of simulations in a loop and I have to restart simulation every 30-60 minutes. E.g. the longest "optimization" was 8 hours ))) it doesn't look to be searching for something ))

To see whether the optimization gets stuck, a simple method is to add a "print("The objective function is invoked")" statement into the objective function you implemented. If this sentence is not printed for an unusually long time, the optimization is stuck. If so, please paste more prompts that zoopt prints or some details in your code, mainly about the definitions of key parameters and how zoopt is used.

If the parameter has been set as follows, could you see the intermediate result that ZOOpt prints? ZOOpt should have printed the best solution so far for each iteration.

parameter = Parameter(..., intermediate_result=True, intermediate_freq=1, ...)

Hi,
yes, I always print "best_value_so_far" (intermediate_result=True). When optimization "get stuck" there is no update of the intermediate results. In this case I reduce exploration_rate (the smallest were 0.001). But in most cases when exploration_rate < 1 there are no updates/no new best positions --> no optimization at all. So it would be grate to be able to print out the new search vectors and "all objective values" (not only "best_value_so_far") to check if something is happens. Then, some exit procedure has to be implemented if the algorithm get stuck or fails.

E.g. I define it as:

n_iter = 1000 (doesn't matter. it get stuck at different state (at 10th or 35th iteration))
# intermediate_freq (doesn't much matter from my experience on "get stuck". I have played around with it. the maximum that I get - no new better search vectors found)
# with parallel=True algorithm get stuck more frequently
dim_size < 60
parameter = Parameter(budget=n_iter, init_samples=[Solution([0] * dim_size)], exploration_rate = 1, intermediate_freq=0.001, intermediate_result=True, parallel=False)