jMetal / MetaJul

Metaheuristics in Julia
MIT License
4 stars 1 forks source link

dominanceComparator function #1

Closed dongzhiming closed 1 year ago

dongzhiming commented 1 year ago

I am not sure whether the dominanceComparator function will become less efficient or not, I wrote it in the following way.

function dominanceComparator(x::Array{T}, y::Array{T})::Int where {T <: Number}
    @assert length(x) == length(y) "The arrays have a different length"

    x==y && return 0

    all(t->(t[1]≤t[2]), zip(x, y)) && return -1
    all(t->(t[1]≤t[2]), zip(y, x)) && return  1
    return 0
end
ajnebro commented 1 year ago

It is a very concise, clear and elegant solution. I will adopt it.