x = 0:0.01:10; y = x + 10*sin(5*x)+7*cos(4*x); figure plot(x, y) xlabel('independent variable') ylabel('dependent variable') title('GA:y = x + 10*sin(5*x) + 7*cos(4*x)利用算法求解最优解—Jason niu') initPop = initializega(50,[0 10],'fitness'); [x endPop bpop t…
%SA:利用SA算法解决TSP(数据是14个虚拟城市的横纵坐标)问题——Jason niu X = [16.4700 96.1000 16.4700 94.4400 20.0900 92.5400 22.3900 93.3700 25.2300 97.2400 22.0000 96.0500 20.4700 97.0200 17.2000 96.2900 16.3000 97.3800 14.0500 98.1200 16.5300 97.3800 21.5200 95.5900 19.4100…
figure [x,y] = meshgrid(-5:0.1:5,-5:0.1:5); z = x.^2 + y.^2 - 10*cos(2*pi*x) - 10*cos(2*pi*y) + 20; mesh(x,y,z) hold on c1 = 1.49445; c2 = 1.49445; maxgen = 1000; sizepop = 100; Vmax = 1; Vmin = -1; popmax = 5; popmin = -5; for i = 1:sizepop pop(i,:)…
from collections import defaultdict import mnist_loader def main(): training_data, validation_data, test_data = mnist_loader.load_data() avgs = avg_darknesses(training_data) # testing phase: see how many of the test images are classified # correctly…
global p global t global R % 输入神经元个数,此处是6个 global S1 % 隐层神经元个数,此处是10个 global S2 % 输出神经元个数,此处是4个 global S % 连接权值个数+阈值个数即(6*10+10*4)+(10+4) S1 = 10; p = [0.01 0.01 0.00 0.90 0.05 0.00; 0.00 0.00 0.00 0.40 0.50 0.00; 0.80 0.00 0.10 0.00 0.00 0.00; 0.00…
%SA:T1法利用Matlab编写主函数实现对定义域[-5,5]上的二元函数求最优解—Jason niu [x,y] = meshgrid(-5:0.1:5,-5:0.1:5); z = x.^2 + y.^2 - 10*cos(2*pi*x) - 10*cos(2*pi*y) + 20; figure mesh(x,y,z) hold on xlabel('x') ylabel('y') zlabel('z') title('SA:利用SA最优化,定义域[-5,5]上的二元函数z = x^2…
load spectra; temp = randperm(size(NIR, 1)); P_train = NIR(temp(1:50),:); T_train = octane(temp(1:50),:); P_test = NIR(temp(51:end),:); T_test = octane(temp(51:end),:); [PCALoadings,PCAScores,PCAVar] = princomp(NIR); figure percent_explained = 100 *…
x = 1:0.01:2; y = sin(10*pi*x) ./ x; figure plot(x, y) title('绘制目标函数曲线图—Jason niu'); hold on c1 = 1.49445; c2 = 1.49445; maxgen = 50; sizepop = 10; Vmax = 0.5; Vmin = -0.5; popmax = 2; popmin = 1; ws = 0.9; we = 0.4; for i = 1:sizepop pop(i,:) = (ran…
x = 1:0.01:2; y = sin(10*pi*x) ./ x; figure plot(x, y) title('绘制目标函数曲线图—Jason niu'); hold on c1 = 1.49445; c2 = 1.49445; maxgen = 50; sizepop = 10; Vmax = 0.5; Vmin = -0.5; popmax = 2; popmin = 1; for i = 1:sizepop pop(i,:) = (rands(1) + 1) / 2 + 1;…
在本系列的第一篇随笔<Entity Framework 实体框架的形成之旅--基于泛型的仓储模式的实体框架(1)>中介绍了Entity Framework 实体框架的一些基础知识,以及构建了一个简单的基于泛型的仓储模式的框架,例子也呈现了一个实体框架应用的雏形,本篇继续介绍这个主题,继续深化介绍Entity Framework 实体框架的知识,以及持续优化这个仓储模式的实体框架,主要介绍业务逻辑层的构建,以及利用Unity和反射进行动态的对象注册. 1.EDMX文件位置的调整 我们从上篇例子,…