单目标优化算法测试函数python绘制及相关代码

【代码分享】四十七种测试函数(关注可免费获取) 智能优化算法测试函数是为了在优化算法研究和开发中测试算法性能的规范问题集合。这些测试函数模拟了真实世界优化问题的不同方面,包括局部最小值、最大值、全局最优解,以及多种复杂性如高维度、非线性、不连续等。优化算法,如遗传算法、粒子群优化、蚁群算法和模拟退火等,常常运用这些测试函数来评估其性能。测试函数大致分为几类:单模函数、多模函数、组合函数和约束优化问题。这些测试函数不但在复杂性上有所不同,其形状也各异,有些呈现为平滑曲面,有些则充满尖峰和陡峭的谷地。 阅读详情

在博客上看到了一些函数,为了练习python画图能力,所以就都绘制了部分函数

函数

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

代码和图像

画图部分

def draw_pic_3D(x, y, z, title, z_min, z_max, offset):
    fig = plt.figure()
    ax = Axes3D(fig)
    ax.plot_surface(x, y, z, rstride=1, cstride=1, cmap = plt.get_cmap('rainbow'),color='orangered')
    # 绘制等高线
    ax.contour(x,y,z,offset=offset,colors='green')
    ax.set_zlim(z_min, z_max)
    ax.set_title(title)
    plt.savefig("image")
    plt.show()

获取x和y的值

def get_x_and_y(x_min, x_max, y_min, y_max):
    x = np.arange(x_min, x_max, 0.1)
    y = np.arange(y_min, y_max, 0.1)
    x, y = np.meshgrid(x, y)  # 生成网格点坐标矩阵
    return x, y

Ackely’s function

def Ackelys_function(z_min = 0,z_max = 15, offset = 0):
    x, y = get_x_and_y(-5,5,-5,5)
    z = -20 * np.exp(-0.2 * np.sqrt(0.5 * (x ** 2 + y ** 2))) - np.exp(0.5 * (np.cos(2 * np.pi * x) + np.cos(2 * np.pi * y))) + 20 + np.e
    return x, y, z, 'Ackely function', z_min, z_max, offset

在这里插入图片描述

Sphere function

def Sphere(z_min = 0,z_max = 20,offset = 0):
    x,y = get_x_and_y( -3,3,-3,3)
    z = x ** 2 + y ** 2
    return x,y,z, "Sphere function", z_min, z_max, offset

别再瞎调参了!用Python复现ZDT/DTLZ测试函数,帮你科学评估多目标优化算法 本文详细介绍了如何使用Python实现ZDT和DTLZ测试函数,科学评估多目标优化算法性能。通过对比不同测试函数的特性与实现方法,帮助开发者避免盲目调参,建立系统化的算法评估体系,提升多目标优化研究的可靠性与效率。 阅读详情

相关推荐

MOGWO多目标灰狼优化算法Matlab实战指南

多目标优化是工程设计中处理冲突目标(如成本、性能、能耗)的核心技术,其本质是求解帕累托最优解集而非单一最优解。基于非支配排序与拥挤度距离的MOGWO算法,继承灰狼群智能机制,通过外部档案与随机领导者选择实现解集多样性与收敛性平衡。相比NSGA-II等传统方法,MOGWO在Matlab平台具备原生向量化计算、高效可视化及与Simulink/HFSS等工程工具链无缝集成的技术优势,特别适用于电池热管理、电力调度、结构轻量化等需多指标协同决策的工业场景。本文聚焦可复现的Matlab实现路径,覆盖算法原理、参数调优

weixin_34014555的博客 379

帝国竞争算法(ICA)原理详解与Python实现:优化问题新思路

优化算法是解决复杂工程与科学问题的核心技术,其核心原理是通过模拟自然或社会现象,在解空间中高效搜索最优解。帝国竞争算法(ICA)作为一种新颖的元启发式算法,其独特之处在于借鉴了历史殖民进程中的“同化”与“竞争”机制。该算法将候选解视为“国家”,通过帝国对殖民地的同化进行局部开发,并通过帝国间的竞争实现全局探索,有效平衡了探索与开发能力,在避免早熟收敛方面展现出优势。这种机制使其在解决多峰、高维的复杂优化问题时具有重要技术价值,广泛应用于机器学习参数调优、工程设计和调度规划等领域。本文聚焦于ICA的核心机制,

weixin_30512965的博客 262

优化算法测试函数.zip

优化算法测试函数其中包括Rosenbrock.m,Schaffer.m,Schewel.m,Schwefel.m,shiftedRosenbrock.m,ShiftedSphere.m,Sphere.m,step.m,SumDifferent.m,SumSquares.m,Zakharov.m,rastrigin.m,sumpow.m,perm0db.m,ellipsoid.m,ackley.m,griewank.m

openwrt编译及第一个安装包教程

Date: 2017.03.14 Made:SuperDeverloper Email: na1206@live.com Target: For mt7688 based board说明:本人在学习过程中走了不少弯路,希望本文档能为后来者提供便利。欢迎复制和使用本文档。本文档记录了搭建openwrt编译环境以及快速创建ipk包(openwrt上的安装程序)。本文档在实际应用中做过几次修改,以帮

SuperDevloper的博客 1万+

产品必备技能(十):如何绘制原型图?先要绘制页面流程图+页面原型图!附实操原型图、流程图实例(抖音)

文章目录目标题目实操步骤模板实操【抖音】APP的视频发布功能页面流程绘制页面流程图合格标准绘制页面原型图合格标准 目标 新入行的产品经理都对原型抱有向往的心境,但是有经验的产品经理不会一上来就画原型,而是先画页面流程再来画原型。通过学习,你将学会如何用页面流程图规划用户行为路径、如何借助原型识别问题、减少风险、有效沟通。 题目 任意选择一款你喜欢的产品,体验某个功能,下载并梳理此功能至少5个以上的页面流程跳转点(后面会解释),还原2 - 3个主要界面的低保真原型图。 实操步骤 可使用手绘以及Process

汪雯琦的博客 4842

小案例:利用图床自动化批量上传图片并获取图片链接

用python爬虫写了一个小脚本,用来自动上传图片到图床,然后返回链接,我们只需直接复制链接就可以。(需要安装Requests库) 因为不同图床需要提交的POST表单不一致,所以在这里我用ImgURL图床做示范,如果大家有需求,可自行修改代码。使用脚本的时候,我们只需把需要上传的图片和这个脚本放在同一个文件夹中,然后运行脚本,稍作等待,看到提示时就可以在脚本运行文件夹中发现一个名为“图片链接地址.txt”的文件,里面就是图片链接啦! 四、图片链接地址.txt(单张图片):...

采菊东篱下,Python满乾坤! 4413

opencv 常用函数总结

本文是一份OpenCV图像处理的常用函数总结,详细介绍了图像的读入、显示、保存、像素处理、图像属性获取、基础操作、阈值处理、图像平滑、形态学转换以及直方图处理等关键技术。文章通过代码示例和参数说明,帮助读者快速掌握OpenCV在图像处理领域的应用。

weixin_44063529的博客 1600

IFIX往Mysql数据库同步数据方法

通过IFix数据库向Mysql数据库同步数据

仙人掌 1596

OpenCV计算机视觉实战(11)——边缘检测详解

在本节中,我们系统介绍了三大经典边缘检测算子,包括 Sobel 算子:一阶导数平衡了噪声抑制与边缘提取,结合方向信息可用于纹理分析与车道检测;Laplacian 算子:二阶导数对微小亮度突变尤为敏感,配合零交叉和细化技术,可精确捕捉任意方向的细节边缘;Canny 算法:集成多阶段处理与双阈值策略,通过多尺度融合与自适应阈值优化,达到抗噪与细节兼顾的卓越效果。

qq_30167691的博客 4377

假新闻检测论文分享(30)MMDFND: Multi-modal Multi-Domain Fake News Detection

现有的假新闻检测方法通常集中在单一领域的新闻上,如健康或政治。然而,社交媒体上的新闻往往来自多个领域,这给单一领域的假新闻检测方法带来了两个主要挑战:数据稀缺性:处理较小、单一领域的新闻数据集时,由于训练数据的稀缺,模型的有效性显著下降。跨领域检测的准确性下降:单一领域的假新闻检测方法在跨领域新闻数据集上的准确性大幅降低。缓解领域间模态语义偏差:通过DPLE网络提取跨领域和领域特定的知识,缓解了不同领域间文本和图像的语义差异。

weixin_41964296的博客 671

国科大学习资料--人工智能原理与算法-第六次作业解析(学长整理)

国科大学习资料–人工智能原理与算法-第六次作业解析(张文生老师主讲)(6.6、6.7、6.11) 6.6 说明如何通过使用辅助变量把诸如A+B=C这样的三元约束转变成三个二元约束。假设值域是有限的。(提示:考虑引进新变量表示变量对的值,引进约束如“X是Y变量对中的第一个元素”。)然后说明如何把多于三个变量的约束类似地转换为二元约束。说明如何通过改变变量的值域来消除一元约束。这就完整演示了任何CSP都可以转变为只含二元约束的CSP。 答:首先,我们引入一个新变量AB,假设A和B的范围均为N,AB的范围为N×N

无名何许人的博客 2870

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

上一篇: pygame五子棋人机游戏
下一篇: PSO算法求函数最优解
Zella Zhang
博客等级 码龄8年 79粉丝 176原创
评论 4
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值