From: Roger Stafford on 13 Jun 2010 15:48 "Petros " <p3tris(a)gmail.com> wrote in message <hv38rn$sfv$1(a)fred.mathworks.com>... > Thanks for replying. Really the function is not that one. The real function is a 2-variable function with quadratic parts and heaviside functions. I just wanted to start with something simpler. I cannot avoid the heaviside functions unfortunately, because they represent decisions made by a controller. So, the functions are > > P={a if 0<x1<5; b if 5<x1} and > Q={c if 0<x2<19; d if 19<x2} and > L=(Q-P-Q0)*FINE(Q-P-Q0) where > FINE(Q-P-Q0)={e if 0<(Q-P-Q0)<100; f if 100<(Q-P-Q0)<200} > > And I try to maximize (Q-P-L) or minimize -(Q-P-L). > It's not something I can do by hand for repeated problems and I thought matlab could help me out. > > Thanks again. You haven't stated what Q0 is, but if it's like P and Q, then you still have a step function, though in two variables. That is, the function is constant over various rectangular regions in the x-y plane, (or I should say x1-x2 plane.) In spite of the '*' operation it is in no sense a quadratic function. The standard optimization routines still cannot handle these flat planar regions properly. I think you have no choice but to evaluate the function on either side of its discontinuities and select the minimum or maximum. After all, the answer lies among only finitely many possible sums, differences, and products of the numbers, a, b, c, d, e, and f. It is a mistake to invoke routines that are attuned to deal with a (nearly) infinite continuum of values? Roger Stafford
From: Roger Stafford on 13 Jun 2010 16:25 (Ignoring the as yet unspecified Q0,) you have discontinuities along the x1 axis only at 0 and 5, and along the x2 axis at 0 and 19. Define x1 = [0-1,(0+5)/2,5+1]; x2 = [0-1,(0+19)/2,19+1]; Now evaluate Q-P-L at each of the nine combinations of values in x1 and x2. That is, at [X1,X2] = meshgrid(x1,x2); and select the maximum of these nine Q-P-L values. As long as your function consists only of constant rectangular regions as in the case you have described, this kind of procedure should be all that is necessary to find the maximum. It is only when the total number of combined discontinuities are too large for practical computation that more heroic methods become necessary. Roger Stafford
From: Petros on 13 Jun 2010 16:25 I understand what you are saying. But, these functions get really complicated. How do I check finite number of possible solutions? I have managed to plot a few of them with syms and ezsurf() after that what? Q0 is a constant and the equation sometimes goes: P={c*x2^2 if x2<5; d*x2^2+e*x2 if x2>5} that's why I said quadratic. If I use the approximation I stated above and use the fmincon, will it be ok?
From: John D'Errico on 13 Jun 2010 16:59 "Petros " <p3tris(a)gmail.com> wrote in message <hv3a6r$ip3$1(a)fred.mathworks.com>... > If I use an approximation like: heaviside(x)=1/(1+exp(-50000*x)) which gives a good approximation of the heaviside funtion, will it be ok for using fmincon? NO!!!!!!! You don't understand that the problem is the non-differentiability of your function, when you then try to use an optimizer that is designed to work on a differentiable objective function. Creating a function that is IDENTICAL to a step function in ALL respects when used in floating point arithmetic is not a valid solution, since that function is also essentially non-differentiable in terms of floating point arithmetic. You can't fool mathematics by being tricky. John
From: Roger Stafford on 13 Jun 2010 18:42 "Petros " <p3tris(a)gmail.com> wrote in message <hv3er0$nk7$1(a)fred.mathworks.com>... > I understand what you are saying. But, these functions get really complicated. How do I check finite number of possible solutions? I have managed to plot a few of them with syms and ezsurf() after that what? > > Q0 is a constant and the equation sometimes goes: > > P={c*x2^2 if x2<5; d*x2^2+e*x2 if x2>5} > > that's why I said quadratic. If I use the approximation I stated above and use the fmincon, will it be ok? I have bad news for you Petros! As John has pointed out, using exp(-50000*x) will do you no good at all. It is necessary to face the discontinuities as they stand and deal with them effectively. It would be easily possible to use combinations of heavyside-type equations in such a way that would produce many not necessarily rectangular regions in the x1-x2 space in which the boundaries are discontinuous for the objective function and inside of which that function is variable in complex ways even though "smooth". If you contemplate something of this kind, I believe there is no option for you but to handle each such region separately, using an optimization routine on each if necessary. I know of no matlab routine that would automatically carry out such an analysis for you. Wasn't it Euclid who said to King Ptolemy, "there is no Royal Road to geometry"? An analogous remark might conceivably be made of functions composed of complicated heavyside-type combinations. Roger Stafford
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 Prev: Spectrogram/FFT Frequency Resolution Next: Real time Analysis |