
Hi, Is there any reason why scipy has no pole placement method (ppol in Scilab or place in Matlab)? I.e for a given linear system xdot=A*X+B*U, and a given set of poles P, find K such as eigenvalues(A-BK)=P ? Or did I miss it in the doc ? I'm aware of python-control (http://www.cds.caltech.edu/~murray/wiki/Control_Systems_Library_for_Python) but 99.9% of the time I use it it is ONLY for pole placement as scipy already provides enough tools for simple linear systems simulations, furthermore python-control's place() function only task is to call the relevant function in the Scilot library (which I also need to install BTW+ bindings from scylot). So, I've started to port in "pure" numpy/python matlab's place() function which is based on Kautsky et Al's algorithm, would it be of any intest for you ? It is not rocket science, and it is not finished yet, but I thought it could be useful for other people. Let me know what you think and sorry for the disturbance if it is not relevant for you. Regards -- Irvin

On Wed, Nov 26, 2014 at 7:59 PM, Irvin Probst < irvin.probst@ensta-bretagne.fr> wrote:
Hi,
Is there any reason why scipy has no pole placement method (ppol in Scilab or place in Matlab)?
Simply that no one has implemented it yet.
I.e for a given linear system xdot=A*X+B*U, and a given set of poles P, find K such as eigenvalues(A-BK)=P ? Or did I miss it in the doc ?
I'm aware of python-control ( http://www.cds.caltech.edu/~murray/wiki/Control_Systems_Library_for_Python ) but 99.9% of the time I use it it is ONLY for pole placement as scipy already provides enough tools for simple linear systems simulations, furthermore python-control's place() function only task is to call the relevant function in the Scilot library (which I also need to install BTW+ bindings from scylot).
So, I've started to port in "pure" numpy/python matlab's place() function which is based on Kautsky et Al's algorithm, would it be of any intest for you ? It is not rocket science, and it is not finished yet, but I thought it could be useful for other people.
This function would be useful to add to scipy.signal it looks like. Contribution very welcome. You cannot submit code that you translated from Matlab though, you'd have to implement it based on a paper describing the algorithm or translate it from BSD-compatible code. Ralf

On Wed, 26 Nov 2014 21:29:11 +0100, Ralf Gommers wrote:
This function would be useful to add to scipy.signal it looks like. Contribution very welcome. You cannot submit code that you translated from Matlab though, you'd have to implement it based on a paper describing the algorithm or translate it from BSD-compatible code.
The problem is that matlab's function was written in 1986 using the paper describing the algorithm I wished to implement (I realized that only after looking at this paper). Whatever I'll do it will still be the same algorithm providing the same solution, which in the end is not a bad thing as matlab's place() is probably the most used pole placement function. Of course I can obfuscate it such as it does not look like matlab's code but you can't change the fact that I wrote it while reading matlab's code... Do you have any advices on what I should do ? If it can be of any help see at the end of this email the header of matlab's place.m. There is also an algorithm in Scilab (I can't remember the main author name) but it's written in Fortran and I'm not fluent in this language... Source is here: http://people.eng.unimelb.edu.au/mcgood/ctrl433/matlab/place.m function [K,prec,message] = place(A,B,P) %PLACE Pole placement technique % % K = PLACE(A,B,P) computes a state-feedback matrix K such that % the eigenvalues of A-B*K are those specified in vector P. % No eigenvalue should have a multiplicity greater than the % number of inputs. % % [K,PREC,MESSAGE] = PLACE(A,B,P) returns PREC, an estimate of how % closely the eigenvalues of A-B*K match the specified locations P % (PREC measures the number of accurate decimal digits in the actual % closed-loop poles). If some nonzero closed-loop pole is more than % 10% off from the desired location, MESSAGE contains a warning % message. % % See also ACKER. % M. Wette 10-1-86 % Revised 9-25-87 JNL % Revised 8-4-92 Wes Wang % Revised 10-5-93, 6-1-94 Andy Potvin % Revised 4-11-2001 John Glass, Pascal Gahinet % % Ref:: Kautsky, Nichols, Van Dooren, "Robust Pole Assignment in Linear % State Feedback," Intl. J. Control, 41(1985)5, pp 1129-1155 % % Copyright 1986-2001 The MathWorks, Inc. % $Revision: 1.13 $ $Date: 2001/08/27 12:58:53 $

On Wed, Nov 26, 2014 at 10:06 PM, Irvin Probst < irvin.probst@ensta-bretagne.fr> wrote:
On Wed, 26 Nov 2014 21:29:11 +0100, Ralf Gommers wrote:
This function would be useful to add to scipy.signal it looks like. Contribution very welcome. You cannot submit code that you translated from Matlab though, you'd have to implement it based on a paper describing the algorithm or translate it from BSD-compatible code.
The problem is that matlab's function was written in 1986 using the paper describing the algorithm I wished to implement (I realized that only after looking at this paper). Whatever I'll do it will still be the same algorithm providing the same solution, which in the end is not a bad thing as matlab's place() is probably the most used pole placement function. Of course I can obfuscate it such as it does not look like matlab's code but you can't change the fact that I wrote it while reading matlab's code...
Well, the issue is not that you implement the same algorithm which might make the source code look similar, but that you looked at the Matlab source code. Linking that source code probably doesn't help either:) What I suggest is that you contact the authors of the Scilab algorithm and ask them if they're willing to relicense their code under the BSD license for inclusion in Scipy. And then wrap that with f2py (probably won't be too hard). Ralf Do you have any advices on what I should do ? If it can be of any help
see at the end of this email the header of matlab's place.m.
There is also an algorithm in Scilab (I can't remember the main author name) but it's written in Fortran and I'm not fluent in this language...
Source is here: http://people.eng.unimelb.edu.au/mcgood/ctrl433/matlab/place.m
function [K,prec,message] = place(A,B,P) %PLACE Pole placement technique % % K = PLACE(A,B,P) computes a state-feedback matrix K such that % the eigenvalues of A-B*K are those specified in vector P. % No eigenvalue should have a multiplicity greater than the % number of inputs. % % [K,PREC,MESSAGE] = PLACE(A,B,P) returns PREC, an estimate of how % closely the eigenvalues of A-B*K match the specified locations P % (PREC measures the number of accurate decimal digits in the actual % closed-loop poles). If some nonzero closed-loop pole is more than % 10% off from the desired location, MESSAGE contains a warning % message. % % See also ACKER.
% M. Wette 10-1-86 % Revised 9-25-87 JNL % Revised 8-4-92 Wes Wang % Revised 10-5-93, 6-1-94 Andy Potvin % Revised 4-11-2001 John Glass, Pascal Gahinet % % Ref:: Kautsky, Nichols, Van Dooren, "Robust Pole Assignment in Linear % State Feedback," Intl. J. Control, 41(1985)5, pp 1129-1155 %
% Copyright 1986-2001 The MathWorks, Inc. % $Revision: 1.13 $ $Date: 2001/08/27 12:58:53 $ _______________________________________________ SciPy-Dev mailing list SciPy-Dev@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-dev

I've already implemented the scicoslab algorithm for my yottalab packages wich covers some not already implemented functions in the python-control package. This file: http://robertobucher.dti.supsi.ch/bucherdl/pyControlDistro.tgz contains the folder "toolbox->supsictrl>pplace" with the required files, and in yottalab.py is implemented the "placep" function. I had contacts with the people developing scicoslab, and the files where from an old slycot library version which were distributed under GPL (if I right remember). Best regards Roberto On 11/26/2014 10:25 PM, Ralf Gommers wrote:
On Wed, Nov 26, 2014 at 10:06 PM, Irvin Probst <irvin.probst@ensta-bretagne.fr <mailto:irvin.probst@ensta-bretagne.fr>> wrote:
On Wed, 26 Nov 2014 21:29:11 +0100, Ralf Gommers wrote: > > This function would be useful to add to scipy.signal it looks like. > Contribution very welcome. You cannot submit code that you translated > from Matlab though, you'd have to implement it based on a paper > describing the algorithm or translate it from BSD-compatible code.
The problem is that matlab's function was written in 1986 using the paper describing the algorithm I wished to implement (I realized that only after looking at this paper). Whatever I'll do it will still be the same algorithm providing the same solution, which in the end is not a bad thing as matlab's place() is probably the most used pole placement function. Of course I can obfuscate it such as it does not look like matlab's code but you can't change the fact that I wrote it while reading matlab's code...
Well, the issue is not that you implement the same algorithm which might make the source code look similar, but that you looked at the Matlab source code. Linking that source code probably doesn't help either:)
What I suggest is that you contact the authors of the Scilab algorithm and ask them if they're willing to relicense their code under the BSD license for inclusion in Scipy. And then wrap that with f2py (probably won't be too hard).
Ralf
Do you have any advices on what I should do ? If it can be of any help see at the end of this email the header of matlab's place.m.
There is also an algorithm in Scilab (I can't remember the main author name) but it's written in Fortran and I'm not fluent in this language...
Source is here: http://people.eng.unimelb.edu.au/mcgood/ctrl433/matlab/place.m
function [K,prec,message] = place(A,B,P) %PLACE Pole placement technique % % K = PLACE(A,B,P) computes a state-feedback matrix K such that % the eigenvalues of A-B*K are those specified in vector P. % No eigenvalue should have a multiplicity greater than the % number of inputs. % % [K,PREC,MESSAGE] = PLACE(A,B,P) returns PREC, an estimate of how % closely the eigenvalues of A-B*K match the specified locations P % (PREC measures the number of accurate decimal digits in the actual % closed-loop poles). If some nonzero closed-loop pole is more than % 10% off from the desired location, MESSAGE contains a warning % message. % % See also ACKER.
% M. Wette 10-1-86 % Revised 9-25-87 JNL % Revised 8-4-92 Wes Wang % Revised 10-5-93, 6-1-94 Andy Potvin % Revised 4-11-2001 John Glass, Pascal Gahinet % % Ref:: Kautsky, Nichols, Van Dooren, "Robust Pole Assignment in Linear % State Feedback," Intl. J. Control, 41(1985)5, pp 1129-1155 %
% Copyright 1986-2001 The MathWorks, Inc. % $Revision: 1.13 $ $Date: 2001/08/27 12:58:53 $ _______________________________________________ SciPy-Dev mailing list SciPy-Dev@scipy.org <mailto:SciPy-Dev@scipy.org> http://mail.scipy.org/mailman/listinfo/scipy-dev
_______________________________________________ SciPy-Dev mailing list SciPy-Dev@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-dev

Hi all, please find attached what I wrote for pole placement. I used the famous KNV algorithms (Kautsky, Nichols, Van Dooreen) method 0 and 1 (see Robust Pole assignments in linear state feedback, http://la.epfl.ch/files/content/sites/la/files/users/105941/public/KautskyNi... ) Method 0 is what Matlab uses, in this implementation it works well if the poles are real, I think I can fix it to work with complex poles also but it's not my top priority. Method 1 is another approach to get the same results, it works most of the time but on some specific cases it fails. It is related to rank(X) decreasing sometimes over the iteration process but I simply can't understand what I'm missing here. As this method yields the same results as method 0 but is much more difficult to implement, I'm not sure I'll investigate this any further. Now knowing the Matlab licensing issue, I used their source code to stay as far as possible from their implementation. Especially they use SVD decomposition all over step A and step F (see p 1144-1145) of the algorithm so I used QR decomposition instead. In step X, method 0 however there is no magic, we implemented the same algorithm so it looks the same ! So if the scipy maintainers think the licensing issues are cleared I would be very happy to work further on the code of method0 in order to integrate it to Scipy, or if is definitely a problem to use the same algorithm as Matlab then I could try to implement method 2/3 if I find some time but I can't promise anything. Finally please discard the tests in the main part of the code, I used matlab to check if my code worked as expected. P.S: Ralf, as I made some changes since yesterday I thought it was better to avoid spamming you and send this directly to the ML.

Hi all, I have finished a new version of a tentative place function for Scipy with Yang Tits' algorithm (improvement over KNV method 0), the user can choose between both Yang Tits or KNV at runtime (method="YT" or method="KNV0"). See http://drum.lib.umd.edu/handle/1903/5598 I think YT is what Slicot uses but this time I played it safe and I did not check the source code, this implementation is 100% original (with all that it implies regarding bugs...). Once again only real poles are supported, rough tests show that YT gives better conditioning of the eigen vectors of (A-BK) on 50% of my tests, KNV 25% and they are equal otherwise. Please not that these are only rough tests with dumb random matrices, it is not a claim over the respective performances of these algorithms in real life, and I'm pretty sure my implementation does not give results as clean as the original matlab/fortran code polished over decades does (I plan to test that later). Is there a documentation/tutorial anywhere about what should or should not be done when trying to include code into Scipy ? I mean coding style, patch format and so on. Regards. P.S: I did not attach my code to this email as it is not yet clean enough but I would be pleased to send it to anyone who requests it

Pole placement without complex poles is not usable in praxis. Usaually we put all the poles on the bandwidth circle, chhosing damping factors to have 3%-5% of overshooting. At present, I'm using a pole plecement routine combined with a Fortran wrapper calling the procedures from an old slycot library. This the same solution implemented in Scicoslab, NSP and I think scilab too. The good conditioning of the results is demostrated by a set of practical implementations on real plants in our laboratory at the SUPSI. Best regards Roberto On 12/05/2014 06:43 PM, Irvin Probst wrote:
Hi all, I have finished a new version of a tentative place function for Scipy with Yang Tits' algorithm (improvement over KNV method 0), the user can choose between both Yang Tits or KNV at runtime (method="YT" or method="KNV0"). See http://drum.lib.umd.edu/handle/1903/5598
I think YT is what Slicot uses but this time I played it safe and I did not check the source code, this implementation is 100% original (with all that it implies regarding bugs...).
Once again only real poles are supported, rough tests show that YT gives better conditioning of the eigen vectors of (A-BK) on 50% of my tests, KNV 25% and they are equal otherwise. Please not that these are only rough tests with dumb random matrices, it is not a claim over the respective performances of these algorithms in real life, and I'm pretty sure my implementation does not give results as clean as the original matlab/fortran code polished over decades does (I plan to test that later).
Is there a documentation/tutorial anywhere about what should or should not be done when trying to include code into Scipy ? I mean coding style, patch format and so on.
Regards.
P.S: I did not attach my code to this email as it is not yet clean enough but I would be pleased to send it to anyone who requests it
_______________________________________________ SciPy-Dev mailing list SciPy-Dev@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-dev
participants (3)
-
Irvin Probst
-
Ralf Gommers
-
SUPSI