diff --git a/docs/src/mcdm.md b/docs/src/mcdm.md index 1087096a..110e7cbc 100644 --- a/docs/src/mcdm.md +++ b/docs/src/mcdm.md @@ -88,8 +88,6 @@ more details about the methods. Performing MCDM using a population. ```julia-repl -julia> using JMcDM - julia> _, _, population = Metaheuristics.TestProblems.ZDT1(); julia> dm = mcdm(population, [0.5, 0.5], TopsisMethod()); @@ -103,8 +101,6 @@ julia> population[dm.bestIndex] Performing MCDM using results from metaheuristic. ```julia-repl -julia> using JMcDM - julia> f, bounds, _ = Metaheuristics.TestProblems.ZDT1(); julia> res = optimize(f, bounds, NSGA2()); diff --git a/src/DecisionMaking/DecisionMaking.jl b/src/DecisionMaking/DecisionMaking.jl index 4e1a769a..81c8a91e 100644 --- a/src/DecisionMaking/DecisionMaking.jl +++ b/src/DecisionMaking/DecisionMaking.jl @@ -5,7 +5,7 @@ include("ROI.jl") include("CompromiseProgramming.jl") export decisionmaking, dm, best_alternative, ROIArchiving, CompromiseProgramming -export WeightedSum, Tchebysheff, AchievementScalarization +export WeightedSum, Tchebysheff, AchievementScalarization, summary """ decisionmaking(fs, w, method) diff --git a/src/DecisionMaking/JMcDM.jl b/src/DecisionMaking/JMcDM.jl index 204953d8..12356927 100644 --- a/src/DecisionMaking/JMcDM.jl +++ b/src/DecisionMaking/JMcDM.jl @@ -10,6 +10,13 @@ export summary export best_alternative +export ArasMethod, CocosoMethod, CodasMethod, CoprasMethod +export EdasMethod, ElectreMethod, GreyMethod, MabacMethod, MaircaMethod +export MooraMethod, SawMethod, TopsisMethod, VikorMethod, WPMMethod +export WaspasMethod, MarcosMethod +export DataFrame + + """ mcdm(fs, w, method) diff --git a/src/PerformanceIndicators/hypervolume.jl b/src/PerformanceIndicators/hypervolume.jl index fdf09e17..19b9ef88 100644 --- a/src/PerformanceIndicators/hypervolume.jl +++ b/src/PerformanceIndicators/hypervolume.jl @@ -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) @@ -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 diff --git a/test/common-methods.jl b/test/common-methods.jl index 430a305d..424a2d51 100644 --- a/test/common-methods.jl +++ b/test/common-methods.jl @@ -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...)') diff --git a/test/decisionmaking.jl b/test/decisionmaking.jl index a9accab8..dfe56e28 100644 --- a/test/decisionmaking.jl +++ b/test/decisionmaking.jl @@ -1,11 +1,3 @@ -import Metaheuristics.JMcDM -import Metaheuristics.JMcDM: ArasMethod, CocosoMethod, CodasMethod, CoprasMethod -import Metaheuristics.JMcDM: EdasMethod, ElectreMethod, GreyMethod, MabacMethod, MaircaMethod -import Metaheuristics.JMcDM: MooraMethod, SawMethod, TopsisMethod, VikorMethod, WPMMethod -import Metaheuristics.JMcDM: WaspasMethod, MarcosMethod -import Metaheuristics.JMcDM: DataFrame - - @testset "DecisionMaking: Compromise Programming" begin function test_cp() _, _, pf = Metaheuristics.TestProblems.ZDT1(); @@ -52,8 +44,6 @@ end w = [0.5, 0.5] - # PrometheeMethod - # PSIMethod, MoosraMethod --err methods = [ ArasMethod, CocosoMethod, CodasMethod, CoprasMethod, EdasMethod, ElectreMethod, GreyMethod, MabacMethod, MaircaMethod, @@ -62,8 +52,8 @@ end ] for method in methods - res_dm = JMcDM.mcdm(res, w, method()) - res_dm2 = JMcDM.mcdm(MCDMSetting(res, w), method()) + res_dm = mcdm(res, w, method()) + res_dm2 = mcdm(MCDMSetting(res, w), method()) @test res_dm.bestIndex == res_dm2.bestIndex # bestIndex can be touple and needs to be handled... @@ -74,7 +64,7 @@ end @test Metaheuristics.compare(fval(best_sol), fval(ref_sol)) == 0 end - @test JMcDM.summary(res, w, [:topsis, :electre, :vikor]) isa DataFrame + @test Metaheuristics.summary(res, w, [:topsis, :electre, :vikor]) isa DataFrame # check default method TopsisMethod @test mcdm(MCDMSetting(res, w)).bestIndex == mcdm(res, w, TopsisMethod()).bestIndex