我正在嘗試使用MATLAB ga()函數來解決優化問題。MATLAB ga()忽略用戶提供的初始羣體
我會盡量簡短。它基本上是一個最小二乘擬合問題,我操縱一些輸入來嘗試匹配一個目標函數。該問題有40個變量。有約束約束,線性等式,線性不等式和非線性約束。
之前我讓MATLAB選擇初始人口,但結果很差。我覺得這是由於MATLAB的選擇缺乏多樣性。因此,我編寫了一個函數,該函數可以創建一個滿足除非線性約束條件(這些是模擬後計算)之外的所有約束條件的初始總體。
我谷歌搜索,並發現只有一個問題在MATLAB中央交易所關係到這個相同的主題,它是從2007年,從來沒有解決。
以下是可能存在問題的代碼部分。我很抱歉,它太大了,但我認爲這是非常合理的。我正在使用ga(問題),並且這段代碼的大部分內容都列出了所有的約束條件。
ineq_con_tau_LB = [zeros(1,nInjections) zeros(1,nInjections) tau_LB/60/1e6 tau_LB/60/1e6 tau_LB/60/1e6 0]
ineq_con_tau_UB = [zeros(1,nInjections) zeros(1,nInjections) 0 0 -tau_UB/60/1e6 0]
problem_structure.Aineq = [ineq_con_tau_LB; ineq_con_tau_UB];
problem_structure.bineq = [nInjections*CP.reactorVolume;-nInjections*CP.reactorVolume];
eq_con_antisolvent = [ones(1,nInjections) zeros(1,nInjections) -1 0 0 0];
eq_con_puresolvent = [zeros(1,nInjections) ones(1,nInjections) 0 -1 0 0];
problem_structure.Aeq = [eq_con_antisolvent; eq_con_puresolvent];
problem_structure.beq = [0 0]';
%Upper and lower bounds.
Atotal_min = 10; Atotal_max = 1000;
Stotal_min = 10; Stotal_max = 1000;
Vfeed_min = 10; Vfeed_max = 1000;
ypercent_min = 0.02;
ypercent_max = 0.07;
problem_structure.lb = [ zeros(1,nInjections) zeros(1,nInjections) Atotal_min Stotal_min Vfeed_min ypercent_min];
problem_structure.ub = [repmat(inf,1,nInjections) repmat(inf,1,nInjections) Atotal_max Stotal_max Vfeed_max ypercent_max];
problem_structure.nonlcon = @constr;
problem_structure.nvars = 2*nInjections + 4;
problem_structure.fitnessfcn = @objfun;
problem_structure.intcon = [];
populationsize = 5;
gapop = dissolution_optimization_initialpop(populationsize,nInjections,problem_structure.Aineq, ...
problem_structure.bineq, ...
problem_structure.lb(:), ...
problem_structure.ub(:), ...
tau_LB, ...
tau_UB, ...
ypercent_min, ...
ypercent_max);
problem_structure.options = gaoptimset('Generations', 25,...
'PopulationSize',populationsize, ...
'InitialPopulation',gapop, ...
'OutputFcn', @sse_outputfcn, ...
'MutationFcn', {@mutationadaptfeasible});
problem_structure.options
save('gapop_save','gapop')
[x,fval,exitflag,output] = ga(problem_structure)
,可以提供任何幫助是不勝感激。請幫忙! :(((