# Optimizing/minimizing functions that use absolute value.

I am trying to optimize the integrated absolute error IAE and integrated time absolute error functions. These are ways of determining best gains for
control transfer functions. In the IAE the absolute value of the error is added to a sum. In the ITAE the absolute value of the error at each time period is multiplied by the time and added to a sum. Normally I use the sum of squared error SSE and it works well and optimizes easily. The SSE squares the error at each time period and adds it to as sum. The SSE results in a continuos and smooth function However, the IAE and ITAE do not. It seems that the discontinuity cause by the abs function GREATY hinders the efficiency of quasi Newton methods of finding minimums. Is this my imagination or is it real?
Also, these coefficients that result in the minimum IAE or ITAE were calculated about 50 years ago. There were computers back then but I doubt they had the techniques or the processing power to compute these coefficients. They must have been calculated by hand. How does one integrate functions ,that use absolute functions, by hand?. It seems to me that one would need to do a separate integration each time the sign of the error changed. These guys must have been very dedicated. However, the coefficients that have been handed down over the years are not quite right. I can prove it for orders up to 5 but the time it takes to find the best coefficients by using optimizing functions is very long. My Mathcad doesn't seem to converge if for 6th order models and above.
Peter Nachtwey
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>

Could you please give us a reference to the literature, showing the coefficients which were calculated?
The following comment might be useless for you, but anyway... In some computer algebra systems (such as Mathematica), if one wants to deal with an absolute value of a real function so that the absolute value may be differentiated or integrated, one should not use the built-in absolute value function (e.g., Abs in Mathematica). That's because Mathematica thinks of Abs as having a potentially complex argument and so derivatives and integrals involving Abs remain essentially unevaluated. The work-around, when one knows that the argument is always real, is to write your own absolute value function:
absreal[x_]:= Sqrt[x^2]
There is then no trouble differentiating or integrating absreal.
David
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>

No such luck for me. Mathcad refuses. Can Mathematica solve problems like this?
Peter Nachtwey
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>

That depends on how simple the problem is. For example, it succeeds with both differentiation and integration of absreal itself:
In:= absreal[x_] := Sqrt[x^2]
In:= D[absreal[x], x]
Out= x/Sqrt[x^2]
In:= Integrate[absreal[x], x]
Out= (x*Sqrt[x^2])/2
(By constrast, it returns D[Abs[x], x] and Integrate[Abs[x], x] unevaluated.)
It always succeeds with problems of the form D[absreal[f[x]], x] if it knows how to differentiate f itself. For problems of the form Integrate[absreal[f[x]], x], whether it succeeds depends on the function f, as you might suspect.
David
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
wrote:

I finally got answers but I had to do it this way ftp://ftp.deltacompsys.com/public/NG/Mathcad%20-%20MinITAE2.pdf I still think that Mathcad is doing this using numerically instead of symbolically. However the answer agree pretty much with what I have be calculating numerically. Mathcad chokes on the symbolic solutions. If I do try to get an answer it runs or locks up forever.
Peter Nactwey
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Peter Nachtwey wrote:

Using Maple (and assuming 0 < a < 2) I get
(cos(1/2*(-a^2+4)^(1/2)*t)+1/(-a^2+4)^(1/2)*a*sin(1/2*(-a^2+4)^(1/2)*t))*exp(-1/2*a*t)
for the inverse Laplace of (1-1/(s^2+a*s+1))/s, which equals your result.
If AbsErr(a,t) denotes its absolute value, then Int(AbsErr(a,t), t=0 ... infinity) can be done by summing the integrals between the zeros and for that I achieve
(1-(exp(-a*Pi/(-a^2+4)^(1/2))+1)/(exp(-a*Pi/(-a^2+4)^(1/2))-1))* exp(-(-arctan((-a^2+4)^(1/2)/a)+Pi)/(-a^2+4)^(1/2)*a)+a
But feel a bit unsure, whether that was the partial question ...
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>

The symbolic answer is impressive. My Mathcad can't do that. See my reply to Santa. Does Maple use multiple cores?
Peter Nachtwey
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
pnachtwey wrote:

It is a brute attack through slicing at the zeros, but Maple did the rest, see http://www.axelvogt.de/temp/Nachtwey.pdf (deleted the graphics for smaller size, 15 KB).
Multicores and/or 64 bit ... not sure, but at most patially, you may ask at the Maple NG.
The problem with that for commercial CAS seems to be: they must work stable over 'all' platforms and operating systems (may be such algorithms taking full advantage not yet exist)
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
wrote:

It is a brute attack through slicing at the zeros, but Maple did the rest, see http://www.axelvogt.de/temp/Nachtwey.pdf (deleted the graphics for smaller size, 15 KB).
Multicores and/or 64 bit ... not sure, but at most patially, you may ask at the Maple NG.
The problem with that for commercial CAS seems to be: they must work stable over 'all' platforms and operating systems (may be such algorithms taking full advantage not yet exist)

JCH:
As partial solution you can solve such tasks. But in practice it is much more complicated to tackle IAE minimum problems.
See error e (Page 1 and 2, red lines) in http://home.arcor.de/janch/janch/_news/20071227-axel /
Page 1: IAE via PID parameters in use (all purely numerically solved) Page 2: With feedforward and disturbance compensation without PID *) Page 3: Definitions
*) In practice one would use PID anyway.
--
Jan C. Hoffmann eMail aktuell: snipped-for-privacy@nospam.arcornews.de
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>

Does that link make sense to anybody? I don't see anything that is right.
Peter Nachtwey
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
wrote:

http://home.arcor.de/janch/janch/_news/20071227-axel /
Does that link make sense to anybody? I don't see anything that is right.
Peter Nachtwey

JCH:
http://home.arcor.de/janch/janch/_news/20071227-axel /
The red line in Page 1 is error (example). That error is minimized numerically by IAE (integrated absolute error).
Page 2 shows improvements.
--
Jan C. Hoffmann eMail aktuell: snipped-for-privacy@nospam.arcornews.de
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
wrote:

I don't see what is so difficult after one has the minimum IAE or ITAE coefficients? It is calculating coefficients accurately that is difficult. If one has the minimum IAE coefficients for each order then all that is required is to plug the plant parameters into the formulas and out pop the PID gains. See page 5 of the link below.
It would be nice if the IAE and ITAE coefficients are calculated accurately using modern software tools and computers once so everyone else can use them. Not every one has access to Maple or Mathematica and multicore 64 bit computers. One of my complaints is that ITAE coefficients appear to be wrong and that people keep using them without question. I haven't looked into the IAE coefficients yet.
BTW, I prefer critically damped systems. They are simple to calculate because there is a binomial pattern to the coefficients. If I make A1 and A2 eqaul to 3 then I would have a critically damped response with no ringing.

Those gains don't look right to me. See the formulas on the bottom of page 5. One can dispute the accuracy of my minimum IAE coefficients but they must be close. The ratio of your Ki of 1500 to a Kc ( Kp? ) of 1 is wrong. You don't show the coefficients you use or the minimum IAE that resulted. In any case your closed loop response looks a lot worse than mine and I bet my closed loop IAE is much lower than your feed forward IAE..
The graphs are STILL mislabeled. The main graph should be velocity and the two graphs below it should be acceleration and jerk. I don't know why you insist that position is proportional to the controller output instead of the velocity. When the power goes off the velocity goes to 0 and the position coasts to a stop and stays where it is at. When the power goes off, the position doesn't go to 0 as in your example.
Notice also that at time 0.25 the 'position' moves +0.1 instantly due to a disturbance. This requires an infinite amount of power. The disturbance act on the plant or actuator the same way the controller does. You need to add another term to your forcing function. Notice that I added a disturbance to my similar. I admit it is rather arbitrary because you provide no information on the distrubance. I just designed mine so the actual velocity is displaced by a litle more than 0.1 so it is similar to your disturbance. The difference is that my disturbance doesn't change the velocity instantly like your does. The response of the system is taken into account instead of just changing the position like you did. Notice that my PID recovers MUCH faster than yours.

How is it that the disturbances don't affect the feed forward control? This is not realistic at all. Also, the open loop system is already critically damped. So what is the point? The controller just outputs a open loop value proportional to the desired velocity. So what? The one reason to have a controller is that it can achieve a faster response than the open loop response.
What is the IAE for your feed forwards graph? You don't show any of your calculations so we can compae your feed forward response with a closed loop response. Your response is limited by the open loop response of the system. The feed forward graphs shows how the open loop control out is limited to 0.9. I can keep increasing omega, see page 5, to make the response as aggressive as is practical. My control output can drive the plant or actuator harder and reduce the my closed loop IAE below your feed forward IAE. This can give the closed loop control a big advantage when making small changes.

Yes feed forwards are cool. They seem to be your one trick.
To see how the coefficients are properly used see ftp://ftp.deltacompsys.com/public/NG/Mathcad%20-%20IAE3.pdf Omega is necessary to make the response faster and the corner frequency or bandwidth will roughly match omega. See tge Bode plot at the bottom. The equations on page 5 can be used to calculate the PID gains for ITAE, IAE or critically damped response. All one needs is the new set of coefficients. Hopefully someone will find the .pdf example useful. JCH should study my .pdf but I bet he will continue to deny and defy reality as he has done for the last 9 months..
Peter Nachtwey
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
wrote:

<cited>

</cited>
I showed IAE (integrated absolute error) on an useful example!
http://home.arcor.de/janch/janch/_news/20071227-axel /
Tackling real practice problems isn't nonsense. If you don't like it skip it.
--