我使用的是ahp包(R(cran.r-project.org/web/packages/ahp))。我使用替代方案和标准构建了一个新文档.ahp
Version: 2.0
#########################
# Alternatives Section
#
Alternatives: &alternatives
# Here, we list all the alternatives, together with their attributes.
A:
hectareas: 1.88
ninos: 1
adultos: 12
B:
hectareas: 21.06
ninos: 14
adultos: 19
#
# End of Alternatives Section
#####################################
#####################################
# Goal Section
#
Goal:
# The goal spans a tree of criteria and the alternatives
name: Zona Verde
description: >
This is a classic single decision maker problem.
author: unknown
preferences:
# preferences are typically defined pairwise
# 1 means: A is equal to B
# 9 means: A is highly preferrable to B
# 1/9 means: B is highly preferrable to A
pairwise:
- [hectareas, ninos, 3]
- [hectareas, adultos, 7]
- [ninos, adultos, 3]
children:
hectareas:
preferences:
pairwise:
- [A, B, 9]
children: *alternatives
ninos:
preferences:
pairwise:
- [A, B, 1/3]
children: *alternatives
adultos:
preferences:
pairwise:
- [A, B, 1/4]
children: *alternatives
#
# End of Goal Section
#####################################
另一个文件是ahp.R by te libray and analysis
library(ahp)
#list example files provided by the package
list.files(system.file("extdata", package="ahp"))
#zonas verdes example
ahpFile <- system.file("extdata", "zonasverdes.ahp", package="ahp")
zonasverdesAhp <- Load(ahpFile)
Calculate(zonasverdesAhp)
Analyze(zonasverdesAhp)
AnalyzeTable(zonasverdesAhp)
当我运行代码来分析AHP结果时出现此错误:
Error in value[[3L]](cond) :
Could not load ahp model. Exception caught when converting into a data.tree: Error in preferences[[type]]: attempt to select less than one element in get1index
我不知道缩进的代码或某些函数中是否存在错误。
由于
答案 0 :(得分:0)
这是关于缩进的问题。 在ahpfile的第49,54和59行中,您需要减少缩进。 像这样:
<code>
children:
hectareas:
preferences:
pairwise:
- [A, B, 9]
children: *alternatives
ninos:
preferences:
pairwise:
- [A, B, 1/3]
children: *alternatives
adultos:
preferences:
pairwise:
- [A, B, 1/4]
children: *alternatives
</code>