I am trying to create a fuzzy system in R using the "sets" packages. In my model, I have three types of fuzzy sets with three states each and with different โuniversesโ. When I draw the system, I have no problem, but when I try to draw a conclusion, I get this error: "Error in gset_charfun (x): The argument" x "must be a generic set." Does anyone have a solution to this problem ?. Here is the code.
library(sets)
U1 <- seq(from = 0, to = 1, by = 0.0001)
U2 <- seq(from = -0.5, to = 0.5, by = 0.001)
variables <- set(produccion = fuzzy_variable(
bajo = fuzzy_trapezoid_gset(corners = c(-2, 0, 0.3, 0.6),universe=U1),
normal = fuzzy_trapezoid_gset(corners = c(0.4, 0.55, 0.55, 0.7), universe=U1),
alto = fuzzy_trapezoid_gset(corners = c(0.5, 0.7, 1, -2), universe=U1)),
tendencia = fuzzy_variable(bajo = fuzzy_trapezoid_gset(corners = c(-10, -0.4, -0.05, 0.1),universe=U2),
normal = fuzzy_triangular_gset(corners = c(-0.067, 0.067, 0.2), universe=U2),
alto = fuzzy_trapezoid_gset(corners = c(0.1, 0.15, 0.15, -10), universe=U2) ) ,
zona = fuzzy_variable(roja = fuzzy_triangular_gset(corners = c(-2, 0, 0.33), universe=U1),
amarilla = fuzzy_triangular_gset(corners = c(0.33, 0.5, 0.66),universe=U1),
verde = fuzzy_triangular_gset(corners = c(0.66, 1, 2), universe=U1))
)
reglas <-
set(
fuzzy_rule(produccion %is% alta || tendencia %is% alta, zona %is% verde),
fuzzy_rule(produccion %is% alta || tendencia %is% baja, zona %is% amarilla),
fuzzy_rule(produccion %is% media|| tendencia %is% baja, zona %is% roja),
fuzzy_rule(produccion %is% baja || tendencia %is% alta, zona %is% verde),
fuzzy_rule(produccion %is% baja || tendencia %is% baj, zona %is% roja)
)
system <- fuzzy_system(variables, reglas)
print(system)
plot(system)
inferencia <- fuzzy_inference(system, list(produccion = 0.6, tendencia = 0.2))