Skip to content

Commit

Permalink
add vebose flag
Browse files Browse the repository at this point in the history
  • Loading branch information
jmejia8 committed Nov 13, 2022
1 parent 1b0182a commit e7495db
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/PerformanceIndicators/hypervolume.jl
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ is a non-dominated set.
If `front::State` and `reference_point::Vector`, then computes `hypervolume(front.population, reference_point)` after
ignoring solutions in `front` that do not dominate `reference_point`.
"""
function hypervolume(front::Array{Vector{T}}, reference_point::Vector) where T <: Real
function hypervolume(front::Array{Vector{T}}, reference_point::Vector; verbose=true) where T <: Real

weaklyDominates(point, other) = begin
for i in 1:length(point)
Expand All @@ -187,16 +187,16 @@ function hypervolume(front::Array{Vector{T}}, reference_point::Vector) where T <
if length(relevantPoints) != length(front)
ign = length(front) - length(relevantPoints)
rel = length(relevantPoints)
@warn "Ignoring $ign points dominated by the reference point ($rel points are used)."
verbose && @warn "Ignoring $ign points dominated by the reference point ($rel points are used)."
end

return HyperVolume.hv(relevantPoints, reference_point)
end

hypervolume(front::Vector{T}, reference_point::Vector{T}) where T <: AbstractMultiObjectiveSolution = hypervolume(fval.(front), fval(reference_point))
hypervolume(front::Vector{T}, reference_point::Vector) where T <: AbstractMultiObjectiveSolution = hypervolume(fval.(front), reference_point)
hypervolume(front::Vector{T}, reference_point::Vector{T}; verbose=true) where T <: AbstractMultiObjectiveSolution = hypervolume(fval.(front), fval(reference_point); verbose)
hypervolume(front::Vector{T}, reference_point::Vector; verbose=true) where T <: AbstractMultiObjectiveSolution = hypervolume(fval.(front), reference_point;verbose)

function hypervolume(front::Matrix, reference_point::Vector)
function hypervolume(front::Matrix, reference_point::Vector; verbose=true)
front_ = [ front[i,:] for i in 1:size(front,1) ]
hypervolume(front_, reference_point)
hypervolume(front_, reference_point; verbose)
end
2 changes: 1 addition & 1 deletion test/common-methods.jl
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ import Random: seed!
[1.1 ,0. ,0. ]]

referencePoint = [2.0, 2, 2]
hyperVolume = Metaheuristics.PerformanceIndicators.hypervolume(front, referencePoint)
hyperVolume = Metaheuristics.PerformanceIndicators.hypervolume(front, referencePoint, verbose=false)
@test hyperVolume 6.793879034744429

front_ = Array(hcat(front...)')
Expand Down

0 comments on commit e7495db

Please sign in to comment.