Bonjour chers tous.
Je suis confronté à une situation de déclaration itérative issue d'une initialisation vectorielle. Dans un premier temps je vais mettre le programme qui fonction normalement lorsque l'initialisation est un scalaire. Je voudrais que vous m'aidez à générer celui dont c'est un vecteur dont je mettrai le programme en cours d'implémentation qui ne marche pas.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42 clear clc if nargin<1, % Number of agents (or different solutions) n=10; end % list of paramters m_k=0; lp1=0.7; lp2=0.5; bg=0; w_k=0; N_IterTotal=2000; nd=2; %% Simple bounds of the search domain %bea function % [ x , y ] Lb= [-4.5, -4.5];% Lower bounds Ub= [4.5, 4.5];% Upper bounds sum =0; for t=1:1; size(Lb); % Random initial solutions %%%%%disp('agent(i,:) bp_k(i)'); for i=1:n, agent(i,:)=Lb+(Ub-Lb).*rand(size(Lb)) w_array(i,:)= agent(i,:); bp_k(i,:)= agent(i,:); disp(strcat(num2str(agent(i,:)))); end
le programme ci-dessus fonctionne bien. Vous trouverez celui qui me crée les difficultés en dessous:
Prière de me donner un coup de pouce.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42 clear clc if nargin<1, % Number of agents (or different solutions) n=10; end % list of paramters m_k=0; lp1=0.7; lp2=0.5; bg=0; w_k=0; N_IterTotal=2000; nd=2; %% Simple bounds of the search domain %bea function % [ x , y, z ] Lb=[36.5*ones(n,1),50*ones(n,1),0.73*ones(n,1)];%% Lower bounds Ub=[41.5*ones(n,1),396*ones(n,1),0.94*ones(n,1)];% Upper bounds sum =0; for t=1:1; size(Lb); % Random initial solutions %%%%%disp('agent(i,:) bp_k(i)'); for i=1:n, agent(i,:)=Lb+(Ub-Lb).*rand(size(Lb))%%%%le problème réside ici sur la déclaration de cette ligne de commande w_array(i,:)= agent(i,:); bp_k(i,:)= agent(i,:); disp(strcat(num2str(agent(i,:)))); end
Partager