
バンバン制御で二点境界値問題を解く方法について
8 views (last 30 days)
Show older comments
Natsuhiro Morita
on 24 May 2016
Answered: Tohru Kikawada
on 13 Jan 2017
matlab上でバンバン制御を解く方法について悩んでいます。
やりたいこと
ある物体がx軸上を次のように動くとする。t=0の時、物体の位置x=0、速度v=0
制御を終了する時間をtfとして、t=tfの時、x=xf、v=0となるような運動を、最短時間で行うような制御を考えています。
ただし、加速度aに関しては制限があり、-amax<a<amaxの範囲で加減速するとします。
状態方程式は、

(uは加速度) 離散時間系にした時の状態方程式は Tをサンプリングタイムとして、

となります。 目的関数(最小としたいもの)は

となります。 fminconを用いて解き、サンプリングタイムTごとのx,v,aの情報を配列として入手したいと考えています。 今、このプログラムを作成しているのですが、fminconではx(tf)=xfの情報をプログラムのどこに記せば良いのかで悩んでいます。 お願いいたします。
0 Comments
Accepted Answer
Tohru Kikawada
on 13 Jan 2017
最適化問題として最適な入力系列を計算させる場合、最適化変数が離散値になりますので勾配を使う fmincon では解けない場合があります。
また、混合整数線形計画法 (MILP)を取り扱える intlinprog も目的関数が非線形の場合には使えません。
整数制約の非線形最適化問題を解く一番簡単な方法はGlobal Optimization Toolboxの遺伝的アルゴリズム ga を使うことです。
簡単な例を下記に示します。
この例では x(tf)=xf の制約自体を目的関数に入れています。
少しでもご参考になれば幸いです。
%%バンバン制御の入力信号の最適化
% 乱数のシードを定義(再現性のため)
rng(4,'twister')
% 目標値
xf = [20; 0];
amax = 1;
% 目的関数
fun = @(x) (costFunc(x,xf));
% 初期値
x0 = zeros(100,1);
% (0,1)の範囲に限定
lb = zeros(100,1);
ub = ones(100,1);
% 遺伝的アルゴリズムを使って整数制約の非線形最適化問題を解く
opt = optimoptions('ga','PlotFcn',@gaplotbestf,...
'MaxGenerations',50,'MaxStallGenerations',50);
[xga,fval,exitflag,output] = ga(@(x)costFunc(x,xf,amax),100,[],[],[],[],lb,ub,[], ...
1:100,opt);
% 時系列の再計算と可視化
[~,xlog] = costFunc(xga,xf,amax);
figure, subplot(211), plot((2*xga-1)*amax);
title('入力信号 u');
subplot(212), plot(xlog);
hold on; plot(xf(1)*ones(100,1));
title('状態変数 x');
legend('位置','速度','位置の目標値');
costFunc.m:
function [J,x_log] = costFunc(u,xf,amax)
J = 0;
tf = 1;
A = [1 1; 0 1];
B = [0; 1];
x = [0; 0];
x_log = zeros(numel(u),2);
while tf <= 100
x = A*x + B*(round(u(tf))*2-1)*amax;
x_log(tf,:) = x;
tf = tf + 1;
J = J + abs(x(1)-xf(1));
end
end
実行結果:

0 Comments
More Answers (0)
See Also
Categories
Find more on Web Services in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!