Project-Platypus / Platypus

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

Added function for objective normalization and a new example of storing `Solution` for each generation. #238

Closed debpal closed 2 months ago

debpal commented 2 months ago

I'm not experienced with managing pull requests and commits on GitHub, but I hope the normalize_objective function in core.py and example_objective_repository.py will be useful to the Platypus community. Given the limited documentation, I suggest adding a link to the example folder in the documentation to help users find the example code. A new release on PyPI would also be beneficial since the version number has been updated.

dhadka commented 2 months ago

Thanks for submitting this PR! For this case, I'd prefer improving the documentation and/or examples to demonstrate how to read attributes. I've added the print_attributes.py example as a starting point.

My reasoning is twofold:

  1. I'm not sure if using a dict is the right approach here versus just reading attributes. In the event someone does need a dict, a one-line "comprehension" can handle the conversion:

    normalized_objectives = {s: s.normalized_objectives for s in solutions if s.feasible}
  2. Adding, removing, or changing examples and documentation is much easier than the library, and I don't want to lock into a particular implementation at this time.

I'm of course open to feedback on this, but for now I'm going to close out this PR.