home Forums Feature Requests Add Center of Gravity Defuzzification Method

This topic contains 4 replies, has 2 voices, and was last updated by Juan Rada-Vilela Juan Rada-Vilela 1 year, 9 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #2578
    aaron.geier
    aaron.geier
    Participant

    Would it be possible to add a new defuzzification method? National Instruments has a Center of Area or Center of Gravity defuzzification method that is extremely useful. We would like to port the fuzzy controller we’ve implemented in National Instruments to FuzzyLite; however, we are unable to do so because we are using the Center of Area/Center of Gravity defuzzification method, which is unsupported by FuzzyLite.

    The following is a description of how that is implemented by National Instruments.

    http://zone.ni.com/reference/en-XX/help/370401H-01/lvpidmain/center_of_area/

    #2579
    Juan Rada-Vilela
    Juan Rada-Vilela
    Keymaster

    Hi,

    thank you for your question.

    There seems to be some differences in the names used by the different players in fuzzy logic control, but the differences are only in the names. The centre of area or gravity that you are asking for is the Centroid in fuzzylite (and also in matlab). In jfuzzylogic, they make a difference between centre of area and centre of gravity, where the centre of area refers to the Bisector (in fuzzylite and matlab), and the centre of gravity refers to the Centroid (in fuzzylite and matlab).

    Let me know if this answers your question.

    Cheers

    #2582
    aaron.geier
    aaron.geier
    Participant

    Hello,

    Thanks for your explanation. There appears to be something different about what National Instruments is doing, and what everyone else does 🙂 At the end of this post I’ve listed a block of FLL “code” that I’m using. I’ve also linked images to what National Instruments GUI shows.

    When I set the “TestInputVar” to a value of 160, National Instruments says the output variable “TestOutputVar” is 100. When I load the FLL block into FuzzyLiteQt, and set the input value to 160, it says that the output variable “TestOutputVar” is 50. So I’m trying to determine what the difference is and how to overcome that.

    In my example, the output variable ranches from 0 to 100 where 0 would represent 0% of something and 100 would represent 100% of something (perhaps a duty cycle). The input variable ranges from 0-550.

    Engine: TestController
    InputVariable: TestInputVar
    enabled: true
    range: 0.000 549.999
    lock-range: false
    term: AtSetpoint PiShape 298.000 299.000 301.00 302.00
    term: VeryLow Trapezoid 0.000 0.000 260.000 300.00
    term: VeryHigh Trapezoid 300.000 305.000 550.000 550.00
    term: Low PiShape 260.000 300.000 300.000 300.00
    term: High PiShape 300.000 300.000 300.000 305.00
    OutputVariable: TestOutputVar
    enabled: true
    range: 0.000 100.000
    lock-range: false
    aggregation: Maximum
    defuzzifier: Centroid 100
    default: nan
    lock-previous: false
    term: Full Constant 100.000
    term: Medium PiShape 10.000 15.000 30.000 35.000
    term: Off Constant 0.000
    term: High PiShape 15.000 20.000 40.000 45.000
    term: Low PiShape 0.000 5.000 25.000 30.000
    RuleBlock: mamdani
    enabled: true
    conjunction: Minimum
    disjunction: Maximum
    implication: Minimum
    activation: General
    rule: if TestInputVar is AtSetpoint then TestOutputVar is Medium
    rule: if TestInputVar is VeryLow then TestOutputVar is Full
    rule: if TestInputVar is VeryHigh then TestOutputVar is Off
    rule: if TestInputVar is Low then TestOutputVar is High
    rule: if TestInputVar is High then TestOutputVar is Low

    Screenshot 1 of NI Fuzzy Logic Controller:
    NI Screenshot 1

    Screenshot 2 of NI Fuzzy Logic Controller:
    NI Screenshot 2

    Screenshot 3 of NI Fuzzy Logic Controller:
    [url=https://flic.kr/p/XuYQ8z]Screenshot3[/url]

    #2583
    aaron.geier
    aaron.geier
    Participant

    Hello,

    Thanks for your explanation. There appears to be something different about what National Instruments is doing, and what everyone else does 🙂 At the end of this post I’ve listed a block of FLL “code” that I’m using. I’ve also linked images to what National Instruments GUI shows.

    When I set the “TestInputVar” to a value of 160, National Instruments says the output variable “TestOutputVar” is 100. When I load the FLL block into FuzzyLiteQt, and set the input value to 160, it says that the output variable “TestOutputVar” is 50. So I’m trying to determine what the difference is and how to overcome that.

    In my example, the output variable ranches from 0 to 100 where 0 would represent 0% of something and 100 would represent 100% of something (perhaps a duty cycle). The input variable ranges from 0-550.

    Engine: TestController
    InputVariable: TestInputVar
    enabled: true
    range: 0.000 549.999
    lock-range: false
    term: AtSetpoint PiShape 298.000 299.000 301.00 302.00
    term: VeryLow Trapezoid 0.000 0.000 260.000 300.00
    term: VeryHigh Trapezoid 300.000 305.000 550.000 550.00
    term: Low PiShape 260.000 300.000 300.000 300.00
    term: High PiShape 300.000 300.000 300.000 305.00
    OutputVariable: TestOutputVar
    enabled: true
    range: 0.000 100.000
    lock-range: false
    aggregation: Maximum
    defuzzifier: Centroid 100
    default: nan
    lock-previous: false
    term: Full Constant 100.000
    term: Medium PiShape 10.000 15.000 30.000 35.000
    term: Off Constant 0.000
    term: High PiShape 15.000 20.000 40.000 45.000
    term: Low PiShape 0.000 5.000 25.000 30.000
    RuleBlock: mamdani
    enabled: true
    conjunction: Minimum
    disjunction: Maximum
    implication: Minimum
    activation: General
    rule: if TestInputVar is AtSetpoint then TestOutputVar is Medium
    rule: if TestInputVar is VeryLow then TestOutputVar is Full
    rule: if TestInputVar is VeryHigh then TestOutputVar is Off
    rule: if TestInputVar is Low then TestOutputVar is High
    rule: if TestInputVar is High then TestOutputVar is Low

    Screenshot 1 of NI Fuzzy Logic Controller:
    NI Screenshot1

    Screenshot 2 of NI Fuzzy Logic Controller:
    NI Screenshot2

    Screenshot 3 of NI Fuzzy Logic Controller:
    NI Screenshot2

    #2604
    Juan Rada-Vilela
    Juan Rada-Vilela
    Keymaster

    Hi Aaron,

    I am sorry that your posts were marked as spam by wordpress, and hence not shown. Thank you for emailing me.

    For completeness, I will elaborate on your issue.

    The problem in your controller is the usage of Constant terms in the output variable for Off and Full. The centroid defuzzifier integrates over the terms in the output variable, and the integration over the constant terms is just not supported by this defuzzifier. The people from National must be doing some very specific handling of this case of integration over.

    The solution I proposed to you (see at the end of post) substitutes the constant terms by integrative Triangle terms at the locations where you want them (0 and 100), which makes me extend the range of the output variable a bit more to integrate over the terms. In addition, I have increased the resolution of the defuzzifier for better accuracy.

    Personally, I do not like my solution much. In the short term, I would avoid using the Engine::process() method to process the engine, and do it manually instead. You can look at the logic inside this method, and add the exceptions to turn the engine off and full if the corresponding memberships are activated.

    In the long term, I want to improve the fuzzy consequents to override defuzzification. For example, if x is a then z is 0.9.

    Lastly, I am sorry I did not see your messages being marked as spam. I would have elaborated on your case then.

    Kindly let me know if this is of any help, or if you found a better solution.

    Cheers.

    
    Engine: TestController
    InputVariable: TestInputVar
      enabled: true
      range: 0.000 549.999
      lock-range: false
      term: AtSetpoint PiShape 298.000 299.000 301.000 302.000
      term: VeryLow Trapezoid 0.000 0.000 260.000 300.000
      term: VeryHigh Trapezoid 300.000 305.000 550.000 550.000
      term: Low PiShape 260.000 300.000 300.000 300.000
      term: High PiShape 300.000 300.000 300.000 305.000
    OutputVariable: TestOutputVar
      enabled: true
      range: -5.000 105.000
      lock-range: false
      aggregation: Maximum
      defuzzifier: Centroid 1000
      default: nan
      lock-previous: false
      term: Off Triangle -1.000 0.000 1.000
      term: Low PiShape 0.000 5.000 25.000 30.000
      term: Medium PiShape 10.000 15.000 30.000 35.000
      term: High PiShape 15.000 20.000 40.000 45.000
      term: Full Triangle 99.000 100.000 101.000
    RuleBlock: mamdani
      enabled: true
      conjunction: Minimum
      disjunction: Maximum
      implication: Minimum
      activation: General
      rule: if TestInputVar is AtSetpoint then TestOutputVar is Medium
      rule: if TestInputVar is VeryLow then TestOutputVar is Full
      rule: if TestInputVar is VeryHigh then TestOutputVar is Off
      rule: if TestInputVar is Low then TestOutputVar is High
      rule: if TestInputVar is High then TestOutputVar is Low
    
Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.