home Forums # Technical Support function in not loaded error

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #6889
    CARLOS GARZON
    Guest

    Hello:

    I have a problem on runtime error do know where to load the function

    —————————————————————————–
    import fuzzylite as fl

    #Declaring and Initializing the Fuzzy Engine
    engine = fl.Engine(
    name=”Tesis”,
    description=”Dimmer Fuzzy System which dims light based upon Light Conditions, Activity and Light Standard”
    )

    #Defining the Input Variables (Fuzzification)
    engine.input_variables = [
    fl.InputVariable(
    name=”Ambient”,
    description=””,
    enabled=True,
    minimum=0.001,
    maximum=255.000,
    lock_range=False,
    terms=[
    fl.Trapezoid(“Sensor”, 0.000, 255.000, 255.000, 255.000),
    ]
    ),
    fl.InputVariable(
    name=”Enable”,
    description=””,
    enabled=True,
    minimum=0.001,
    maximum=1.000,
    lock_range=False,
    terms=[
    fl.Rectangle(“On”, 0.500, 1.000),
    fl.Rectangle(“Off”, 0.000, 0.500),
    ]
    ),
    fl.InputVariable(
    name=”NormActivity”,
    description=””,
    enabled=True,
    minimum=7.000,
    maximum=255.000,
    lock_range=False,
    terms=[
    fl.Rectangle(“GralTV”, 7.000, 17.000),
    fl.Rectangle(“GralZones”, 58.000, 68.000),
    fl.Rectangle(“GralKitchen”, 92.000, 102.000),
    fl.Rectangle(“Bathroom”, 160.000, 170.000),
    fl.Rectangle(“FoodPrep”, 194.000, 204.000),
    fl.Rectangle(“WorkClean”, 245.000, 254.999)
    ]
    )
    ]

    #Defining the Output Variables (Defuzzification)
    engine.output_variables = [
    fl.OutputVariable(
    name=”Power”,
    description=””,
    enabled=True,
    minimum=0.000,
    maximum=255.000,
    lock_range=False,
    aggregation=fl.AlgebraicSum,
    defuzzifier=fl.SmallestOfMaximum(200),
    lock_previous=False,
    terms=[
    fl.Function(“LED2″,”le(Ambient,NormActivity)”,engine)
    ]
    )
    ]

    #Creation of Fuzzy Rule Base
    engine.rule_blocks = [
    fl.RuleBlock(
    name=”TesisRule”,
    description=””,
    enabled=True,
    conjunction=fl.AlgebraicProduct(),
    disjunction=None,
    implication=fl.Minimum(),
    activation=fl.General(),
    rules=[
    fl.Rule.create(“if Ambient is Sensor and Enable is On then Power is not LED2”,engine)
    ]
    )
    ]

    ambient = engine.input_variable(“Ambient”)
    enable = engine.input_variable(“Enable”)
    normActivity = engine.input_variable(“NormActivity”)
    power = engine.output_variable(“Power”)

    ambient.value = 7
    enable.value = 1
    normActivity.value = 250

    engine.process()

    print(“Salida en LED: “,power.value.as_integer_ratio)

    ———————————————————————-

    File “C:\Users\Direccion\Anaconda3\lib\site-packages\fuzzylite\term.py”, line 1235, in evaluate
    raise RuntimeError(f”function ‘{self.formula}’ is not loaded”)

    RuntimeError: function ‘le(Ambient,NormActivity)’ is not loaded

    #6912

    Hi,

    I am very sorry for such a late response. It was classified as spam and I had no visibility.

    The problem is that fl.Function(“LED2″,”le(Ambient,NormActivity)”,engine) does not load automatically, which is a bug. You have to load that function manually.

    
    led2 = fl.Function(“LED2″,”le(Ambient,NormActivity)”,engine)
    led2.load()
    # And then add into your controller.
    

    Cheers,

    Juan

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.