DexiAttribute-class {DEXiR} | R Documentation |
DexiAttribute
Description
DexiAttribute
is a RC class representing a DEXi attribute in R.
Details
In a DEXi model, attributes are variables that represent observed properties of decision alternatives. Attributes are structured in a tree, so each attribute may, but need not, have one or more direct descendants (lower-level attributes) in the tree. Attributes without descendants are called basic and serve as model inputs. Attributes with one or more descendants are called aggregate and represent model outputs. In order to represent attribute hierarchies rather than plain trees, some attributes may be linked: two attributes of which one links to another one collectively represent, in a conceptual sense, a single attribute in the hierarchy.
When completely defined, each attribute is associated with a value scale represented by a DexiScale object. An object DexiFunction is also defined for each aggregate attribute, aimed at defining the aggregation of the attribute's inputs to values of that attribute.
Fields
name
character. Name of the attribute as defined in the original DEXi model. Notice that such names may not be unique and may contain characters that cannot be used for variable names in R.
id
character. A unique identification of the attribute in the model. Derived from
name
so that it can be used as a variable name in R.description
character. An optional textual description of the attribute.
inputs
list of DexiAttributes. A list of immediate descendants of this attribute in the tree/hierarchy.
NULL
for basic attributes.link
DexiAttribute.
NULL
or a link to another DexiAttributescale
DexiScale. Value scale associated with this attribute, or
NULL
.funct
DexiFunction. Aggregation function associated with this attribute, or
NULL
.parent
DexiAttribute or DexiModel (only for
DexiModel$root
). Parent attribute of this attribute in the tree/hierarchy. TheDexiModel$root
's parent is the DexiModel, which contains all those attributes..alternatives
list. An internal field providing temporary storage for names or values of alternatives while reading them from a
.dxi
file.
Methods
affects(ant)
ant
(as "antecedent") is someDexiAttribute
. The function returnsTRUE
ifant
lies on the path leading from this attribute towards the root, and is therefore affected by this attribute.count()
Return the number of
input
s of this attribute.dim()
Dimensions of the value space determined by this attribute's
inputs
. Result: a numeric vector of length equal toninp()
, containingDexiScale$count()
of all descendant attributes, orNA
for attributes without associated scales. For basic attributes,dim()
returnsNULL
.initialize( name = "", description = "", inputs = list(), id = "", link = NULL, scale = NULL, funct = NULL, parent = NULL, ... )
Initialize a
DexiAttribute
object.inp_index(inp)
Return the index of attribute
inp
ininputs
of this attribute.is_aggregate()
Logical:
TRUE
for aggregate attributes (attributes whoseninp() > 0
).is_basic(include_linked = TRUE)
Logical:
TRUE
for basic attributes (attributes whoseninp() == 0
.include_linked
determines whether linked attributes are counted as basic (TRUE
) or not (FALSE
).is_continuous()
Logical: Indicates whether or not this is a continuous attribute.
is_discrete()
Logical: Indicates whether or not this is a discrete attribute.
is_link()
Logical: Indicates whether or not this is a linked attribute.
level()
Return the level of this attribute in the hierarchy. The level of
DexiModel$root
is 0.model()
Return the
DexiModel
that contains this attribute.ninp()
Return the number of
input
s of this attribute.structure()
Make an indentation string for this attribute, used for printing it in
show()
.tree_indent(none = " ", thru = "|", link = "*", last = "+", line = "-")
Construct a string for representing the indentation of this attribute in the model structure. The arguments
none
,thru
,link
,last
andline
are character strings to be used in the construction.verify()
Check the correctnes of a
DexiAttribute
object and its fields. Result:error()
orTRUE
.
Examples
# Load "Car.dxi"
CarDxi <- system.file("extdata", "Car.dxi", package = "DEXiR")
Car <- read_dexi(CarDxi)
# For example, consider attribute PRICE
att <- Car$attrib("PRICE")
# Print fields and basic properties of att
att$verify()
att$name
att$id
att$description
att_names(att$inputs)
att$link
att$scale
att$funct
att_names(att$parent)
att$is_aggregate()
att$is_basic()
att$is_link()
att$level()
att$count()
att$ninp()
att$dim()
att$model()
att$structure()
# Check if att affects attribute CAR
att$affects(Car$attrib("CAR"))
# Find the index of other attributes in att's inputs
att$inp_index(Car$attrib("MAINT.PRICE"))
att$inp_index(Car$attrib("CAR"))