GPOPS-II教程(3): 航天器最优控制问题

文章目录

  • 问题描述
  • GPOPS代码
    • `main function`
    • `continuous function`
    • `endpoint function`
    • 完整代码
    • 代码仿真结果
  • 最后

问题描述

例子出自论文 Direct solution of nonlinear optimal control problems using quasilinearization and Chebyshev polynomials(DOI:10.1016/S0016-0032(02)00028-5) Section 5.2. Example 2: Rigid asymmetric spacecraft

题目如下:

一个刚体非对称航天器控制问题,其状态方程为

{ ω ˙ 1 = − I 3 − I 2 I 1 ω 2 ω 3 + u 1 I 1 , ω ˙ 2 = − I 1 − I 3 I 2 ω 1 ω 3 + u 2 I 2 , ω ˙ 3 = − I 2 − I 1 I 3 ω 1 ω 2 + u 3 I 3 , (1) \left \{ \begin{matrix} \dot{\omega}_1 = -\frac{I_3-I_2}{I_1} \omega_2 \omega_3 + \frac{u_1}{I_1}, \\ \dot{\omega}_2 = -\frac{I_1-I_3}{I_2} \omega_1 \omega_3 + \frac{u_2}{I_2}, \\ \dot{\omega}_3 = -\frac{I_2-I_1}{I_3} \omega_1 \omega_2 + \frac{u_3}{I_3}, \end{matrix} \right. \tag{1} ω˙1=I1I3I2ω2ω3+I1u1,ω˙2=I2I1I3ω1ω3+I2u2,ω˙3=I3I2I1ω1ω2+I3u3,(1)

式中, ω 1 \omega_1 ω1 ω 2 \omega_2 ω2 ω 3 \omega_3 ω3 为航天器的角速度。

控制量为 u 1 u_1 u1 u 2 u_2 u2 u 3 u_3 u3,目标函数为

J = 0.5 ∫ 0 100 ( u 1 2 + u 2 2 + u 3 2 ) d t . (2) J = 0.5 \int_{0}^{100}(u_1^2+u_2^2+u_3^2) \text{d}t. \tag{2} J=0.50100(u12+u22+u32)dt.(2)

其余参数为

ω 1 ( 0 ) = 0.01 r/s , ω 1 ( t f ) = 0 r/s , ω 2 ( 0 ) = 0.005 r/s , ω 2 ( t f ) = 0 r/s , ω 3 ( 0 ) = 0.001 r/s , ω 3 ( t f ) = 0 r/s , I 1 = 86.24 kg m 2 , I 2 = 85.07 kg m 2 , I 3 = 113.59 kg m 2 . (3) \begin{array}{lll} \omega_1(0)\ = 0.01\ \text{r/s} &, \ & \omega_1(t_f) = 0 \ \text{r/s}, \\ \omega_2(0)\ = 0.005\ \text{r/s} &, \ & \omega_2(t_f) = 0 \ \text{r/s}, \\ \omega_3(0)\ = 0.001\ \text{r/s} &, \ & \omega_3(t_f) = 0 \ \text{r/s}, \\ I_1=86.24 \ \text{kg m}^2 \ &,\ & I_2=85.07 \ \text{kg m}^2,\\ I_3=113.59 \ \text{kg m}^2. \end{array} \tag{3} ω1(0) =0.01 r/sω2(0) =0.005 r/sω3(0) =0.001 r/sI1=86.24 kg m2 I3=113.59 kg m2., , , , ω1(tf)=0 r/s,ω2(tf)=0 r/s,ω3(tf)=0 r/s,I2=85.07 kg m2,(3)

GPOPS代码

main function

首先设置GPOPS-II的参数。式 ( 3 ) (3) (3)给出了所有用到的参数,按照式 ( 3 ) (3) (3)写出代码即可。

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 功能描述:刚体非对称航天器控制问题
% 文件名解释:mainSpacecraftOCP.m 中,main 代表 主函数,
%             Spacecraft 代表 航天器,
%             OCP 代表 最优控制问题
% 作者:Lei Lie
% 时间:2024/06/22
% 版本:1.0
% - 完成了代码框架的初始搭建
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clc;clear;close all;
tic;
%% 01.初始参数设置
%-------------------------------------------------------------------------%
%----------------------- 设置问题的求解边界 ------------------------------%
%-------------------------------------------------------------------------%
% 设置时间
t0 = 0;
tf = 100;
% 设置状态量初值
w10 = .01;
w20 = .005;
w30 = .001;
% 设置状态量边界条件
w1_max = 1;
w1_min = 0;
w2_max = 1;
w2_min = 0;
w3_max = 1;
w3_min = 0;
% 设置控制量初值
u10 = -.009;
u20 = -.004;
u30 = -.001;
% 设置控制量边界条件
u1_max = 0;
u1_min = -.01;
u2_max = 0;
u2_min = -.01;
u3_max = 0;
u3_min = -.01;
% 设置静态参数
auxdata.I1 = 86.24;
auxdata.I2 = 85.07;
auxdata.I3 = 113.59;
% 设置不等式约束边界条件(路径约束)
path_max = .002;
path_min = 0;%% 02.边界条件设置
%-------------------------------------------------------------------------%
%------------------------ 将求解边界设置于问题中 -------------------------%
%-------------------------------------------------------------------------%
bounds.phase.initialtime.lower  = t0; 
bounds.phase.initialtime.upper  = t0;
bounds.phase.finaltime.lower    = tf; 
bounds.phase.finaltime.upper    = tf;
bounds.phase.initialstate.lower = [w10 w20 w30]; 
bounds.phase.initialstate.upper = [w10 w20 w30];
bounds.phase.state.lower        = [w1_min w2_min w3_min]; 
bounds.phase.state.upper        = [w1_max w2_max w3_max];
bounds.phase.finalstate.lower   = [0 0 0];
bounds.phase.finalstate.upper   = [0 0 0];
bounds.phase.control.lower      = [u1_min u2_min u3_min]; 
bounds.phase.control.upper      = [u1_max u2_max u3_max];
bounds.phase.integral.lower     = 0; 
bounds.phase.integral.upper     = 10000;%% 03.初值猜测
%-------------------------------------------------------------------------%
%------------------------------- 初值猜想 --------------------------------%
%-------------------------------------------------------------------------%
guess.phase.time     = [t0; tf]; 
guess.phase.state    = [[w10 w20 w30];[0 0 0]];
guess.phase.control  = [[u10 u20 u30];[u10 u20 u30]];
guess.phase.integral = 100;%% 04.设置GPOPS求解器参数
%-------------------------------------------------------------------------%
%---------------------------- 设置求解器参数 -----------------------------%        
%-------------------------------------------------------------------------%
setup.name = 'Spacecraft-OCP';
setup.functions.continuous  = @socpContinuous;
setup.functions.endpoint   	= @socpEndpoint;
setup.bounds                = bounds;
setup.guess                 = guess;
setup.auxdata               = auxdata;
setup.nlp.solver            = 'ipopt';
setup.derivatives.supplier  = 'sparseCD';
setup.derivatives.derivativelevel = 'second';
setup.mesh.method           = 'hp1';
setup.mesh.tolerance        = 1e-6;
setup.mesh.maxiteration     = 45;
setup.mesh.colpointsmax     = 4;
setup.mesh.colpointsmin     = 10;
setup.mesh.phase.fraction   = 0.1*ones(1,10);
setup.mesh.phase.colpoints  = 4*ones(1,10);
setup.method = 'RPMintegration';%% 05.求解
%-------------------------------------------------------------------------%
%----------------------- 使用 GPOPS2 求解最优控制问题 --------------------%
%-------------------------------------------------------------------------%
output = gpops2(setup);
solution = output.result.solution;
toc;

把结果画出来,代码如下。

%% 06.画图
t = solution.phase.time(:,1);
w1 = solution.phase.state(:,1);
w2 = solution.phase.state(:,2);
w3 = solution.phase.state(:,3);
u1 = solution.phase.control(:,1);
u2 = solution.phase.control(:,2);
u3 = solution.phase.control(:,3);figure('Color',[1,1,1]);
plot(t,w1,'-','LineWidth',1.5);hold on;
plot(t,w2,'-.','LineWidth',1.5);
plot(t,w3,'--','LineWidth',1.5);
xlabel('Time',...'FontWeight','bold');
ylabel('States',...'FontWeight','bold');
legend('w1','w2','w3',...'LineWidth',1,...'EdgeColor',[1,1,1],...'Orientation','horizontal',...'Position',[0.5,0.93,0.40,0.055]);
set(gca,'FontName','Times New Roman',...'FontSize',15,...'LineWidth',1.3);
print -dpng spacecraft_ocp_state.pngfigure('Color',[1,1,1]);
plot(t,u1,'-','LineWidth',1.5);hold on;
plot(t,u2,'-.','LineWidth',1.5);
plot(t,u3,'--','LineWidth',1.5);
xlabel('Time',...'FontWeight','bold');
ylabel('Control',...'FontWeight','bold');
legend('u1','u2','u3',...'LineWidth',1,...'EdgeColor',[1,1,1],...'Orientation','horizontal',...'Position',[0.5,0.93,0.40,0.055]);
set(gca,'FontName','Times New Roman',...'FontSize',15,...'LineWidth',1.3);
print -dpng spacecraft_ocp_control.png

continuous function

现在写动力学方程,再把式 ( 1 ) (1) (1)重新写一遍,放在这里。
{ ω ˙ 1 = − I 3 − I 2 I 1 ω 2 ω 3 + u 1 I 1 , ω ˙ 2 = − I 1 − I 3 I 2 ω 1 ω 3 + u 2 I 2 , ω ˙ 3 = − I 2 − I 1 I 3 ω 1 ω 2 + u 3 I 3 , \left \{ \begin{matrix} \dot{\omega}_1 = -\frac{I_3-I_2}{I_1} \omega_2 \omega_3 + \frac{u_1}{I_1}, \\ \dot{\omega}_2 = -\frac{I_1-I_3}{I_2} \omega_1 \omega_3 + \frac{u_2}{I_2}, \\ \dot{\omega}_3 = -\frac{I_2-I_1}{I_3} \omega_1 \omega_2 + \frac{u_3}{I_3}, \end{matrix} \right. ω˙1=I1I3I2ω2ω3+I1u1,ω˙2=I2I1I3ω1ω3+I2u2,ω˙3=I3I2I1ω1ω2+I3u3,
那么在代码中可以这么写:

dw1 = -((I3-I2)/I1) .* w2 .* w3 + u1 ./ I1;
dw2 = -((I1-I3)/I2) .* w1 .* w3 + u2 ./ I2;
dw3 = -((I2-I1)/I2) .* w1 .* w2 + u3 ./ I3;

性能指标的形式为
J = 0.5 ∫ 0 100 ( u 1 2 + u 2 2 + u 3 2 ) d t . J = 0.5 \int_{0}^{100}(u_1^2+u_2^2+u_3^2) \text{d}t. J=0.50100(u12+u22+u32)dt.
对应的代码如下。

phaseout.integrand = 0.5*(u1.^2 + u2.^2 + u3.^2);

那么,continues function的完整代码如下。

function phaseout = socpContinuous(input)w1 = input.phase.state(:,1);w2 = input.phase.state(:,2);w3 = input.phase.state(:,3);u1 = input.phase.control(:,1);u2 = input.phase.control(:,2);u3 = input.phase.control(:,3);I1 = input.auxdata.I1;I2 = input.auxdata.I2;I3 = input.auxdata.I3;dw1 = -((I3-I2)/I1) .* w2 .* w3 + u1 ./ I1;dw2 = -((I1-I3)/I2) .* w1 .* w3 + u2 ./ I2;dw3 = -((I2-I1)/I2) .* w1 .* w2 + u3 ./ I3;phaseout.dynamics = [dw1 dw2 dw3];phaseout.integrand = 0.5*(u1.^2 + u2.^2 + u3.^2);
end

endpoint function

此处代码很简单,只有2行。

function output = socpEndpoint(input)J  = input.phase.integral;output.objective = J;
end

完整代码

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 功能描述:刚体非对称航天器控制问题
% 文件名解释:mainSpacecraftOCP.m 中,main 代表 主函数,
%             Spacecraft 代表 航天器,
%             OCP 代表 最优控制问题
% 作者:Lei Lie
% 时间:2024/06/22
% 版本:1.0
% - 完成了代码框架的初始搭建
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clc;clear;close all;
tic;
%% 01.初始参数设置
%-------------------------------------------------------------------------%
%----------------------- 设置问题的求解边界 ------------------------------%
%-------------------------------------------------------------------------%
% 设置时间
t0 = 0;
tf = 100;
% 设置状态量初值
w10 = .01;
w20 = .005;
w30 = .001;
% 设置状态量边界条件
w1_max = 1;
w1_min = 0;
w2_max = 1;
w2_min = 0;
w3_max = 1;
w3_min = 0;
% 设置控制量初值
u10 = -.009;
u20 = -.004;
u30 = -.001;
% 设置控制量边界条件
u1_max = 0;
u1_min = -.01;
u2_max = 0;
u2_min = -.01;
u3_max = 0;
u3_min = -.01;
% 设置静态参数
auxdata.I1 = 86.24;
auxdata.I2 = 85.07;
auxdata.I3 = 113.59;
% 设置不等式约束边界条件(路径约束)
path_max = .002;
path_min = 0;%% 02.边界条件设置
%-------------------------------------------------------------------------%
%------------------------ 将求解边界设置于问题中 -------------------------%
%-------------------------------------------------------------------------%
bounds.phase.initialtime.lower  = t0; 
bounds.phase.initialtime.upper  = t0;
bounds.phase.finaltime.lower    = tf; 
bounds.phase.finaltime.upper    = tf;
bounds.phase.initialstate.lower = [w10 w20 w30]; 
bounds.phase.initialstate.upper = [w10 w20 w30];
bounds.phase.state.lower        = [w1_min w2_min w3_min]; 
bounds.phase.state.upper        = [w1_max w2_max w3_max];
bounds.phase.finalstate.lower   = [0 0 0];
bounds.phase.finalstate.upper   = [0 0 0];
bounds.phase.control.lower      = [u1_min u2_min u3_min]; 
bounds.phase.control.upper      = [u1_max u2_max u3_max];
bounds.phase.integral.lower     = 0; 
bounds.phase.integral.upper     = 10000;%% 03.初值猜测
%-------------------------------------------------------------------------%
%------------------------------- 初值猜想 --------------------------------%
%-------------------------------------------------------------------------%
guess.phase.time     = [t0; tf]; 
guess.phase.state    = [[w10 w20 w30];[0 0 0]];
guess.phase.control  = [[u10 u20 u30];[u10 u20 u30]];
guess.phase.integral = 100;%% 04.设置GPOPS求解器参数
%-------------------------------------------------------------------------%
%---------------------------- 设置求解器参数 -----------------------------%        
%-------------------------------------------------------------------------%
setup.name = 'Spacecraft-OCP';
setup.functions.continuous  = @socpContinuous;
setup.functions.endpoint   	= @socpEndpoint;
setup.bounds                = bounds;
setup.guess                 = guess;
setup.auxdata               = auxdata;
setup.nlp.solver            = 'ipopt';
setup.derivatives.supplier  = 'sparseCD';
setup.derivatives.derivativelevel = 'second';
setup.mesh.method           = 'hp1';
setup.mesh.tolerance        = 1e-6;
setup.mesh.maxiteration     = 45;
setup.mesh.colpointsmax     = 4;
setup.mesh.colpointsmin     = 10;
setup.mesh.phase.fraction   = 0.1*ones(1,10);
setup.mesh.phase.colpoints  = 4*ones(1,10);
setup.method = 'RPMintegration';%% 05.求解
%-------------------------------------------------------------------------%
%----------------------- 使用 GPOPS2 求解最优控制问题 --------------------%
%-------------------------------------------------------------------------%
output = gpops2(setup);
solution = output.result.solution;
toc;%% 06.画图
t = solution.phase.time(:,1);
w1 = solution.phase.state(:,1);
w2 = solution.phase.state(:,2);
w3 = solution.phase.state(:,3);
u1 = solution.phase.control(:,1);
u2 = solution.phase.control(:,2);
u3 = solution.phase.control(:,3);figure('Color',[1,1,1]);
plot(t,w1,'-','LineWidth',1.5);hold on;
plot(t,w2,'-.','LineWidth',1.5);
plot(t,w3,'--','LineWidth',1.5);
xlabel('Time',...'FontWeight','bold');
ylabel('States',...'FontWeight','bold');
legend('w1','w2','w3',...'LineWidth',1,...'EdgeColor',[1,1,1],...'Orientation','horizontal',...'Position',[0.5,0.93,0.40,0.055]);
set(gca,'FontName','Times New Roman',...'FontSize',15,...'LineWidth',1.3);
print -dpng spacecraft_ocp_state.pngfigure('Color',[1,1,1]);
plot(t,u1,'-','LineWidth',1.5);hold on;
plot(t,u2,'-.','LineWidth',1.5);
plot(t,u3,'--','LineWidth',1.5);
xlabel('Time',...'FontWeight','bold');
ylabel('Control',...'FontWeight','bold');
legend('u1','u2','u3',...'LineWidth',1,...'EdgeColor',[1,1,1],...'Orientation','horizontal',...'Position',[0.5,0.93,0.40,0.055]);
set(gca,'FontName','Times New Roman',...'FontSize',15,...'LineWidth',1.3);
print -dpng spacecraft_ocp_control.png%% 函数模块部分
% ----------------------------------------------------------------------- %
% ------------------------- BEGIN: vsopcContinuous.m -------------------- %
% ----------------------------------------------------------------------- %
function phaseout = socpContinuous(input)w1 = input.phase.state(:,1);w2 = input.phase.state(:,2);w3 = input.phase.state(:,3);u1 = input.phase.control(:,1);u2 = input.phase.control(:,2);u3 = input.phase.control(:,3);I1 = input.auxdata.I1;I2 = input.auxdata.I2;I3 = input.auxdata.I3;dw1 = -((I3-I2)/I1) .* w2 .* w3 + u1 ./ I1;dw2 = -((I1-I3)/I2) .* w1 .* w3 + u2 ./ I2;dw3 = -((I2-I1)/I2) .* w1 .* w2 + u3 ./ I3;phaseout.dynamics = [dw1 dw2 dw3];phaseout.integrand = 0.5*(u1.^2 + u2.^2 + u3.^2);
end
% ----------------------------------------------------------------------- %
% -------------------------- END: vsopcContinuous.m --------------------- %
% ----------------------------------------------------------------------- %% ----------------------------------------------------------------------- %
% -------------------------- BEGIN: vsopcEndpoint.m --------------------- %
% ----------------------------------------------------------------------- %
function output = socpEndpoint(input)J  = input.phase.integral;output.objective = J;
end
% ----------------------------------------------------------------------- %
% --------------------------- END: vsopcEndpoint.m ---------------------- %
% ----------------------------------------------------------------------- %

代码仿真结果

状态量:

在这里插入图片描述

控制量:

在这里插入图片描述

论文仿真结果:

状态量:

在这里插入图片描述

控制量:

在这里插入图片描述

最后

欢迎通过邮箱联系我:lordofdapanji@foxmail.com

来信请注明你的身份,否则恕不回信。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/diannao/35805.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

新手选择代理IP时这几点误区一定要避开!

在选择代理IP时,许多用户可能会因为对代理IP的认识不足或受到一些误导,而陷入一些常见的误区。这些误区不仅可能导致用户无法达到预期的效果,还可能带来一些不必要的风险。下面,IPIDEA代理IP就与大家一同分析在选择代理IP时需要避…

国企:2024年6月中国铁路相关招聘信息,6.27截止

中国铁路济南局集团有限公司2024年度 招聘普通高校本科及以上学历毕业生公告(三) 中国铁路济南局集团有限公司根据企业发展需要,拟招聘普通高等院校本科及以上学历毕业生,现将有关事项公告如下: 一、招聘计划 本次招聘岗位均为生产一线操作技能岗位,具体岗位、专业要求…

【教资优秀作文】

目录 不沉湎于过去, 向未来进发 转变思维方式,风景这边独好 一英尺的距离 面对逆境,智者生存 机遇与准备 1. 巴西足球名将贝利在足坛初露锋芒时 ,一个记者问他:“你哪一个球踢得最好? ” 他回答说&am…

说说ThreadLocal的实现原理

ThreadLocal是什么? ThreadLocal是Java中的一个类,用于创建线程局部变量和解决线程安全。每个线程都有自己独立的变量副本,彼此之间互不影响。它的主要作用是在多线程环境下,确保每个线程都有自己的变量实例,避免了变…

Retrofit类型安全的HTTP客户端库(json)

简介 Retrofit是Square公司开发的一个类型安全的HTTP客户端库,用于Android和Java平台,它使得与Web服务的交互变得更加简单快捷。Retrofit将HTTP API转换成Java接口,让你可以用更简洁的代码形式调用RESTful API,Android网络编程重点…

在前端开发过程中如果函数参数很多,该如何精简

1. 在前端开发过程中如果函数参数很多,该如何精简 1.1. 对象参数(对象字面量):1.2. 默认参数和解构赋值:1.3. 使用类或构造函数:1.4. 利用闭包或者高阶函数:1.5. 利用ES6的扩展运算符&#xff1…

【LeetCode】每日一题:反转链表

题解思路 循环的方法需要注意prev应该是None开始,然后到结束的时候prev是tail,递归的思路很难绕过弯来,主要在于很难想清楚为什么可以返回尾节点,需要多做递归题,以及递归过程中,可以不使用尾节点来找当前…

Nuxt3 的生命周期和钩子函数(二)

title: Nuxt3 的生命周期和钩子函数(二) date: 2024/6/26 updated: 2024/6/26 author: cmdragon excerpt: 摘要:本文深入介绍了Nuxt.js框架中几个关键的生命周期钩子函数,包括app:redirected(SSR环境下重定向前触发…

20240626让飞凌的OK3588-C开发板在相机使用1080p60分辨率下预览

20240626让飞凌的OK3588-C开发板在相机使用1080p60分辨率下预览 2024/6/26 15:15 4.2.1 全编译测试 在源码路径内,提供了编译脚本 build.sh,运行该脚本对整个源码进行编译,需要在终端切换到解压 出来的源码路径,找到 build.sh 文件…

6.26作业

1.整理思维导图 2.统计家目录下.c文件的个数 ls ~/*.c | wc -l 3.终端输入一个.sh文件,判断文件是否由可执行权限,如果有可执行权限运行脚本,没有可执行权限添加可执行权限后,再运行脚本 #!/bin/bash read -p "请输入一个.…

spring模块(二)SpringBean(2)InitializingBean

一、介绍 InitializingBean是Spring框架提供的一个接口,用于在Bean初始化完成后执行特定的初始化逻辑。 二、使用 1、使用方法 1.1、实现InitializingBean接口 可以让Bean实现该接口,并重写其afterPropertiesSet()方法 1.2、注册 也即让bean初始化…

从官方源码精简出第1个FreeRTOS程序

一、下载官方源码 1、打开百度搜索freerots,找到官网:FreeRTOS官网 2、将源码解压到没有中文目录的路径下 二、删减目录 1、删除FreeRTOS-Plus和tools 2、删除FreeRTOS/Demo下除CORTEX_STM32F103_Keil外的所有文件 3、删除FreeRTOS\Source\portable下除RVDS和MemM…

vue2面试题——API

1. $set this.$set(目标对象target&#xff0c;改的位置&#xff0c;最终数据) /* 数据更新了而视图没有更新的情况 */ <template><div>{{ arr }}<button clickbtn>按钮</button></div> </template> <script> export default {name:…

海康威视摄像头修复

一、适用场景 1、室外安装的摄像头&#xff0c;长时间日晒雨淋后&#xff0c;可能因风向导致雨水进入水晶头&#xff0c;进而摄像头无法识别&#xff1b; 2、在经常施工的场地&#xff0c;可能由于车辆的进出&#xff0c;或施工设备的运行导致摄像头的网线水晶头断裂而无法使用…

浔川社团正式启用 代码付费制度——浔川总社部

浔川社团正式启用 代码付费制度。 规则&#xff1a; 浔川社团源代码收费标准表&#xff08;1&#xff09; 1-5行代码0.2元/行1-10行代码0.3元/行1-20行代码0.5元/行 浔川社团源代码收费标准表&#xff08;2&#xff09; 1-30行代码0.6元/行1-40行代码0.8元/行1-50行代码0.09元…

【PythonWeb开发】Flask中间件钩子函数实现封IP

在 Flask 框架中&#xff0c; 提供了几种类型的钩子&#xff08;类似于Django的中间件&#xff09;&#xff0c;它们是在请求的不同阶段自动调用的函数。这些钩子让你能够对请求和响应的处理流程进行扩展&#xff0c;而无需修改核心代码。 Flask钩子的四种类型 before_first_r…

IT入门知识第八部分《云计算》(8/10)

目录 云计算&#xff1a;现代技术的新篇章 1. 云计算基础 1.1 云计算的起源和发展 云计算的早期概念 云计算的发展历程 1.2 云计算的核心特点 按需自助服务 广泛的网络访问 资源池化 快速弹性 按使用量付费 1.3 云计算的优势和挑战 成本效益 灵活性和可扩展性 维…

[leetcode]intersection-of-two-arrays-ii 两个数组的交集 II

. - 力扣&#xff08;LeetCode&#xff09; class Solution { public:vector<int> intersect(vector<int>& nums1, vector<int>& nums2) {sort(nums1.begin(), nums1.end());sort(nums2.begin(), nums2.end());int length1 nums1.size(), length2 …

动态规划——123. 买卖股票的最佳时机 III

目录 1、题目链接 2、题目分析 1.状态表示 2.状态转移方程 3.初始化 4.填表 5.返回值 3、代码解析 1、题目链接 123. 买卖股票的最佳时机 III 2、题目分析 1.状态表示 由题目可知&#xff0c;我们分为两种状态&#xff0c;买入和卖出&#xff0c;又因为只能完成两次交易…

windows下如何配置vs code的编译环境

在 Windows 上配置 VS Code 的编译环境涉及安装编译器、配置 VS Code 以及编写和运行代码。以下是具体的步骤&#xff1a; 步骤 1&#xff1a;安装必要的软件 安装 Visual Studio Code&#xff1a; 访问 VS Code 的官方网站并下载安装包。按照安装向导进行安装。 安装 C/C 编译…