Miscellanea#

class pygmo.thread_safety#

Thread safety level.

This enumeration defines a set of values that can be used to specify the thread safety of problems, algorithms, etc.

Note

For safety reasons, pygmo currently does not allow to set a thread safety level higher than none for any user-defined object implemented in Python. That is, only problems, algorithms, etc. implemented in C++ can have some degree of thread safety.

Members:

none : no thread safety - concurrent operations on distinct objects are unsafe (value = 0)

basic : basic thread safety - concurrent operations on distinct objects are safe (value = 1)

constant : constant thread safety - constant (i.e., read-only) concurrent operations on the same object are safe (value = 2)


class pygmo.evolve_status#

Evolution status.

This enumeration contains status flags used to represent the current status of asynchronous evolution/optimisation in pygmo.island and pygmo.archipelago.

Members:

idle : no asynchronous operations are ongoing, and no error was generated by an asynchronous operation in the past (value = 0)

busy : asynchronous operations are ongoing, and no error was generated by an asynchronous operation in the past (value = 1)

idle_error : no asynchronous operations are ongoing, but an error was generated by an asynchronous operation in the past (value = 2)

busy_error : asynchronous operations are ongoing, and an error was generated by an asynchronous operation in the past (value = 3)


class pygmo.migration_type#

Migration type.

This enumeration represents the available migration policies in an archipelago:

  • with the point-to-point migration policy, during migration an island will consider individuals from only one of the connecting islands;

  • with the broadcast migration policy, during migration an island will consider individuals from all the connecting islands.

Members:

p2p : point-to-point migration (value = 0)

broadcast : broadcast migration (value = 1)


class pygmo.migrant_handling#

Migrant handling policy.

This enumeration represents the available migrant handling policies in an archipelago.

During migration, individuals are selected from the islands and copied into a migration database, from which they can be fetched by other islands. This policy establishes what happens to the migrants in the database after they have been fetched by a destination island:

  • with the preserve policy, a copy of the candidate migrants remains in the database;

  • with the evict policy, the candidate migrants are removed from the database.

Members:

preserve : perserve migrants in the database (value = 0)

evict : evict migrants from the database (value = 1)


pygmo.set_serialization_backend(name)#

Set pygmo’s serialization backend.

This function allows to specify the serialization backend that is used internally by pygmo for the (de)serialization of pythonic user-defined entities (e.g., user-defined pythonic problems, algorithms, etc.).

By default, pygmo uses the cloudpickle module, which extends the capabilities of the standard pickle module with support for lambdas, functions and classes defined interactively in the __main__ module, etc.

In some specific cases, however, different serialization backends might work better than cloudpickle, and thus pygmo provides the possibility for the cognizant user to switch to another serialization backend.

The valid backends are:

  • 'pickle' (i.e., the standard Python pickle module),

  • 'cloudpickle'.

Warning

Setting the serialization backend is not thread-safe: do not set the serialization backend while concurrently setting/getting it from another thread, or while asynchronous evolutions/optimisations are ongoing.

Parameters

name (str) – the name of the desired backend

Raises
pygmo.get_serialization_backend()#

Get pygmo’s serialization backend.

This function will return pygmo’s current serialization backend (see set_serialization_backend() for an explanation of the available backends).

Returns

the current serialization backend (as a Python module)

Return type

types.ModuleType