资源简介
CMAES(自适应协方差矩阵进化算法)的Matlab实现,包含动画演示的小Demo。
代码片段和文件信息
% CMA-ES: Evolution Strategy with Covariance Matrix Adaptation for
% nonlinear function minimization.
%
% This code is an excerpt from cmaes.m and implements the key parts
% of the algorithm. It is intendend to be used for READING and
% UNDERSTANDING the basic flow and all details of the CMA *algorithm*.
% Computational efficiency is sometimes disregarded.
% -------------------- Initialization --------------------------------
% User defined input parameters (need to be edited)
clear all;clc;
target_function = @(x)(x(1)-1).^2+0.3*sin(x(1))+(x(2)-1).^2+0.3*sin(x(2));
x_o = [3:-0.01:0];
y_o = zeros(length(x_o)length(x_o));
for index_i = 1:length(x_o)
for index_j = 1:length(x_o)
y_o(index_iindex_j) = target_function([x_o(index_i) x_o(index_j)]);
end
end
subplot(121);
mesh(x_ox_oy_o);
subplot(122);
mesh(x_ox_oy_o);
% subplot(222);
% contourf(x_ox_oy_o20);
set(gcf‘outerposition‘get(0‘screensize‘));
noise = 0.1;
N = 2; % number of objective variables/problem dimension
xmean = [2.5;2.5]; % objective variables initial point
sigma = 0.05; % coordinate wise standard deviation (step-size)
stopeval = 20;
% Strategy parameter setting: Selection
lambda = 4+floor(3*log(N)); % population size offspring number
lambda = 20;
mu = lambda/2; % lambda=12; mu=3; weights = ones(mu1); would be (3_I12)-ES
weights = log(mu+1/2)-log(1:mu)‘; % muXone recombination weights
mu = floor(mu); % number of parents/points for recombination
weights = weights/sum(weights); % normalize recombination weights array
mueff=sum(weights)^2/sum(weights.^2); % variance-effective size of mu
% Strategy parameter setting: Adaptation
cc = (4+mueff/N) / (N+4 + 2*mueff/N); % time constant for cumulation for C
cs = (mueff+2)/(N+mueff+5); % t-const for cumulation for sigma control
c1 = 2 / ((N+1.3)^2+mueff); % learning rate for rank-one update of C
cmu = 2 * (mueff-2+1/mueff) / ((N+2)^2+2*mueff/2); % and for rank-mu update
damps = 1 + 2*max(0 sqrt((mueff-1)/(N+1))-1) + cs; % damping for sigma
% Initialize dynamic (internal) strategy parameters and constants
pc = zeros(N1); ps = zeros(N1); % evolution paths for C and sigma
B = eye(N); % B defines the coordinate system
D = eye(N); % diagonal matrix D defines the scaling
C = B*D*(B*D)‘; % covariance matrix
eigeneval = 0; % B and D updated at counteval == 0
chiN=N^0.5*(1-1/(4*N)+1/(21*N^2)); % expectation of
Opt_Record = [];
n=0;
pause(1);
% -------------------- Generation Loop --------------------------------
counteval = 0; % the next 40 lines contain the 20 lines of interesting code
while counteval < stopeval
% Generate and evaluate lambda offspring
for k=1:lambda
arz(:k) = randn(N1); % standard normally distributed vector
arx(:k) = xmean + sigma * (B*D * arz(:k)); % add mutation % Eq. 40
arfitness(k) = target_function(arx(:k)) + noise*randn; % objective function call
end
%% 绘制响应
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 4689 2019-04-19 23:04 CMAES_demo.m
文件 174 2019-03-26 20:31 Opt_Target_Function.m
- 上一篇:数字图像处理作业
- 下一篇:基于SIFT算法的图像拼接 matlab代码
相关资源
- 基于SIFT算法的图像拼接 matlab代码
- 传输矩阵法计算薄膜的反射率和透射
- Matlab非线性方程求解代码
- 倒立摆matlab代码
- 预测控制多种算法matlab实现
- K-L变换matlab代码
- 高阶马尔科夫matlab code实现与文献
- Matlab.vR2016b_NMac.to.torrent
- matlab-KNN分类器
- 最小二乘定位算法 Matlab
- 基于MATLAB的Prony方法实现
- 数学建模国赛题目,代码。圆桌优化
- matlab读取ENVI .img文件
- 基于直接驱动永磁同步电机的 1.5 mw
- 将8位图片转换为coe文件
- GPS_INS位置组合Matlab仿真源码
- 肺实质提取
- 节约法车路路径问题VRP的Matlab程序代
- 增广拉格朗日方法MATLAB程序
- 半监督分类算法源程序-matlab代码
-
QPSK调制与解调的simuli
nk仿真 - RNN算法打包matlab
- 基于暗通道先验的图像去雾MATLAB算法
- 数字图像处理维纳滤波Matlab代码分享
- 手写体识别matlab代码
- FXLMS算法的matlab仿真
- 水果识别matlab程序,有界面
- louvain鲁文社团检测算法matlab实现
- 基于matlab的三维杆系有限元软件
- LTE小区搜索matlab仿真
评论
共有 条评论