-
Notifications
You must be signed in to change notification settings - Fork 449
Description
Checklist
- I searched existing issues
- I'm using the latest pymoo version
Bug Description
I attempted to add a sub-parameter of a model I'm optimizing to the objective function. Basically I exposed one of the variables being permuted as an output as well.
The variable (parameter) is always negative and I want the optimizer to drive it more negative.
Doing say causes the optimizer to fail on a TypeError: < not implemented between float and 'None'.
I've verified that the type of the parameter being passed in is always float.
I've verified that the value is always real (not nan)
Negating the output parameter so that it's always positive makes the optimizer happy. The code runs fine but I end up with the wrong outcome (the parameter is driven closer to zero which I don't want).
I thought maybe there was an issue with it being always negative so overriding what's coming out of my model and directly feeding the optimizer with a constant -1 on that parameter didn't trigger an issue.
Minimal Code to Reproduce
This is a huge model which represents proprietary design. I will attempt to condense it if absolutely necessary (issue not obvious from the error).Error Message
==========================================================================================
n_gen | n_eval | n_nds | cv_min | cv_avg | eps | indicator
==========================================================================================
1 | 40 | 7 | 0.000000E+00 | nan | - | -
Traceback (most recent call last):
File "C:\Code\System-Models\model_optim_PODEFC.py", line 208, in <module>
res = minimize(problem, algorithm, termination, seed=1,save_history=True, verbose=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Code\System-Models\venv\Lib\site-packages\pymoo\optimize.py", line 67, in minimize
res = algorithm.run()
^^^^^^^^^^^^^^^
File "C:\Code\System-Models\venv\Lib\site-packages\pymoo\core\algorithm.py", line 138, in run
self.next()
File "C:\Code\System-Models\venv\Lib\site-packages\pymoo\core\algorithm.py", line 154, in next
infills = self.infill()
^^^^^^^^^^^^^
File "C:\Code\System-Models\venv\Lib\site-packages\pymoo\core\algorithm.py", line 190, in infill
infills = self._infill()
^^^^^^^^^^^^^^
File "C:\Code\System-Models\venv\Lib\site-packages\pymoo\algorithms\base\genetic.py", line 85, in _infill
off = self.mating.do(self.problem, self.pop, self.n_offsprings, algorithm=self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Code\System-Models\venv\Lib\site-packages\pymoo\core\infill.py", line 38, in do
_off = self._do(problem, pop, n_remaining, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Code\System-Models\venv\Lib\site-packages\pymoo\core\mating.py", line 28, in _do
parents = self.selection(problem, pop, n_matings, n_parents=self.crossover.n_parents, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Code\System-Models\venv\Lib\site-packages\pymoo\core\operator.py", line 27, in __call__
out = self.do(problem, elem, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Code\System-Models\venv\Lib\site-packages\pymoo\core\selection.py", line 49, in do
ret = self._do(problem, pop, n_select, n_parents, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Code\System-Models\venv\Lib\site-packages\pymoo\operators\selection\tournament.py", line 49, in _do
S = self.func_comp(pop, P, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Code\System-Models\venv\Lib\site-packages\pymoo\algorithms\moo\nsga2.py", line 60, in binary_tournament
S[i] = compare(a, cd_a, b, cd_b, method='larger_is_better', return_random_if_equal=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Code\System-Models\venv\Lib\site-packages\pymoo\operators\selection\tournament.py", line 56, in compare
if a_val > b_val:
^^^^^^^^^^^^^
TypeError: '<' not supported between instances of 'float' and 'NoneType'`PyMoo & Python Version
pymoo 0.6.1.5, python 3.12.5