以下の内容はhttps://seinzumtode.hatenadiary.jp/entry/2024/10/30/202836より取得しました。


OctaveでGAを用いた最適化

ローゼンブロック関数の最適化

pkg load ga;
function y = rosenbrock(x)
    % Rosenbrock function, commonly used for testing optimization algorithms
    y = 100 * (x(2) - x(1)^2)^2 + (1 - x(1))^2;
end
nvars = 2;
lb = [-5, -5]; % Lower bounds
ub = [5, 5];   % Upper bounds
ga_options = gaoptimset('Generations', 200, 'PopulationSize', 100, 'InitialPopulation', x0,  'Vectorized', 'off');
[x, fval] = ga(@rosenbrock, nvars, [], [], [], [], lb, ub, ga_options);
% Display the result
disp("Optimized variables:");
disp(x);
disp("Minimum value of the function:");
disp(fval);



以上の内容はhttps://seinzumtode.hatenadiary.jp/entry/2024/10/30/202836より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14