Accelerator/Rapid Accelerator use with Fuzzy Logic Controller

5 visualizzazioni (ultimi 30 giorni)
I'm trying to use a genetic algorithm to iterate over my model, tuning the FIS parameters that i'm passing into the FLC in my Simulink model. Currently, the MATLAB code looks similar to the following:
global generic_fis;
% generic_fis = object.convertChromosome2FIS(chromosome); (edited out as not strictly accurate - replaced with following)
generic_fis = newfis('testfis');
sim(mdl);
Where generic_fis is specified as the input parameter to the Fuzzy Logic Controller block. I've also tried saving this FIS to a file, i.e. 'tunableFIS.fis', and specifying this as the input parameter to the Fuzzy Logic Controller block, but this has yielded the same result. Essentially, in Accelerator mode the model builds every time the sim() command is called. I've read through previous questions about this, which seem to indicate that any tunable parameters need to be contained within an inport to the model, but I'm not sure how to apply this to a Fuzzy Logic Controller since what i'm altering is the parameter of this block, and I'm not sure how to use a model variable to change this value as the only input available for this block is the input signal.
So to summarise, my question is: How do I stop the model re-building/initialising every time the sim() command is called in accelerator/rapid accelerator mode given that what i'm trying to update is the FIS parameter of the Fuzzy Logic Controller block?
Cheers,
Sam

Risposta accettata

Sam Dowling
Sam Dowling il 19 Set 2017
After a lengthy discussion with MathWorks Customer Support, I've found out that this isn't possible. The Fuzzy Logic Controller block rebuilds the logic when it reads the fis parameter, and so if the contents of the parameter are changed, it forces a rebuild of the simulink logic.
I haven't got a working solution yet, but from our discussions it seems like there are a number of solutions:
1) Compartmentalise the simulations, i.e. use two simulation files. This solves the issue partially in that it allows the simulation file with all the static logic to be built only once, whilst the simulation file with the FLC block still gets rebuilt everytime the fis parameter is changed. Reasonable solution in that it's easy to implement and saves a lot of time rebuilding the code.
2) Use a MATLAB Function to call a C/C++ function which handles the logic of the fuzzy logic controller. This is a bit more effort because it involves writing the functionality myself, but this shouldn't trigger a rebuild.
3) Use of an S-Function. Still exploring this but it seems like it would have similar functionality to above.

Più risposte (1)

Ning Zhang
Ning Zhang il 6 Set 2017
You can consider to use the rapid simulation, to run over a range of parameters:
https://www.mathworks.com/help/rtw/examples/using-rsim-target-for-parameter-survey.html
If you are on MATLAB R2017a, you can consider to incorporate the "parsim" with mutli-core CPUs
https://www.mathworks.com/help/simulink/examples/parallel-simulations-using-parsim-parameter-sweep-in-rapid-accelerator-mode.html
  1 Commento
Sam Dowling
Sam Dowling il 7 Set 2017
Thanks for the reply Ning. I've been through the tutorial you linked, but unfortunately I run into errors when trying to make this FIS a tunable parameter. Presumably this is due to the way an fis is structured in MATLAB (Assume this has been created using MATLABs newfis() function):
gen_fis =
struct with fields:
name: 'genetic_fis'
type: 'mamdani'
andMethod: 'min'
orMethod: 'max'
defuzzMethod: 'centroid'
impMethod: 'min'
aggMethod: 'max'
input: [1×2 struct]
output: [1×1 struct]
rule: [1×9 struct]
reading from https://au.mathworks.com/help/simulink/ug/using-structure-parameters.html:
"The value of a field that you use to set a block parameter must be numeric or of an enumerated type. The value of a field can be a real or complex scalar, vector, or multidimensional array."
Now, the error in turning a FIS into a tunable block parameter using this method is obvious: some values associated with fields in the struct are strings, and are therefore not compatible. I'm a bit stuck in terms of how I can possibly get around this. Do you have any suggestions?

Accedi per commentare.

Categorie

Scopri di più su Fuzzy Logic in Simulink in Help Center e File Exchange

Prodotti

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by