首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将AHP用于R CRUN.r-project.org/web/packages/ahp时出错

将AHP用于R CRUN.r-project.org/web/packages/ahp时出错
EN

Stack Overflow用户
提问于 2017-08-01 19:50:46
回答 1查看 174关注 0票数 0

我使用的是针对R的ahp包(crean.r-project.org/web/ package /ahp)。我构建了一个包含备选方案和条件的新文档.ahp

代码语言:javascript
复制
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

代码语言:javascript
复制
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结果时,出现以下错误:

代码语言:javascript
复制
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

我不知道缩进的代码或某些函数中是否有错误。

谢谢

EN

回答 1

Stack Overflow用户

发布于 2018-06-02 09:20:25

这是一个关于缩进的问题。在ahpfile的49、54和59行,需要减少缩进。如下所示:

代码语言:javascript
复制
<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>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45437026

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档