- 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 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
MULI
2024-4-24
编辑:MULI
2024-4-24
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!
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Fuzzy Logic in Simulink 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!