1 | version="$Id: control.lib,v 1.2 2004-07-22 18:49:14 plural Exp $"; |
---|
2 | category="System and Control Theory"; |
---|
3 | info=" |
---|
4 | LIBRARY: control.lib Procedures for System and Control Theory |
---|
5 | AUTHORS: Oleksandr Iena yena@mathematik.uni-kl.de |
---|
6 | @* Markus Becker mbecker@mathematik.uni-kl.de |
---|
7 | |
---|
8 | SUPPORT: Forschungsschwerpunkt 'Mathematik und Praxis' |
---|
9 | |
---|
10 | |
---|
11 | PROCEDURES: |
---|
12 | declare(string NameOfRing, string Variables[, list #]); |
---|
13 | Defining the ring, optional parametes are a string of parameters and a sting of ordering. |
---|
14 | |
---|
15 | Print(); Well-formatted output of lists, modules and matrixes |
---|
16 | control(module R); Computes everthing related to controllability |
---|
17 | autonom(module R); Computes everything related to autonomy(using Exts) |
---|
18 | autonom2(module R); Computes everything related to autonomy(using dim) |
---|
19 | LeftKernel(module R); Computing the left kernel of R |
---|
20 | RightKernel(module R); Computing the right kernel of R |
---|
21 | |
---|
22 | static space(int n) Procedure used inside the procedure 'Print' to have a better formatted output |
---|
23 | static control_output(); Generating the output for the procedure 'control' |
---|
24 | static autonom_output(); Generating the output for the procedure 'autonom' and 'autonom2' |
---|
25 | |
---|
26 | "; |
---|
27 | |
---|
28 | LIB "homolog.lib"; |
---|
29 | LIB "poly.lib"; |
---|
30 | LIB "primdec.lib"; |
---|
31 | //--------------------------------------------------------------- |
---|
32 | proc declare(string NameOfRing, string Variables, list #) |
---|
33 | { |
---|
34 | if(size(#)==0) |
---|
35 | { |
---|
36 | execute("ring "+NameOfRing+"=0,("+Variables+"),dp;"); |
---|
37 | } |
---|
38 | else |
---|
39 | { |
---|
40 | if(size(#)==1) |
---|
41 | { |
---|
42 | execute( "ring " + NameOfRing + "=(0," + #[1] + "),(" + Variables + "),dp;" ); |
---|
43 | } |
---|
44 | else |
---|
45 | { |
---|
46 | if( (size(#[1])!=0)&&(#[1]!=" ") ) |
---|
47 | { |
---|
48 | execute( "ring " + NameOfRing + "=(0," + #[1] + "),(" + Variables + "),("+#[2]+");" ); |
---|
49 | } |
---|
50 | else |
---|
51 | { |
---|
52 | execute( "ring " + NameOfRing + "=0,("+Variables+"),("+#[2]+");" ); |
---|
53 | }; |
---|
54 | }; |
---|
55 | }; |
---|
56 | keepring(basering); |
---|
57 | return(); |
---|
58 | }; |
---|
59 | example |
---|
60 | {"EXAMPLE:";echo = 2; |
---|
61 | string v="x,y,z"; |
---|
62 | string p="q,p"; |
---|
63 | string Ord ="c,lp"; |
---|
64 | |
---|
65 | declare("Ring_1",v); |
---|
66 | print(nameof(basering)); |
---|
67 | print(basering); |
---|
68 | |
---|
69 | declare("Ring_2",v,p); |
---|
70 | print(basering); |
---|
71 | print(nameof(basering)); |
---|
72 | |
---|
73 | declare("Ring_3",v,p,Ord); |
---|
74 | print(basering); |
---|
75 | print(nameof(basering)); |
---|
76 | |
---|
77 | declare("Ring_4",v,"",Ord); |
---|
78 | print(basering); |
---|
79 | print(nameof(basering)); |
---|
80 | |
---|
81 | declare("Ring_5",v," ",Ord); |
---|
82 | print(basering); |
---|
83 | print(nameof(basering)); |
---|
84 | }; |
---|
85 | // |
---|
86 | //maybe reasonable to add this in declare |
---|
87 | // |
---|
88 | // print("Please enter your representation matrix in the following form: |
---|
89 | // module R=[1st row],[2nd row],..."); |
---|
90 | // print("Type the command: R=transpose(R)"); |
---|
91 | // print(" To compute controllability please enter: control(R)"); |
---|
92 | // print(" To compute autonomy please enter: autonom(R)"); |
---|
93 | // |
---|
94 | // |
---|
95 | // |
---|
96 | //------------------------------------------------------------------------- |
---|
97 | static proc space(int n) |
---|
98 | //the procedure is used in the procedure Print to have a better formatted output |
---|
99 | //USAGE:spase(int n) |
---|
100 | //RETURN: string consisting of n spases |
---|
101 | { |
---|
102 | int i; |
---|
103 | string s=""; |
---|
104 | for(i=1;i<=n;i++) |
---|
105 | { |
---|
106 | s=s+" "; |
---|
107 | }; |
---|
108 | return(s); |
---|
109 | }; |
---|
110 | //----------------------------------------------------------------------------- |
---|
111 | proc Print(M) |
---|
112 | //procedure for a well-formatted output of lists, modules and matrixes |
---|
113 | { |
---|
114 | if ( (typeof(M)=="module")||(typeof(M)=="matrix") ) |
---|
115 | { |
---|
116 | int @R=nrows(M); |
---|
117 | int @C=ncols(M); |
---|
118 | int i; |
---|
119 | int j; |
---|
120 | list MaxLength=list(); |
---|
121 | int Size=0; |
---|
122 | int max; |
---|
123 | string s; |
---|
124 | |
---|
125 | for(i=1;i<=@C;i++) |
---|
126 | { |
---|
127 | max=0; |
---|
128 | |
---|
129 | for(j=1;j<=@R;j++) |
---|
130 | { |
---|
131 | Size=size( string( M[j,i] ) ); |
---|
132 | if( Size>max ) |
---|
133 | { |
---|
134 | max=Size; |
---|
135 | }; |
---|
136 | }; |
---|
137 | MaxLength[i] = max; |
---|
138 | }; |
---|
139 | |
---|
140 | for(i=1;i<=@R;i++) |
---|
141 | { |
---|
142 | s=""; |
---|
143 | for(j=1;j<@C;j++) |
---|
144 | { |
---|
145 | s=s+string(M[i,j])+space( MaxLength[j]-size( string( M[i,j] ) ) ) +","; |
---|
146 | }; |
---|
147 | |
---|
148 | s=s+string(M[i,j])+space( MaxLength[j]-size( string( M[i,j] ) ) ); |
---|
149 | |
---|
150 | if (i!=@R) |
---|
151 | { |
---|
152 | s=s+","; |
---|
153 | }; |
---|
154 | print(s); |
---|
155 | }; |
---|
156 | |
---|
157 | return(); |
---|
158 | }; |
---|
159 | |
---|
160 | if(typeof(M)=="list") |
---|
161 | { |
---|
162 | int sz=size(M); |
---|
163 | int i; |
---|
164 | for(i=1;i<=sz;i++) |
---|
165 | { |
---|
166 | Print(M[i]); |
---|
167 | print(""); |
---|
168 | }; |
---|
169 | |
---|
170 | return(); |
---|
171 | }; |
---|
172 | print(M); |
---|
173 | return(); |
---|
174 | }; |
---|
175 | //-------------------------------------------------------------------------- |
---|
176 | proc RightKernel(matrix M) |
---|
177 | { |
---|
178 | return(syz(M)); |
---|
179 | }; |
---|
180 | //------------------------------------------------------------------------- |
---|
181 | proc LeftKernel(matrix M) |
---|
182 | { |
---|
183 | return( transpose( syz( transpose(M) ) ) ); |
---|
184 | }; |
---|
185 | //------------------------------------------------------------------------ |
---|
186 | static proc control_output(int i, int NVars, module R, module Ext_1) |
---|
187 | //in this procedure the output list with all the contollability properties of the system is generated |
---|
188 | { |
---|
189 | int d=dim( std( Ann( transpose(R) ) ) ) ;;//this is the dimension of the system |
---|
190 | string DofS= "dimension of the system:"; |
---|
191 | if(i==1) |
---|
192 | { |
---|
193 | module RK=RightKernel(R); |
---|
194 | return( |
---|
195 | list ( i, |
---|
196 | "not controllable , image representation for controllable part:", |
---|
197 | RK, |
---|
198 | "kernel representation for controllable part:", |
---|
199 | LeftKernel( RK ), |
---|
200 | "obstruction to controllability", |
---|
201 | Ext_1, |
---|
202 | "annihilator of torsion module(of obstruction to controllability)", |
---|
203 | Ann(Ext_1), |
---|
204 | DofS, |
---|
205 | d |
---|
206 | ) |
---|
207 | ); |
---|
208 | }; |
---|
209 | |
---|
210 | if(i>NVars) |
---|
211 | { |
---|
212 | return( list( -1, |
---|
213 | "strongly controllable, image representation:", |
---|
214 | RightKernel(R), |
---|
215 | DofS, |
---|
216 | d) |
---|
217 | ); |
---|
218 | }; |
---|
219 | |
---|
220 | // |
---|
221 | //now i<=NVars |
---|
222 | // |
---|
223 | |
---|
224 | if( (i==2) ) |
---|
225 | { |
---|
226 | return( list( i, |
---|
227 | "controllable, not reflexive, imagerepresentation:", |
---|
228 | RightKernel(R), |
---|
229 | DofS, |
---|
230 | d ) |
---|
231 | ); |
---|
232 | }; |
---|
233 | |
---|
234 | if( (i>=3) ) |
---|
235 | { |
---|
236 | return( list ( i, |
---|
237 | "reflexive, not strongly controllable, image representation:", |
---|
238 | RightKernel(R), |
---|
239 | DofS, |
---|
240 | d) |
---|
241 | ); |
---|
242 | }; |
---|
243 | |
---|
244 | |
---|
245 | }; |
---|
246 | //------------------------------------------------------------------------- |
---|
247 | |
---|
248 | proc control(module R) |
---|
249 | //"Computes the controllability of a behaviour represented by the matrix R" |
---|
250 | { |
---|
251 | int i; |
---|
252 | int NVars=nvars(basering); |
---|
253 | int ExtIsZero; |
---|
254 | |
---|
255 | |
---|
256 | module Ext_1 = std(Ext_R(1,R)); |
---|
257 | |
---|
258 | ExtIsZero=is_zero(Ext_1); |
---|
259 | i=1; |
---|
260 | while( (ExtIsZero) && (i<=NVars) ) |
---|
261 | { |
---|
262 | i++; |
---|
263 | ExtIsZero = is_zero( Ext_R(i,R) ); |
---|
264 | }; |
---|
265 | |
---|
266 | return( control_output( i, NVars, R, Ext_1 ) ); |
---|
267 | }; |
---|
268 | example |
---|
269 | {"EXAMPLE:";echo = 2; |
---|
270 | //------------------------------- |
---|
271 | ring r=0,(s1,s2,s3),dp; |
---|
272 | module R=[0,-s3,s2], |
---|
273 | [s3,0,-s1]; |
---|
274 | R=transpose(R); |
---|
275 | Print( R ); |
---|
276 | Print( control(R) ); |
---|
277 | |
---|
278 | module Rc=[0,-s3,s2], |
---|
279 | [s3,0,-s1], |
---|
280 | [-s2,s1,0]; |
---|
281 | Rc=transpose(Rc); |
---|
282 | Print( Rc ); |
---|
283 | Print( control(Rc) ); |
---|
284 | //---------------------------------- |
---|
285 | //reflector antenna |
---|
286 | ring A = (0, K1, K2, Te, Kp, Kc),(Dt, delta), dp; |
---|
287 | module R; |
---|
288 | R = [Dt, -K1, 0, 0, 0, 0, 0, 0, 0], |
---|
289 | [0, Dt+K2/Te, 0, 0, 0, 0, -Kp/Te*delta, -Kc/Te*delta, -Kc/Te*delta], |
---|
290 | [0, 0, Dt, -K1, 0, 0, 0, 0, 0], |
---|
291 | [0, 0, 0, Dt+K2/Te, 0, 0, -Kc/Te*delta, -Kp/Te*delta, -Kc/Te*delta], |
---|
292 | [0, 0, 0, 0, Dt, -K1, 0, 0, 0], |
---|
293 | [0, 0, 0, 0, 0, Dt+K2/Te, -Kc/Te*delta, -Kc/Te*delta, -Kp/Te*delta]; |
---|
294 | R=transpose(R); |
---|
295 | Print(R); |
---|
296 | Print(control(R)); |
---|
297 | //---------------------------------- |
---|
298 | //Flexible Rod |
---|
299 | ring A = 0,(D1, delta), dp; |
---|
300 | module R; |
---|
301 | R = [D1, -D1*delta, -1], |
---|
302 | [2*D1*delta, -D1-D1*delta^2, 0]; |
---|
303 | R=transpose(R); |
---|
304 | Print(R); |
---|
305 | Print(control(R)); |
---|
306 | //------------------------------------- |
---|
307 | //TwoPendula |
---|
308 | ring r=(0,m1,m2,M,g,L1,L2),Dt,dp; |
---|
309 | module R; |
---|
310 | R = [m1*L1*Dt^2, m2*L2*Dt^2, -1, (M+m1+m2)*Dt^2], |
---|
311 | [m1*L1^2*Dt^2-m1*L1*g, 0, 0, m1*L1*Dt^2], |
---|
312 | [0, m2*L2^2*Dt^2-m2*L2*g, 0, m2*L2*Dt^2]; |
---|
313 | R=transpose(R); |
---|
314 | Print(R); |
---|
315 | Print(control(R)); |
---|
316 | //---------------------------------------- |
---|
317 | //Wind Tunnel |
---|
318 | ring A = (0,a, omega, zeta, k),(D1, delta),dp; |
---|
319 | module R; |
---|
320 | R = [D1+a, -k*a*delta, 0, 0], |
---|
321 | [0, D1, -1, 0], |
---|
322 | [0, omega^2, D1+2*zeta*omega, -omega^2]; |
---|
323 | R=transpose(R); |
---|
324 | Print(R); |
---|
325 | Print(control(R)); |
---|
326 | //------------------------------------------- |
---|
327 | |
---|
328 | }; |
---|
329 | //------------------------------------------------------------------------ |
---|
330 | static proc autonom_output( int i, int NVars ) |
---|
331 | //in this procedure the output list with all the autonomy properties of the system is generated |
---|
332 | { |
---|
333 | int d=NVars-i;//that is the dimension of the system |
---|
334 | string DofS="dimension of the system:"; |
---|
335 | if(i==0) |
---|
336 | { |
---|
337 | return( list( i, |
---|
338 | "not autonomous", |
---|
339 | DofS, |
---|
340 | d ) |
---|
341 | ); |
---|
342 | }; |
---|
343 | |
---|
344 | if( i>NVars ) |
---|
345 | { |
---|
346 | return( list( -1, |
---|
347 | "trivial", |
---|
348 | DofS, |
---|
349 | d ) |
---|
350 | ); |
---|
351 | }; |
---|
352 | |
---|
353 | // |
---|
354 | //now i<=NVars |
---|
355 | // |
---|
356 | |
---|
357 | |
---|
358 | if( i==1 ) |
---|
359 | //in case that NVars==1 there is no sence to consider the notion |
---|
360 | //of strongly autonomous behavior, because it does not imply |
---|
361 | //that system is overdetermined in this case |
---|
362 | { |
---|
363 | return( list ( i, |
---|
364 | "autonomous, not overdetermined", |
---|
365 | DofS, |
---|
366 | d ) |
---|
367 | ); |
---|
368 | }; |
---|
369 | |
---|
370 | if( i==NVars ) |
---|
371 | { |
---|
372 | return( list( i, |
---|
373 | "strongly autonomous,in particular overdetermined", |
---|
374 | DofS, |
---|
375 | d) |
---|
376 | ); |
---|
377 | }; |
---|
378 | |
---|
379 | if( i<NVars ) |
---|
380 | { |
---|
381 | return( list ( i, |
---|
382 | "overdetermined, not strongly autonomous", |
---|
383 | DofS, |
---|
384 | d) |
---|
385 | ); |
---|
386 | }; |
---|
387 | |
---|
388 | }; |
---|
389 | //-------------------------------------------------------------------------- |
---|
390 | proc autonom2(module R) |
---|
391 | //analogue to autonom using dim calculations |
---|
392 | { |
---|
393 | int d; |
---|
394 | int NVars = nvars(basering); |
---|
395 | R=transpose(R); |
---|
396 | d=dim( std( Ann(R) ) ); |
---|
397 | return( autonom_output(NVars-d,NVars) ); |
---|
398 | }; |
---|
399 | example |
---|
400 | {"EXAMPLE:"; echo = 2; |
---|
401 | ring r=0,(s1,s2,s3),dp; |
---|
402 | module R=[0,-s3,s2], |
---|
403 | [s3,0,-s1]; |
---|
404 | R=transpose(R); |
---|
405 | Print( R ); |
---|
406 | Print( autonom2(R) ); |
---|
407 | |
---|
408 | module Rc=[0,-s3,s2], |
---|
409 | [s3,0,-s1], |
---|
410 | [-s2,s1,0]; |
---|
411 | Rc=transpose(Rc); |
---|
412 | Print( Rc ); |
---|
413 | Print( autonom2(Rc) ); |
---|
414 | //----------------------------------- |
---|
415 | ring r=0,(s1,s2),dp; |
---|
416 | module R= [s1,-s2], |
---|
417 | [s2, s1]; |
---|
418 | R=transpose(R); |
---|
419 | Print( R ); |
---|
420 | Print( autonom2(R) ); |
---|
421 | |
---|
422 | ring r=0,(s1,s2,s3,s4),dp; |
---|
423 | module R= [s1,-s2], |
---|
424 | [s2, s1], |
---|
425 | [s3,-s4], |
---|
426 | [s4, s3]; |
---|
427 | R=transpose(R); |
---|
428 | Print( R ); |
---|
429 | Print( autonom2(R) ); |
---|
430 | //---------------------------------------- |
---|
431 | ring r=0,(d1,d2),dp; |
---|
432 | module R=[d1^2-d2], |
---|
433 | [d2^2-1]; |
---|
434 | R=transpose(R); |
---|
435 | Print(R); |
---|
436 | Print(autonom2(R)); |
---|
437 | }; |
---|
438 | //--------------------------------------------------------------------------- |
---|
439 | |
---|
440 | proc autonom(module R) |
---|
441 | //"Computes the autonomy of a behaviour represented by the matrix R" |
---|
442 | { |
---|
443 | int i; |
---|
444 | int NVars=nvars(basering); |
---|
445 | int ExtIsZero; |
---|
446 | |
---|
447 | |
---|
448 | R=transpose(R); |
---|
449 | |
---|
450 | |
---|
451 | ExtIsZero=is_zero(Ext_R(0,R)); |
---|
452 | |
---|
453 | i=0; |
---|
454 | while( (ExtIsZero)&&(i<=NVars) ) |
---|
455 | { |
---|
456 | i++; |
---|
457 | ExtIsZero = is_zero(Ext_R(i,R)); |
---|
458 | }; |
---|
459 | |
---|
460 | return(autonom_output(i,NVars)); |
---|
461 | |
---|
462 | }; |
---|
463 | example |
---|
464 | {"EXAMPLE:"; echo = 2; |
---|
465 | ring r=0,(s1,s2,s3),dp; |
---|
466 | module R=[0,-s3,s2], |
---|
467 | [s3,0,-s1]; |
---|
468 | R=transpose(R); |
---|
469 | Print( R ); |
---|
470 | Print( autonom(R) ); |
---|
471 | |
---|
472 | module Rc=[0,-s3,s2], |
---|
473 | [s3,0,-s1], |
---|
474 | [-s2,s1,0]; |
---|
475 | Rc=transpose(Rc); |
---|
476 | Print( Rc ); |
---|
477 | Print( autonom(Rc) ); |
---|
478 | //----------------------------------- |
---|
479 | ring r=0,(s1,s2),dp; |
---|
480 | module R= [s1,-s2], |
---|
481 | [s2, s1]; |
---|
482 | R=transpose(R); |
---|
483 | Print( R ); |
---|
484 | Print( autonom(R) ); |
---|
485 | |
---|
486 | ring r=0,(s1,s2,s3,s4),dp; |
---|
487 | module R= [s1,-s2], |
---|
488 | [s2, s1], |
---|
489 | [s3,-s4], |
---|
490 | [s4, s3]; |
---|
491 | R=transpose(R); |
---|
492 | Print( R ); |
---|
493 | Print( autonom(R) ); |
---|
494 | //---------------------------------------- |
---|
495 | ring r=0,(d1,d2),dp; |
---|
496 | module R=[d1^2-d2], |
---|
497 | [d2^2-1]; |
---|
498 | R=transpose(R); |
---|
499 | Print(R); |
---|
500 | Print(autonom(R)); |
---|
501 | |
---|
502 | }; |
---|
503 | //--------------------------------------------------------------------------- |
---|