Learn R Programming

RXMCDA (version 1.5.5)

getAlternativesComparisonsLabels: Get comparisons of alternatives

Description

Extracts from an XML tree written according to the XMCDA standard and stores the IDs of the concerned alternatives.

Usage

getAlternativesComparisonsLabels(tree, altIDs=NULL, mcdaConcept = NULL)

Arguments

tree
Object containing the XMCDA XML tree.
altIDs
A vector containing the IDs of the alternatives to be considered for the extractions.
mcdaConcept
A string containing the specific mcdaConcept attribute which should be searched for.

Value

The function returns a list structured as follows:
--
The first elements contain the found in as matrices. These elements are named according to the mcdaConcept attribute if it can be found. Each line of each matrix corresponds to one constraint of the type "alternative a is preferred to alternative b with preference threshold delta". A line is structured as follows: the first element encodes the ID of alternative a, the second element encodes the ID of alternative b, and the last element contains the preference threshold delta.
status
Either OK if all the tags could be correctly read, or the description of the error.

Examples

Run this code
tree = newXMLDoc()

newXMLNode("xmcda:XMCDA", 
           namespace = c("xsi" = "http://www.w3.org/2001/XMLSchema-instance", 
           "xmcda" = "http://www.decision-deck.org/2009/XMCDA-2.1.0"), 
           parent=tree)

root<-getNodeSet(tree, "/xmcda:XMCDA")

aC<-newXMLNode("alternativesComparisons", parent=root[[1]], namespace=c())

pairs<-newXMLNode("pairs", parent=aC, namespace=c())
pair<-newXMLNode("pair", parent=pairs, namespace=c())

initial<-newXMLNode("initial", parent=pair, namespace=c())
newXMLNode("alternativeID", "a01", parent=initial, namespace=c())

terminal<-newXMLNode("terminal", parent=pair, namespace=c())
newXMLNode("alternativeID", "a02", parent=terminal, namespace=c())

value<-newXMLNode("value", parent=pair, namespace=c())
newXMLNode("real", "0.5", parent=value, namespace=c())

alternativesIDs <- c("a01","a02")

y<-getNodeSet(tree,"//alternativesComparisons")

x<-getAlternativesComparisonsLabels(y[[1]], alternativesIDs)

Run the code above in your browser using DataLab