37.利用linprog解 有约束条件多元变量函数最小值(matlab程序)
1.简述
linprog函数主要用来求线型规划中的最小值问题(最大值的镜像问题,求最大值只需要加个“-”)
2. 算法结构及使用方法
针对约束条件为Ax=b或Ax≤b的问题
2.1 linprog函数
x=linprog(f,A,b)
x=linprog(f,A,b,Aeq,beq)
x=linprog(f,A,b,Aeq,beq,lb,ub)
x=linprog(f,A,b,Aeq,beq,lb,ub,x0)
2.2 参数简介
f:目标函数
A:不等式约束条件矩阵
b:对应不等式右侧的矩阵
Aeq:等式约束条件矩阵
beq:不等式右侧的矩阵
Aeq:等式约束条件矩阵
beq:对应等式右侧的矩阵
lb:x的下界
ub:x的上界
x0:设置初始点x0,这个选择项只是对medium-scale算法有效。默认的large-scale算法和简单的算法忽略任何初始点。(一般用不到)
2.3 常用linprog函数及用法举例
linprog函数常用形式为:
x=linprog(f,A,b,Aep,beq,lb,ub);
例子: 学习目标:有约束条件多元变量函数最小值
适合 计划生产盈利最大 的模式求解,
最大值解法可转化为求解最小值算法,非常容易
求最大值转化为求最小值 f=70*x1+120*x2 的最大值,当然x1,x2是有约束的。
转化为求 f=-(70*x1+120*x2) 的最小值。
约束条件:9*x1+4*x2<=3600;4*x1+5*x2<=2000;3*x1+10*x2<=3000;-x1,-x2<
2.代码
主函数:
clc
clear
f=[-70 -120];
A=[9 4;4 5;3 10];
B=[3600;2000;3000];
Aeq=[]; Beq=[];
lb=[0 0];ub=[inf inf];
x0=[1 1];
options=optimset('display','iter','Tolx',1e-8);
[x,f,exitflag]=linprog(f,A,B,Aeq,Beq,lb,ub,x0,options)
%[xmincon,fval,exitflag,output] = fmincon(@(x)-(70*x(1)+120*x(2)),x0,A,B,Aeq,Beq,lb,ub,[],options)
子函数:
function [x,fval,exitflag,output,lambda]=linprog(f,A,B,Aeq,Beq,lb,ub,x0,options)
%LINPROG Linear programming.
% X = LINPROG(f,A,b) attempts to solve the linear programming problem:
%
% min f'*x subject to: A*x <= b
% x
%
% X = LINPROG(f,A,b,Aeq,beq) solves the problem above while additionally
% satisfying the equality constraints Aeq*x = beq. (Set A=[] and B=[] if
% no inequalities exist.)
%
% X = LINPROG(f,A,b,Aeq,beq,LB,UB) defines a set of lower and upper
% bounds on the design variables, X, so that the solution is in
% the range LB <= X <= UB. Use empty matrices for LB and UB
% if no bounds exist. Set LB(i) = -Inf if X(i) is unbounded below;
% set UB(i) = Inf if X(i) is unbounded above.
%
% X = LINPROG(f,A,b,Aeq,beq,LB,UB,X0) sets the starting point to X0. This
% option is only available with the active-set algorithm. The default
% interior point algorithm will ignore any non-empty starting point.
%
% X = LINPROG(PROBLEM) finds the minimum for PROBLEM. PROBLEM is a
% structure with the vector 'f' in PROBLEM.f, the linear inequality
% constraints in PROBLEM.Aineq and PROBLEM.bineq, the linear equality
% constraints in PROBLEM.Aeq and PROBLEM.beq, the lower bounds in
% PROBLEM.lb, the upper bounds in PROBLEM.ub, the start point
% in PROBLEM.x0, the options structure in PROBLEM.options, and solver
% name 'linprog' in PROBLEM.solver. Use this syntax to solve at the
% command line a problem exported from OPTIMTOOL.
%
% [X,FVAL] = LINPROG(f,A,b) returns the value of the objective function
% at X: FVAL = f'*X.
%
% [X,FVAL,EXITFLAG] = LINPROG(f,A,b) returns an EXITFLAG that describes
% the exit condition. Possible values of EXITFLAG and the corresponding
% exit conditions are
%
% 3 LINPROG converged to a solution X with poor constraint feasibility.
% 1 LINPROG converged to a solution X.
% 0 Maximum number of iterations reached.
% -2 No feasible point found.
% -3 Problem is unbounded.
% -4 NaN value encountered during execution of algorithm.
% -5 Both primal and dual problems are infeasible.
% -7 Magnitude of search direction became too small; no further
% progress can be made. The problem is ill-posed or badly
% conditioned.
% -9 LINPROG lost feasibility probably due to ill-conditioned matrix.
%
% [X,FVAL,EXITFLAG,OUTPUT] = LINPROG(f,A,b) returns a structure OUTPUT
% with the number of iterations taken in OUTPUT.iterations, maximum of
% constraint violations in OUTPUT.constrviolation, the type of
% algorithm used in OUTPUT.algorithm, the number of conjugate gradient
% iterations in OUTPUT.cgiterations (= 0, included for backward
% compatibility), and the exit message in OUTPUT.message.
%
% [X,FVAL,EXITFLAG,OUTPUT,LAMBDA] = LINPROG(f,A,b) returns the set of
% Lagrangian multipliers LAMBDA, at the solution: LAMBDA.ineqlin for the
% linear inequalities A, LAMBDA.eqlin for the linear equalities Aeq,
% LAMBDA.lower for LB, and LAMBDA.upper for UB.
%
% NOTE: the interior-point (the default) algorithm of LINPROG uses a
% primal-dual method. Both the primal problem and the dual problem
% must be feasible for convergence. Infeasibility messages of
% either the primal or dual, or both, are given as appropriate. The
% primal problem in standard form is
% min f'*x such that A*x = b, x >= 0.
% The dual problem is
% max b'*y such that A'*y + s = f, s >= 0.
%
% See also QUADPROG.
% Copyright 1990-2018 The MathWorks, Inc.
% If just 'defaults' passed in, return the default options in X
% Default MaxIter, TolCon and TolFun is set to [] because its value depends
% on the algorithm.
defaultopt = struct( ...
'Algorithm','dual-simplex', ...
'Diagnostics','off', ...
'Display','final', ...
'LargeScale','on', ...
'MaxIter',[], ...
'MaxTime', Inf, ...
'Preprocess','basic', ...
'TolCon',[],...
'TolFun',[]);
if nargin==1 && nargout <= 1 && strcmpi(f,'defaults')
x = defaultopt;
return
end
% Handle missing arguments
if nargin < 9
options = [];
% Check if x0 was omitted and options were passed instead
if nargin == 8
if isa(x0, 'struct') || isa(x0, 'optim.options.SolverOptions')
options = x0;
x0 = [];
end
else
x0 = [];
if nargin < 7
ub = [];
if nargin < 6
lb = [];
if nargin < 5
Beq = [];
if nargin < 4
Aeq = [];
end
end
end
end
end
end
% Detect problem structure input
problemInput = false;
if nargin == 1
if isa(f,'struct')
problemInput = true;
[f,A,B,Aeq,Beq,lb,ub,x0,options] = separateOptimStruct(f);
else % Single input and non-structure.
error(message('optim:linprog:InputArg'));
end
end
% No options passed. Set options directly to defaultopt after
allDefaultOpts = isempty(options);
% Prepare the options for the solver
options = prepareOptionsForSolver(options, 'linprog');
if nargin < 3 && ~problemInput
error(message('optim:linprog:NotEnoughInputs'))
end
% Define algorithm strings
thisFcn = 'linprog';
algIP = 'interior-point-legacy';
algDSX = 'dual-simplex';
algIP15b = 'interior-point';
% Check for non-double inputs
msg = isoptimargdbl(upper(thisFcn), {'f','A','b','Aeq','beq','LB','UB', 'X0'}, ...
f, A, B, Aeq, Beq, lb, ub, x0);
if ~isempty(msg)
error('optim:linprog:NonDoubleInput',msg);
end
% After processing options for optionFeedback, etc., set options to default
% if no options were passed.
if allDefaultOpts
% Options are all default
options = defaultopt;
end
if nargout > 3
computeConstrViolation = true;
computeFirstOrderOpt = true;
% Lagrange multipliers are needed to compute first-order optimality
computeLambda = true;
else
computeConstrViolation = false;
computeFirstOrderOpt = false;
computeLambda = false;
end
% Algorithm check:
% If Algorithm is empty, it is set to its default value.
algIsEmpty = ~isfield(options,'Algorithm') || isempty(options.Algorithm);
if ~algIsEmpty
Algorithm = optimget(options,'Algorithm',defaultopt,'fast',allDefaultOpts);
OUTPUT.algorithm = Algorithm;
% Make sure the algorithm choice is valid
if ~any(strcmp({algIP; algDSX; algIP15b},Algorithm))
error(message('optim:linprog:InvalidAlgorithm'));
end
else
Algorithm = algDSX;
OUTPUT.algorithm = Algorithm;
end
% Option LargeScale = 'off' is ignored
largescaleOn = strcmpi(optimget(options,'LargeScale',defaultopt,'fast',allDefaultOpts),'on');
if ~largescaleOn
[linkTag, endLinkTag] = linkToAlgDefaultChangeCsh('linprog_warn_largescale');
warning(message('optim:linprog:AlgOptsConflict', Algorithm, linkTag, endLinkTag));
end
% Options setup
diagnostics = strcmpi(optimget(options,'Diagnostics',defaultopt,'fast',allDefaultOpts),'on');
switch optimget(options,'Display',defaultopt,'fast',allDefaultOpts)
case {'final','final-detailed'}
verbosity = 1;
case {'off','none'}
verbosity = 0;
case {'iter','iter-detailed'}
verbosity = 2;
case {'testing'}
verbosity = 3;
otherwise
verbosity = 1;
end
% Set the constraints up: defaults and check size
[nineqcstr,nvarsineq] = size(A);
[neqcstr,nvarseq] = size(Aeq);
nvars = max([length(f),nvarsineq,nvarseq]); % In case A is empty
if nvars == 0
% The problem is empty possibly due to some error in input.
error(message('optim:linprog:EmptyProblem'));
end
if isempty(f), f=zeros(nvars,1); end
if isempty(A), A=zeros(0,nvars); end
if isempty(B), B=zeros(0,1); end
if isempty(Aeq), Aeq=zeros(0,nvars); end
if isempty(Beq), Beq=zeros(0,1); end
% Set to column vectors
f = f(:);
B = B(:);
Beq = Beq(:);
if ~isequal(length(B),nineqcstr)
error(message('optim:linprog:SizeMismatchRowsOfA'));
elseif ~isequal(length(Beq),neqcstr)
error(message('optim:linprog:SizeMismatchRowsOfAeq'));
elseif ~isequal(length(f),nvarsineq) && ~isempty(A)
error(message('optim:linprog:SizeMismatchColsOfA'));
elseif ~isequal(length(f),nvarseq) && ~isempty(Aeq)
error(message('optim:linprog:SizeMismatchColsOfAeq'));
end
[x0,lb,ub,msg] = checkbounds(x0,lb,ub,nvars);
if ~isempty(msg)
exitflag = -2;
x = x0; fval = []; lambda = [];
output.iterations = 0;
output.constrviolation = [];
output.firstorderopt = [];
output.algorithm = ''; % not known at this stage
output.cgiterations = [];
output.message = msg;
if verbosity > 0
disp(msg)
end
return
end
if diagnostics
% Do diagnostics on information so far
gradflag = []; hessflag = []; constflag = false; gradconstflag = false;
non_eq=0;non_ineq=0; lin_eq=size(Aeq,1); lin_ineq=size(A,1); XOUT=ones(nvars,1);
funfcn{1} = []; confcn{1}=[];
diagnose('linprog',OUTPUT,gradflag,hessflag,constflag,gradconstflag,...
XOUT,non_eq,non_ineq,lin_eq,lin_ineq,lb,ub,funfcn,confcn);
end
% Throw warning that x0 is ignored (true for all algorithms)
if ~isempty(x0) && verbosity > 0
fprintf(getString(message('optim:linprog:IgnoreX0',Algorithm)));
end
if strcmpi(Algorithm,algIP)
% Set the default values of TolFun and MaxIter for this algorithm
defaultopt.TolFun = 1e-8;
defaultopt.MaxIter = 85;
[x,fval,lambda,exitflag,output] = lipsol(f,A,B,Aeq,Beq,lb,ub,options,defaultopt,computeLambda);
elseif strcmpi(Algorithm,algDSX) || strcmpi(Algorithm,algIP15b)
% Create linprog options object
algoptions = optimoptions('linprog', 'Algorithm', Algorithm);
% Set some algorithm specific options
if isfield(options, 'InternalOptions')
algoptions = setInternalOptions(algoptions, options.InternalOptions);
end
thisMaxIter = optimget(options,'MaxIter',defaultopt,'fast',allDefaultOpts);
if strcmpi(Algorithm,algIP15b)
if ischar(thisMaxIter)
error(message('optim:linprog:InvalidMaxIter'));
end
end
if strcmpi(Algorithm,algDSX)
algoptions.Preprocess = optimget(options,'Preprocess',defaultopt,'fast',allDefaultOpts);
algoptions.MaxTime = optimget(options,'MaxTime',defaultopt,'fast',allDefaultOpts);
if ischar(thisMaxIter) && ...
~strcmpi(thisMaxIter,'10*(numberofequalities+numberofinequalities+numberofvariables)')
error(message('optim:linprog:InvalidMaxIter'));
end
end
% Set options common to dual-simplex and interior-point-r2015b
algoptions.Diagnostics = optimget(options,'Diagnostics',defaultopt,'fast',allDefaultOpts);
algoptions.Display = optimget(options,'Display',defaultopt,'fast',allDefaultOpts);
thisTolCon = optimget(options,'TolCon',defaultopt,'fast',allDefaultOpts);
if ~isempty(thisTolCon)
algoptions.TolCon = thisTolCon;
end
thisTolFun = optimget(options,'TolFun',defaultopt,'fast',allDefaultOpts);
if ~isempty(thisTolFun)
algoptions.TolFun = thisTolFun;
end
if ~isempty(thisMaxIter) && ~ischar(thisMaxIter)
% At this point, thisMaxIter is either
% * a double that we can set in the options object or
% * the default string, which we do not have to set as algoptions
% is constructed with MaxIter at its default value
algoptions.MaxIter = thisMaxIter;
end
% Create a problem structure. Individually creating each field is quicker
% than one call to struct
problem.f = f;
problem.Aineq = A;
problem.bineq = B;
problem.Aeq = Aeq;
problem.beq = Beq;
problem.lb = lb;
problem.ub = ub;
problem.options = algoptions;
problem.solver = 'linprog';
% Create the algorithm from the options.
algorithm = createAlgorithm(problem.options);
% Check that we can run the problem.
try
problem = checkRun(algorithm, problem, 'linprog');
catch ME
throw(ME);
end
% Run the algorithm
[x, fval, exitflag, output, lambda] = run(algorithm, problem);
% If exitflag is {NaN, <aString>}, this means an internal error has been
% thrown. The internal exit code is held in exitflag{2}.
if iscell(exitflag) && isnan(exitflag{1})
handleInternalError(exitflag{2}, 'linprog');
end
end
output.algorithm = Algorithm;
% Compute constraint violation when x is not empty (interior-point/simplex presolve
% can return empty x).
if computeConstrViolation && ~isempty(x)
output.constrviolation = max([0; norm(Aeq*x-Beq, inf); (lb-x); (x-ub); (A*x-B)]);
else
output.constrviolation = [];
end
% Compute first order optimality if needed. This information does not come
% from either qpsub, lipsol, or simplex.
if exitflag ~= -9 && computeFirstOrderOpt && ~isempty(lambda)
output.firstorderopt = computeKKTErrorForQPLP([],f,A,B,Aeq,Beq,lb,ub,lambda,x);
else
output.firstorderopt = [];
end
3.运行结果
相关文章:

37.利用linprog解 有约束条件多元变量函数最小值(matlab程序)
1.简述 linprog函数主要用来求线型规划中的最小值问题(最大值的镜像问题,求最大值只需要加个“-”) 2. 算法结构及使用方法 针对约束条件为Axb或Ax≤b的问题 2.1 linprog函数 xlinprog(f,A,b) xlinprog(f,A,b,Aeq,beq) xlinprog(f,A,b,Aeq,…...

分页Demo
目录 一、分页对象封装 分页数据对象 分页查询实体类 实体类用到的utils ServiceException StringUtils SqlUtil BaseMapperPlus,> BeanCopyUtils 二、示例 controller service dao 一、分页对象封装 分页数据对象 import cn.hutool.http.HttpStatus; import com.…...
ChatGPT超详细介绍与功能与免费网页版(超全面!)
ChatGPT ChatGPT前言ChatGPT介绍ChatGPT的优点关于ChatGPT的一些问题1.chatgpt是什么意思?2.chatgpt国内能用吗? 国内可用的ChatGPT网页版:1.ChatGPT prompts2.这个网站收集了5000多个ChatGPT 应用,可以在线运行3.ChatGPT Box4.飞书chatgpt5.AI-Produc…...

3.PyCharm安装
PyCharm是由JetBrains推出的Python开发IDE,是最受欢迎的Python IDE之一。PyCharm为Python开发者提供了许多高级功能如代码自动完成、调试等。它使用智能引擎来分析代码,能够自动识别代码中的错误并提供快速修复方案。PyCharm适用于各种规模的项目,包括小型Python脚本和大型P…...

【C语言进阶篇】关于指针的八个经典笔试题(图文详解)
🎬 鸽芷咕:个人主页 🔥 个人专栏:《C语言初阶篇》 《C语言进阶篇》 ⛺️生活的理想,就是为了理想的生活! 文章目录 📋 前言💬 指针笔试题💭 笔试题 1:✅ 代码解析⁉️ 检验结果&…...
用Rust实现23种设计模式之 策略模式
关注我,学习Rust不迷路!! 优点 灵活性:策略模式允许你在运行时动态地选择不同的算法或行为,而无需修改已有的代码。可扩展性:通过添加新的策略类,你可以轻松地扩展策略模式的功能。可维护性&a…...

面试题:说说JS的this指向问题?
1、this永远指向一个对象; 2、this的指向完全取决于函数调用的位置; 可以借鉴这篇文章,说的很详细(点击) 总结: 1、 以方法的形式调用时, this 是调用方法的对象; 2、绑定事件函…...
ansible——roles 角色
一、概述 1.roles角色简介 roles用于层次性、结构化地组织playbook。roles能够根据层次型结构自动装载变量文件、tasks以及handlers等。要使用roles只需要在playbook中使用include指令引入即可。 简单来讲,roles就是通过分别将变量、文件、任务、模板及处理器放置…...

GitHub上删除项目后,IDEA分享项目到GitHub提示Remote is already on GitHub
文章目录 一、错误信息二、解决方法1.删除GitHub上的项目2.找到项目里的.git隐藏文件3.找到config文件4.打开config文件,删除[remote "git-test"]及下面两行内容5.继续使用IDEA分享项目到GitHub即可 一、错误信息 二、解决方法 1.删除GitHub上的项目 2.…...

【机器学习 | 决策树】利用数据的潜力:用决策树解锁洞察力
🤵♂️ 个人主页: AI_magician 📡主页地址: 作者简介:CSDN内容合伙人,全栈领域优质创作者。 👨💻景愿:旨在于能和更多的热爱计算机的伙伴一起成长!!&…...

postgis mvt矢量切片 django drf mapboxgl
postgis mvt矢量切片 django drf mapboxgl 目录 0.前提 1.sql代码 2.django drf后端服务代码 3.具体的应用(整体代码) 4.参考 0.前提 [1] 静态的矢量切片可以采用 tippecanoe 生成,nginx代理,这种数据是不更新的;…...
C语言编程工具软件推荐!
1、VS(Visual Studio) [VS是目前最受欢迎的适用于Windows平台应用程序的综合开发环境,由于大多数同学使用的都是Windows操作系统,因此VS非常适合大家。在日常课堂和考试中,我们使用的VS2010支持多种不同的编程语言,VS2010最初支持…...

单体架构和微服务架构的区别
文章目录 一、单体架构的定义1. 单体架构的优点:2. 单体架构的缺点: 二、微服务架构的定义1. 微服务架构的优点:2. 微服务架构的缺点: 三、单体架构VS微服务架构1. 区别:1.1 架构规模:1.2 依赖关系…...
python--local对象、flask上下文源码分析
一、local对象 背景: 多线成并发操作一个变量,会导致数据错乱,可以使用互斥锁加锁处理数据不安全的情况 (临界区) 解决: 使用local对象处理,多个线程操作的变量是local对象,就不会…...

类文件一些内容
1、类加载 将类的字节码加载到JVM中,并转换为可以被JVM运行的数据结构的过程 类文件结构...
28 Java练习——实现两个集合的交集和并集
求并集的思路:假设传入的是一个ArrayList对象,求并集的时候直接调用其中一个List集合的addAll方法将另一个集合合并过来,而List的特性是有序,重复的。因此,使用Set接口的无序不可重复的特性,把Collection对…...
ES6学习-Promise
Promise 简单说就是一个容器,里面保存着某个未来才会结束的事件(通常是一个异步操作)的结果。 语法上: Promise 是一个对象,从它可以获取异步操作的消息。 特点 对象的状态不受外界影响。Promise 对象戴白哦一个异步操…...

《Web安全基础》03. SQL 注入
web 1:简要 SQL 注入2:MySQL 注入2.1:信息获取2.2:跨库攻击2.3:文件读写2.4:常见防护 3:注入方法3.1:类型方法明确3.2:盲注3.3:编码3.4:二次注入3…...

算法与数据结构(二十一)二叉树(纲领篇)
备注:本文旨在通过 labuladong 的二叉树(纲领篇)理解框架思维,用于个人笔记及交流学习,版权归原作者 labuladong 所有; 我刷了这么多年题,浓缩出二叉树算法的一个总纲放在这里,也许…...

visio,word添加缺少字体,仿宋_GB2312、楷体_GB2312、方正小标宋简体等字体下载
一. 内容简介 visio,word添加缺少字体,仿宋_GB2312、楷体_GB2312、方正小标宋简体等字体下载 二. 软件环境 2.1 visio 三.主要流程 3.1 下载字体 http://www.downza.cn/ 微软官方给的链接好多字体没有,其他好多字体网站,就是给你看个样式ÿ…...
后进先出(LIFO)详解
LIFO 是 Last In, First Out 的缩写,中文译为后进先出。这是一种数据结构的工作原则,类似于一摞盘子或一叠书本: 最后放进去的元素最先出来 -想象往筒状容器里放盘子: (1)你放进的最后一个盘子(…...

linux arm系统烧录
1、打开瑞芯微程序 2、按住linux arm 的 recover按键 插入电源 3、当瑞芯微检测到有设备 4、松开recover按键 5、选择升级固件 6、点击固件选择本地刷机的linux arm 镜像 7、点击升级 (忘了有没有这步了 估计有) 刷机程序 和 镜像 就不提供了。要刷的时…...
【论文笔记】若干矿井粉尘检测算法概述
总的来说,传统机器学习、传统机器学习与深度学习的结合、LSTM等算法所需要的数据集来源于矿井传感器测量的粉尘浓度,通过建立回归模型来预测未来矿井的粉尘浓度。传统机器学习算法性能易受数据中极端值的影响。YOLO等计算机视觉算法所需要的数据集来源于…...

vue3+vite项目中使用.env文件环境变量方法
vue3vite项目中使用.env文件环境变量方法 .env文件作用命名规则常用的配置项示例使用方法注意事项在vite.config.js文件中读取环境变量方法 .env文件作用 .env 文件用于定义环境变量,这些变量可以在项目中通过 import.meta.env 进行访问。Vite 会自动加载这些环境变…...

selenium学习实战【Python爬虫】
selenium学习实战【Python爬虫】 文章目录 selenium学习实战【Python爬虫】一、声明二、学习目标三、安装依赖3.1 安装selenium库3.2 安装浏览器驱动3.2.1 查看Edge版本3.2.2 驱动安装 四、代码讲解4.1 配置浏览器4.2 加载更多4.3 寻找内容4.4 完整代码 五、报告文件爬取5.1 提…...
C++.OpenGL (20/64)混合(Blending)
混合(Blending) 透明效果核心原理 #mermaid-svg-SWG0UzVfJms7Sm3e {font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}#mermaid-svg-SWG0UzVfJms7Sm3e .error-icon{fill:#552222;}#mermaid-svg-SWG0UzVfJms7Sm3e .error-text{fill…...
日常一水C
多态 言简意赅:就是一个对象面对同一事件时做出的不同反应 而之前的继承中说过,当子类和父类的函数名相同时,会隐藏父类的同名函数转而调用子类的同名函数,如果要调用父类的同名函数,那么就需要对父类进行引用&#…...
文件上传漏洞防御全攻略
要全面防范文件上传漏洞,需构建多层防御体系,结合技术验证、存储隔离与权限控制: 🔒 一、基础防护层 前端校验(仅辅助) 通过JavaScript限制文件后缀名(白名单)和大小,提…...

C++中vector类型的介绍和使用
文章目录 一、vector 类型的简介1.1 基本介绍1.2 常见用法示例1.3 常见成员函数简表 二、vector 数据的插入2.1 push_back() —— 在尾部插入一个元素2.2 emplace_back() —— 在尾部“就地”构造对象2.3 insert() —— 在任意位置插入一个或多个元素2.4 emplace() —— 在任意…...

Linux入门课的思维导图
耗时两周,终于把慕课网上的Linux的基础入门课实操、总结完了! 第一次以Blog的形式做学习记录,过程很有意思,但也很耗时。 课程时长5h,涉及到很多专有名词,要去逐个查找,以前接触过的概念因为时…...