Checklist
Bug Description
Several implementations in Cython seem to have mismatched types (this might be platform dependent, running Windows 11 in x86 architecture). Some parameters are defined as long, where outputs from np.argsort, no.lexsort and np.arange are passed, which by default are of dtype np.int64. That matches a long long instead of a long. The issues occur in:
- stochastic_ranking.pyx
- Parameter "I" from stochastic_ranking and c_stochastic_ranking (lines 10 and 17) are defined as long but get passed a np.int64 array in StochasticRankingSurvival, or if none is provided the first one creates and passes one to the second.
- Parameter "x" in c_swap is defined as long but when called the previous "I" is passed.
This was detected in failure in documentation tests (because algorithm tests don't ever use a constrained function for ISRES/SRES, which is the only code path that calls the function). In the minimal example the specific code that triggers this error is pasted.
- non_dominated_sorting.pyx
- "b", defined in line 582 in c_construct_domination_matrix as long, but the value is a np.int64 array.
- "b", defined in line 593 in c_construct_comparison_matrix as long, gets called in the previous function with the same value, which seems to be expected to be a long long.
- "sorted_indices", defined in line 663 in c_dda_end_get_fronts as long, but on runtime (lines 388-391, same file) it always gets passed the value of a call to np.lexsort which returns a np.int64 array.
This second one can directly be reproduced calling:
pytest .\tests\misc\test_non_dominated_sorting.py
In my machine at least, declaring all those as long long solves the issues, but I'm not knowledgeable enough in Cython to know whether the build is fine in other architectures/OS's and these changes would break them.
Minimal Code to Reproduce
# Code for stochastic_ranking call from
from pymoo.algorithms.soo.nonconvex.isres import ISRES
from pymoo.problems import get_problem
from pymoo.optimize import minimize
problem = get_problem("g1")
algorithm = ISRES(n_offsprings=200, rule=1.0 / 7.0, gamma=0.85, alpha=0.2)
res = minimize(problem,
algorithm,
("n_gen", 200),
seed=1,
verbose=False)
print("Best solution found: \nX = %s\nF = %s\nCV = %s" % (res.X, res.F, res.CV))
Error Message
File pymoo/functions/compiled/stochastic_ranking.pyx:10, in pymoo.functions.compiled.stochastic_ranking.stochastic_ranking()
---> 10 'Could not get source, probably due dynamically evaluated source code.'
ValueError: Buffer dtype mismatch, expected 'long' but got 'long long'
PyMoo & Python Version
pymoo 0.6.1.6, python 3.14.4
Checklist
Bug Description
Several implementations in Cython seem to have mismatched types (this might be platform dependent, running Windows 11 in x86 architecture). Some parameters are defined as long, where outputs from np.argsort, no.lexsort and np.arange are passed, which by default are of dtype np.int64. That matches a long long instead of a long. The issues occur in:
This was detected in failure in documentation tests (because algorithm tests don't ever use a constrained function for ISRES/SRES, which is the only code path that calls the function). In the minimal example the specific code that triggers this error is pasted.
This second one can directly be reproduced calling:
In my machine at least, declaring all those as long long solves the issues, but I'm not knowledgeable enough in Cython to know whether the build is fine in other architectures/OS's and these changes would break them.
Minimal Code to Reproduce
Error Message
PyMoo & Python Version
pymoo 0.6.1.6, python 3.14.4