Pagmo2 Pygmo2 warm start capablities

171 views Asked by At

I am experimenting with Pygmo and find it very convenient for setting up global optimization tasks. However, it would be great to have more CPU cores (>32) which I do not have on my computer. I would like to keep everything as cost efficient as possible and thought about using either an AWS spot instance or a preemptive VM instance on a google cloud instance. Because the instance can be shutdown at any time, I need some warm start capability. I found a archipelago::save function in the API but do not understand if this function can be used to save the state of the optimizer. Is it possible to warm start Pygmo/Pagmo2 ?

1

There are 1 answers

0
Dario Izzo On

All objects in pagmo can be serialized, the archipelago too. In python via pickle / dill, in c++ using the boost::serialization library. The method you found, i.e. archipelago::save implements the serialization of the object pagmo::archipelago following the API of the boost library.

    a = pagmo::archipelago(my...args);
    a.evolve(12);
    a.wait();

    // Now serialize and deserialize
    {
        boost::archive::binary_oarchive oarchive(ss);
        oarchive << a;
    }
    b = archipelago{};
    {
        boost::archive::binary_iarchive iarchive(ss);
        iarchive >> b;
    }
    b.evolve();

Something like this its the use of the serialization to restart the evolution. Note that ss can also be written and read from file.