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 > > # example from Marichal and Roubens (cooks) > > a <- c(18,15,19) > b <- c(15,18,19) > c <- c(15,18,11) > d <- c(18,15,11) > > delta.C <- 0.05 > > Acp <- rbind(c(a,b,delta.C),c(c,d,delta.C)) > > s <- lin.prog.capa.ident(3,2,A.Choquet.preorder = Acp) Success: the objective function is 1.449996 > > s $solution Mobius.capacity {} 0.000000 {1} 0.000001 {2} 0.500000 {3} 0.499999 {1,2} -0.000000 {1,3} 0.499999 {2,3} -0.499999 $value [1] 1.449996 $lp.object Success: the objective function is 1.449996 > m <- s$solution > print(summary(m)) Shapley value : 1 2 3 0.2500003 0.2500003 0.4999995 Shapley interaction indices : 1 2 3 1 NA -4.440892e-16 0.4999985 2 -4.440892e-16 NA -0.4999985 3 4.999985e-01 -4.999985e-01 NA Orness : 0.5 Veto indices : 1 2 3 0.5000000 0.3750004 0.6249996 Favor indices : 1 2 3 0.3750004 0.5000000 0.6249996 Normalized variance : 0.3749978 Normalized entropy : 0.52579 > > out <- 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))) > > print(out) [,1] [,2] [,3] [,4] [,5] [1,] 18 15 19 17.33333 18.50000 [2,] 15 18 19 17.33333 17.00000 [3,] 15 18 11 14.66667 14.50000 [4,] 18 15 11 14.66667 13.00001 > > ## 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(2) - Sh(1) >= delta.S > delta.S <- 0.0 > Asp <- rbind(c(2,1,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 LP 2-additive solution > lin.prog <- lin.prog.capa.ident(5,2,A.Choquet.preorder = Acp) Success: the objective function is 0.1666608 > m <- lin.prog$solution > m Mobius.capacity {} 0.000000 {1} 0.499999 {2} 0.333333 {3} 0.333333 {4} 0.000001 {5} 0.666664 {1,2} -0.333332 {1,3} 0.000000 {1,4} 0.000000 {1,5} -0.166666 {2,3} -0.000000 {2,4} -0.000000 {2,5} 0.000000 {3,4} -0.000000 {3,5} -0.333332 {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 16.83332 [2,] 18 18 11 11 11 13.8 14.50000 [3,] 11 11 18 18 11 13.8 13.33334 [4,] 18 11 11 11 18 13.8 17.99998 [5,] 11 11 18 11 18 13.8 15.66666 > > ## the Shapley value > Shapley.value(m) 1 2 3 4 5 0.2499998 0.1666668 0.1666668 0.0000010 0.4166656 > > ## a LP 3-additive more constrainted solution > lin.prog2 <- lin.prog.capa.ident(5,3, + A.Choquet.preorder = Acp, + A.Shapley.preorder = Asp) Success: the objective function is 0.2068941 > m <- lin.prog2$solution > m Mobius.capacity {} 0.000000 {1} 0.000001 {2} 0.172414 {3} 0.000001 {4} 0.000001 {5} 0.344828 {1,2} 0.000000 {1,3} 0.517240 {1,4} -0.000000 {1,5} 0.344827 {2,3} 0.827582 {2,4} -0.000000 {2,5} -0.034486 {3,4} 0.000000 {3,5} 0.000000 {4,5} -0.000000 {1,2,3} -0.517240 {1,2,4} 0.000000 {1,2,5} 0.172413 {1,3,4} 0.000000 {1,3,5} -0.517240 {1,4,5} 0.000000 {2,3,4} -0.000000 {2,3,5} -0.310341 {2,4,5} 0.000000 {3,4,5} -0.000000 > 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.62070 [2,] 18 18 11 11 11 13.8 12.20691 [3,] 11 11 18 18 11 13.8 11.00001 [4,] 18 11 11 11 18 13.8 15.82759 [5,] 11 11 18 11 18 13.8 13.41380 > Shapley.value(m) 1 2 3 4 5 0.1436789 0.3505730 0.2241380 0.0000010 0.2816091 > > ## a LP 5-additive more constrainted solution > lin.prog3 <- lin.prog.capa.ident(5,5, + A.Choquet.preorder = Acp, + A.Shapley.preorder = Asp, + A.Shapley.interval = Asi, + A.interaction.preorder = Aip, + A.interaction.interval = Aii + ) Success: the objective function is 0.01 > > m <- lin.prog3$solution > m Mobius.capacity {} 0.000000 {1} 0.184316 {2} 0.184316 {3} 0.000001 {4} 0.000001 {5} 0.037430 {1,2} -0.184315 {1,3} 0.288571 {1,4} 0.432857 {1,5} 0.395428 {2,3} 0.000000 {2,4} 0.000000 {2,5} -0.037429 {3,4} 0.000000 {3,5} 0.291171 {4,5} 0.000000 {1,2,3} 0.527109 {1,2,4} -0.000000 {1,2,5} 0.037429 {1,3,4} -0.288571 {1,3,5} -0.579743 {1,4,5} -0.432857 {2,3,4} 0.645238 {2,3,5} 0.354067 {2,4,5} 0.645238 {3,4,5} -0.000000 {1,2,3,4} -0.789524 {1,2,3,5} -0.498353 {1,2,4,5} -0.262415 {1,3,4,5} 0.288571 {2,3,4,5} -1.290476 {1,2,3,4,5} 1.051939 > 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.31022 [2,] 18 18 11 11 11 13.8 12.29022 [3,] 11 11 18 18 11 13.8 11.00001 [4,] 18 11 11 11 18 13.8 15.32022 [5,] 11 11 18 11 18 13.8 13.30022 > summary(m) Shapley value : 1 2 3 4 5 0.3000000 0.3100000 0.1471814 0.1030390 0.1397796 Shapley interaction indices : 1 2 3 4 5 1 NA -0.15582482 0.04785183 0.08067177 0.01342863 2 -0.15582482 NA 0.16674072 0.12741780 0.06017466 3 0.04785183 0.16674072 NA -0.15582482 -0.05876773 4 0.08067177 0.12741780 -0.15582482 NA -0.05226474 5 0.01342863 0.06017466 -0.05876773 -0.05226474 NA Orness : 0.4854817 Veto indices : 1 2 3 4 5 0.5643810 0.6092025 0.4810234 0.4509767 0.4670077 Favor indices : 1 2 3 4 5 0.5606190 0.5282975 0.4529533 0.4278220 0.4577168 Normalized variance : 0.3175543 Normalized entropy : 0.5640267 > > > > > proc.time() user system elapsed 0.51 0.09 0.59