国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

Policy Iteration Adaptive Dynamic Programming Algorithm for Discrete-Time Nonlinear Systems

這篇具有很好參考價(jià)值的文章主要介紹了Policy Iteration Adaptive Dynamic Programming Algorithm for Discrete-Time Nonlinear Systems。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

Policy Iteration Adaptive Dynamic Programming Algorithm for Discrete-Time Nonlinear Systems,2014, Derong Liu, Fellow, IEEE, and Qinglai Wei, Member, IEEE

本文是第一次對(duì)離散非線性系統(tǒng)采用策略迭代的方法分析收斂性和穩(wěn)定性。反復(fù)實(shí)驗(yàn)獲得初始的可容許控制策略,迭代值函數(shù)是單調(diào)不增,收斂到HJB方程的最優(yōu)值。證明任意迭代控制策略使非線性系統(tǒng)穩(wěn)定。神經(jīng)網(wǎng)絡(luò)近似值函數(shù)和求最優(yōu)控制,且分析權(quán)重矩陣的收斂性。
根據(jù)Discrete-Time Nonlinear HJB Solution Using Approximate Dynamic Programming: Convergence Proof ,2008 Asma Al-Tamimi; Frank L. Lewis; Murad Abu-Khalaf IEEE Transactions on Systems。對(duì)初始值函數(shù)為0,其值迭代VI算法迭代控制策略使得系統(tǒng)不能保證穩(wěn)定。收斂的控制策略才可控制系統(tǒng)。
常見的VI算法是離線進(jìn)行的,而PI算法幾乎是在線迭代ADP。

  1. 策略迭代算法尋找最優(yōu)控制策略
  2. 迭代控制策略可穩(wěn)定非線性系統(tǒng)
  3. 迭代控制策略采用策略迭代算法是迭代性能指標(biāo)(代價(jià)函數(shù)收斂到最優(yōu)值)

獲得最優(yōu)控制策略,必須先獲得最優(yōu)值函數(shù)。但在考慮迭代控制策略前, J ? ( x k ) J*\left( x_k \right) J?(xk?)未知。傳統(tǒng)的DP方法會(huì)面臨維數(shù)災(zāi)難問題,控制序列是無限的,幾乎不可能由HJB方程獲得最優(yōu)控制。
當(dāng)?shù)螖?shù)趨于無窮時(shí),PI算法收斂,有迭迭代控制策略近似最優(yōu)控制策略,迭代值函數(shù)是單調(diào)不增收斂到最優(yōu)。
Theorem3.1給出在PI算法下,迭代值函數(shù)是單調(diào)不增的。進(jìn)而Corollary3.1給出當(dāng)任意可容許控制,后續(xù)迭代控制策略均是可容許的。Theorem3.2給出迭代值函數(shù)收斂到最優(yōu)性能指標(biāo)。證明a:迭代性能指標(biāo)的極限滿足HJB方程;b:對(duì)任意可容許控制策略,無限次迭代下值函數(shù)小于等于迭代值函數(shù) V ∞ ( x k ) ≤ P ( x k ) V_{\infty}\left( x_k \right) \le P\left( x_k \right) V?(xk?)P(xk?);c:無限次迭代下值函數(shù)等價(jià)于最優(yōu)值函數(shù)。同樣Corollary3.2給出迭代控制策略收斂到最優(yōu)控制策略。連續(xù)時(shí)間和離散時(shí)間的策略迭代算法不同,首先HJB方程不同,且連續(xù)時(shí)間下的分析方法基于微分。
Algorithm1給出選定半正定函數(shù),獲得可容許控制策略,兩個(gè)神經(jīng)網(wǎng)絡(luò)滿足收斂到一定精度。Algorithm2給出離散時(shí)間下的PI算法。創(chuàng)建動(dòng)作網(wǎng)絡(luò)后,在評(píng)價(jià)網(wǎng)絡(luò)的權(quán)重收斂之前,控制策略的可容許性是未知的,則說明Algorithm1是離線的。
Policy Iteration Adaptive Dynamic Programming Algorithm for Discrete-Time Nonlinear Systems,ADP-最優(yōu)調(diào)節(jié)控制,筆記,學(xué)習(xí)

Theorem3.3給出須獲得可容許控制的值函數(shù)條件。
Policy Iteration Adaptive Dynamic Programming Algorithm for Discrete-Time Nonlinear Systems,ADP-最優(yōu)調(diào)節(jié)控制,筆記,學(xué)習(xí)

兩種方法得到迭代值函數(shù):
定義內(nèi)迭代和外迭代分別更新Policy Iteration Adaptive Dynamic Programming Algorithm for Discrete-Time Nonlinear Systems,ADP-最優(yōu)調(diào)節(jié)控制,筆記,學(xué)習(xí)
和直接根據(jù)求和Policy Iteration Adaptive Dynamic Programming Algorithm for Discrete-Time Nonlinear Systems,ADP-最優(yōu)調(diào)節(jié)控制,筆記,學(xué)習(xí)
Theorem4.1給出目標(biāo)的迭代值函數(shù)和迭代控制策略的權(quán)重收斂到最優(yōu)。
對(duì)不穩(wěn)定系統(tǒng),盡管可通過值迭代和策略迭代獲得最優(yōu)控制策略,但值迭代下并非所有的控制策略是可穩(wěn)定系統(tǒng)的,且VI算法的迭代控制性質(zhì)不能分析,只能離線實(shí)現(xiàn)。而策略迭代使系統(tǒng)的穩(wěn)定性得到保證。

仿真:1線性系統(tǒng)中比較策略迭代算法與一般的求解代數(shù)里卡提方程;2 非線性系統(tǒng)中比較策略迭代與值迭代 3 倒立擺系統(tǒng) 4非線性衛(wèi)星姿態(tài)
展望:由于神經(jīng)網(wǎng)絡(luò)近似迭代值函數(shù)和迭代控制策略,近似誤差不可避免,這種情況下不能證明迭代性能指標(biāo)函數(shù)的收斂性和系統(tǒng)在迭代控制策略下的穩(wěn)定性。需要后續(xù)額外的證明判據(jù)。

matlab實(shí)現(xiàn)

檢驗(yàn)PI算法的可行性,線性

預(yù)訓(xùn)練狀態(tài)數(shù)據(jù)

給定系統(tǒng)矩陣和權(quán)矩陣,通過隨機(jī)函數(shù)得到狀態(tài)的訓(xùn)練數(shù)據(jù)

%------------------------- generate training data & system information ----------------------------
clear; close all; clc;

% system matrices
A = [  0,      0.1;...
       0.3,    -1   ];
B = [  0;...
       0.5  ];

state_dim = size(A,1);
control_dim = size(B,2);

% cost function parameters
Q = 1*eye(state_dim);
R = 1*eye(control_dim);

% training data
x_train = zeros(state_dim,1);
x0 = [1;-1];

for i = 1:50
    x_train = [x_train, zeros(state_dim,1)];  
    x_train = [x_train,2*(rand(state_dim,1)-0.5)]; 
    x_train = [x_train,1*(rand(state_dim,1)-0.5)];
    x_train = [x_train,0.5*(rand(state_dim,1)-0.5)];
end

r = randperm(size(x_train,2));   % randomization according to column
x_train = x_train(:, r);         % reorder

save training_data/state_data x_train state_dim control_dim A B Q R x0;

獲取可容許策略

比較LQR求得到最優(yōu)增益和黎卡提方程的解 與 動(dòng)作網(wǎng)絡(luò)訓(xùn)練輸出的初始控制策略。并測(cè)試兩者控制策略所得到性能指標(biāo)函數(shù)

%-------------------------- obtain the initial admissible control ----------------------------
clear; close all; clc;

load training_data/state_data.mat

[K, P] = dlqr(A,B,Q,100*R); % 離散線性二次型函數(shù)得到最優(yōu)增益K和黎卡提方程的解P

actor_target = -K*x_train; % 最優(yōu)增益求得控制策略

cover = 1;
if isempty(dir('training_data/actor_init.mat')) == 1 || cover == 1 % 訓(xùn)練初始可容許控制不存在時(shí)
    % action network
    actor_init_middle_num = 15; % 動(dòng)作網(wǎng)絡(luò)輸入層數(shù)
    actor_init_epoch = 10000;
    actor_init_err_goal = 1e-9;
    actor_init_lr = 0.01;
    actor_init = newff(minmax(x_train), [actor_init_middle_num control_dim], {'tansig' 'purelin'},'trainlm');
    actor_init.trainParam.epochs = actor_init_epoch;
    actor_init.trainParam.goal = actor_init_err_goal;
    actor_init.trainParam.show = 10;
    actor_init.trainParam.lr = actor_init_lr;
    actor_init.biasConnect = [1;0];
    
    actor_init = train(actor_init, x_train, actor_target);
    
    save training_data/actor_init actor_init % 保存生成的可容許控制
else
    load training_data/actor_init
end


%-------------------------- test the initial control ----------------------------
x = x0;
x_net = x;

xx = x;
xx_net = x_net;
uu = [];
uu_net = [];

Fsamples = 200;
JK = 0; % 由dlqr得到最優(yōu)增益K得到最優(yōu)控制計(jì)算性能指標(biāo)
Jnet = 0; % 由動(dòng)作網(wǎng)絡(luò)生成初始可容許控制計(jì)算性能指標(biāo)

h = waitbar(0,'Please wait');
for k = 1:Fsamples
    u = -K*x;
    u_net = actor_init(x_net);
    JK = JK + x'*Q*x + u'*R*u;
    Jnet = Jnet + x_net'*Q*x_net + u_net'*R*u_net;
    x = A*x + B*u;
    xx = [xx x];
    x_net = A*x_net + B*u_net;
    xx_net = [xx_net x_net];
    uu = [uu u];
    uu_net = [uu_net u_net];
    waitbar(k/Fsamples,h,['Running...',num2str(k/Fsamples*100),'%']);
end
close(h)

JK
Jnet

figure,
plot(0:Fsamples,xx,'b-',0:Fsamples,xx_net,'r--','linewidth',1)
xlabel('Time steps');
ylabel('States'); 
set(gca,'FontName','Times New Roman','FontSize',14,'linewidth',1);
grid on;

figure,
plot(0:Fsamples-1,uu,'b-',0:Fsamples-1,uu_net,'r--','linewidth',1)
xlabel('Time steps');
ylabel('Control');
set(gca,'FontName','Times New Roman','FontSize',14,'linewidth',1);
grid on;

PI算法實(shí)現(xiàn)

加載訓(xùn)練數(shù)據(jù),構(gòu)建Action和Critic網(wǎng)絡(luò)分別進(jìn)行策略提升和策略改進(jìn),更新值函數(shù)和控制策略

function pi_algorithm
% This demo checks the feasibility of the policy iteration adaptive dynamic 
% programming  algorithm


%-------------------------------- start -----------------------------------
clear; close all; clc;

% information of system & cost function
global A; global B; global Q; global R;

load training_data/state_data.mat;
load training_data/actor_init.mat; % 加載預(yù)訓(xùn)練離散狀態(tài)數(shù)據(jù)和可容許控制策略

% action network
actor = actor_init;

actor_epoch = 20000;
actor_err_goal = 1e-9;
actor_lr = 0.01;
actor.trainParam.epochs = actor_epoch; 
actor.trainParam.goal = actor_err_goal; 
actor.trainParam.show = 10; 
actor.trainParam.lr = actor_lr; 

% critic network
critic_middle_num = 15;
critic_epoch = 10000;
critic_err_goal = 1e-9;
critic_lr = 0.01;
critic = newff(minmax(x_train), [critic_middle_num 1], {'tansig' 'purelin'},'trainlm'); % 構(gòu)造評(píng)價(jià)網(wǎng)絡(luò)
critic.trainParam.epochs = critic_epoch;
critic.trainParam.goal = critic_err_goal; % 訓(xùn)練指標(biāo)達(dá)到多少時(shí)停止
critic.trainParam.show = 10;  % 每多少數(shù)據(jù)刷新依次
critic.trainParam.lr = critic_lr; 
critic.biasConnect = [1;0];

epoch = 10;
eval_step = 400;
performance_index = ones(1,epoch + 1);

figure(1),hold on;
h = waitbar(0,'Please wait');
for i = 1:epoch
    % update critic
    % evaluate policy
    critic_target = evaluate_policy(actor, x_train, eval_step);
    critic = train(critic,x_train,critic_target); 
    
    performance_index(i) = critic(x0);
    figure(1),plot(i,performance_index(i),'*'),xlim([1 epoch]),hold on;
    
    waitbar(i/epoch,h,['Training controller...',num2str(i/epoch*100),'%']);
    if i == epoch
        break;
    end
    
    % update actor
    actor_target = zeros(control_dim,size(x_train,2));
    for j = 1:size(x_train,2)
        x = x_train(:,j);
        if x == zeros(state_dim,1)
            ud = zeros(control_dim,1);
        else
            objective = @(u) cost_function(x,u) + critic(controlled_system(x,u));
            u0 = actor(x);
            ud = fminunc(objective, u0);
        end
        actor_target(:,j) = ud;
    end
    
    actor = train(actor, x_train, actor_target);
end
close(h)

figure(1),
xlabel('Iterations');
ylabel('$V(x_0)$','Interpreter','latex');
set(gca,'FontName','Times New Roman','FontSize',14,'linewidth',1);
grid on;
hold off;

save training_results/actor_critic actor critic
end

%---------------------------- evaluate policy 策略評(píng)估-----------------------------
function y = evaluate_policy(actor,x,eval_step)
critic_target = zeros(1,size(x,2));
for k = 1:eval_step
    uep = actor(x); % 策略評(píng)估下動(dòng)作網(wǎng)絡(luò)的輸出
    critic_target = critic_target +  cost_function(x,uep); % 策略評(píng)估下將控制代入到值函數(shù)
    x = controlled_system(x,uep); % 代入被控系統(tǒng)得到下一步狀態(tài)
end
y = critic_target; 
end
%--------------------------- outpout of system 被控系統(tǒng)輸出狀態(tài)值----------------------------
function y = controlled_system(x,u)
% system matrices
global A; global B;
y = A*x + B*u;  % dot product should be adopt in nolinear systems
end
%----------------------------- cost function ------------------------------
function y = cost_function(x,u)
global Q; global R;
y = (diag(x'*Q*x) + diag(u'*R*u))';
end

PI算法的驗(yàn)證

加載預(yù)訓(xùn)練的狀態(tài)數(shù)據(jù)和評(píng)價(jià)、動(dòng)作網(wǎng)絡(luò)數(shù)據(jù)。
給出LQR計(jì)算下得到的最優(yōu)控制策略和黎卡提方程的解(HJB方程的精確解)比較
迭代值函數(shù)和迭代控制策略收斂的近似最優(yōu)值代入到性能指標(biāo)函數(shù)中文章來源地址http://www.zghlxwxcb.cn/news/detail-842271.html

clear; close all; clc;

load training_data/state_data.mat;
load training_results/actor_critic.mat


[Kopt, Popt] = dlqr(A,B,Q,R);

x = x0;
x_net = x;
xx = x;
xx_net = x_net;
uu_opt = [];
uu_net = [];

Jreal = 0;

Fsamples = 50;
h = waitbar(0,'Please wait');
for k = 1:Fsamples
    uopt = -Kopt*x;
    x = A*x + B*(uopt);
    xx = [xx x];
    u_net = sim(actor,x_net);
    Jreal = Jreal + x_net'*Q*x_net + u_net'*R*u_net;
    x_net = A*x_net + B*u_net;
    xx_net = [xx_net x_net];
    uu_opt = [uu_opt uopt];
    uu_net = [uu_net u_net];
    waitbar(k/Fsamples,h,['Running...',num2str(k/Fsamples*100),'%']);
end
close(h)

Jopt = x0'*Popt*x0
Jnet = critic(x0)
Jreal

figure(1),
plot(0:Fsamples,xx,'b-',0:Fsamples,xx_net,'r--','linewidth',1)
legend('Optimal ','NN','Interpreter','latex');
xlabel('Time steps');
ylabel('States'); 
set(gca,'FontName','Times New Roman','FontSize',14,'linewidth',1);
grid on;
figure(2),
plot(0:Fsamples-1,uu_opt,'b-',0:Fsamples-1,uu_net,'r--','linewidth',1)
legend('Optimal ','NN','Interpreter','latex'); 
xlabel('Time steps');
ylabel('Control');
set(gca,'FontName','Times New Roman','FontSize',14,'linewidth',1);
grid on;

到了這里,關(guān)于Policy Iteration Adaptive Dynamic Programming Algorithm for Discrete-Time Nonlinear Systems的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 算法——?jiǎng)討B(tài)規(guī)劃(DP,Dynamic Programming)

    算法——?jiǎng)討B(tài)規(guī)劃(DP,Dynamic Programming)

    動(dòng)態(tài)規(guī)劃常用于解決優(yōu)化問題。 動(dòng)態(tài)規(guī)劃通常以自底向上或自頂向下的方式進(jìn)行求解。 自底向上的動(dòng)態(tài)規(guī)劃從最簡(jiǎn)單的子問題開始,逐步解決更復(fù)雜的問題,直到達(dá)到原始問題。 自頂向下的動(dòng)態(tài)規(guī)劃則從原始問題出發(fā),分解成子問題,并逐步求解這些子問題。 動(dòng)態(tài)規(guī)劃算法

    2024年02月02日
    瀏覽(17)
  • 【數(shù)據(jù)結(jié)構(gòu)】動(dòng)態(tài)規(guī)劃(Dynamic Programming)

    【數(shù)據(jù)結(jié)構(gòu)】動(dòng)態(tài)規(guī)劃(Dynamic Programming)

    求解決策過程(decision process)最優(yōu)化的數(shù)學(xué)方法。 將多階段決策過程轉(zhuǎn)化為一系列單階段問題,利用各階段之間的關(guān)系,逐個(gè)求解。 與分治法類似,將待求解問題 分解成若干個(gè)子問題 。 但是經(jīng)分解得到的子問題往往 不是相互獨(dú)立 的。 如果使用分治法求解問題,有些子問

    2024年02月03日
    瀏覽(20)
  • 數(shù)據(jù)結(jié)構(gòu)與算法:動(dòng)態(tài)規(guī)劃(Dynamic Programming)詳解

    動(dòng)態(tài)規(guī)劃(Dynamic Programming,簡(jiǎn)稱DP) 是一種在數(shù)學(xué)、管理科學(xué)、計(jì)算機(jī)科學(xué)、經(jīng)濟(jì)學(xué)和生物信息學(xué)等領(lǐng)域中使用的,通過把原問題分解為相對(duì)簡(jiǎn)單的子問題的方式求解復(fù)雜問題的方法。動(dòng)態(tài)規(guī)劃經(jīng)常被用于求解優(yōu)化問題。 動(dòng)態(tài)規(guī)劃的核心思想是將復(fù)雜問題分解為更小的子問

    2024年04月25日
    瀏覽(27)
  • 數(shù)據(jù)結(jié)構(gòu)與算法 | 動(dòng)態(tài)規(guī)劃算法(Dynamic Programming)

    上一篇文末已經(jīng)提到了記憶化搜索是動(dòng)態(tài)規(guī)劃(Dynamic Programming)的一種形式,是一種自頂向下(Top-Down)的思考方式,通常采用遞歸的編碼形式;既然動(dòng)態(tài)規(guī)劃有自頂向下(Top-Down)的遞歸形式,自然想到對(duì)應(yīng)的另外一種思考方式 自底向上( Bottom-Up ) ,也就是本篇要寫的內(nèi)

    2024年02月05日
    瀏覽(24)
  • 算法設(shè)計(jì)與分析-Dynamic Programming「國科大」卜東波老師

    A robber is planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security system connected and it will automatically contact the police if two adjacent houses were broken into on the same night. (a) Given a list of non-negative integers

    2024年02月22日
    瀏覽(23)
  • Speeding Up Dynamic Programming Computation: Tips and

    作者:禪與計(jì)算機(jī)程序設(shè)計(jì)藝術(shù) 動(dòng)態(tài)規(guī)劃(Dynamic programming)是一種解決最優(yōu)化問題的關(guān)鍵算法。它通過將子問題的解重復(fù)計(jì)算而節(jié)省時(shí)間。對(duì)于多種問題都可以用動(dòng)態(tài)規(guī)劃求解。動(dòng)態(tài)規(guī)劃算法經(jīng)過幾十年的發(fā)展,已經(jīng)成為計(jì)算機(jī)科學(xué)中一個(gè)重要的研究領(lǐng)域。然而,如何高效地實(shí)

    2024年02月07日
    瀏覽(58)
  • Dynamic-Programming(動(dòng)態(tài)規(guī)劃)最細(xì)解題思路+代碼詳解(1)

    Dynamic-Programming(動(dòng)態(tài)規(guī)劃)最細(xì)解題思路+代碼詳解(1)

    案例二:二維數(shù)組的 DP 我做了幾十道 DP 的算法題,可以說,80% 的題,都是要用二維數(shù)組的,所以下面的題主要以二維數(shù)組為主,當(dāng)然有人可能會(huì)說,要用一維還是二維,我怎么知道?這個(gè)問題不大,接著往下看。 問題描述 一個(gè)機(jī)器人位于一個(gè) m x n 網(wǎng)格的左上角 (起始點(diǎn)在

    2024年04月26日
    瀏覽(19)
  • GDLink+Keil5在線仿真時(shí)提示cannot Load Flash Programming Algorithm的解決辦法

    GDLink+Keil5在線仿真時(shí)提示cannot Load Flash Programming Algorithm的解決辦法

    本次使用的是GD官方的START評(píng)估板,在嘗試用Keil仿真調(diào)試時(shí)遇到下圖的情況 ?提示仿真算法錯(cuò)誤 查看DEBUG設(shè)置發(fā)現(xiàn)! ? ?有識(shí)別,算法設(shè)置正確,一切正常。 解決辦法 問題出在RAM地址設(shè)置上,因?yàn)槭亲约盒陆ǖ墓こ?,所以在設(shè)置這一塊都是默認(rèn)設(shè)置,打開GD官方的示例,發(fā)現(xiàn)

    2024年02月09日
    瀏覽(21)
  • LC狂刷66道Dynamic-Programming算法題。跟動(dòng)態(tài)規(guī)劃說拜拜

    LC狂刷66道Dynamic-Programming算法題。跟動(dòng)態(tài)規(guī)劃說拜拜

    一種是從 (i-1, j) 這個(gè)位置走一步到達(dá) 一種是從(i, j - 1) 這個(gè)位置走一步到達(dá) 因?yàn)槭怯?jì)算所有可能的步驟,所以是把所有可能走的路徑都加起來,所以關(guān)系式是 dp[i] [j] = dp[i-1] [j] + dp[i] [j-1]。 步驟三、找出初始值 顯然,當(dāng) dp[i] [j] 中,如果 i 或者 j 有一個(gè)為 0,那么還能使用關(guān)

    2024年04月10日
    瀏覽(22)
  • Dynamic-Programming(動(dòng)態(tài)規(guī)劃)最細(xì)解題思路+代碼詳解,Android布局優(yōu)化之include、merge、ViewStub的使用

    Dynamic-Programming(動(dòng)態(tài)規(guī)劃)最細(xì)解題思路+代碼詳解,Android布局優(yōu)化之include、merge、ViewStub的使用

    dp[0…m-1] [0] = 1; // 相當(dāng)于最左面一列,機(jī)器人只能一直往下走 擼代碼 三個(gè)步驟都寫出來了,直接看代碼 public static int uniquePaths(int m, int n) { if (m = 0 || n = 0) { return 0; } int[][] dp = new int[m][n]; // // 初始化 for(int i = 0; i m; i++){ dp[i][0] = 1; } for(int i = 0; i n; i++){ dp[0][i] = 1; } // 推導(dǎo)出 d

    2024年04月26日
    瀏覽(28)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包