当前位置: 首页 > news >正文

MATLAB ga函数的使用方法

一、ga句法结构

x = ga(fitnessfcn,nvars)
x = ga(fitnessfcn,nvars,A,b)
x = ga(fitnessfcn,nvars,A,b,Aeq,beq)
x = ga(fitnessfcn,nvars,A,b,Aeq,beg,IB,UB)
x = ga(fitnessfcn,nvars,A,b,Aeq,beq,LB,UB,nonlcon)
x = ga(fitnessfcn,nvars,A,b,Aeq,beq,LB,UB,nonlcon,options)
x = ga(fitnessfcn,nvars,A,b,[],[],LB,UB,nonlcon,IntCon)
x = ga(fitnessfcn,nvars,A,b,[],[],LB,UB,nonlcon,IntCon,options)
x = ga(problem)
[x,fval] = ga(fitnessfcn,nvars,...)
[x,fval,exitflag] = ga (fitnessfcn,nvars,...)
[x,fval,exitflag,output] = ga(fitnessfcn,nvars,...)
[x,fval,exitflag,output,population] = gafitnessfcn,nvars,...)
[x,fval,exitflag,output,population,scores] = ga(fitnessfcn,nvars,...)

二、释义及解读

  • fitnessfcn 为适应度句柄函数(即:目标函数);
  • nvars 为目标函数自变量的个数;
  • options 为算法的属性设置,该属性是通过函数gaoptimset赋予的;
  • x 为经过遗传进化以后自变量最佳染色体返回值;
  • fval 为最佳染色体的适应度;
  • exitflag 为算法停止的原因;
  • output 为输出的算法结构;

  • population 为最终得到种群适应度的列向量(即当前群体,而群体里性能最好的个体,便是最优值点);

  • scores 为最终得到的种群(即:最优值点的目标函数取值);

  • A A A b b b:线性不等式约束 A ∗ x ≤ b A*x\leq b Axb 中的矩阵;
    (Note: If the problem has m linear inequality constraints and nvars variables. then A is a matrix of size m-by-nvars and b is a vector of length m. ga evaluates the matrix product A*x as if x is transposed (Ax’). )

  • A e q Aeq Aeq b e q beq beq:线性等式约束 A e q ∗ x = b e q Aeq*x=beq Aeqx=beq 中的矩阵;
    (Note: ga does not enforce linear constraints to be satisfied when the PopulationType option is ‘bitstring’ or ‘custom’.)

  • nonlcon:非线性约束,该函数返回两个输出,即:[g,h] = nonlcon(x) ,g为非线性不等式约束,所有的不等式约束均以列向量的形式存在变量g中。h为非线性等式约束,也以列向量的形式存储。非线性约束中[g,h]使用规则与我另一篇博客MATLAB fmincon函数 进阶资料(磕盐记录)一样,这里不展开叙述了。 需要注意:ga atempts to achieve g = 0 g = 0 g=0 and h = 0 h= 0 h=0. g g g and h are row vectors when there are multiple constraints. Set unused outputs to g = [ ] or h = [ ].

  • IntCon:若变量 x 中存在整数变量,则在这里设置!具体地,IntCon 是由正数整数组成的向量,取值从 1 到 nvars,IntCon 中的每个值代表决策变量 x 中相应位置的索引变量是整数变量。
    (Note: When IntCon is nonempty, Aeq and beq must be empty ([ ]), and nonlcon must return empty for ceq. For more information on integer programming, see Mixed Integer Optimizaton.)

  • options:Create options using gaoptimset. 下一章节将详细介绍 options 中关于 gaoptimset 的设置规则。


三、gaoptimset 介绍(初级)

gaoptimset 常用来设置 options 中的各个选项,其句式结构如下:

options = gaoptimset('param1',value1,'param2',value2,...)

其中, ‘Param1’、 ‘Param2’等是需要设定的参数,比如:种群规模(PopulationSize)、交叉比例(CrossoverFraction)等,value1、value2等则是Param的具体值,常用的参数名如下表:

设定的参数名(Param名)说明默认值
CrossoverFraction交叉比例0.8
Generations算法中止的最大迭代次数100
PopulationSize种群规模20
MigrationFraction变异概率0.2
FitnessLimit当适应度函数达到设定的值时算法中止-
StallGenLimit当超过StallGenLimit代适应度函数为改善时,算法中止50

更多参数设定详见 MATLAB 官方文档,可在MATLAB命令窗口中输入 “doc gaoptimset” 查看 [2]:

或参见本博客“第六节”。

四、实例运行

实例原始网址: MATLAB利用遗传算法函数求目标函数的最优解

  1. 目标函数如下:
function f = myfit( x )f = (339-0.01*x(1)-0.003*x(2))*x(1)...+ (399-0.004*x(1)-0.01*x(2))*x(2)...- (400000+195*x(1)+225*x(2));f = -f; %因为GA是寻找最小值,所以为了求这个函数的最大值,取f的相反数
end 
  1. 主函数如下:
options = gaoptimset();
options.Generations = 2000; %最大迭代数设为2000% 当然,如果有很多参数都需要设置时,可以按照 options = gaoptimset('param1',value1,'param2',value2,...) 的形式统一设置
% options = gaoptimset('PopulationSize', 20, ...     % 种群包含个体数目
%                      'EliteCount', 10, ...          % 种群中精英个体数目
%                      'CrossoverFraction', 0.75, ... % 交叉后代比率
%                      'Generations', 500, ...        % 迭代代数
%                      'StallGenLimit', 500, ...      % 停止代数
%                      'TolFun', 1e-100, ...          % 适应度函数偏差
%                      'PlotFcns', {@gaplotbestf,  @gaplotbestindiv, @gaplotstopping}); % 绘制最优个体适应度函数与最优个体[X,FVAL,EXITFLAG,OUTPUT] =ga(@myfit, 2 ,[], [],[],[],[],[],[],[],options)

运行结果为:

EXITFLAG 返回值为1,说明所求结果无特殊情况。

需要注意的是:如果 options.Generations 不设为 2000,采用默认迭代100轮来运行上述代码,则运行结果如下图所示:

注意到此时,EXITFLAG 返回值为0,显示信息为:Optimization terminated: maximum number of generations exceeded.

即:达到最大迭代轮数,此时的结果与最优理想结果相差甚远。由此例可知,关于最大迭代次数的设定,一定要小心,务必满足迭代次数的要求!


五、关于 exitflag 取值的说明(重要)

前文给出了 exitflag 取值的一个表格,说明了 GA 停止运行的原因 [3],这几类原因可概括为 exitflag 取值为以下三种情况:

  1. exitflag 为正值:意味着 GA 认为它做得相当好,有特定的理由停止运行
  2. exitflag = -2:无可行解,你肯定没有得到有用的答案
  3. exitflag 取其他情况时:意味着 GA 认为如果让它运行更长时间,你可能会得到更好的解决方案。 它没有在函数值中看到停止的具体原因,但它遇到了你设置的资源限制。

更详细的原因,可解释为 [3]:

  • As I know, good solution is when it converges, the change of few last iteration does not improves (exit flag 1, 3). Or when solution meets your specified value (exit flag 5).
  • And not so good solution is if it stops due to max time/iteration (exit flag 0, -4, -5), means it may not converge. It may gives better solution when you increase those limits. Or when the solution change is smaller than matlab capability (exit flag 4), this means you may need to improve your objective function.
  • Clearly bad solution is when no solution is found (exit flag -2).

六、gaoptimset 详述(进阶)

options 选项在 GA 函数中,是以结构体的形式存在,该结构体包含哪些变量呢?在第四节中介绍了几个常见的变量,我将在本节详细介绍所有变量,以及各变量的作用。

首先,在MATLAB命令窗口中输入下述命令:

gaoptimset(@ga)

显示结果如下:

上述结果中,每一行都对应一个可设置的参数项(左侧是变量名,右侧是默认取值)

各变量名的详细解读:

  • 大括号 { } 中的值表示默认值;

  • { }* 表示当问题具有线性约束且 MutationFcn 有边界时的默认值;

  • I* 表示 ga 以不同的方式处理整数约束的选项; 此表示法不适用于 gamultiobj;

  • NM 表示该选项不适用于 GA 的多目标优化问题中(gamultiobj)。

序号OptionDescriptionValues
1ConstraintTolerance确定了非线性约束的可行性。此外,max(sqrt(eps),Constraint Tolerance) 确定了线性约束的可行性. (我理解,此参数表示约束违反的精度误差)

For an options structure, use TolCon.
Positive scalar | {1e-3}
2CreationFcn创建初始种群的函数。 指定为内置创建函数或函数句柄的名称。See Population Options.{‘gacreationuniform’}|{‘gacreationlinearfeasible’}* |‘gacreationnonlinearfeasible’ |{‘gacreationuniformint’}I* for ga | {‘gacreationsobol’}I* for gamultiobj | Custom creation function
3CrossoverFcn算法用于创建交叉子代(crossover children)的函数。 指定为内置交叉函数或函数句柄的名称。See Crossover Options.{‘crossoverscattered’} for ga, {‘crossoverintermediate’}* for gamultiobj |{‘crossoverlaplace’}I* | ‘crossoverheuristic’ |‘crossoversinglepoint’ | ‘crossovertwopoint’ | ‘crossoverarithmetic’| Custom crossover function
4CrossoverFraction交叉函数产生的下一代人口比例(不包括精英子代)Positive scalar | {0.8}
5DisplayLevel of display.‘off’ | ‘iter’ |‘diagnose’ | {‘final’}
6DistanceMeasureFcn计算个体距离度量的函数。 指定为内置距离测量函数或函数句柄的名称。 The value applies to the decision variable or design space (genotype) or to function space (phenotype). The default ‘distancecrowding’ is in function space (phenotype). For gamultiobj only. See Multiobjective Options.

For an options structure, use a function handle, not a name.
{‘distancecrowding’} means the same as {@distancecrowding,‘phenotype’} | {@distancecrowding,‘genotype’} | Custom distance function
7EliteCountNM 指定当前一代中有多少个体可以保证生存到下一代,必须是正整数。Not used in gamultiobj.Positive integer | {ceil(0.05PopulationSize)} | {0.05(default PopulationSize)} for mixed-integer problems
8FitnessLimitNM 如果适应度函数达到 FitnessLimit 的值,算法将停止。(我理解,这个函数设定不取默认的 -inf ,则最后输出的 exitflag 的取值应该是 5)Scalar | {-Inf}
9FitnessScalingFcn该函数用以缩放适应度函数值。 指定为内置缩放函数或函数句柄的名称。 Option unavailable for gamultiobj.{‘fitscalingrank’} | ‘fitscalingshiftlinear’ | ‘fitscalingprop’ | ‘fitscalingtop’ | Custom fitness scaling function
10FunctionTolerance(与表格第17项关联)翻译: 如果 MaxStallGenerations 代以后,最佳适应度函数值的平均相对变化小于或等于 FunctionTolerance,则算法停止。 如果 StallTest 为“geometricWeighted”,则当加权平均相对变化小于或等于 FunctionTolerance 时,算法将停止。原文: The algorithm stops if the average relative change in the best fitness function value over MaxStallGenerations generations is less than or equal to FunctionTolerance. If StallTest is ‘geometricWeighted’, then the algorithm stops if the weighted average relative change is less than or equal to FunctionTolerance.

For gamultiobj, the algorithm stops when the geometric average of the relative change in value of the spread over options.MaxStallGenerations generations is less than options.FunctionTolerance, and the final spread is less than the mean spread over the past options.MaxStallGenerations generations. See gamultiobj Algorithm.

For an options structure, use TolFun.
Positive scalar | {1e-6} for ga, {1e-4} for gamultiobj
11HybridFcnI* 翻译: ga 终止后继续优化的函数。 指定为名称或函数句柄。 原文: Function that continues the optimization after ga terminates. (我理解,此参数用以保留当前子代,留之用以在此子代的基础上二次优化) Alternatively, a cell array specifying the hybrid function and its options. See ga Hybrid Function. For gamultiobj, the only hybrid function is @fgoalattain. See gamultiobj Hybrid Function. When the problem has integer constraints, you cannot use a hybrid function. See When to Use a Hybrid Function.Function name or handle | ‘fminsearch’ | ‘patternsearch’ | ‘fminunc’ | ‘fmincon’ | {[]} or 1-by-2 cell array
12InitialPenaltyNM I* Initial value of the penalty parameterPositive scalar | {10}
13InitialPopulationMatrix调用遗传算法的初始Population。 最多具有 “PopulationSize ” 行 N 列,其中 N 是变量数。 您可以传递部分Population,即行数少于 PopulationSize 的总体。 在这种情况下,遗传算法使用 CreationFcn 来生成剩余的Population。See Population Options.

For an options structure, use InitialPopulation.
Matrix | {[]}
14InitialPopulationRange指定初始Population中个体的范围,该参数是一个矩阵或向量。 适用于 gacreationuniform 创建功能。ga shifts and scales the default initial range to match any finite bounds.

For an options structure, use PopInitRange.
Matrix or vector | {[-10;10]} for unbounded components, {[-1e4+1;1e4+1]} for unbounded components of integer-constrained problems, {[lb;ub]} for bounded components, with the default range modified to match one-sided bounds
15InitialScoresMatrixInitial scores used to determine fitness. 最多有“PopulationSize ”行和 Nf 列,其中 Nf 是适应度函数的数量(即:单目标的 ga 函数中为 1,多目标的 gamultiobj 函数则大于 1)。 You can pass a partial scores matrix, meaning one with fewer than PopulationSize rows. In that case, the solver fills in the scores when it evaluates the fitness functions.

For an options structure, use InitialScores.
Column vector for single objective| matrix for multiobjective | {[]}
16MaxGenerations(重要!!!) 算法停止之前的最大迭代次数。

For an options structure, use Generations.
Positive integer | {100numberOfVariables} for ga, {200numberOfVariables} for gamultiobj
17MaxStallGenerationsThe algorithm stops if the average relative change in the best fitness function value over MaxStallGenerations generations is less than or equal to FunctionTolerance. If StallTest is ‘geometricWeighted’, then the algorithm stops if the weighted average relative change is less than or equal to FunctionTolerance.

For gamultiobj, the algorithm stops when the geometric average of the relative change in value of the spread over options.MaxStallGenerations generations is less than options.FunctionTolerance, and the final spread is less than the mean spread over the past options.MaxStallGenerations generations. See gamultiobj Algorithm.

For an options structure, use StallGenLimit.
Positive integer | {50} for ga, {100} for gamultiobj
18MaxStallTimeNM 如果目标函数在 MaxStallTime 秒(通过 tic 和 toc 测量)内没有改善,则算法停止。

For an options structure, use StallTimeLimit.
Positive scalar | {Inf}
19MaxTime算法在运行 MaxTime 秒后停止(通过 tic 和 toc 测量)。 每次迭代后都会强制执行此限制,因此当迭代花费大量时间时 ga 可能会超出此限制。

For an options structure, use TimeLimit.
Positive scalar | {Inf}
20MigrationDirectionDirection of migration. See Migration Options.‘both’ | {‘forward’}
21MigrationFractionScalar from 0 through 1 specifying the fraction of individuals in each subpopulation that migrates to a different subpopulation. See Migration Options.Scalar | {0.2}
22MigrationInterval翻译: 指定了个体(individuals )在 subpopulations之间迁移之间发生的代数,该参量是正整数。原文: Positive integer specifying the number of generations that take place between migrations of individuals between subpopulations. See Migration Options.Positive integer | {20}
23MutationFcnFunction that produces mutation children. Specify as a name of a built-in mutation function or a function handle. See Mutation Options.{‘mutationgaussian’} for ga without constraints | {‘mutationadaptfeasible’}* for gamultiobj and for ga with constraints | {‘mutationpower’}I* | ‘mutationpositivebasis’ | ‘mutationuniform’ | Custom mutation function
24NonlinearConstraintAlgorithmNonlinear constraint algorithm. See Nonlinear Constraint Solver Algorithms for Genetic Algorithm. Option unchangeable for gamultiobj.

For an options structure, use NonlinConAlgorithm.
{‘auglag’} for ga, {‘penalty’} for gamultiobj
25OutputFcn翻译: ga 在每次迭代时调用的函数。 原文: Functions that ga calls at each iteration. Specify as a function handle or a cell array of function handles. See Output Function Options.

For an options structure, use OutputFcns.
Function handle or cell array of function handles | {[]}
26ParetoFractionScalar from 0 through 1 specifying the fraction of individuals to keep on the first Pareto front while the solver selects individuals from higher fronts, for gamultiobj only. See Multiobjective Options.Scalar | {0.35}
27PenaltyFactorNM I* Penalty update parameter.Positive scalar | {100}
28PlotFcnFunction that plots data computed by the algorithm. Specify as a name of a built-in plot function, a function handle, or a cell array of built-in names or function handles. See Plot Options. For an options structure, use PlotFcns.ga or gamultiobj: {[]} | ‘gaplotdistance’ | ‘gaplotgenealogy’ | ‘gaplotselection’ | ‘gaplotscorediversity’ | ‘gaplotscores’ | ‘gaplotstopping’ | ‘gaplotmaxconstr’ | Custom plot function

ga only: ‘gaplotbestf’ | ‘gaplotbestindiv’ | ‘gaplotexpectation’ | ‘gaplotrange’

gamultiobj only: ‘gaplotpareto’ | ‘gaplotparetodistance’ | ‘gaplotrankhist’ | ‘gaplotspread’
29PlotIntervalPositive integer specifying the number of generations between consecutive calls to the plot functions.Positive integer | {1}
30PopulationSize(重要!!!) Size of the population.Positive integer | {50} when numberOfVariables <= 5, {200} otherwise |{min(max(10*nvars,40),100)} for mixed-integer problems
31PopulationTypeData type of the population. Must be ‘doubleVector’ for mixed-integer problems.‘bitstring’ | ‘custom’ | {‘doubleVector’}

ga ignores all constraints when PopulationType is set to ‘bitString’ or ‘custom’. See Population Options.
32SelectionFcnFunction that selects parents of crossover and mutation children. Specify as a name of a built-in selection function or a function handle.

gamultiobj uses only ‘selectiontournament’.
{‘selectionstochunif’} for ga, {‘selectiontournament’} for gamultiobj | ‘selectionremainder’ | ‘selectionuniform’ | ‘selectionroulette’ | Custom selection function
33StallTestNM Stopping test type.‘geometricWeighted’ | {‘averageChange’}
34UseParallelCompute fitness and nonlinear constraint functions in parallel. See Vectorize and Parallel Options (User Function Evaluation) and How to Use Parallel Processing in Global Optimization Toolbox.true | {false}
35UseVectorizedSpecifies whether functions are vectorized. See Vectorize and Parallel Options (User Function Evaluation) and Vectorize the Fitness Function. For an options structure, use Vectorized with the values ‘on’ or ‘off’.true | {false}

注:上表内容为部分翻译版本,因为担心自己的翻译失真于原始文献,所以表格中会存在中英文混写的情况,完整版的英文原文参见 [2]


参考网址:

  1. Genetic Algorithm options
  2. gaoptimset
  3. exitFlag meaning in GA solver

相关文章:

MATLAB ga函数的使用方法

一、ga句法结构 x ga(fitnessfcn,nvars) x ga(fitnessfcn,nvars,A,b) x ga(fitnessfcn,nvars,A,b,Aeq,beq) x ga(fitnessfcn,nvars,A,b,Aeq,beg,IB,UB) x ga(fitnessfcn,nvars,A,b,Aeq,beq,LB,UB,nonlcon) x ga(fitnessfcn,nvars,A,b,Aeq,beq,LB,UB,nonlcon,options) x …...

基于STM32和MQ-2传感器的无线烟雾检测系统设计

随着科技的不断发展&#xff0c;人们对生活安全的要求也越来越高。其中&#xff0c;烟雾检测系统在预防火灾方面起着至关重要的作用。本文将介绍一种基于STM32和MQ-2传感器的无线烟雾检测系统设计&#xff0c;旨在实时检测环境中的烟雾&#xff0c;并及时发出警报&#xff0c;以…...

华为vrrp+mstp+ospf+dhcp+dhcp relay配置案例

1、左边是vlan 10主桥&#xff0c;右边是vlan 20的主桥&#xff0c;并且互为备桥 2、 vlan 10 vrrp网关默认用左边&#xff0c;vlan 20的vrrp 网关默认用右边&#xff0c;对应mstp生成树 3、两边都track检测&#xff0c;不通就把vrrp减掉60&#xff0c;这样就会自动切另一边了 …...

5-Docker实例-tomcat application

1.安装如下树形结构创建目录及文件,内容如下: 目录结构: [root@centos79 ~]# tree demo demo ├── index.html └── WEB-INF└── web.xml1 directory, 2 files [root@centos79 ~]# index.html文件内容 [root@centos79 demo]# cat index.html <h1>hello dock…...

Pikachu靶场 “Http Header”SQL注入

1. 先在 pikachu 打开 Http Header 注入模块&#xff0c;点击提示 查看登录 账号 和 密码&#xff0c;登陆后去 Burp 中找到登陆的 GET请求 2. 设置payload1 &#xff1a;在 User-Agent最后 输入 查看 数据库名 or updatexml(1,concat(0x7e,database()),0) or 查看 用户名…...

OpenEuler安装内网穿透工具实现ssh连接openEuler系统

文章目录 1. 本地SSH连接测试2. openEuler安装Cpolar3. 配置 SSH公网地址4. 公网远程SSH连接5. 固定连接SSH公网地址6. SSH固定地址连接测试 本文主要介绍在openEuler中安装Cpolar内网穿透工具实现远程也可以ssh 连接openEuler系统使用. 欧拉操作系统(openEuler, 简称“欧拉”…...

【效率工具】利用python进行本地知识库(PDF和WORK文件内容)的批量模糊搜索

目录 前言 一、为什么要进行本地文档的批量搜索? 二、如何去做呢?...

快速入门学习定时任务框架-xxljob

定时任务框架-xxljob 简介 主要用于分布式任务调度&#xff0c;可以将任务调度和执行分布在多个节点上。它提供了一个集中式的管理平台&#xff0c;支持动态添加、修改、删除任务&#xff0c;以及任务的分片执行&#xff0c;确保任务在分布式环境中的高可用性的一个框架 spr…...

Floyd(弗洛伊德)算法总结

知识概览 Floyd算法适合解决多源汇最短路问题&#xff0c;其中源点是起点&#xff0c;汇点是终点。时间复杂度是。 例题展示 题目链接 活动 - AcWing 系统讲解常用算法与数据结构&#xff0c;给出相应代码模板&#xff0c;并会布置、讲解相应的基础算法题目。https://www.acw…...

西南科技大学计算机网络实验二 (IP协议分析与以太网协议分析)

一、实验目的 通过分析由跟踪执行traceroute程序发送和接收捕获得到的IP 数据报,深入研究在IP 数据报中的各种字段,理解IP协议。基于ARP命令和Ethereal进行以太网帧捕获与分析,理解和熟悉ARP协议原理以及以太网帧格式。 二、实验环境 与因特网连接的计算机网络系统;主机操…...

SICP : The Elements of Programming

好的计算机编程语言应具备的三个特性 基础单元表达式&#xff0c;计算机编程语言最最最基础单元&#xff0c;理应具备的表达式组合的能力&#xff0c;能够通过基础单元表达式组合成更复杂的元素抽象的能力&#xff0c;能通过复杂的元素抽象成更高层的单元 基础单元表达式 加 …...

支付宝、学习强国小程序input、textarea数据双向绑定

前言 和 vue 的绑定有些区别&#xff0c;需要注意。直接 value"{{inputValue}}" 是无法双向绑定的。 正确思路 文档说的比较详细&#xff0c;不过没有组合使用的案例&#xff0c;需要自行理解。这里正确的方法是先用 value 绑定数据&#xff0c;再使用 onInput 事件…...

AI“百模大战”现状:向垂直、B端谋场景,算力仍是主要制约因素

文章目录 每日一句正能量前言AI&#xff08;人工智能&#xff09;大模型正“飞入”百姓家和行业中。向垂直、B端谋场景算力仍是主要制约因素构建“数据-模型-应用”飞轮后记 每日一句正能量 我们必须在失败中寻找胜利&#xff0c;在绝望中寻求希望。 前言 在当前快速发展的人工…...

手机上的软件怎么修改网络IP地址

在手机上修改网络IP地址通常需要通过以下两种方法&#xff1a; 1. 使用VPN&#xff08;虚拟私人网络&#xff09;或代理软件&#xff1a; 步骤如下&#xff1a; - 下载并安装一个可靠的VPN或代理软件到你的手机上。 - 打开VPN或代理软件&#xff0c;选择一个你希望获取IP地址…...

返回按钮点击坐标

返回按钮的点击坐标&#xff08;按钮本身的相对位置&#xff09;主要用于自绘控件时响应点击对应的数据变化。效果如下图&#xff1a; 代码实现 private void button1_MouseClick(object sender, MouseEventArgs e){Point p e.Location;this.Text p.ToString();} 利用 Mouse…...

arm32 arm64 读取PMCCNTR cpu cycle counter

ARM 的时钟周期计数保存在PMCCNTR 寄存器&#xff0c;不像x86用户态可以直接读取&#xff0c;需内核态使能&#xff0c;一种是在内核中使能&#xff0c;比如init&#xff0c;比较简单的是在模块中使能。 本来写了两个&#xff0c;arm32一个&#xff0c;arm64一个&#xff0c;方…...

vue 项目/备案网页/ip网页打包成 apk 安装到平板/手机(含vue项目跨域代理打包成apk后无法访问接口的解决方案)

下载安装HBuilder X编辑器 https://www.dcloud.io/hbuilderx.html 新建 5APP 项目 打开 HBuilder X&#xff0c;新建项目 此处项目名以 ‘test’ 为例 含跨域代理的vue项目改造 若 vue 项目中含跨域代理&#xff0c;如 vue.config.js module.exports {publicPath: "./&…...

面试复盘4——后端开发——一面

前言 本文主要用于个人复盘学习&#xff0c;因此为保障公平&#xff0c;所以本文不指出公司名&#xff0c;题目编号只是为了自己区别而已。对待面经&#xff0c;望读者还是更多从其中学习总结&#xff0c;而不是去碰原题。 面试岗位信息 北京某初创&#xff0c;go开发&#…...

使用 Postman 进行并发请求:实用教程与最佳实践

背景介绍 最近&#xff0c;我们发起了一个在线图书管理系统的项目。我负责的一个关键模块包括三个主要后台接口&#xff1a; 实现对books数据的检索。实施对likes数据的获取。通过collections端点访问数据。 应对高流量的挑战 在设计并部署接口时&#xff0c;我们不可避免地…...

河南工程学院第六届程序设计竞赛-A组-题解

更好的阅读体验 \color{red}{更好的阅读体验} 更好的阅读体验 远古时期的签到题 原题链接 描述&#xff1a; 远古时期奇妙的事情… 远古时期有一个比赛&#xff0c;里面有这样一道签到题&#xff1a; 给定一个正整数 N N N求这个整数转化为二进制后的数有多少位是 0 0 0。…...

韩版传奇 2 源码分析与 Unity 重制(二)客户端启动与交互流程

专题介绍 该专题将会分析 LOMCN 基于韩版传奇 2&#xff0c;使用 .NET 重写的传奇源码&#xff08;服务端 客户端&#xff09;&#xff0c;分析数据交互、状态管理和客户端渲染等技术&#xff0c;此外笔者还会分享将客户端部分移植到 Unity 和服务端用现代编程语言重写的全过…...

JVM面试——运行时数据区

一&#xff1a;JVM的运行时内存区域是怎样的? 根据Java虚拟机规范的定义&#xff0c;JVM的运行时内存区域主要由程序计数器、虚拟机栈、本地方法 栈、Java堆、方法区和以及运行时常量池组成。其中堆、方法区以及运行时常量池是线程之间共享的区域&#xff0c;而栈&#xff08…...

ssh工具 向指定的ssh服务器配置公钥

此文分享一个python脚本,用于向指定的ssh服务器配置公钥,以达到免密登录ssh服务器的目的。 效果演示 🔥完整演示效果 👇第一步,显然,我们需要选择功能 👇第二步,确认 or 选择ssh服务器 👇第三步,输入ssh登录密码,以完成公钥配置 👇验证,我们通过ssh登录…...

uni-app pages.json之globalStyle全局页面样式配置

锋哥原创的uni-app视频教程&#xff1a; 2023版uniapp从入门到上天视频教程(Java后端无废话版)&#xff0c;火爆更新中..._哔哩哔哩_bilibili2023版uniapp从入门到上天视频教程(Java后端无废话版)&#xff0c;火爆更新中...共计23条视频&#xff0c;包括&#xff1a;第1讲 uni…...

Blazor 混合开发_MAUI+Vue_WPF+Vue

Blazor 混合开发_MAUIVue_WPFVue 背景混合开发的核心为什么必须使用 wwwroot 文件夹放置 Web 项目文件 创建 MAUI 项目创建 wwwroot 文件夹服务注册创建 _import.razor添加 Main.razor 组件修改 MainPage.xaml 文件 创建 WPF 项目创建 wwwroot 文件夹服务注册创建 _import.razo…...

udp异步方式接收消息

C#实现 //定义结构体 public struct UdpState { public UdpClient u; public IPEndPoint e; } private UdpClient _client; //_client的初始化请参考其他资料 IPEndPoint remoteEP null; //TODO //public static bool mess…...

【RocketMQ笔记01】安装RocketMQ消息队列运行环境

这篇文章&#xff0c;主要介绍如何安装RocketMQ消息队列运行环境。 目录 一、RocketMQ消息队列 1.1、下载RocketMQ 1.2、解压安装包 1.3、配置RocketMQ环境变量 1.4、修改启动脚本 1.5、启动RocketMQ &#xff08;1&#xff09;启动NameServer &#xff08;2&#xff0…...

使用 Privoxy 实现对多域名的定向转发

需求与思路 内网一台主机想要访问公网的两个不同站点, 想要实现访问两个站点时表现出不同的公网 IP 地址. 即在公网的站点服务器端看到的客户端 IP 是不同的. 思路是搭建两台具有不同公网 IP 的服务器, 分别安装配置 Privoxy 后进行串联, 并将其中一台作为主服务器暴露给内网…...

《PySpark大数据分析实战》-19.NumPy介绍ndarray介绍

&#x1f4cb; 博主简介 &#x1f496; 作者简介&#xff1a;大家好&#xff0c;我是wux_labs。&#x1f61c; 热衷于各种主流技术&#xff0c;热爱数据科学、机器学习、云计算、人工智能。 通过了TiDB数据库专员&#xff08;PCTA&#xff09;、TiDB数据库专家&#xff08;PCTP…...

图解LRU缓存

图解LRU缓存 OJ链接 介绍 LRU 缓存机制可以通过哈希表辅以双向链表实现&#xff0c;我们用一个哈希表和一个双向链表维护所有在缓存中的键值对。 双向链表按照被使用的顺序存储了这些键值对&#xff0c;靠近尾部的键值对是最近使用的&#xff0c;而靠近头部的键值对是最久未…...

FFmpeg常见命令行

1、ffmpeg命令行 视频生成图片 ffmpeg -i test.mp4 -r 25 -f image2 data/image%3d.jpg这个命令行使用FFmpeg工具将视频文件&#xff08;test.mp4&#xff09;转换为一系列图像文件。 让我们逐个解释每个参数的含义&#xff1a; -i test.mp4: 指定输入文件为test.mp4。-i是F…...

智能优化算法应用:基于斑马算法3D无线传感器网络(WSN)覆盖优化 - 附代码

智能优化算法应用&#xff1a;基于斑马算法3D无线传感器网络(WSN)覆盖优化 - 附代码 文章目录 智能优化算法应用&#xff1a;基于斑马算法3D无线传感器网络(WSN)覆盖优化 - 附代码1.无线传感网络节点模型2.覆盖数学模型及分析3.斑马算法4.实验参数设定5.算法结果6.参考文献7.MA…...

《C++避坑神器·二十五》简单搞懂json文件的读写之遍历json文件读写

json.hpp库放在文章末尾 1、遍历json文件读写 &#xff08;1&#xff09;插入新键值对到json之情形1 原来json文件如下所示&#xff1a; {"Connection": {"IpAddress": "192.168.20.1","Rock": 0,"Solt": 1}, "Data…...

使用 fixture 机制重构 appium_helloworld

一、前置说明 在 pytest 基础讲解 章节,介绍了 pytest 的特性和基本用法,现在我们可以使用 pytest 的一些机制,来重构 appium_helloworld 。 appium_helloworld 链接: 编写第一个APP自动化脚本 appium_helloworld ,将脚本跑起来 代码目录结构: pytest.ini 设置: [pyt…...

基于python的excel检查和读写软件

软件版本&#xff1a;python3.6 窗口和界面gui代码&#xff1a; class mygui:def _init_(self):passdef run(self):root Tkinter.Tk()root.title(ExcelRun)max_w, max_h root.maxsize()root.geometry(f500x500{int((max_w - 500) / 2)}{int((max_h - 300) / 2)}) # 居中显示…...

Podman配置mongodb

文章目录 查询镜像拉取镜像查看镜像运行容器创建root用户 查询镜像 podman search mongo拉取镜像 podman pull docker.io/library/mongo查看镜像 podman images运行容器 podman run -d -p 27017:27017 --namemongodb-test docker.io/library/mongo创建root用户 podman exe…...

java实现矩阵谱峰搜索算法

矩阵谱峰搜索算法&#xff0c;也称为矩阵谱峰查找算法&#xff0c;是一种用于搜索二维矩阵中谱峰的方法。谱峰是指在矩阵中的一个元素&#xff0c;它比其上下左右四个相邻元素都大或相等。 该算法的基本思想是从矩阵的中间列开始&#xff0c;找到该列中的最大元素&#xff0c;…...

Jenkins的特殊操作定时自动执行任务以及测试报告调优

java -Dhudson.model.DirectoryBrowserSupport.CSP -jar Jenkins.war 测试报告 不美丽 执行上面的代码 重启jenkins 就好了...

【Grafana】Grafana匿名访问以及与LDAP连接

上一篇文章利用Docker快速部署了Grafana用来展示Zabbix得监控数据&#xff0c;但还需要给用户去创建账号允许他们登录后才能看展示得数据&#xff0c;那有什么办法让非管理员更方便得去访问Grafana呢&#xff1f;下面介绍两个比较方便实现的&#xff1a; 在开始设置前&#xff…...

elasticsearch-py 8.x的一些优势

​ 早在 2022 年 2 月,当 Elasticsearch 8.0 发布时,Python 客户端也发布了 8.0 版本。它是对 7.x 客户端的部分重写,并带有许多不错的功能(如下所述),但也带有弃用警告和重大更改。今天,客户端的 7.17 版本仍然相对流行,每月下载量超过 100 万次,占 8.x 下载量的 ~50…...

RK3588平台开发系列讲解(AI 篇)RKNN 数据结构详解

文章目录 一、rknn_sdk_version二、rknn_input_output_num三、rknn_tensor_attr四、rknn_perf_detail五、rknn_perf_run六、rknn_mem_size七、rknn_tensor_mem八、rknn_input九、rknn_output沉淀、分享、成长,让自己和他人都能有所收获!😄 📢本篇章主要讲解 RKNN 相关的数…...

2023版本QT学习记录 -6- UDP通信之UDP接收端

———————UDP接收端——————— &#x1f384;动图演示 &#x1f384;发送端通信步骤思维导图 &#x1f384;添加组件 QT core gui network&#x1f384;添加头文件 #include "qudpsocket.h"&#x1f384;创建接收对象 QUdpSocket *recvsocket;&…...

C预处理 | pragma详解

欢迎关注博主 Mindtechnist 或加入【Linux C/C/Python社区】一起学习和分享Linux、C、C、Python、Matlab&#xff0c;机器人运动控制、多机器人协作&#xff0c;智能优化算法&#xff0c;滤波估计、多传感器信息融合&#xff0c;机器学习&#xff0c;人工智能等相关领域的知识和…...

轻松搭建知识付费小程序:让知识传播更便捷

明理信息科技saas知识付费平台 在当今数字化时代&#xff0c;知识付费已经成为一种趋势&#xff0c;越来越多的人愿意为有价值的知识付费。然而&#xff0c;公共知识付费平台虽然内容丰富&#xff0c;但难以满足个人或企业个性化的需求和品牌打造。同时&#xff0c;开发和维护…...

沉浸式go-cache源码阅读!

大家好&#xff0c;我是豆小匠。 这期来阅读go-cache的源码&#xff0c;了解本地缓存的实现方式&#xff0c;同时掌握一些阅读源码的技巧~ 1. 源码获取 git clone https://github.com/patrickmn/go-cache.git用Goland打开可以看到真正实现功能的也就两个go文件&#xff0c;ca…...

伪协议和反序列化 [ZJCTF 2019]NiZhuanSiWei

打开题目 代码审计 第一层绕过 if(isset($text)&&(file_get_contents($text,r)"welcome to the zjctf")){ echo "<br><h1>".file_get_contents($text,r)."</h1></br>"; 要求我们get传参的text内容必须为w…...

性能优化之资源优化

性能优化之资源优化 资源优化性能关键检测流程。浅析一下基于Unity3D 美术规则约束一、模型层面二、贴图层面三、动画层面四、声音层面&#xff1a;&#xff08;音频通用设置&#xff09;五、UI层面&#xff1a; 题外点&#xff1a;诚然在优化中&#xff0c;美术占比是很重要的…...

ChatGPT免费 | 8个免费使用GPT-4的方法

这篇文章为寻找免费使用GPT-4技术的读者提供了一份实用的指南。 每个推荐的平台都包括了简要的描述和链接&#xff0c;方便读者直接访问。 以下是根据你提供的内容&#xff0c;稍作整理的文章结构&#xff1a; 1. HuggingFace 描述: 提供GPT-4等多种语言模型的平台。 如何使用:…...

解决Qt“报无法定位程序输入点xxx于动态连接库“问题

今天&#xff0c;在使用QtVS2019编译工程时&#xff0c;弹出"无法定位程序输入点xxx于动态链接库"问题&#xff0c;如图(1)所示&#xff1a; 图(1) 报"无法定位程序输入点xxx于动态链接库"问题 出现这种问题的原因有很多&#xff1a; (1) 工程Release/Deb…...

wpf-MVVM绑定时可能出现的内存泄漏问题

文章速览 引言错误示范示例1示例2 坚持记录实属不易&#xff0c;希望友善多金的码友能够随手点一个赞。 共同创建氛围更加良好的开发者社区&#xff01; 谢谢~ 引言 正确结构&#xff1a; Model <——> ViewModel <——> View 但很多时候&#xff0c;很容易出现…...