導航:首頁 > 源碼編譯 > mua演算法

mua演算法

發布時間:2023-01-02 00:27:40

Ⅰ 運行遺基於遺傳演算法的BP神經網路MATLAB代碼程序時總是出錯!!!

這個問題也困擾了我好久,終於解決了。給你個ga.m程序,新建m文件復制進去,再運行程序試試。
%ga.m
function [x,endPop,bPop,traceInfo] = ga(bounds,evalFN,evalOps,startPop,opts,...
termFN,termOps,selectFN,selectOps,xOverFNs,xOverOps,mutFNs,mutOps)
% GA run a genetic algorithm
% function [x,endPop,bPop,traceInfo]=ga(bounds,evalFN,evalOps,startPop,opts,
% termFN,termOps,selectFN,selectOps,
% xOverFNs,xOverOps,mutFNs,mutOps)
%
% Output Arguments:
% x - the best solution found ring the course of the run
% endPop - the final population
% bPop - a trace of the best population
% traceInfo - a matrix of best and means of the ga for each generation
%
% Input Arguments:
% bounds - a matrix of upper and lower bounds on the variables
% evalFN - the name of the evaluation .m function
% evalOps - options to pass to the evaluation function ([NULL])
% startPop - a matrix of solutions that can be initialized
% from initialize.m
% opts - [epsilon prob_ops display] change required to consider two
% solutions different, prob_ops 0 if you want to apply the
% genetic operators probabilisticly to each solution, 1 if
% you are supplying a deterministic number of operator
% applications and display is 1 to output progress 0 for
% quiet. ([1e-6 1 0])
% termFN - name of the .m termination function (['maxGenTerm'])
% termOps - options string to be passed to the termination function
% ([100]).
% selectFN - name of the .m selection function (['normGeomSelect'])
% selectOpts - options string to be passed to select after
% select(pop,#,opts) ([0.08])
% xOverFNS - a string containing blank seperated names of Xover.m
% files (['arithXover heuristicXover simpleXover'])
% xOverOps - A matrix of options to pass to Xover.m files with the
% first column being the number of that xOver to perform
% similiarly for mutation ([2 0;2 3;2 0])
% mutFNs - a string containing blank seperated names of mutation.m
% files (['boundaryMutation multiNonUnifMutation ...
% nonUnifMutation unifMutation'])
% mutOps - A matrix of options to pass to Xover.m files with the
% first column being the number of that xOver to perform
% similiarly for mutation ([4 0 0;6 100 3;4 100 3;4 0 0])

% Binary and Real-Valued Simulation Evolution for Matlab
% Copyright (C) 1996 C.R. Houck, J.A. Joines, M.G. Kay
%
% C.R. Houck, J.Joines, and M.Kay. A genetic algorithm for function
% optimization: A Matlab implementation. ACM Transactions on Mathmatical
% Software, Submitted 1996.
%
% This program is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation; either version 1, or (at your option)
% any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details. A of the GNU
% General Public License can be obtained from the
% Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

%%$Log: ga.m,v $
%Revision 1.10 1996/02/02 15:03:00 jjoine
% Fixed the ordering of imput arguments in the comments to match
% the actual order in the ga function.
%
%Revision 1.9 1995/08/28 20:01:07 chouck
% Updated initialization parameters, updated mutation parameters to reflect
% b being the third option to the nonuniform mutations
%
%Revision 1.8 1995/08/10 12:59:49 jjoine
%Started Logfile to keep track of revisions
%

n=nargin;
if n<2 | n==6 | n==10 | n==12
disp('Insufficient arguements')
end
if n<3 %Default evalation opts.
evalOps=[];
end
if n<5
opts = [1e-6 1 0];
end
if isempty(opts)
opts = [1e-6 1 0];
end

if any(evalFN<48) %Not using a .m file
if opts(2)==1 %Float ga
e1str=['x=c1; c1(xZomeLength)=', evalFN ';'];
e2str=['x=c2; c2(xZomeLength)=', evalFN ';'];
else %Binary ga
e1str=['x=b2f(endPop(j,:),bounds,bits); endPop(j,xZomeLength)=',...
evalFN ';'];
end
else %Are using a .m file
if opts(2)==1 %Float ga
e1str=['[c1 c1(xZomeLength)]=' evalFN '(c1,[gen evalOps]);'];
e2str=['[c2 c2(xZomeLength)]=' evalFN '(c2,[gen evalOps]);'];
else %Binary ga
e1str=['x=b2f(endPop(j,:),bounds,bits);[x v]=' evalFN ...
'(x,[gen evalOps]); endPop(j,:)=[f2b(x,bounds,bits) v];'];
end
end

if n<6 %Default termination information
termOps=[100];
termFN='maxGenTerm';
end
if n<12 %Default muatation information
if opts(2)==1 %Float GA
mutFNs=['boundaryMutation multiNonUnifMutation nonUnifMutation unifMutation'];
mutOps=[4 0 0;6 termOps(1) 3;4 termOps(1) 3;4 0 0];
else %Binary GA
mutFNs=['binaryMutation'];
mutOps=[0.05];
end
end
if n<10 %Default crossover information
if opts(2)==1 %Float GA
xOverFNs=['arithXover heuristicXover simpleXover'];
xOverOps=[2 0;2 3;2 0];
else %Binary GA
xOverFNs=['simpleXover'];
xOverOps=[0.6];
end
end
if n<9 %Default select opts only i.e. roullete wheel.
selectOps=[];
end
if n<8 %Default select info
selectFN=['normGeomSelect'];
selectOps=[0.08];
end
if n<6 %Default termination information
termOps=[100];
termFN='maxGenTerm';
end
if n<4 %No starting population passed given
startPop=[];
end
if isempty(startPop) %Generate a population at random
%startPop=zeros(80,size(bounds,1)+1);
startPop=initializega(80,bounds,evalFN,evalOps,opts(1:2));
end

if opts(2)==0 %binary
bits=calcbits(bounds,opts(1));
end

xOverFNs=parse(xOverFNs);
mutFNs=parse(mutFNs);

xZomeLength = size(startPop,2); %Length of the xzome=numVars+fittness
numVar = xZomeLength-1; %Number of variables
popSize = size(startPop,1); %Number of indivials in the pop
endPop = zeros(popSize,xZomeLength); %A secondary population matrix
c1 = zeros(1,xZomeLength); %An indivial
c2 = zeros(1,xZomeLength); %An indivial
numXOvers = size(xOverFNs,1); %Number of Crossover operators
numMuts = size(mutFNs,1); %Number of Mutation operators
epsilon = opts(1); %Threshold for two fittness to differ
oval = max(startPop(:,xZomeLength)); %Best value in start pop
bFoundIn = 1; %Number of times best has changed
done = 0; %Done with simulated evolution
gen = 1; %Current Generation Number
collectTrace = (nargout>3); %Should we collect info every gen
floatGA = opts(2)==1; %Probabilistic application of ops
display = opts(3); %Display progress

while(~done)
%Elitist Model
[bval,bindx] = max(startPop(:,xZomeLength)); %Best of current pop
best = startPop(bindx,:);

if collectTrace
traceInfo(gen,1)=gen; %current generation
traceInfo(gen,2)=startPop(bindx,xZomeLength); %Best fittness
traceInfo(gen,3)=mean(startPop(:,xZomeLength)); %Avg fittness
traceInfo(gen,4)=std(startPop(:,xZomeLength));
end

if ( (abs(bval - oval)>epsilon) | (gen==1)) %If we have a new best sol
if display
fprintf(1,'\n%d %f\n',gen,bval); %Update the display
end
if floatGA
bPop(bFoundIn,:)=[gen startPop(bindx,:)]; %Update bPop Matrix
else
bPop(bFoundIn,:)=[gen b2f(startPop(bindx,1:numVar),bounds,bits)...
startPop(bindx,xZomeLength)];
end
bFoundIn=bFoundIn+1; %Update number of changes
oval=bval; %Update the best val
else
if display
fprintf(1,'%d ',gen); %Otherwise just update num gen
end
end

endPop = feval(selectFN,startPop,[gen selectOps]); %Select

if floatGA %Running with the model where the parameters are numbers of ops
for i=1:numXOvers,
for j=1:xOverOps(i,1),
a = round(rand*(popSize-1)+1); %Pick a parent
b = round(rand*(popSize-1)+1); %Pick another parent
xN=deblank(xOverFNs(i,:)); %Get the name of crossover function
[c1 c2] = feval(xN,endPop(a,:),endPop(b,:),bounds,[gen xOverOps(i,:)]);

if c1(1:numVar)==endPop(a,(1:numVar)) %Make sure we created a new
c1(xZomeLength)=endPop(a,xZomeLength); %solution before evaluating
elseif c1(1:numVar)==endPop(b,(1:numVar))
c1(xZomeLength)=endPop(b,xZomeLength);
else
%[c1(xZomeLength) c1] = feval(evalFN,c1,[gen evalOps]);
eval(e1str);
end
if c2(1:numVar)==endPop(a,(1:numVar))
c2(xZomeLength)=endPop(a,xZomeLength);
elseif c2(1:numVar)==endPop(b,(1:numVar))
c2(xZomeLength)=endPop(b,xZomeLength);
else
%[c2(xZomeLength) c2] = feval(evalFN,c2,[gen evalOps]);
eval(e2str);
end

endPop(a,:)=c1;
endPop(b,:)=c2;
end
end

for i=1:numMuts,
for j=1:mutOps(i,1),
a = round(rand*(popSize-1)+1);
c1 = feval(deblank(mutFNs(i,:)),endPop(a,:),bounds,[gen mutOps(i,:)]);
if c1(1:numVar)==endPop(a,(1:numVar))
c1(xZomeLength)=endPop(a,xZomeLength);
else
%[c1(xZomeLength) c1] = feval(evalFN,c1,[gen evalOps]);
eval(e1str);
end
endPop(a,:)=c1;
end
end

else %We are running a probabilistic model of genetic operators
for i=1:numXOvers,
xN=deblank(xOverFNs(i,:)); %Get the name of crossover function
cp=find(rand(popSize,1)<xOverOps(i,1)==1);
if rem(size(cp,1),2) cp=cp(1:(size(cp,1)-1)); end
cp=reshape(cp,size(cp,1)/2,2);
for j=1:size(cp,1)
a=cp(j,1); b=cp(j,2);
[endPop(a,:) endPop(b,:)] = feval(xN,endPop(a,:),endPop(b,:),...
bounds,[gen xOverOps(i,:)]);
end
end
for i=1:numMuts
mN=deblank(mutFNs(i,:));
for j=1:popSize
endPop(j,:) = feval(mN,endPop(j,:),bounds,[gen mutOps(i,:)]);
eval(e1str);
end
end
end

gen=gen+1;
done=feval(termFN,[gen termOps],bPop,endPop); %See if the ga is done
startPop=endPop; %Swap the populations

[bval,bindx] = min(startPop(:,xZomeLength)); %Keep the best solution
startPop(bindx,:) = best; %replace it with the worst
end

[bval,bindx] = max(startPop(:,xZomeLength));
if display
fprintf(1,'\n%d %f\n',gen,bval);
end

x=startPop(bindx,:);
if opts(2)==0 %binary
x=b2f(x,bounds,bits);
bPop(bFoundIn,:)=[gen b2f(startPop(bindx,1:numVar),bounds,bits)...
startPop(bindx,xZomeLength)];
else
bPop(bFoundIn,:)=[gen startPop(bindx,:)];
end

if collectTrace
traceInfo(gen,1)=gen; %current generation
traceInfo(gen,2)=startPop(bindx,xZomeLength); %Best fittness
traceInfo(gen,3)=mean(startPop(:,xZomeLength)); %Avg fittness
end

Ⅱ 求C代碼:遺傳演算法求函數最大值f(x)=xsin(10Pix)+1.0

%輸出參數:x:求的最優解
% endpop:最終的種群
% bpop:最優種群的一個搜索軌跡
% 輸出參數:
% bounds:代表變數的上下界的矩陣
% eevalFN:適應度函數
% startPop:初始群體
% termFN:終止函數的名字
% termOps: 終止函數的參數
% selectFN:選擇函數的名稱
% selectOpts:選擇參數。
function [x,endPop,bPop,traceInfo] = ga(bounds,eevalFN,eevalOps,startPop,opts,...
termFN,termOps,selectFN,selectOps,xOverFNs,xOverOps,mutFNs,mutOps)

n=nargin;
if n<2 | n==6 | n==10 | n==12
disp('Insufficient arguements')
end
if n<3 %Default eevalation opts.
eevalOps=[];
end
if n<5
opts = [1e-6 1 0];
end
if isempty(opts)
opts = [1e-6 1 0];
end

if any(eevalFN<48) %Not using a .m file
if opts(2)==1 %Float ga
e1str=['x=c1; c1(xZomeLength)=', eevalFN ';'];
e2str=['x=c2; c2(xZomeLength)=', eevalFN ';'];
else %Binary ga
e1str=['x=b2f(endPop(j,:),bounds,bits); endPop(j,xZomeLength)=',...
eevalFN ';'];
end
else %Are using a .m file
if opts(2)==1 %Float ga
e1str=['[c1 c1(xZomeLength)]=' eevalFN '(c1,[gen eevalOps]);'];
e2str=['[c2 c2(xZomeLength)]=' eevalFN '(c2,[gen eevalOps]);'];
else %Binary ga
e1str=['x=b2f(endPop(j,:),bounds,bits);[x v]=' eevalFN ...
'(x,[gen eevalOps]); endPop(j,:)=[f2b(x,bounds,bits) v];'];
end
end

if n<6 %Default termination information
termOps=[100];
termFN='maxGenTerm';
end
if n<12 %Default muatation information
if opts(2)==1 %Float GA
mutFNs=['boundaryMutation multiNonUnifMutation nonUnifMutation unifMutation'];
mutOps=[4 0 0;6 termOps(1) 3;4 termOps(1) 3;4 0 0];
else %Binary GA
mutFNs=['binaryMutation'];
mutOps=[0.05];
end
end
if n<10 %默認的交叉信息
if opts(2)==1 %浮點編碼
xOverFNs=['arithXover heuristicXover simpleXover'];
xOverOps=[2 0;2 3;2 0];
else %Binary GA
xOverFNs=['simpleXover'];
xOverOps=[0.6];
end
end
if n<9 %Default select opts only i.e. roullete wheel.
selectOps=[];
end
if n<8 %Default select info
selectFN=['normGeomSelect'];
selectOps=[0.08];
end
if n<6 %默認的演算法終止准則
termOps=[100];
termFN='maxGenTerm';
end
if n<4 %初始種群為空
startPop=[];
end
if isempty(startPop) %隨機生成初始種群
startPop=initializega(80,bounds,eevalFN,eevalOps,opts(1:2));
end

if opts(2)==0 %二進制編碼
bits=calcbits(bounds,opts(1));
end

xOverFNs=parse(xOverFNs);
mutFNs=parse(mutFNs);

xZomeLength = size(startPop,2); %Length of the xzome=numVars+fittness
numVar = xZomeLength-1; %變數數目
popSize = size(startPop,1); %種群中個體數目
endPop = zeros(popSize,xZomeLength); %次種群矩陣
c1 = zeros(1,xZomeLength); %個體
c2 = zeros(1,xZomeLength); %個體
numXOvers = size(xOverFNs,1); %交叉操作次數
numMuts = size(mutFNs,1); %變異操作次數
epsilon = opts(1); %適應度門限值
oeval = max(startPop(:,xZomeLength)); %初始種群中的最優值
bFoundIn = 1;
done = 0;
gen = 1;
collectTrace = (nargout>3);
floatGA = opts(2)==1;
display = opts(3);

while(~done)
[beval,bindx] = max(startPop(:,xZomeLength)); %當前種群的最優值
best = startPop(bindx,:);

if collectTrace
traceInfo(gen,1)=gen; %當前代
traceInfo(gen,2)=startPop(bindx,xZomeLength); %最優適應度
traceInfo(gen,3)=mean(startPop(:,xZomeLength)); %平均適應度
traceInfo(gen,4)=std(startPop(:,xZomeLength));
end

if ( (abs(beval - oeval)>epsilon) | (gen==1))
if display
fprintf(1,'\n%d %f\n',gen,beval);
end
if floatGA
bPop(bFoundIn,:)=[gen startPop(bindx,:)];
else
bPop(bFoundIn,:)=[gen b2f(startPop(bindx,1:numVar),bounds,bits)...
startPop(bindx,xZomeLength)];
end
bFoundIn=bFoundIn+1;
oeval=beval;
else
if display
fprintf(1,'%d ',gen);
end
end

endPop = feeval(selectFN,startPop,[gen selectOps]); %選擇操作

if floatGA
for i=1:numXOvers,
for j=1:xOverOps(i,1),
a = round(rand*(popSize-1)+1); %一個父代個體
b = round(rand*(popSize-1)+1); %另一個父代個體
xN=deblank(xOverFNs(i,:)); %交叉函數
[c1 c2] = feeval(xN,endPop(a,:),endPop(b,:),bounds,[gen… xOverOps(i,:)]);

if c1(1:numVar)==endPop(a,(1:numVar))
c1(xZomeLength)=endPop(a,xZomeLength);
elseif c1(1:numVar)==endPop(b,(1:numVar))
c1(xZomeLength)=endPop(b,xZomeLength);
else
eeval(e1str);
end
if c2(1:numVar)==endPop(a,(1:numVar))
c2(xZomeLength)=endPop(a,xZomeLength);
elseif c2(1:numVar)==endPop(b,(1:numVar))
c2(xZomeLength)=endPop(b,xZomeLength);
else
eeval(e2str);
end

endPop(a,:)=c1;
endPop(b,:)=c2;
end
end

for i=1:numMuts,
for j=1:mutOps(i,1),
a = round(rand*(popSize-1)+1);
c1 = feeval(deblank(mutFNs(i,:)),endPop(a,:),bounds,[gen mutOps(i,:)]);
if c1(1:numVar)==endPop(a,(1:numVar))
c1(xZomeLength)=endPop(a,xZomeLength);
else
eeval(e1str);
end
endPop(a,:)=c1;
end
end

else %遺傳操作的統計模型
for i=1:numXOvers,
xN=deblank(xOverFNs(i,:));
cp=find(rand(popSize,1)<xOverOps(i,1)==1);
if rem(size(cp,1),2) cp=cp(1:(size(cp,1)-1)); end
cp=reshape(cp,size(cp,1)/2,2);
for j=1:size(cp,1)
a=cp(j,1); b=cp(j,2);
[endPop(a,:) endPop(b,:)] = feeval(xN,endPop(a,:),endPop(b,:), bounds,[gen xOverOps(i,:)]);
end
end
for i=1:numMuts
mN=deblank(mutFNs(i,:));
for j=1:popSize
endPop(j,:) = feeval(mN,endPop(j,:),bounds,[gen mutOps(i,:)]);
eeval(e1str);
end
end
end

gen=gen+1;
done=feeval(termFN,[gen termOps],bPop,endPop); %
startPop=endPop; %更新種群

[beval,bindx] = min(startPop(:,xZomeLength));
startPop(bindx,:) = best;
end

[beval,bindx] = max(startPop(:,xZomeLength));
if display
fprintf(1,'\n%d %f\n',gen,beval);
end

x=startPop(bindx,:);
if opts(2)==0 %binary
x=b2f(x,bounds,bits);
bPop(bFoundIn,:)=[gen b2f(startPop(bindx,1:numVar),bounds,bits), startPop(bindx,xZomeLength)];
else
bPop(bFoundIn,:)=[gen startPop(bindx,:)];
end
if collectTrace
traceInfo(gen,1)=gen;
traceInfo(gen,2)=startPop(bindx,xZomeLength); %Best fittness
traceInfo(gen,3)=mean(startPop(:,xZomeLength)); %Avg fittness
end

Ⅲ Lua,Mua什麼意思

Lua最著名的應用是在暴雪公司的網路游戲WOW中。 Lua腳本可以很容易的被C/C++代碼調用.nif是NTFS格式.
MUA
KISS的擬聲詞
也就是親臉蛋的聲音 網路新流行起的語言
呵呵

Ⅳ 你輕輕一個吻,我瘋狂體會是什麼歌

這首歌是蔡徐坤的《情人》,具體如下:

眼色是幻覺,泳池邊你的身影勾成線

溫熱蔓延,多少個午夜,肆無忌憚,醉夢酣歡

無意追逐,無法止步,熱度包圍了我

All I wanna do is fool around

(我想做的就是四處游盪)

我的心在小鹿亂撞,從日落到清晨的月光

抱你到天亮,你輕輕一個吻,我瘋狂體會

氣氛開始升溫,危險又迷人

I really wanna dance tonight,Feel a little bit dangerous

(今晚我真的很想跳舞,感覺有點危險)

少了些安全感,做我的情人,I know you want it

(我知道你想要這個)

掉落人間,你像丘比特賜予我的首選,靠在枕邊

ah,光繞過你天使般的臉,ah,這感覺實在太危險

能否再對我溫柔一點點,不忍心再帶你去冒險

All I wanna do is fool around

(我想做的就是四處游盪)

我的心在小鹿亂撞,從日落到清晨的月光

抱你到天亮,你輕輕一個吻,我瘋狂體會

氣氛開始升溫,危險又迷人

I really wanna dance tonight,Feel a little bit dangerous

(今晚我真的很想跳舞,感覺有點危險)

少了些安全感,做我的情人,I know you want it

(我知道你想要這個)

怪這感覺狂熱,燈光晃了,音樂放著

感受體溫上升,妝花了,你晃著

I know u really wanna,You know u really wanna

(我知道你真的很想,你知道你真的很想)

你輕輕一個吻,我瘋狂體會

氣氛開始升溫,危險又迷人

I know you wanna dance tonight,Feel a little bit dangerous

(今晚我真的很想跳舞,感覺有點危險)

少了些安全感,做我的情人

I know you want it,Be my lover

(我知道你想要,做我的愛人)

(4)mua演算法擴展閱讀:

《情人》在迷幻音色中加入回聲,性感又高級。塑造了超強的聲音空間感,增強了溫柔繾綣的意味。舞美設計利用多媒體幕布打造了分屏式體驗,以視覺演算法和多媒體環境創造3D空間感,改編後的舞台頗具代入感。

開篇「Be my Lover」式的主線混編,有一種電影大片高級轉場的視聽效果,愈加強烈的音樂節奏巧妙地渲染了氛圍。沉鬱頓挫的節奏漸轉平緩,再過度到兩者飽和的狀態盡顯編曲高級感。

Ⅳ 發郵件的流程

先進入油箱,點機「寫信」輸入對方的油箱地址,再輸入自己寫寫給對方的內容,最後在點擊「發送」,就OK了!

Ⅵ matlab中的mua是什麼意思

matlab中的mua是什麼意思1. MATLAB所定義的特殊變數及其意義變數名 意義 help 在線幫助命令, 如用help plot調用命令函數plot的幫助說明。 who 列出所有定義過的變數名稱 ans 最近
2. MATLAB中的運算符和特殊字元說明符號 符號用途說明 +加 -減 .* 點乘 詳細說明help arith * 矩陣相乘 ^ 矩陣求冪 .^ 點冪

閱讀全文

與mua演算法相關的資料

熱點內容
山西有什麼app 瀏覽:406
app怎麼樣購買內存 瀏覽:30
如何注冊sqlserver伺服器 瀏覽:76
上士命令 瀏覽:490
股市中帶星號的app是什麼 瀏覽:709
什麼路由可以刷機做列印機伺服器 瀏覽:7
電腦怎麼找到雲伺服器 瀏覽:871
微信怎麼發應用app 瀏覽:776
花生殼dns伺服器地址 瀏覽:648
squad伺服器一般什麼時候人多 瀏覽:479
程序員戰門課 瀏覽:474
config保存伺服器地址 瀏覽:317
預訂網吧座位的app叫什麼 瀏覽:416
香港伺服器主機地址 瀏覽:640
網店美工pdf 瀏覽:447
一堆文件夾怎麼弄出來 瀏覽:743
博途如何編譯硬體 瀏覽:418
fortran程序pdf 瀏覽:504
電池消耗演算法 瀏覽:394
伺服器中斷連接怎麼處理 瀏覽:222