fastgic_0

24 Reputation

2 Badges

18 years, 176 days

MaplePrimes Activity


These are answers submitted by fastgic_0

recuitsimule:=proc(M::array) local temperature,B,choix,meilleur,travail,i,j,variationdenergie,niveauxconsecutifs,memoire,iterations; temperature:=30000; meilleur:=M; travail:=M; B:=array(0..2); iterations:=0; niveauxconsecutifs:=0; while niveauxconsecutifs<>4 do; memoire:=meilleur; while iterations<>100 do; i:=roll();j:=roll(); B[0]:=travail[0,i]; B[1]:=travail[1,i]; travail[0,i]:=travail[0,j]; travail[1,i]:=travail[1,j]; travail[0,j]:=B[0]; travail[1,j]:=B[1]; variationdenergie:=longueur(travail)-longueur(meilleur); if variationdenergie>=0 then if 10000*exp((-variationdenergie)/T)>roll() then meilleur:=travail;fi; else meilleur:=travail;fi; travail:=meilleur; iterations:=iterations+1;od; T:=9/10T; if memoire=meilleur then niveauxconsecutifs:=niveauxconsecutifs+1;fi; od; print(meilleur); end proc; i don't put it in "maple" brackets because it doesn't work very well and doesn't display the whole code... comparaison is rand(1..10000) and roll is rand (0..99), assuming that i work on an (2,100) array... longueur is an auxiliary procedure, i can't explain you what it is, because i would be forced in this case to explain the whole principle, and i suppose it's not the algorithm which is a problem. It's called simulated annealing (directly translated from French...)
roll is a procedure that creates a random integer in [0,99] I've got this kind of object : A := array(0 .. 1, 0 .. 99) And I want to use it in a procedure doing the following thing : travail:=A; I suppose the problem is triggered by the fact I want to assign an array to another one... Isn't there anything to do it without replacing each of the array's values ?
i think i got the thing actually it corresponds to a:=b ? But then, i think the problem is triggered by the fact that i have an array called A and that i write : best:=A If i can't do this, then how am i supposed to do to make my array "best" become A ??
Page 1 of 1