gugarosa / opytimizer

🐦 Opytimizer is a Python library consisting of meta-heuristic optimization algorithms.
https://opytimizer.readthedocs.io
Apache License 2.0
604 stars 41 forks source link

positions #19

Closed 321HG closed 3 years ago

321HG commented 3 years ago

I can export 'positions' in the old version, but I cannot export the 'positions' in the new version. Could you help me?

gugarosa commented 3 years ago

Hello 321HG! I hope everything is going well with you!

What do you mean by exporting? Save into a file? In the newest version, you can save the whole optimization object using the following:

...
opt = Opytimizer(space, optimizer, function, save_agents=False)
opt.start(n_iterations=1000)  
opt.save('output_path')

This saved file is a regular pickle file, which you can load it whenever you want and access its inner properties, for example the history attribute. Such an attribute will hold the best_agent you desire.

On the other hand, you can use the history.get_convergence() method in the same way as the old history.get() method to directly retrieve the list of fitness, positions, etc.

Hope that I could help at all, if not, please let me know!

Best regards, Gustavo.

321HG commented 3 years ago

Thank you very much, I have solved it according to your prompt