Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with unassigned input variables #6

Closed
wilsonts01 opened this issue Sep 1, 2021 · 1 comment
Closed

Problem with unassigned input variables #6

wilsonts01 opened this issue Sep 1, 2021 · 1 comment

Comments

@wilsonts01
Copy link

Hi Juan,
I am attempting to create a fuzzy model with multiple outputs but have run into a problem which it took me quite a while to find a solution to. I was unable to find this issue documented anywhere.
My model works fine in the Fuzzylite GUI which by the way I find very nice to use . When I call it from my code which accesses the C++ Fuzzylite library, the call to the output returns a nan. I finally figured out that all input variables in the model, even ones that aren't assigned to the output that is being called seem to have to be assigned a value.
I tried many different ways of locking and unlocking inputs and outputs but it seemed to make no difference. I also notice that the linear variables that I am using in my Takagi-Sugeno style output variables have terms fields in them for all variables in the model, whether they are used in that output variable or not. I found this very confusing and when you have a large number of input variables, the gui interface gets very congested.

The following code returns an error (NAN) from the call to GetOutputVal

SetInputValue("distanceToProfitStop", glvTradeData.distanceToProfitStop);

SetInputValue("recentGradient", glvTradeData.scaledRecentGrad);

calcStatus = CalcFuzzyOutput();

if (calcStatus == SUCCESS)
{
       fuzzyResult =GetOutputVal("letProfitsRunAction");
        ........
}  

The following code returns a valid number

SetInputValue("distanceToProfitStop", glvTradeData.distanceToProfitStop);

SetInputValue("recentGradient", glvTradeData.scaledRecentGrad);

SetInputValue("profitGivenBack", 0);  // This value is not used in the "letProfitsRunAction" but is required to prevent error

calcStatus = CalcFuzzyOutput();

if (calcStatus == SUCCESS)
{
     fuzzyResult =GetOutputVal("letProfitsRunAction");
      ........
} 

A cut down version of the fll file that will reproduce the problem is attached in a zip file.
Test2.zip

Regards
Tim Wilson

@jcrada
Copy link
Member

jcrada commented Sep 1, 2021

Hi Tim,

thanks for your post and for using the FuzzyLite Libraries.

You mentioned that it all works fine in the QtFuzzyLite app, which is great.

Unfortunately, it seems you may have created some wrapper around fuzzylite, which may have introduced a bug. For example, SetInputValue, CalcFuzzyOutput and GetOutputVal are not fuzzylite functions. You may want to either remove the wrapper and work directly with fuzzylite objects, or review the code of your functions. I find removing the wrapper would be the easiest option.

The QtFuzzyLite app uses the fuzzylite library so any fuzzy engine in the app will behave exactly the same as they would in the library.

I am closing this issue because I believe the bug is in the wrapper functions you created. Feel free to reopen if you remove the wrapper and still get unexpected values.

@jcrada jcrada closed this as completed Sep 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants