Comments (8)
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.
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.
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.
The files have been moved to github gist (https://gist.github.com/darioizzo/9215291)
from pagmo.
Hello, I've started writing a tutorial at https://github.com/neduard/pagmo/wiki/PaGMO-C---Tutorial
However, I have a couple of questions:
- 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?
- I am unable to load
my_pygmo_probs
into Python:
Using the compile command fromcompile.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.
Maybe you need to import PyGMO before importing my_pygmo_probs?
from pagmo.
@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.
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)
- Linking issue HOT 10
- Is it possible to set the initial values for variable? HOT 3
- Support for general PAGMO2 installation HOT 1
- how to choose a binary chromomse encoding while creating a new problem ?
- Missing pygmo.problem & pygmo_plugins_nonfree issue HOT 2
- Compiling getting_started.cpp takes 1 minutes HOT 3
- Dominance checking when working with multiple objective functions HOT 2
- Multi objective Problems with Non Linear Constraints HOT 1
- AttributeError: module 'pygmo' has no attribute 'problem' HOT 2
- terminate called after throwing an instance of 'std::invalid_argument' what: function: best_idx HOT 3
- Please do not install Eigen headers, it is available on all systems HOT 2
- Question: Why are you not exposing DIRECT from the NLOpt library?
- Question: Which method to use for hypervolume calculations HOT 1
- gaco not in Pygmo HOT 1
- type object 'algorithm' has no attribute 'nspso' HOT 3
- GPGPU optimization problem with archipelago HOT 1
- C Wrapper for PAGMO HOT 2
- What happened to the pygmo 2.x documentation? HOT 1
- Line No. 554, /pagmo_plugins_nonfree/src/snopt7.cpp
- Upload pygmo source to PyPI as well as Python 3.9 and 3.10 wheels HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pagmo.