Click here to Skip to main content
15,905,963 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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
Posted

1 solution

Hello Guchu,

Fuzzy logic is somewhat that... so just saying go to the left if you are too far to the right and as far as the severity to the right is, and all that without really specifying what to far exactly is.

To apply this an array would be hard instead of fuzzy I guess. You should define the too much value and some kind of rule to determine the severity.
Like in simple terms, the speed to the left is 0.1 times the distance of the defined border. The border left is at 100 and you are currently at 120 then you should move at a speed of 20 * 0.1 = 2 per (whatever) unit to the right. Re-evaluating at each step what would mean that you would go slower when coming closer to the left border. There are no solid rules except the definition of the boundaries and the rest is put into a rule to stay between those boundaries. Nothing in hard array values though because this would also mean it ain't scalable. The rule just applied could work with ants as well with elephants because the rule is relative and therefore adapts to the situation. Hopefully this gives you some idea how to create some great rules. The way to describe these are up to you and depend on the situation.

Good luck!
 
Share this answer
 
Comments
guchu 25-Jul-10 18:52pm    
dear Nijboer,

Thanks for the explanation however I have an idea of how this thing works. but for implementation you have a rule base. I have defined a rule base but due to the no of intervals in my membership functions and no of input variable I have hundreds of rule. Now for taking any decision the program goes through all the rules and then usind 'and' logic find out the fuzzy solution. this further gets defuzzified by another method. Now what I was asking was how to implement this rule database. there are a no of rules and if i keep entering each rule one by one it will take huge amount of time. this is why i was talking of the matrix approach where each state of variables in a rule can be defined by a no and outputs depend upon various combinations of inputs.
E.F. Nijboer 26-Jul-10 5:53am    
You mean that with the matrix approach you would in a way pre-process all possible values possible so it would be a lookup instead of rules processing? Based on the number of rules this would become a huge database.
What about implementing the composite pattern where you can simply add the rules and use the visitor pattern for certain intervals that occur. This way the organization of the rules is done by the composite pattern and done almost by itself when implemented correctly and the interval visitors do not need to know anything about the underlying rules because it simply visits them and letting each rule decide to act or not. The main program stays in perfect control over the intervals and just calls the top node of the composite with the right visitor on each interval. This is the most easy and controlled way I can think of.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900