【问题标题】:R fuzzy sets - Cannot plot tuple of fuzzy multisetsR模糊集 - 无法绘制模糊多重集的元组
【发布时间】:2016-09-02 17:28:32
【问题描述】:

我正在尝试使用 R 的模糊集功能来实现 this example。代码:

sets_options("universe", seq(from = -200, to = 200, by = 1))
#------------------------------------------------------------------------------------------
# Fuzzy Variables
variables <-
  set (
    temp = fuzzy_variable(cold   = fuzzy_trapezoid(corners=c(-101, -100, 40, 70)),
                          ok     = fuzzy_triangular(corners=c(40,70,100)),
                          hot    = fuzzy_trapezoid(corners=c(70, 100, 200, 201))),
    ctrl = fuzzy_variable(small  = fuzzy_triangular(corners=c(-50,0,50)),
                          med    = fuzzy_triangular(corners=c(0, 50, 100)),
                          large  = fuzzy_triangular(corners=c(50, 100, 150)))
  )

#------------------------------------------------------------------------------------------
# Fuzzy Rules
rules <-
  set(
    fuzzy_rule(temp %is% cold, ctrl %is% large),
    fuzzy_rule(temp %is% ok,   ctrl %is% med),
    fuzzy_rule(temp %is% hot,  ctrl %is% small)
  )

#------------------------------------------------------------------------------------------
# Set up Fuzzy System
system <- fuzzy_system(variables, rules)
print(system)
plot(system)

#------------------------------------------------------------------------------------------
# Example
# If the measured temperature is 80 degrees, what's the control effort?
fi <- fuzzy_inference(system, list(temp=80))
## plot resulting fuzzy set
plot(fi)
## defuzzify
gset_defuzzify(fi, "centroid")

## reset universe
sets_options("universe", NULL)

然而,当我运行它时,我得到了两个错误:

> plot(system)
Error in lines.tuple(as.tuple(x), ...) : 
  Cannot plot tuple of fuzzy multisets.
> fi <- fuzzy_inference(system, list(temp=80))
Error in rep.int(0, len - length(ret)) : invalid 'times' value

我有点难过。确实找到了this,这看起来像一个类似的问题,但我看不到上面的拼写错误。

任何帮助表示赞赏。谢谢。在 Windows 上使用 R v3.2.4 以防万一。

【问题讨论】:

    标签: r fuzzy-logic


    【解决方案1】:

    这是一个环境问题。重置 RStudio 环境并成功。将问答留在这里,以防有人看到相同的内容。

    【讨论】:

    • 不需要。你可以删除。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-05-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-31
    • 1970-01-01
    • 2020-08-28
    相关资源
    最近更新 更多