- Eliminate Console Output: By removing the "fprintf" command, you can eliminate the I/O overhead, allowing the algorithm to focus on computational task.
- Utilize Local Variables: Assigning the current 'FIS' object to a local variable before entering the inner loop can minimize the number of times the system needs to navigate through object properties.
- Batch Updates: After making all necessary updates to the local 'FIS' object, writing it back to the array in a single operation can reduce the overall number of property accesses.
Updating fuzzy rules fast
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello,
I am trying to run an evolutionary algoritm where fuzzy rules consequents are updating.
I have N=100 zero-order sugfis objects, each has 729 rules (frb_size), and 2 outputs.
The algorithm sets values in PopDec matrix of N*(2*frb_size), so that all the consequents of all the controllres should change.
Unfortunately, the "for" loops, especially the inner one is a performance killer. It is extremely slow. Εven specifying 'DisableStructuralChecks',true in sugfis() call, cannot do too much.
for n=1:obj.N
fprintf("updating %s\n",obj.nfc_pop(n).Name);
for r=1:obj.frb_size
obj.nfc_pop(n).Rules(r).Consequent=[PopDec(n,r+r-1) PopDec(n,r+r)];
end
end
I am looking for a way to initialize all the conseqents of the rules in the n-th controller using a simple assignment.
How can this be accomplished
Thank you,
Joseph
0 comentarios
Respuestas (1)
MULI
el 24 de Abr. de 2024
Editada: MULI
el 24 de Abr. de 2024
Hi Joseph,
I understand that you are looking for efficient method to initialize the consequents of fuzzy rules in your evolutionary algorithm avoiding the slow execution of nested loops.
Here are a few optimized strategies you might find helpful:
Below is the modified code incorporating these suggestions:
for n = 1:obj.N
currentFIS = nfc_pop(n);
for r = 1:obj.frb_size
currentFIS.Rules(r).Consequent = [PopDec(n, 2*r-1), PopDec(n, 2*r)];
end
nfc_pop(n) = currentFIS;
end
Hope this answers your query!
1 comentario
Ver también
Categorías
Más información sobre Fuzzy Logic in Simulink en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!