Giter VIP home page Giter VIP logo

Comments (8)

lsangild avatar lsangild commented on July 23, 2024

I failed to mention that I am running pygmo 2.4 on Python 3.6.2 64-bit through Anaconda on Windows 10.

from pagmo2.

darioizzo avatar darioizzo commented on July 23, 2024

Your code is valid and works in our installation.
Maybe you have some installation problems?
How did you install pygmo2?

from pagmo2.

lsangild avatar lsangild commented on July 23, 2024

I am uncertain if it was prepackaged with my Anaconda install or if installed using conda install pygmo.
conda list shows
pygmo 2.4 np112py36_0 conda-forge

*Edit
According to https://docs.anaconda.com/anaconda/packages/pkg-docs#python-3-6 pygmo is not prepackaged with Anaconda, so install has been through conda install pygmo

*Edit 2
I have uninstalled Python and Anaconda. Installed Miniconda, updated via conda update --all and installed pygmo with conda install pygmo. The error is the same as before.

from pagmo2.

bluescarni avatar bluescarni commented on July 23, 2024

@lsangild Can you try to put the last three lines in a main block? Something like this:

if __name__ == "__main__":
    prob = pg.problem(sphere_function(3))
    algo = pg.algorithm(pg.bee_colony(gen = 20, limit = 20))
    archi = pg.archipelago(n=1, algo=algo, prob=prob, pop_size=10)

from pagmo2.

lsangild avatar lsangild commented on July 23, 2024

@bluescarni That worked!
Actually I only need to put the archipelago line in a main block.
Can you elaborate on the cause of the issue?

from pagmo2.

bluescarni avatar bluescarni commented on July 23, 2024

@lsangild The first instantiation of an island/archipelago triggers the creation of a pool of processes that do the actual parallel optimisation work when you call evolve(). These processes need to import your script in order to "see" the definition of your problem, but if in the import phase of your script you are creating an archipelago then this recursively triggers the creation of another pool of processes, which again will try to import your script, triggering the creation of an archipelago, etc. etc.

See also the first two answers here:

https://stackoverflow.com/questions/20360686/compulsory-usage-of-if-name-main-in-windows-while-using-multiprocessi

For pygmo, it means in practice that you should not create islands/archipelagos as part of the module code (i.e., the code that gets executed upon importing the module).

from pagmo2.

darioizzo avatar darioizzo commented on July 23, 2024

I renamed the issue for future references.
Can we close this?

from pagmo2.

lsangild avatar lsangild commented on July 23, 2024

Thank you for your help 👍

from pagmo2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.