HI all,

I have been working on fuzzy logic since some time now and have been developing models using matlab fuzzy logic toolbox.
Now however I am trying to work on c# platform. The problem with me is that the no of rules i have is in hundreds and earlier when i have written smaller programs i used if-else for these things but now can u give me some idea on the algo i should follow. I was thinking in terms of saving the rules as numerical variables in form of matrix or sumthing. I dont want a code from u but give me some idea about how should i proceed.

Thanx in advance

Hitchhiker

Try using Switch Case

switch(n)  //basically like saying if n = case      
      {         
         case 1:   //so if n = 1 then
            cost += 25;
            break;                  
         case 2:   // if n = 2 then         
            cost += 25;
            goto case 1;    // do n=2 then n=1 you need a break to end the case or it will keep going on see in case 1 there is a break       
         case 3:   // is n = 3 then          
            cost += 50;
            goto case 1;         
         default:   // else         
            Console.WriteLine("Invalid selection. Please select 1, 2, or 3.");            
            break;      // stop or ENDIF
       }

or (condition)? then:else;

( x < 1 )? j = 0 : j = 1;

I am not sure what you are trying to do so this is as much as I can help you.

the exact problem which i am having is that due to the no of input variables and the no of intervals in them the no of rules are in hundreds. hence if i manually feed each rule as this one then it will be a very lengthy process and moreover debugging will be very tough. Hence I was thinking of entering rules as conditions in a matrix of numerical values. I was asking on suggestions regarding the same.

Hmm.
I have never tried this but I guess you could define a boolean array.
something like.

bool[][] Matrice = new bool[4][4] / Make a 4 by 4 Bool array
Matrice[0][1] = x < y;
Matrice[0][2] = x > y;
// etc.

//and then just

if (Matrice[0][1])
   j=5;
else
   j=10;

Hope this helps.

I guess since you added rep, this helped you, Can you mark this thread as solved so it can help other people thanks.

P.S. Appreciate the Rep.

Iam having the same problem but worse, i have tried reading so many articles on fuzzy logic but none seems to have the answers i need. iam not so good in programming as i only did an elementary course, a hinderence in my quest for suggestions. Am trying to write rules to my fuzzy system, i know what rules i should write but the problem is how to write them and if say i wrote them as how exactly can i assert them to the two inputs i ntend to use and how to retrieve them is an even bigger mystery. i have been working with greg voits creating a fuzzy based inference engine but the linked lists are too many and what is worse is that i still cannot manipulate them. does anyone have a better alternative to greg voits work? or does anyone understand the entire program and could maybe explain it better.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.