The MAUT decision models are defined with aid of utility functions u1, …, un which are evaluated over indexes x1, …, xn and those utilities are aggregated considering additional weights w1, …, wn, the whole final utility is given by the sum
u(x1, …, xn)=∑1 ≤ i ≤ n wi ui (xi)
With mau you can build and test decision models based in Multi Attribute Utility Theory (MAUT). The utilities of any level of the decision model can be easily evaluated.
To install mau you can proceed in the following way making use of the devtools library
library( devtools )
install_github( "pedroguarderas/mau" )
The utility functions for a MAUT model could be defined in a practical format when those are are piecewise defined like constant risk averse functions, in such case it is only necessary to define the parameters of the function for each part of the domain of definition. This is because, the constant risk averse functions are of the form u(x)=a ⋅ x + b or u(x)=a ⋅ eb ⋅ x + c.
File format for the piecewise defintion of utilities, is specified as
follows. > Header
>
> Function name
> min1 max1 a1 b1 c1
> min2 max2 a2 b2 c2
> min3 max3 a3 b3 c3
> …
> Function name
> min1 max1 a1 b1 c1
> min2 max2 a2 b2 c2
> min3 max3 a3 b3 c3
> …
If ci is 0 then the utility is linear, otherwise is an exponential function. For example:
library( mau )
<-system.file("extdata", "utilities.txt", package = "mau" )
file<-readLines( file )
linesfor ( i in 1:length( lines ) ) {
cat( lines[i], '\n' )
}#> Utilities
#>
#> Project
#> 1 2 1.5 -0.5 0
#> 2 3 1.5 -0.5 0
#>
#> Self implementation
#> 1 2 1.5 -0.5 0
#> 2 3 1.5 -0.5 0
#>
#> External and local relations
#> 1 10 1 0 0
#> 0 1 0 1 0
#>
#> Scope of capabilities
#> 6 15 1 0 0
#> 0 6 1.225 -1.225 0.2824
In the sources below is developed a complete example of a decision
model, the package mau is employed to load utilities
defined in the file utilities.txt
, provided in the package
itself, automatically the script with utilies is built and saved in the
local working directory, after that with Eval.Utilities
every function is evaluated over the columns of the index table, the
names for utilities were previously standarized with
Stand.String
. With another file tree.csv
the
decision tree associated to the MAUT model is built and every weight and
relative weight assigned with the Make.Decision.Tree
function, in addition the whole model with utilies of every criteria is
obtained with Compute.Model
. The simulation of constrained
weights is made with Sim.Const.Weights
, the result could be
employed for a sensitivy test of the decision model under a variation of
weights.
# Loading packages --------------------------------------------------------------------------------
library( mau )
library( data.table )
library( igraph )
library( ggplot2 )
# Table of indexes --------------------------------------------------------------------------------
<-data.table( cod = paste( 'A', 1:10, sep = '' ),
indexi1 = c( 0.34, 1, 1, 1, 1, 0.2, 0.7, 0.5, 0.11, 0.8 ),
i2 = c( 0.5, 0.5, 1, 0.5, 0.3, 0.1, 0.4, 0.13, 1, 0.74 ),
i3 = c( 0.5, 1.0, 0.75, 0.25, 0.1, 0.38, 0.57, 0.97, 0.3, 0.76 ),
i4 = c( 0, 0.26, 0.67, 0.74, 0.84, 0.85, 0.74, 0.65, 0.37, 0.92 ) )
# Loading utilities -------------------------------------------------------------------------------
<-system.file("extdata", "utilities.txt", package = "mau" )
file<-'utilities.R'
script<-17
lines<-2
skip<-'utf-8'
encoding<-Read.Utilities( file, script, lines, skip, encoding )
functionssource( 'utilities.R' )
# Index positions ---------------------------------------------------------------------------------
<-c( 2, 3, 4, 5 )
columns
# Function names
<-sapply( c( 'Project',
functions'Self implementation',
'External and local relations',
'Scope of capabilities' ),
FUN = Stand.String )
names( functions )<-NULL
# Evaluation of utilities -------------------------------------------------------------------------
<-Eval.Utilities( index, columns, functions )
utilities
# Tree creation -----------------------------------------------------------------------------------
<-system.file("extdata", "tree.csv", package = "mau" )
file<-Read.Tree( file, skip = 0, nrow = 8 )
tree.data<-Make.Decision.Tree( tree.data )
tree
# Compute the decision model ----------------------------------------------------------------------
<-tree.data[ !is.na( weight ) ]$weight
weights<-Compute.Model( tree, utilities, weights )
model
# Weights simulation ------------------------------------------------------------------------------
<-200
n<-c( 0.2, 0.5, 0.1, 0.2 )
alpha<-list( list( c(1,2), 0.7 ),
constraintslist( c(3,4), 0.3 ) )
<-Sim.Const.Weights( n, utilities, alpha, constraints )
S<-Plot.Simulation.Weight( S$simulation, title = 'Simulations',
plot.Sxlab = 'ID', ylab = 'Utility' )
plot( plot.S )