GithubHelp home page GithubHelp logo

Comments (8)

darioizzo avatar darioizzo commented on August 15, 2024

Originally posted by mmarcusx on 2013-11-25 15:44:27.

I have already written a tutorial on that:

https://sourceforge.net/apps/mediawiki/pagmo/index.php?title=Developing_guide

it could be improved though...

from pagmo.

darioizzo avatar darioizzo commented on August 15, 2024

Originally posted by darioizzo on 2013-11-25 15:55:19.

The tutorial you refer to is for developers. It shows how a developer can put in PaGMO a new problem / algorithm that is to be shipped in the next release.

Since v 1.1.5 we allow the option to install header files. The tutorial I am asking should show how a normal user (not touching/compiling the pagmo code) can still use libpagmo and PyGMO to code its own problems in c++ and have them visible in Python. You can see the attached files for an example.

from pagmo.

darioizzo avatar darioizzo commented on August 15, 2024

Originally posted by darioizzo on 2013-11-28 16:51:08.

And here is a new updated version of the scripts that are more robust to porting

from pagmo.

darioizzo avatar darioizzo commented on August 15, 2024

The files have been moved to github gist (https://gist.github.com/darioizzo/9215291)

from pagmo.

neduard avatar neduard commented on August 15, 2024

Hello, I've started writing a tutorial at https://github.com/neduard/pagmo/wiki/PaGMO-C---Tutorial

However, I have a couple of questions:

  1. What should be the format? Currently it's written as a github Markdown wiki page in line with the project's other wiki pages. Is this acceptable?
  2. I am unable to load my_pygmo_probs into Python:
    Using the compile command from compile.script, I get:
$ g++ -shared -o my_pygmo_probs.so my_pygmo_probs.o prob_A.o  -std=c++11 -lboost_python-mt -pthread -DNDEBUG -lpython2.7 -lboost_serialization-mt -lpagmo
/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.4/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lboost_python-mt
collect2: error: ld returned 1 exit status

I can compile successfully using -lboost_python-2.7-mt flag instead.
However, when I go into Python and type import my_pygmo_probs I get:

>>> import my_pygmo_probs
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
RuntimeError: extension class wrapper for base class pagmo::problem::base has not been created yet

I found https://mail.python.org/pipermail/cplusplus-sig/2009-February/014244.html but changing the position of the -lboost_python-2.7-mt flag didn't seem to help.

I then fiddled with the code in my_pygmo_probs.cpp:
Changing class_<Problem,bases<problem::base> > to class_<Problem> seems to remove the issue allowing to import the module in Python (and allowing me to execute methods such as a_method()), but I am unsure of what is the impact of removing bases<problem::base>.

Any ideas on what I am missing?
My box setup:

Funtoo Linux (Gentoo Based)
boost package: dev-libs/boost-1.56.0-r1000:0/1.56.0  USE="icu nls python threads -c++11 -context -debug -doc -mpi -static-libs -tools" ABI_X86="(64) -32 (-x32)" PYTHON_ABIS="2.7 3.3 -2.6 -3.1 -3.2 -3.4 (-3.5)
Python version 2.7.9

from pagmo.

darioizzo avatar darioizzo commented on August 15, 2024

Maybe you need to import PyGMO before importing my_pygmo_probs?

from pagmo.

neduard avatar neduard commented on August 15, 2024

@darioizzo Thanks! That did the trick!

I finished writing the rest of the tutorial.
Should I leave it at its current address or should I move it somewhere else so that it can be reviewed and commented upon?

from pagmo.

darioizzo avatar darioizzo commented on August 15, 2024

The tutorial is now available in the wiki at https://github.com/esa/pagmo/wiki/%5BTUTORIAL%5D-Code-a-problem-in-Cpp,-use-it-in-Python

from pagmo.

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.