Project-Platypus / Platypus

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

Best solution from "solution.objectives" #159

Closed RafaHPSUnicamp closed 1 year ago

RafaHPSUnicamp commented 3 years ago

Hi,

I am trying to select the best result from a single objective problem, however since I am novice on Platypus, I do not know how to do that. Any suggestions to select the best solution from the vector of "solution.objectives". The same applies for variables.

I am needed that since I am comparing the Platypus with another optimization software.

dhadka commented 3 years ago

Hey @RafaHPSUnicamp,

Please note that solution.objectives contains the objective values for a single result. For a single objective problem, solution.objectives will be an array containing a single value. Likewise, solution.variables contains the variables for that result.

To get the best result, you should use unique(nondominated(algorithm.result)). This returns the best result(s). There could be more than one result as they could have identical fitness (objective) values.

best = unique(nondominated(algorithm.result))[0]
best.objectives   # the objective value for the best result
best.variables    # the variables for the best result
RafaHPSUnicamp commented 3 years ago

Hi, thank you. Also, do you have an e-mail contact. I also send another issue to solve my code. I wrote my code, however, I discovered that restrictions does not working. The code is working, however the restrictions are being ignored for unknown reasons.

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.