55#include " newton_type.hpp"
66#include " constrained.hpp"
77#include " first_order.hpp"
8+ #include " additional_optimizers.hpp"
89
910namespace py = pybind11;
1011
@@ -245,4 +246,81 @@ PYBIND11_MODULE(_pyensmallen, m)
245246 &PyAdamType<ens::NadamUpdate>::getResetPolicy,
246247 &PyAdamType<ens::NadamUpdate>::setResetPolicy)
247248 .def (" optimize" , &PyAdamType<ens::NadamUpdate>::Optimize);
249+
250+ // Coordinate Descent optimizers
251+ py::class_<PyCyclicDescent>(m, " CyclicDescent" )
252+ .def (py::init<double , size_t , double , size_t >(),
253+ py::arg (" stepSize" ) = 0.01 ,
254+ py::arg (" maxIterations" ) = 100000 ,
255+ py::arg (" tolerance" ) = 1e-5 ,
256+ py::arg (" updateInterval" ) = 1000 )
257+ .def_property (" stepSize" , &PyCyclicDescent::getStepSize,
258+ &PyCyclicDescent::setStepSize)
259+ .def_property (" maxIterations" , &PyCyclicDescent::getMaxIterations,
260+ &PyCyclicDescent::setMaxIterations)
261+ .def_property (" tolerance" , &PyCyclicDescent::getTolerance,
262+ &PyCyclicDescent::setTolerance)
263+ .def_property (" updateInterval" , &PyCyclicDescent::getUpdateInterval,
264+ &PyCyclicDescent::setUpdateInterval)
265+ .def (" optimize" , &PyCyclicDescent::Optimize<PyObjectiveFunction>);
266+
267+ py::class_<PyRandomDescent>(m, " RandomDescent" )
268+ .def (py::init<double , size_t , double , size_t >(),
269+ py::arg (" stepSize" ) = 0.01 ,
270+ py::arg (" maxIterations" ) = 100000 ,
271+ py::arg (" tolerance" ) = 1e-5 ,
272+ py::arg (" updateInterval" ) = 1000 )
273+ .def_property (" stepSize" , &PyRandomDescent::getStepSize,
274+ &PyRandomDescent::setStepSize)
275+ .def_property (" maxIterations" , &PyRandomDescent::getMaxIterations,
276+ &PyRandomDescent::setMaxIterations)
277+ .def_property (" tolerance" , &PyRandomDescent::getTolerance,
278+ &PyRandomDescent::setTolerance)
279+ .def_property (" updateInterval" , &PyRandomDescent::getUpdateInterval,
280+ &PyRandomDescent::setUpdateInterval)
281+ .def (" optimize" , &PyRandomDescent::Optimize<PyObjectiveFunction>);
282+
283+ py::class_<PyGreedyDescent>(m, " GreedyDescent" )
284+ .def (py::init<double , size_t , double , size_t >(),
285+ py::arg (" stepSize" ) = 0.01 ,
286+ py::arg (" maxIterations" ) = 100000 ,
287+ py::arg (" tolerance" ) = 1e-5 ,
288+ py::arg (" updateInterval" ) = 1000 )
289+ .def_property (" stepSize" , &PyGreedyDescent::getStepSize,
290+ &PyGreedyDescent::setStepSize)
291+ .def_property (" maxIterations" , &PyGreedyDescent::getMaxIterations,
292+ &PyGreedyDescent::setMaxIterations)
293+ .def_property (" tolerance" , &PyGreedyDescent::getTolerance,
294+ &PyGreedyDescent::setTolerance)
295+ .def_property (" updateInterval" , &PyGreedyDescent::getUpdateInterval,
296+ &PyGreedyDescent::setUpdateInterval)
297+ .def (" optimize" , &PyGreedyDescent::Optimize<PyObjectiveFunction>);
298+
299+ // Simulated Annealing optimizer
300+ py::class_<PySimulatedAnnealingDefault>(m, " SimulatedAnnealing" )
301+ .def (py::init<size_t , double , size_t , size_t , double , size_t , double , double , double >(),
302+ py::arg (" maxIterations" ) = 1000000 ,
303+ py::arg (" initT" ) = 10000.0 ,
304+ py::arg (" initMoves" ) = 1000 ,
305+ py::arg (" moveCtrlSweep" ) = 100 ,
306+ py::arg (" tolerance" ) = 1e-5 ,
307+ py::arg (" maxToleranceSweep" ) = 3 ,
308+ py::arg (" maxMoveCoef" ) = 20 ,
309+ py::arg (" initMoveCoef" ) = 0.3 ,
310+ py::arg (" gain" ) = 0.3 )
311+ .def_property (" maxIterations" , &PySimulatedAnnealingDefault::getMaxIterations,
312+ &PySimulatedAnnealingDefault::setMaxIterations)
313+ .def_property (" temperature" , &PySimulatedAnnealingDefault::getTemperature,
314+ &PySimulatedAnnealingDefault::setTemperature)
315+ .def_property (" initMoves" , &PySimulatedAnnealingDefault::getInitMoves,
316+ &PySimulatedAnnealingDefault::setInitMoves)
317+ .def_property (" moveCtrlSweep" , &PySimulatedAnnealingDefault::getMoveCtrlSweep,
318+ &PySimulatedAnnealingDefault::setMoveCtrlSweep)
319+ .def_property (" tolerance" , &PySimulatedAnnealingDefault::getTolerance,
320+ &PySimulatedAnnealingDefault::setTolerance)
321+ .def_property (" maxToleranceSweep" , &PySimulatedAnnealingDefault::getMaxToleranceSweep,
322+ &PySimulatedAnnealingDefault::setMaxToleranceSweep)
323+ .def_property (" gain" , &PySimulatedAnnealingDefault::getGain,
324+ &PySimulatedAnnealingDefault::setGain)
325+ .def (" optimize" , &PySimulatedAnnealingDefault::Optimize<PyObjectiveFunction>);
248326}
0 commit comments