0

I am new to python and want to rewrite my MATLAB code (i.e., the struct part) into python. Unlike a single case, this involves nested-like objects.

The code is as follows:

no_par=10;
no_var=5;
lb=[-5 -5];
ub =[5 5];

    for ii =1:no_par
       flocks.birds(ii).X =(ub-lb).*rand(1,no_var) + lb;
       flocks.birds(ii).V = zeros(1,no_var);
       flocks.birds(ii).O = zeros(1,no_var);
       flocks.birds(ii).PBEST.X =zeros(1,no_var);
       flocks.birds(ii).PBEST.O =inf;
       
       flocks.GBEST.X =zeros(1,no_var);
       flocks.GBEST.O =inf;
    end

0 Answers0