1 | function ildp
|
---|
2 |
|
---|
3 | tic
|
---|
4 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
---|
5 | %pocatecni konstanty
|
---|
6 |
|
---|
7 | % [b=1, yr=1] - to jsme zkouseli spolu sigma = 0.1; rho = 0.5;
|
---|
8 | % [b=-1, yr=1] sigma = 0.1; rho = 0.5; !aprior
|
---|
9 | % [b=10, yr=5] sigma = 0.5; rho = 2.0;
|
---|
10 | % [b=0.6, yr=10] sigma = 0.1; rho = 1.0;
|
---|
11 |
|
---|
12 | Iterace = 20; %iterace
|
---|
13 | K = 20; %casy
|
---|
14 | N = 100; %vzorky
|
---|
15 |
|
---|
16 | sigma = 0.1;
|
---|
17 | Sigmas = [[sigma^2 0 0]; [0 0 0]; [0 0 0]];
|
---|
18 |
|
---|
19 | h = 0;
|
---|
20 | hdx = [0; 0; 0];
|
---|
21 | hdxdx = [[0 0 0]; [0 0 0]; [0 0 0]];
|
---|
22 |
|
---|
23 | Rk = 1*ones(1, K);
|
---|
24 | x0 = [0; 1; 1];
|
---|
25 |
|
---|
26 | %velikost okoli pro lokalni metodu
|
---|
27 | rho = 0.5;
|
---|
28 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
---|
29 | %globalni promenne
|
---|
30 |
|
---|
31 | Kpi = ones(4, K);
|
---|
32 | Kpi(4, :) = zeros(1, K);
|
---|
33 | % Kpi(3, :) = zeros(1, K);
|
---|
34 |
|
---|
35 | Wv = zeros(9, K);
|
---|
36 |
|
---|
37 | Xkn = zeros(3, K, N);
|
---|
38 | Xstripe = zeros(3, K);
|
---|
39 |
|
---|
40 |
|
---|
41 | % Kpi = [[1.0308 0.9990 0.9797 0.9899 1.0075 0.9830 1.0050 1.0173 0.9659 1.0000];
|
---|
42 | % [0.4104 0.5562 0.6933 0.4674 0.3817 0.5036 0.4203 0.3461 0.7750 1.0000];
|
---|
43 | % [0.9204 0.8378 0.6707 0.3629 0.9815 0.8955 1.2227 1.1550 1.9374 1.0000];
|
---|
44 | % [0.5756 0.4225 0.4055 0.5941 0.5188 0.3218 0.3435 0.3210 0.0333 0]];
|
---|
45 |
|
---|
46 | gka = 0;
|
---|
47 | gnu = 0;
|
---|
48 |
|
---|
49 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
---|
50 | %iteracni smycka
|
---|
51 | % clf reset
|
---|
52 |
|
---|
53 | % PtMin = 0.0001;
|
---|
54 |
|
---|
55 | % UU=zeros(K,N);
|
---|
56 | for i = 1:Iterace,
|
---|
57 | %generovani stavu
|
---|
58 | % hold off
|
---|
59 | for n = 1:N,
|
---|
60 | Xkn(:, 1, n) = x0 + [sigma*randn(); 0; 0];
|
---|
61 | for k = 1:K-1,
|
---|
62 | Uk = uPi(k, Xkn(:, k, n));
|
---|
63 | % UU(k,n) = Uk;
|
---|
64 | Kk = Uk*Xkn(3, k, n)/(Uk^2*Xkn(3, k, n) + sigma^2);
|
---|
65 | Xkn(1, k+1, n) = Xkn(1, k, n) + Xkn(2, k, n)*Uk + sigma*randn();
|
---|
66 | Xkn(2, k+1, n) = Xkn(2, k, n) + Kk*(Xkn(1, k+1, n) - Xkn(1, k, n) - Xkn(2, k, n)*Uk);
|
---|
67 | Xkn(3, k+1, n) = (1 - Kk*Uk)*Xkn(3, k, n);
|
---|
68 | % plot(1:K,Xkn(1,:,n))
|
---|
69 | end
|
---|
70 | % hold all
|
---|
71 | % subplot(4,1,1);
|
---|
72 | % plot(1:K,Xkn(1,:,n))
|
---|
73 | % hold all
|
---|
74 | % subplot(4,1,2);
|
---|
75 | % plot(1:K,Xkn(2,:,n))
|
---|
76 | % hold all
|
---|
77 | % subplot(4,1,3);
|
---|
78 | % plot(1:K,Xkn(3,:,n))
|
---|
79 | % hold all
|
---|
80 | % subplot(4,1,4);
|
---|
81 | % plot(1:K-1,UU(:,n))
|
---|
82 |
|
---|
83 | end
|
---|
84 | Xstripe = mean(Xkn, 3);
|
---|
85 | % hold all
|
---|
86 | % subplot(4,1,1);
|
---|
87 | % plot(1:K,Xstripe(1,:),'-ro')
|
---|
88 | % hold all
|
---|
89 | % subplot(4,1,2);
|
---|
90 | % plot(1:K,Xstripe(2,:),'-ro')
|
---|
91 | % hold all
|
---|
92 | % subplot(4,1,3);
|
---|
93 | % plot(1:K,Xstripe(3,:),'-ro')
|
---|
94 |
|
---|
95 | %hold off
|
---|
96 | % Epsl = randn(3,N);
|
---|
97 | %iterace pro k = K-1..1
|
---|
98 | for k = K-1:-1:1,
|
---|
99 | gka = k;
|
---|
100 | % 1]
|
---|
101 | for n = 1:N,
|
---|
102 | %krive okoli
|
---|
103 | Xkn(1, k, n) = Xstripe(1, k) + rho*randn();
|
---|
104 | Xkn(2, k, n) = Xstripe(2, k) + rho*randn();
|
---|
105 | Xkn(3, k, n) = Xstripe(3, k)*exp(rho*randn());
|
---|
106 | % %rovne okoli
|
---|
107 | % Xkn(1, k, n) = Xstripe(1, k) + Epsl(1,n);
|
---|
108 | % Xkn(2, k, n) = Xstripe(2, k) + Epsl(2,n);
|
---|
109 | % Xkn(3, k, n) = Xstripe(3, k)*exp(Epsl(3,n));
|
---|
110 | end
|
---|
111 | % Xkn(:,k,:)
|
---|
112 |
|
---|
113 | % 2]
|
---|
114 | for n = 1:N,
|
---|
115 | gnu = n;
|
---|
116 | % if(k == 1)
|
---|
117 | % Uopt(n) = Rk(k)/2;
|
---|
118 | % Hmin(n) = Hamilt(Uopt(n));
|
---|
119 | % else
|
---|
120 | [Uopt(n), Hmin(n)] = fminunc(@Hamilt, uPi(k, Xkn(:, k, n)), optimset('GradObj','on','Display','notify'));
|
---|
121 | % % [i, k, n]
|
---|
122 | % end
|
---|
123 | %
|
---|
124 | % interv = -1000:1:1000;
|
---|
125 | % for ll = 1:2001,
|
---|
126 | % hodnot(ll) = Hamilt(interv(ll));
|
---|
127 | % end
|
---|
128 | % plot(interv, hodnot,'-b',Uopt(n),Hmin(n),'rs',uPi(k, Xkn(:, k, n)),Hamilt(uPi(k, Xkn(:, k, n))),'go')
|
---|
129 | % prah = 100;
|
---|
130 | % if(Uopt(n) > prah)
|
---|
131 | % Uopt(n) = prah;
|
---|
132 | % Hmin(n) = Hamilt(prah);
|
---|
133 | % disp('u > horni mez');
|
---|
134 | % elseif(Uopt(n) < -prah)
|
---|
135 | % Uopt(n) = -prah;
|
---|
136 | % Hmin(n) = Hamilt(-prah);
|
---|
137 | % disp('u < dolni mez');
|
---|
138 | % end
|
---|
139 | % if(extfl < 1)
|
---|
140 | % disp('exitflag < 1')
|
---|
141 | % end
|
---|
142 | end
|
---|
143 | % 3]
|
---|
144 | for n = 1:N, % V??? nema to byt k+1? ale asi ne
|
---|
145 | Vn(n) = Hmin(n) + Vtilde(k+1, Xkn(:, k, n));
|
---|
146 | % xxx(n) = Xkn(1,k,n);
|
---|
147 | % xxy(n) = Xkn(2,k,n);
|
---|
148 | % xxz(n) = Xkn(3,k,n);
|
---|
149 | % Vn(n) = xxx(n).*xxx(n).*xxx(n);
|
---|
150 | end
|
---|
151 | % xxx2 = sort(xxx);
|
---|
152 | % xxy2 = sort(xxy);
|
---|
153 | % xxz2 = sort(xxz);
|
---|
154 |
|
---|
155 | % 4]
|
---|
156 | Epsilon = zeros(3, N);
|
---|
157 | for n = 1:N,
|
---|
158 | Epsilon(1, n) = Xkn(1, k, n) - Xstripe(1, k);
|
---|
159 | Epsilon(2, n) = Xkn(2, k, n) - Xstripe(2, k);
|
---|
160 | Epsilon(3, n) = Xkn(3, k, n)/Xstripe(3, k);
|
---|
161 | end
|
---|
162 | mFi = matrixFi(Epsilon);
|
---|
163 | FiFiTInvFi = (mFi*mFi')\mFi;
|
---|
164 | Wv(:,k) = FiFiTInvFi * Vn';
|
---|
165 | % Wv = zeros(10,1);
|
---|
166 | % Wv(1, k) = Wvtmp(1);
|
---|
167 | % Wv(2, k) = Wvtmp(2);
|
---|
168 | % Wv(3, k) = Wvtmp(3);
|
---|
169 | % Wv(4, k) = Wvtmp(4);
|
---|
170 | % FiFiTInvFi = (mFi'*mFi)\mFi';
|
---|
171 | % Wv(:, k) = FiFiTInvFi' * Vn';
|
---|
172 | % UU(k,:) = Uopt;
|
---|
173 | % for n = 1:N,
|
---|
174 | % rozd(n) = Vn(n) - Vtilde(k,Xkn(:,k,n));
|
---|
175 | % end
|
---|
176 |
|
---|
177 | for n = 1:N,
|
---|
178 | yt(n) = Xkn(1, k, n);
|
---|
179 | bt(n) = Xkn(2, k, n);
|
---|
180 | pt(n) = Xkn(3, k, n);
|
---|
181 | end
|
---|
182 | mPsi = [yt',...
|
---|
183 | bt'.*Uopt',...
|
---|
184 | pt'.*Uopt',...
|
---|
185 | Uopt'];
|
---|
186 | PsiPsiTInvPsi = (mPsi'*mPsi)\mPsi';
|
---|
187 | Kpi(:,k) = PsiPsiTInvPsi * (Rk(k)*ones(N,1));
|
---|
188 |
|
---|
189 | % for nn=1:N,
|
---|
190 | % vlv(nn) = Vtilde(k, [xxx2(nn);xxy2(nn);xxz2(nn)]);
|
---|
191 | % end
|
---|
192 | % subplot(3,1,1);
|
---|
193 | % plot(xxx,Vn,'rs',xxx2,vlv,'-b')
|
---|
194 | % subplot(3,1,2);
|
---|
195 | % plot(xxy,Vn,'rs',xxy2,vlv,'-b')
|
---|
196 | % subplot(3,1,3);
|
---|
197 | % plot(xxz,Vn,'rs',xxz2,vlv,'-b')
|
---|
198 | % clf reset
|
---|
199 | % hold off
|
---|
200 | %
|
---|
201 | % yii = 0.5:0.025:1.5;
|
---|
202 | % bjj = 0.5:0.025:1.5;
|
---|
203 | % for ii= 1:41,
|
---|
204 | % for jj= 1:41,
|
---|
205 | % vmtrx(ii,jj) = Vtilde(k, [yii(ii);bjj(jj);0]);
|
---|
206 | % end
|
---|
207 | % end
|
---|
208 | %
|
---|
209 | % % xlabel('yt')
|
---|
210 | % % ylabel('bt')
|
---|
211 | % % zlabel('Vt')
|
---|
212 | % surf(yii,bjj,vmtrx)
|
---|
213 | % % % for n=1:N,
|
---|
214 | % % % hold all
|
---|
215 | % % % surf(yt(n),bt(n),Vn(n),'LineStyle','','Marker','o');
|
---|
216 | % % % end
|
---|
217 | % hold all
|
---|
218 | % plot3(bt, yt, Vn, 'ro')
|
---|
219 |
|
---|
220 |
|
---|
221 | end
|
---|
222 | % clf reset
|
---|
223 | % for n=1:N,
|
---|
224 | %
|
---|
225 | % hold all
|
---|
226 | % subplot(4,1,1);
|
---|
227 | % plot(1:K,Xkn(1,:,n),'-b')
|
---|
228 | % hold all
|
---|
229 | % subplot(4,1,2);
|
---|
230 | % plot(1:K,Xkn(2,:,n),'-b')
|
---|
231 | % hold all
|
---|
232 | % subplot(4,1,3);
|
---|
233 | % plot(1:K,Xkn(3,:,n),'-b')
|
---|
234 | % hold all
|
---|
235 | % % subplot(4,1,4);
|
---|
236 | % % plot(1:K,UU(:,n),'-b')
|
---|
237 | % end
|
---|
238 | % for k=1:K,
|
---|
239 | % riz(k) = uPi(k, Xstripe(:, k));
|
---|
240 | % ce(k) = (Rk(k) - Xstripe(1, k))/(Xstripe(2, k) + Xstripe(3, k));
|
---|
241 | % end
|
---|
242 | % plot(1:K,riz,1:K,ce,1:K,Xstripe(1,:))
|
---|
243 |
|
---|
244 | end
|
---|
245 | %%%%%%%%%%%
|
---|
246 | toc
|
---|
247 |
|
---|
248 | Kpi
|
---|
249 | %graficky vystup
|
---|
250 |
|
---|
251 | % X1 = zeros(3, K);
|
---|
252 | % UU1 = zeros(1,K);
|
---|
253 | %
|
---|
254 | % X1(:,1) = x0 + [sigma*randn(); 0; 0];
|
---|
255 | % for k = 1:K-1,
|
---|
256 | % Upi = uPi(k, X1);
|
---|
257 | % UU1(k) = Upi;
|
---|
258 | % Ktmp = Upi*X1(3,k)/(Upi^2*X1(3,k) + sigma^2);
|
---|
259 | % X1(1,k+1) = X1(1,k)+X1(2,k)*Upi + sigma*randn();
|
---|
260 | % X1(2,k+1) = X1(2,k) + Ktmp*(X1(1,k+1) - X1(1,k) - X1(2,k)*Upi);
|
---|
261 | % X1(3,k+1) = X1(3,k)*(1-Ktmp*Upi);
|
---|
262 | % end
|
---|
263 | % % X
|
---|
264 | % % hold off
|
---|
265 | % subplot(4,1,1);
|
---|
266 | % plot(1:K,X(1,:),'-gs')
|
---|
267 | % % hold off
|
---|
268 | % subplot(4,1,2);
|
---|
269 | % plot(1:K,X(2,:),'-gs')
|
---|
270 | % % hold off
|
---|
271 | % subplot(4,1,3);
|
---|
272 | % plot(1:K,X(3,:),'-gs')
|
---|
273 | % % hold off
|
---|
274 | % subplot(4,1,4);
|
---|
275 | % plot(1:K,UU,'-gs')
|
---|
276 | %
|
---|
277 | % figure
|
---|
278 | % for k=1:K,
|
---|
279 | % riz(k) = uPi(k, Xstripe(:, k));
|
---|
280 | % ce(k) = (Rk(k) - Xstripe(1, k))/(Xstripe(2, k) + Xstripe(3, k));
|
---|
281 | % end
|
---|
282 | % plot(1:K,riz,1:K,ce,1:K,Xstripe(1,:))
|
---|
283 | for n = 1:N,
|
---|
284 | Xkn(:, 1, n) = x0 + [sigma*randn(); 0; 0];
|
---|
285 | for k = 1:K-1,
|
---|
286 | Uk = uPi(k, Xkn(:, k, n));
|
---|
287 | UU(k,n) = Uk;
|
---|
288 | Kk = Uk*Xkn(3, k, n)/(Uk^2*Xkn(3, k, n) + sigma^2);
|
---|
289 | Xkn(1, k+1, n) = Xkn(1, k, n) + Xkn(2, k, n)*Uk + sigma*randn();
|
---|
290 | Xkn(2, k+1, n) = Xkn(2, k, n) + Kk*(Xkn(1, k+1, n) - Xkn(1, k, n) - Xkn(2, k, n)*Uk);
|
---|
291 | Xkn(3, k+1, n) = (1 - Kk*Uk)*Xkn(3, k, n);
|
---|
292 | % plot(1:K,Xkn(1,:,n))
|
---|
293 | end
|
---|
294 | hold all
|
---|
295 | subplot(4,1,1);
|
---|
296 | plot(1:K,Xkn(1,:,n))
|
---|
297 | hold all
|
---|
298 | subplot(4,1,2);
|
---|
299 | plot(1:K,Xkn(2,:,n))
|
---|
300 | hold all
|
---|
301 | subplot(4,1,3);
|
---|
302 | plot(1:K,Xkn(3,:,n))
|
---|
303 | hold all
|
---|
304 | subplot(4,1,4);
|
---|
305 | plot(1:K-1,UU(:,n))
|
---|
306 |
|
---|
307 | end
|
---|
308 | title('iLDP')
|
---|
309 | figure
|
---|
310 | for n = 1:N,
|
---|
311 | Xkn(:, 1, n) = x0 + [sigma*randn(); 0; 0];
|
---|
312 | for k = 1:K-1,
|
---|
313 | Uk = (Rk(k) - Xkn(1, k, n))/(Xkn(2, k, n) + Xkn(3, k, n));
|
---|
314 | UU(k,n) = Uk;
|
---|
315 | Kk = Uk*Xkn(3, k, n)/(Uk^2*Xkn(3, k, n) + sigma^2);
|
---|
316 | Xkn(1, k+1, n) = Xkn(1, k, n) + Xkn(2, k, n)*Uk + sigma*randn();
|
---|
317 | Xkn(2, k+1, n) = Xkn(2, k, n) + Kk*(Xkn(1, k+1, n) - Xkn(1, k, n) - Xkn(2, k, n)*Uk);
|
---|
318 | Xkn(3, k+1, n) = (1 - Kk*Uk)*Xkn(3, k, n);
|
---|
319 | % plot(1:K,Xkn(1,:,n))
|
---|
320 | end
|
---|
321 | hold all
|
---|
322 | subplot(4,1,1);
|
---|
323 | plot(1:K,Xkn(1,:,n))
|
---|
324 | hold all
|
---|
325 | subplot(4,1,2);
|
---|
326 | plot(1:K,Xkn(2,:,n))
|
---|
327 | hold all
|
---|
328 | subplot(4,1,3);
|
---|
329 | plot(1:K,Xkn(3,:,n))
|
---|
330 | hold all
|
---|
331 | subplot(4,1,4);
|
---|
332 | plot(1:K-1,UU(:,n))
|
---|
333 |
|
---|
334 | end
|
---|
335 | title('CE')
|
---|
336 |
|
---|
337 | for vzorek = 1:100,
|
---|
338 | loss(vzorek) = 0;
|
---|
339 | bb = randn() + x0(2);
|
---|
340 | yy(1) = x0(1);
|
---|
341 | for k=1:K-1,
|
---|
342 | yy(k+1)=yy(k)+bb*uPi(k,[yy(k); bb; 0]);
|
---|
343 | loss(vzorek) = loss(vzorek) + (yy(k+1) - Rk(k+1))^2;
|
---|
344 | end
|
---|
345 | end
|
---|
346 | figure
|
---|
347 | hist(log(loss))
|
---|
348 |
|
---|
349 | % disp()
|
---|
350 | % X = zeros(1, K);
|
---|
351 | % b = 0;
|
---|
352 | % UU = zeros(1,K);
|
---|
353 | %
|
---|
354 | % X(1) = sigma*randn();
|
---|
355 | % for k = 1:K-1,
|
---|
356 | % Upi = uPi(k, [X,b,0]);
|
---|
357 | % UU(k) = Upi;
|
---|
358 | % X(k+1) = X(k) + b*Upi + sigma*randn();
|
---|
359 | % end
|
---|
360 | %
|
---|
361 | % % hold off
|
---|
362 | % subplot(2,1,1);
|
---|
363 | % plot(1:K,X,'-gs')
|
---|
364 | % % hold off
|
---|
365 | % subplot(2,1,2);
|
---|
366 | % plot(1:K,UU,'-gs')
|
---|
367 |
|
---|
368 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
---|
369 | %pomocne funkce
|
---|
370 |
|
---|
371 | function [val_uPi] = uPi(k_uPi, x_uPi)
|
---|
372 | val_uPi = (Rk(k_uPi) - Kpi(1, k_uPi)*x_uPi(1))/(Kpi(2, k_uPi)*x_uPi(2) + Kpi(3, k_uPi)*x_uPi(3) + Kpi(4, k_uPi));
|
---|
373 |
|
---|
374 | end
|
---|
375 |
|
---|
376 | function [val_ham, val_grad] = Hamilt(u_ham)
|
---|
377 | % Vtddx = Vtilde_dx(gka+1, Xkn(:, gka, gnu));
|
---|
378 | val_ham = (Xkn(1, gka, gnu) + Xkn(2, gka, gnu)*u_ham - Rk(gka+1))^2 + Xkn(3, gka, gnu)*u_ham^2 ... + sigma^2 ... %ztrata l
|
---|
379 | + [Xkn(2, gka, gnu)*u_ham; ...
|
---|
380 | Xkn(3, gka, gnu)*u_ham*(Xkn(1, gka+1, gnu) - Xkn(1, gka, gnu) - Xkn(2, gka, gnu)*u_ham)/(Xkn(3, gka, gnu)*u_ham^2 + sigma^2); ...
|
---|
381 | -Xkn(3, gka, gnu)^2*u_ham^2/(Xkn(3, gka, gnu)*u_ham^2 + sigma^2)]' ... %fce f
|
---|
382 | *Vtilde_dx(gka+1, Xkn(:, gka, gnu)) ...
|
---|
383 | + Wv(5, gka+1)*sigma;%+ Wv(4, gka+1)*sigma;
|
---|
384 |
|
---|
385 | val_grad = 2*(Xkn(1, gka, gnu) + Xkn(2, gka, gnu)*u_ham - Rk(gka+1))*Xkn(2, gka, gnu) + 2*Xkn(3, gka, gnu)*u_ham ... %ztrata du
|
---|
386 | + [Xkn(2, gka, gnu);...
|
---|
387 | (2*u_ham^2*Xkn(3, gka, gnu)^2*(Xkn(1, gka, gnu) - Xkn(1, gka+1, gnu) + u_ham*Xkn(2, gka, gnu)))/(sigma^2 + u_ham^2*Xkn(3, gka, gnu))^2 - (u_ham*Xkn(2, gka, gnu)*Xkn(3, gka, gnu))/(sigma^2 + u_ham^2*Xkn(3, gka, gnu)) - (Xkn(3, gka, gnu)*(Xkn(1, gka, gnu) - Xkn(1, gka+1, gnu) + u_ham*Xkn(2, gka, gnu)))/(sigma^2 + u_ham^2*Xkn(3, gka, gnu));...
|
---|
388 | (2*u_ham^3*Xkn(3, gka, gnu)^3)/(sigma^2 + u_ham^2*Xkn(3, gka, gnu))^2 - (2*u_ham*Xkn(3, gka, gnu)^2)/(sigma^2 + u_ham^2*Xkn(3, gka, gnu))]' ... %fce f du
|
---|
389 | * Vtilde_dx(gka+1, Xkn(:, gka, gnu)); %derivace Bellman fce
|
---|
390 | end
|
---|
391 |
|
---|
392 | function [val_Vt] = Vtilde(k_Vt, x_Vt)
|
---|
393 | if(k_Vt == K)
|
---|
394 | val_Vt = h;
|
---|
395 | else
|
---|
396 | Epsl = zeros(3, 1);
|
---|
397 | Epsl(1) = x_Vt(1) - Xstripe(1, k_Vt);
|
---|
398 | Epsl(2) = x_Vt(2) - Xstripe(2, k_Vt);
|
---|
399 | Epsl(3) = x_Vt(3)/Xstripe(3, k_Vt);
|
---|
400 |
|
---|
401 | val_Vt = vectFi(Epsl)' * Wv(:,k_Vt);
|
---|
402 | end
|
---|
403 | end
|
---|
404 |
|
---|
405 | function [val_Vt] = Vtilde_dx(k_Vt, x_Vt)
|
---|
406 | if(k_Vt == K)
|
---|
407 | val_Vt = hdx;
|
---|
408 | else
|
---|
409 | Epsl = zeros(3, 1);
|
---|
410 | Epsl(1) = x_Vt(1) - Xstripe(1, k_Vt);
|
---|
411 | Epsl(2) = x_Vt(2) - Xstripe(2, k_Vt);
|
---|
412 | Epsl(3) = x_Vt(3)/Xstripe(3, k_Vt);
|
---|
413 |
|
---|
414 | val_Vt = difFi(Epsl)' * Wv(:,k_Vt);
|
---|
415 | end
|
---|
416 | end
|
---|
417 |
|
---|
418 | % function [val_Vt] = Vtilde_dx_dx(k_Vt, x_Vt)
|
---|
419 | % if(k_Vt == K)
|
---|
420 | % val_Vt = hdxdx;
|
---|
421 | % else
|
---|
422 | % val_Vt = zeros(3,3);
|
---|
423 | % val_Vt(1,1) = 2*Wv(5,k_Vt);
|
---|
424 | % val_Vt(2,2) = 2*Wv(8,k_Vt);
|
---|
425 | % val_Vt(3,3) = 2*Wv(10,k_Vt);
|
---|
426 | %
|
---|
427 | % val_Vt(1,2) = Wv(6,k_Vt);
|
---|
428 | % val_Vt(1,3) = Wv(7,k_Vt);
|
---|
429 | % val_Vt(2,3) = Wv(9,k_Vt);
|
---|
430 | %
|
---|
431 | % val_Vt(2,1) = val_Vt(1,2);
|
---|
432 | % val_Vt(3,1) = val_Vt(1,3);
|
---|
433 | % val_Vt(3,2) = val_Vt(2,3);
|
---|
434 | % end
|
---|
435 | % end
|
---|
436 |
|
---|
437 | % function [val_Vt] = trSgVt(k_Vt)
|
---|
438 | % if(k_Vt == K)
|
---|
439 | % val_Vt = 0;
|
---|
440 | % else
|
---|
441 | % val_Vt = 2*Wv(5,k_Vt)*sigma;
|
---|
442 | % end
|
---|
443 | % end
|
---|
444 |
|
---|
445 | function [val_Fi] = vectFi(x_Fi)
|
---|
446 | val_Fi = [ ...
|
---|
447 | 1; ...
|
---|
448 | x_Fi(1); ...
|
---|
449 | x_Fi(2); ...
|
---|
450 | log(x_Fi(3)); ...
|
---|
451 | x_Fi(1)^2; ...
|
---|
452 | x_Fi(1)*x_Fi(2); ...
|
---|
453 | x_Fi(1)*log(x_Fi(3)); ...
|
---|
454 | x_Fi(2)^2; ...
|
---|
455 | x_Fi(2)*log(x_Fi(3)); ...
|
---|
456 | % 2*ln(x_Fi(3)); ...
|
---|
457 | ];
|
---|
458 | end
|
---|
459 |
|
---|
460 | function [val_Fi] = matrixFi(x_Fi)
|
---|
461 | val_Fi = [ ...
|
---|
462 | ones(1, N); ...
|
---|
463 | x_Fi(1, :); ...
|
---|
464 | x_Fi(2, :); ...
|
---|
465 | log(x_Fi(3, :)); ...
|
---|
466 | x_Fi(1, :).^2; ...
|
---|
467 | x_Fi(1, :).*x_Fi(2, :); ...
|
---|
468 | x_Fi(1, :).*log(x_Fi(3, :)); ...
|
---|
469 | x_Fi(2, :).^2; ...
|
---|
470 | x_Fi(2, :).*log(x_Fi(3, :)); ...
|
---|
471 | % 2*ln(x_Fi(3, :)); ...
|
---|
472 | ];
|
---|
473 | % val_Fi = [ ...
|
---|
474 | % ones(1, N); ...
|
---|
475 | % x_Fi(1, :); ...
|
---|
476 | % x_Fi(2, :); ...
|
---|
477 | % x_Fi(3, :); ...
|
---|
478 | % ];
|
---|
479 | end
|
---|
480 |
|
---|
481 | function [val_Fi] = difFi(x_Fi)
|
---|
482 | val_Fi = [ ...
|
---|
483 | 0 0 0; ...
|
---|
484 | 1 0 0; ...
|
---|
485 | 0 1 0; ...
|
---|
486 | 0 0 1/(x_Fi(3)); ...
|
---|
487 | 2*x_Fi(1) 0 0; ...
|
---|
488 | x_Fi(2) x_Fi(1) 0; ...
|
---|
489 | log(x_Fi(3)) 0 x_Fi(1)/(x_Fi(3)); ...
|
---|
490 | 0 2*x_Fi(2) 0; ...
|
---|
491 | 0 log(x_Fi(3)) x_Fi(2)/(x_Fi(3)); ...
|
---|
492 | % 0 0 2*x_Fi(3); ...
|
---|
493 | ];
|
---|
494 | end
|
---|
495 | end |
---|