R Under development (unstable) (2023-11-06 r85483 ucrt) -- "Unsuffered Consequences" Copyright (C) 2023 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(kappalab) Loading required package: lpSolve Loading required package: quadprog Loading required package: kernlab > > ## some alternatives > a <- c(18,11,18,11,11) > b <- c(18,18,11,11,11) > c <- c(11,11,18,18,11) > d <- c(18,11,11,11,18) > e <- c(11,11,18,11,18) > > ## preference threshold relative > ## to the preorder of the alternatives > delta.C <- 1 > > ## corresponing Choquet preorder constraint matrix > Acp <- rbind(c(d,a,delta.C), + c(a,e,delta.C), + c(e,b,delta.C), + c(b,c,delta.C) + ) > > ## a Shapley preorder constraint matrix > ## Sh(1) - Sh(2) >= -delta.S > ## Sh(2) - Sh(1) >= -delta.S > ## Sh(3) - Sh(4) >= -delta.S > ## Sh(4) - Sh(3) >= -delta.S > ## i.e. criteria 1,2 and criteria 3,4 > ## should have the same global importances > delta.S <- 0.01 > Asp <- rbind(c(1,2,-delta.S), + c(2,1,-delta.S), + c(3,4,-delta.S), + c(4,3,-delta.S) + ) > > ## a Shapley interval constraint matrix > ## 0.3 <= Sh(1) <= 0.9 > Asi <- rbind(c(1,0.3,0.9)) > > > ## an interaction preorder constraint matrix > ## such that I(12) = I(34) > delta.I <- 0.01 > Aip <- rbind(c(1,2,3,4,-delta.I), + c(3,4,1,2,-delta.I)) > > ## an interaction interval constraint matrix > ## i.e. -0.20 <= I(12) <= -0.15 > delta.I <- 0.01 > Aii <- rbind(c(1,2,-0.2,-0.15)) > > > ## a minimum variance 2-additive solution > min.var <- mini.var.capa.ident(5,2,A.Choquet.preorder = Acp) > m <- min.var$solution > m Mobius.capacity {} 0.000000 {1} 0.291962 {2} 0.183746 {3} 0.149105 {4} 0.036238 {5} 0.398582 {1,2} -0.183745 {1,3} 0.136610 {1,4} -0.000000 {1,5} 0.029991 {2,3} 0.005046 {2,4} 0.101568 {2,5} -0.000000 {3,4} -0.036237 {3,5} -0.112867 {4,5} 0.000000 > > ## the resulting global evaluations > rbind(c(a,mean(a),Choquet.integral(m,a)), + c(b,mean(b),Choquet.integral(m,b)), + c(c,mean(c),Choquet.integral(m,c)), + c(d,mean(d),Choquet.integral(m,d)), + c(e,mean(e),Choquet.integral(m,e))) [,1] [,2] [,3] [,4] [,5] [,6] [,7] [1,] 18 11 18 11 11 13.8 15.04374 [2,] 18 18 11 11 11 13.8 13.04374 [3,] 11 11 18 18 11 13.8 12.04374 [4,] 18 11 11 11 18 13.8 16.04374 [5,] 11 11 18 11 18 13.8 14.04374 > > ## the Shapley value > Shapley.value(m) 1 2 3 4 5 0.28339006 0.14518087 0.14538137 0.06890384 0.35714386 > > ## a minimum variance 3-additive more constrainted solution > min.var2 <- mini.var.capa.ident(5,3, + A.Choquet.preorder = Acp, + A.Shapley.preorder = Asp) > m <- min.var2$solution > m Mobius.capacity {} 0.000000 {1} 0.244167 {2} 0.240948 {3} 0.118006 {4} 0.118006 {5} 0.289053 {1,2} -0.224250 {1,3} 0.184406 {1,4} -0.009865 {1,5} 0.156216 {2,3} 0.055736 {2,4} 0.111378 {2,5} -0.070164 {3,4} -0.118005 {3,5} -0.003337 {4,5} 0.001006 {1,2,3} -0.005691 {1,2,4} 0.086434 {1,2,5} 0.064969 {1,3,4} 0.009865 {1,3,5} -0.261833 {1,4,5} -0.109146 {2,3,4} -0.000039 {2,3,5} 0.021339 {2,4,5} -0.052047 {3,4,5} 0.152851 > rbind(c(a,mean(a),Choquet.integral(m,a)), + c(b,mean(b),Choquet.integral(m,b)), + c(c,mean(c),Choquet.integral(m,c)), + c(d,mean(d),Choquet.integral(m,d)), + c(e,mean(e),Choquet.integral(m,e))) [,1] [,2] [,3] [,4] [,5] [,6] [,7] [1,] 18 11 18 11 11 13.8 14.82605 [2,] 18 18 11 11 11 13.8 12.82605 [3,] 11 11 18 18 11 13.8 11.82605 [4,] 18 11 11 11 18 13.8 15.82605 [5,] 11 11 18 11 18 13.8 13.82605 > Shapley.value(m) 1 2 3 4 5 0.2256191 0.2156191 0.1495690 0.1395690 0.2696237 > > ## a minimum variance 5-additive more constrainted solution > min.var3 <- mini.var.capa.ident(5,5, + A.Choquet.preorder = Acp, + A.Shapley.preorder = Asp, + A.Shapley.interval = Asi, + A.interaction.preorder = Aip, + A.interaction.interval = Aii) > > m <- min.var3$solution > m Mobius.capacity {} 0.000000 {1} 0.277968 {2} 0.277968 {3} 0.117798 {4} 0.116752 {5} 0.141094 {1,2} -0.277967 {1,3} 0.167917 {1,4} 0.095170 {1,5} 0.287479 {2,3} 0.118908 {2,4} 0.139738 {2,5} 0.098626 {3,4} -0.099439 {3,5} 0.161934 {4,5} -0.000044 {1,2,3} 0.096023 {1,2,4} 0.164392 {1,2,5} -0.024410 {1,3,4} -0.112483 {1,3,5} -0.447648 {1,4,5} -0.211878 {2,3,4} -0.061228 {2,3,5} -0.237635 {2,4,5} -0.094907 {3,4,5} -0.017268 {1,2,3,4} -0.113658 {1,2,3,5} 0.184804 {1,2,4,5} -0.019047 {1,3,4,5} 0.229190 {2,3,4,5} 0.071460 {1,2,3,4,5} -0.029610 > rbind(c(a,mean(a),Choquet.integral(m,a)), + c(b,mean(b),Choquet.integral(m,b)), + c(c,mean(c),Choquet.integral(m,c)), + c(d,mean(d),Choquet.integral(m,d)), + c(e,mean(e),Choquet.integral(m,e))) [,1] [,2] [,3] [,4] [,5] [,6] [,7] [1,] 18 11 18 11 11 13.8 14.94578 [2,] 18 18 11 11 11 13.8 12.94578 [3,] 11 11 18 18 11 13.8 11.94578 [4,] 18 11 11 11 18 13.8 15.94578 [5,] 11 11 18 11 18 13.8 13.94578 > summary(m) Shapley value : 1 2 3 4 5 0.3000000 0.2900000 0.1194055 0.1094055 0.1811889 Shapley interaction indices : 1 2 3 4 5 1 NA -0.150000000 0.02857307 0.03994551 0.069757382 2 -0.15000000 NA 0.05762099 0.11604925 -0.008179734 3 0.02857307 0.057620989 NA -0.14000000 -0.034926277 4 0.03994551 0.116049246 -0.14000000 NA -0.075605322 5 0.06975738 -0.008179734 -0.03492628 -0.07560532 NA Orness : 0.5381275 Veto indices : 1 2 3 4 5 0.5271926 0.5254204 0.4053566 0.4042635 0.4471292 Favor indices : 1 2 3 4 5 0.5978074 0.5870796 0.4939004 0.4824934 0.5293569 Normalized variance : 0.108694 Normalized entropy : 0.8465558 > > > > > proc.time() user system elapsed 0.51 0.07 0.57