我使用的是针对R的ahp包(crean.r-project.org/web/ package /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
#####################################另一个文档是由te libray and analysis编写的ahp.R
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我不知道缩进的代码或某些函数中是否有错误。
谢谢
发布于 2018-06-02 09:20:25
这是一个关于缩进的问题。在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>https://stackoverflow.com/questions/45437026
复制相似问题