Closed Scarf195 closed 2 years ago
Hi, that's quite an interesting way of calling/assigning Sets and Domains! If I may ask, what kind of application are you working at or is this purely academic? Regarding your problem, two things come to my mind: the way you write those rules, you explicitly write or
between tuples, which python will always evaluate to True, so that's probably one issue. The other thing is, fuzzylogic Rules reduce insignificant weights to None instead of working with zeros to be able to entirely ignore irrelevant stuff, optimizing performance a little. I hope that helps.
I guess Rules should be type-checked to avoid this kind of issue.. note to self
I'm working with Autonomous Underwater Vehicles and I would like to implement a Fuzzy PID Controller for vehicle heading control. Yes, the way in which I explicit rules is wrong, however I've made this to avoid expliciting rules one by one (some lead to the same result in terms of membership).
I'm working with Autonomous Underwater Vehicles and I would like to implement a Fuzzy PID Controller for vehicle heading control. Yes, the way in which I explicit rules is wrong, however I've made this to avoid expliciting rules one by one (some lead to the same result in terms of membership).
That's awesome! I don't work with fuzzy rules much myself, only implemented them by request of a guy who worked on industrial climate control and fleshed it out some for a lady who was using it in her master's thesis.. I'd love to help you out with a better way of defining complex rules, but currently I'm restricted to snail internet via mobile phone. If you have any suggestions on how to improve that or maybe a pull request, I'll take it.
Hi @amogorkon, thank you very much for your interesting. It could be very useful implementing complex rules definition, maybe in matrix form for example
Hi @amogorkon, thank you very much for your interesting. It could be very useful implementing complex rules definition, maybe in matrix form for example
When you say matrix form, I'm thinking numpy or pandas, could there be a possible solution?
Okay, I experimented a little and found that numpy arrays of Sets could work for this as a possible solution. Since Set functions are closures, it won't be possible to serialize them as-is, but with a proper __repr__
it might be feasible to work around that limitation.
Ahh, I have an idea! Since proper serialization won't work anyway and I have to make __repr__
work, the round-trip will require calling eval() on each cell, it would be required to have a function anyway that could take a numpy array of str - THAT on the other hand would make it possible to take a pandas dataframe of str and since pandas has no problem with loading from Excel, you could basically prepare the whole table of functions in excel, load that in via pandas, eval and turn the table into Rules.. sounds probably more convoluted than it is. Question is whether Excel actually works well with inputting those function names. There are well known issues with data conversion and broken name completion with Excel.. also, IDEs can't help with sanity checks, name completion/typo checking..on the other hand, if you already have your whole logic worked out that way, there's less chance to typo between.. question is what is your tool of choice to work on that table of logic?
Well, it doesn't have to be excel, but pandas could interface with any table input, so that'd be a plus. Only drawback is that the functions are in str repr for the input, but that's a given.
I found a way to actually serialize those closures. The dill
package seems to be able to do it, but I'm not sure if it would actually help us..
Experimenting with table-rules, I'm wondering how you would want to specify rules that depend on more than two variables?
I figured out how to write a table as text like you posted initially and make it work with Rules, but it's still some way off to get it in the code. Need to write tests and make sure everything works as it should.
I got it all working rather nicely, but I can only upload it by next week (no internet on my PC).
You will be able to write a table just like you posted initially as input.
Finally got internet back again. Tested and pushed to release 1.2.0. Check https://github.com/amogorkon/fuzzylogic/blob/master/docs/Showcase.ipynb on the bottom for an example.
Hi, I'm using fuzzylogic library to implement a Fuzzy Logic Controller. I've started implementing a P Controller with this rule attached:
I'm getting issue during the execution, in fact by setting the error values and error speed the result is almost always "None". Probably I’m setting the rules wrong but I can't figure it out...
Entire script:
Returning this output:
None