stevengj / nlopt

library for nonlinear optimization, wrapping many algorithms for global and local, constrained or unconstrained, optimization
Other
1.8k stars 555 forks source link

Can't deepcopy or pickle optimizers in Python #58

Open moloney opened 8 years ago

moloney commented 8 years ago

It would be nice if the optimizer instances provided __getstate__ and __setstate__ methods so that they could be pickled and passed to deepcopy. In particular, the pickle protocol is used by things like multiprocessing and mpi4py for inter-process communication.

stevengj commented 8 years ago

I think it should be technically possible, but will be tricky because the nlopt_opt_s structure is full of pointers and was not designed to be serialized easily.