在R中,如何使用模糊逻辑的集合包在3D图中最好地绘制模糊表面?服务变量和食物变量应该是x和y轴,z轴应该是模糊推理变量去模糊化的质心。
我是R的初学者,尝试使用expand.grid绘制模糊表面的4,000个点,并且我的计算机磁盘达到100%并且即使在2次重启后也保持这种状态。为了您的计算机安全,我故意不会向您展示我编写的代码。
这个示例系统来自他们的文档将是一个很好的起点。你能帮我画一下结果吗?感谢。
library(sets)
# set universe
sets_options("universe", seq(from = 0, to = 25, by = 1))
# set up fuzzy variables
variables <-
set(service = fuzzy_partition(varnames = c(poor = 0, good = 5, excellent = 10), sd = 1.5),
food = fuzzy_variable(rancid = fuzzy_trapezoid(corners = c(-2, 0, 2, 4)),
delicious = fuzzy_trapezoid(corners = c(7, 9, 11, 13))),
tip = fuzzy_partition(varnames = c(cheap = 5, average = 12.5, generous = 20),
FUN = fuzzy_cone, radius = 5)
)
# set up rules
rules <-
set(
fuzzy_rule(service %is% poor || food %is% rancid, tip %is% cheap),
fuzzy_rule(service %is% good, tip %is% average),
fuzzy_rule(service %is% excellent || food %is% delicious, tip %is% generous)
)
# combine to a system
system <- fuzzy_system(variables, rules)
print(system)
plot(system) ## plots variables
# do inference
fi <- fuzzy_inference(system, list(service = 3, food = 8.123))
# plot resulting fuzzy set
plot(fi)
# defuzzify
print(gset_defuzzify(fi, "centroid"))
# reset universe
sets_options("universe", NULL)
答案 0 :(得分:0)
尽管我造成了计算机的伤害,但我决定继续进行实验。下面的代码有效,但我仍然感谢更有经验的程序员的回答。
.on('input', function {
setTimeout(function(){
// heavy computation
}, 0)
})