These are chat archives for bluescarni/pagmo_reborn

21st
Jun 2016
Dario Izzo
@darioizzo
Jun 21 2016 10:30
Had to modify the decompose meta-problem logic slightly. Two public methods are now offered to compute directly the original fitness and the decomposed fitness. They are used in fitness too and exposed to python.
Dario Izzo
@darioizzo
Jun 21 2016 12:08
really well said!!
Dario Izzo
@darioizzo
Jun 21 2016 14:19
@bluescarni ci sei?
Francesco Biscani
@bluescarni
Jun 21 2016 14:19
yep
Dario Izzo
@darioizzo
Jun 21 2016 14:19
I would like to expose to python a method in a user_defined problem.
It returns a vector and needs a vector:
vector_double original_fitness(const vector_double &x) const
I wrote:
        .def("original_fitness", &decompose::original_fitness,"Returns the original", (bp::arg("dv")))
and, of course, it does not work
COmpiles and all, but in python if i write:
In [39]: probd.original_fitness(dv=[1]*30)
---------------------------------------------------------------------------
ArgumentError                             Traceback (most recent call last)
<ipython-input-39-3439cd0db5f1> in <module>()
----> 1 probd.original_fitness(dv=[1]*30)

ArgumentError: Python argument types in
    decompose.original_fitness(decompose)
did not match C++ signature:
    original_fitness(pagmo::decompose {lvalue}, std::vector<double, std::allocator<double> > dv)
he does not see the kwarg, but also if i explicitly pass a list he does not convert ..... how is this supposed to be done?
Francesco Biscani
@bluescarni
Jun 21 2016 14:22
Dario Izzo
@darioizzo
Jun 21 2016 14:23
ok. so no automatic conversions for containers .. right?
Francesco Biscani
@bluescarni
Jun 21 2016 14:23
no, it could be done but I chose not to
Dario Izzo
@darioizzo
Jun 21 2016 14:24
k
this will create the need to make a lot of wrappers ... I guess its ok
trying
Francesco Biscani
@bluescarni
Jun 21 2016 14:25
it is not ideal, but I cannot think of any other solution that checks all the requirements
Dario Izzo
@darioizzo
Jun 21 2016 14:26
the only problem I see is that the file core.cpp will soon get enormously long ...
Francesco Biscani
@bluescarni
Jun 21 2016 14:26
it would help if boost python supported lambda functions directly instead of having to write a wrapper somewhere
Dario Izzo
@darioizzo
Jun 21 2016 14:26
I get lost in these long files.... :)
Francesco Biscani
@bluescarni
Jun 21 2016 14:29
still not too bad at 600 lines, but yes, maybe it should be split eventually
Dario Izzo
@darioizzo
Jun 21 2016 14:30
when is long considered to be too long? 1000?
Francesco Biscani
@bluescarni
Jun 21 2016 14:30
I think my longest file in piranha is 4600
Dario Izzo
@darioizzo
Jun 21 2016 14:31
fuck
Francesco Biscani
@bluescarni
Jun 21 2016 14:32
I don't find it particularly troublesome, if the file is well-structured
Dario Izzo
@darioizzo
Jun 21 2016 14:33
I will try
Francesco Biscani
@bluescarni
Jun 21 2016 14:34
I think the largest non-autogenerated files in Boost are around 6000 lines
actually it looks like you can use lambdas in boost python, as long as they don't capture anything and you use a slightly funky syntax
 .def("original_fitness", +[](const pagmo::problem &p, const bp::object &dv) {return vd_to_a(p.whatever(to_vd(dv)));},"Returns the original", (bp::arg("dv")))
this should work
Dario Izzo
@darioizzo
Jun 21 2016 14:39
+ ?
Francesco Biscani
@bluescarni
Jun 21 2016 14:39
that will trigger the conversion of the lambda function to a function pointer
- would work as well
Dario Izzo
@darioizzo
Jun 21 2016 14:40
:)
any reason you are not using pygmo; in core.cpp ?
Francesco Biscani
@bluescarni
Jun 21 2016 14:42
not that I remember, maybe fear of name clashes between pygmo:: and pagmo::
Marcus Märtens
@CoolRunning
Jun 21 2016 19:50
I just pushed a new commit to the hypervolume branch. Mostly minor changes from Darios comments on the Merge-request. I also commented on some of the comments.
There is one thing missing which are the lambda expressions instead of the functors. I will give this a shot tomorrow.
Additionally, I believe we have by now some form of documentation-style? All the crap in hypervolume needs to be adapted to it, I guess?