Project-Platypus / Platypus

A Free and Open Source Python Library for Multiobjective Optimization
GNU General Public License v3.0
563 stars 153 forks source link

Inconsistency in return type for CMA-ES #172

Closed microprediction closed 1 year ago

microprediction commented 3 years ago

Hi there. First, thanks for the library, and anything named after a monotreme can't be bad. I'm filing this ticket because I noticed an inconsistency in the return type for CMA-ES versus all the others.

One has to do something like this...

best_obj, best_x = feasible_solution_obj[0] if isinstance(best_x,FixedLengthArray): best_x = best_x._data # CMA-ES returns it this way for some reason

in order to enforce consistency across different algos. Perhaps this could be cleaned up? The change would simply be to return x._data in the feasible solution list in place of x.

github-actions[bot] commented 1 year ago

This issue is stale and will be closed soon. If you feel this issue is still relevant, please comment to keep it active. Please also consider working on a fix and submitting a PR.

microprediction commented 1 year ago

Hello bot. Um, yeah maybe worth keeping open and a PR might even be forthcoming

dhadka commented 1 year ago

@microprediction How are you creating feasible_solution_obj? Any chance you have a complete example I could run to reproduce the issue?

The list of variables, objectives, and constraints are stored in a FixedLengthArray, but that should behave just like any regular list. I did notice it's not overloading __repr__ so it displays like <platypus.core.FixedLengthArray object at 0x000001DD0EEFA610>. If that's the root of the problem, I'm going to merge a fix shortly.

dhadka commented 1 year ago

Closing as the fix I mentioned above is releases.