模糊系统存在哪些问题?

What are the problems with the fuzzy system?

所以我有创建基于规则的模糊系统的代码:

install.packages("sets")
library(sets)
sets_options("universe", seq(1,100,0.5))

variables<-set(
  temperature=fuzzy_partition(varnames=c(cold=30, 
                                         good=70, hot=90), sd=5),
  humidity=fuzzy_partition(varnames=c(dry=30, good=60, wet=80), sd=3),
  precipitations=fuzzy_partition(varnames=c(no.rain=30, 
                                          little.rain=60, rain=90), sd=7.5),
  weather=fuzzy_partition(varnames=c(bad=40, ok=65, perfect=80), FUN=fuzzy_cone,
                        radius=10)
)

rules<-set(
  fuzzy_rule(temperature %is% good && humidity %is% dry &&
               precipitations %is% no.rain , weather %is% perfect),
  fuzzy_rule(temperature %is% hot && humidity %is% wet &&
               precipitations %is% rain, weather %is% bad),
  fuzzy_rule(temperature %is% cold && weather %is% bad),
  fuzzy_rule(temperature %is% good || humidity %is% good || precipitations %is%
               little.rain, weather %is%ok),
  fuzzy_rule(temperature %is% hot && precipitations %is% little.rain , weather %is% ok),
  fuzzy_rule(temperature %is% hot && humidity %is% dry  
             &&precipitations %is% little.rain, weather %is% ok))

model<-fuzzy_system(variables, rules)
plot(model)


example<-fuzzy_inference(model,list(temperature=65,
                             humidity=0, precipitations=80)) //here is the error 
plot(example)

错误是这样的:“[[<-(i$consequent, 1L, as.name("$")) 中的错误: 'symbol' 类型的对象不可子集化”,我不知道这是什么意思。

OP 中存在一些问题 'rules'

library(sets)
as.list(rules)
#[[1]]
#temperature %is% hot && precipitations %is% little.rain => weather %is% ok

#[[2]]
#Error in format.default(x$consequent) : 
#  Found no format() method for class "name"

基本上,第三条规则没有价值

...
fuzzy_rule(temperature %is% cold && weather %is% bad),  ### 
...

另一个问题是 'variables' 使用 fuzzy_cone 创建 'radius' 不重叠创建 NULL 集

variables
#{weather = (bad = {}, ok = {}, perfect = {}), humidity = (dry = <<gset(201)>>, good = <<gset(201)>>, wet = <<gset(201)>>),
#temperature = (cold = <<gset(201)>>, good = <<gset(201)>>, hot = <<gset(201)>>), precipitations = (no.rain = <<gset(201)>>,
#little.rain = <<gset(201)>>, rain = <<gset(201)>>)}

如果我们进行必要的更改,它就会起作用

variables<-set(
      temperature=
         fuzzy_partition(varnames=
                     c(cold=30, good=70, hot=90), 
                     sd=5),
       humidity=
          fuzzy_partition(varnames=
               c(dry=30, good=60, wet=80), 
               sd=3),
       precipitations=
              fuzzy_partition(varnames=
                      c(no.rain=30, little.rain =60, rain=90), sd=7.5),
      weather=fuzzy_partition(varnames=c(bad=40, ok=65, perfect=80), FUN=fuzzy_cone,
                            radius=75)
    )


rules<-set(
               fuzzy_rule(temperature %is% good && humidity %is% dry && precipitations %is% no.rain , 
                        weather %is% perfect),
               fuzzy_rule(temperature %is% hot && humidity %is% wet &&  precipitations %is% rain, 
                 weather %is% bad),
               fuzzy_rule(temperature %is% cold,
                   weather %is% bad),           
              fuzzy_rule(temperature %is% good || humidity %is% good || precipitations %is% little.rain,
                   weather %is% ok),
              fuzzy_rule(temperature %is% hot && precipitations %is% little.rain,
                   weather %is% ok),
              fuzzy_rule(temperature %is% hot && humidity %is% dry && precipitations %is% little.rain,
                   weather %is% ok))

-查看规则

as.list(rules)
#[[1]]
#temperature %is% hot && precipitations %is% little.rain => weather %is% ok

#[[2]]
#temperature %is% hot && humidity %is% dry && precipitations %is%  => weather %is% ok
#    little.rain => weather %is% ok

#[[3]]
#temperature %is% hot && humidity %is% wet && precipitations %is%  => weather %is% bad
#    rain => weather %is% bad

#[[4]]
#temperature %is% good && humidity %is% dry && precipitations %is%  => weather %is% perfect
 #   no.rain => weather %is% perfect

#[[5]]
#temperature %is% good || humidity %is% good || precipitations %is%  => weather %is% ok
 #   little.rain => weather %is% ok

#[[6]]
#temperature %is% cold => weather %is% bad

建立fuzzy_system

model <- fuzzy_system(variables, rules)
example <- fuzzy_inference(model,list(temperature=65,
                                 humidity=0, precipitations=80))