library(ror)
## Example with 3 alternatives and 3 criteria
performances <- matrix(c(1.0, 1.0, 1.0, 2.0, 1.0, 1.1, 2.0, 0.5, 3.0), ncol=3, byrow=TRUE)
## a3 > a2 (strongly preferred)
strongPrefs <- matrix(c(3, 2), ncol=2, byrow=TRUE)
## Necessary relation
necrel <- utagms(performances, strongPrefs, necessary=TRUE, strictVF=TRUE)
## Possible relation with strictly increasing value functions
posrel <- utagms(performances, strongPrefs, necessary=FALSE, strictVF=FALSE)
## Sanity check, the necessary relation should be
## T F F
## T T F
## T T T
stopifnot(necrel == matrix(c(TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE), ncol=3, byrow=TRUE))
## Sanity check, the possible relation should be
## T T F
## T T F
## T T T
stopifnot(posrel == matrix(c(TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE), ncol=3, byrow=TRUE))
## Test with a2 ~ a3
necrel <- utagms(performances, strongPrefs=NULL, indifPrefs=strongPrefs, necessary=TRUE, strictVF=TRUE)
## Sanity check, the necessary relation should represent (a2 ~ a3)
stopifnot(necrel[2,3] == necrel[3,2] && necrel[3,2] == TRUE)
## Not run:
#
# ## Plot the relation
# plot(necrel)
#
# ## a3 > a2 and a2 > a3
# strongPrefs <- matrix(c(3, 2, 2, 3), ncol=2, byrow=TRUE)
#
# ## Error as the model is infeasible
# necrel <- utagms(performances, strongPrefs, necessary=TRUE, strictVF=TRUE)
# ## End(Not run)
Run the code above in your browser using DataLab