I am learning about genetic algorithms (GA), but I encountered a question about the definition of the fitness function used in GA.
I understand that the fitness function should return a scalar value (e.g. to make sure to return the maximum value for a given individual).
For example, if one wanted to optimize a small molecule $logP$ (to ensure that the returned $logP$ has the maximum values), one can define the fitness value thusly: $J(m) = logP$, and then use GA to optimize the $logP$.
But my question is that I want to make sure that the $logP$ has a value close to 9 (rather than the larger the better), the more closer to 9 the better.
In this case how can I define the fitness function used in GA?
Thanks.