From: Greg Heath on
On Jun 13, 1:37 pm, "Petros " <p3t...(a)gmail.com> wrote:
> I try to run a one-variable optimization of a function that makes use of the heaviside function.
>
> I have:
> Q={700 if x(1)<5, 600 if 5<x(1)<10, 200 if 10<x(1)} or using heaviside functions,
> Q=700-100*heaviside(x(1)-5)-400*heaviside(x(1)-10)
>
> also I have
> P=100+100*heaviside(x(1)-6)+400*heaviside(x(1)-13)
>
> bound: x(1)>0
>
> I want to minimize f=Q-P
>
> I always get:
> Optimization completed because the objective function is non-decreasing in
> feasible directions, to within the default value of the function tolerance,
> and constraints were satisfied to within the default value of the constraint tolerance.
>
> and I get as solution the point I give as starting point. I believe the problem is the heavisides?
>
> Thanks.

If that, indeed, is your ONLY problem then you probably can
sneak up on the answer by replacing the Heaviside by a
sequence of logsigs (if you have the NN Toolbox otherwise
just use the definition)

logsig(a(n)*x) = 1/(1+exp(-a(n)*x))

a(n) > a(n-1) >= a(1) = 1

Hope this helps.

Greg
From: Petros on
Greg Heath <heath(a)alumni.brown.edu> wrote in message <dde7f674-e072-434d-8213-10ee9a1a9d2e(a)5g2000vbf.googlegroups.com>...
> On Jun 13, 1:37 pm, "Petros " <p3t...(a)gmail.com> wrote:
> > I try to run a one-variable optimization of a function that makes use of the heaviside function.
> >
> > I have:
> > Q={700 if x(1)<5, 600 if 5<x(1)<10, 200 if 10<x(1)} or using heaviside functions,
> > Q=700-100*heaviside(x(1)-5)-400*heaviside(x(1)-10)
> >
> > also I have
> > P=100+100*heaviside(x(1)-6)+400*heaviside(x(1)-13)
> >
> > bound: x(1)>0
> >
> > I want to minimize f=Q-P
> >
> > I always get:
> > Optimization completed because the objective function is non-decreasing in
> > feasible directions, to within the default value of the function tolerance,
> > and constraints were satisfied to within the default value of the constraint tolerance.
> >
> > and I get as solution the point I give as starting point. I believe the problem is the heavisides?
> >
> > Thanks.
>
> If that, indeed, is your ONLY problem then you probably can
> sneak up on the answer by replacing the Heaviside by a
> sequence of logsigs (if you have the NN Toolbox otherwise
> just use the definition)
>
> logsig(a(n)*x) = 1/(1+exp(-a(n)*x))
>
> a(n) > a(n-1) >= a(1) = 1
>
> Hope this helps.
>
> Greg

Sorry, didn't get that NN thing.

I understand what all you people are saying and I agree. The problem is that with a rough estimation I have made the full scale problem will have more than 100 000 "pieces". That is why I hoped for the optimization. I can do it brute force (with x1 x2 increments of 0.1) but... Normally, if I aggregate all the heaviside in large number I can approximate each function with fit curve 2a+b*x+c*x^2+..." and go from there. I will go with the brute force program now and I will see how it goes.

Thanks for help. You gave me plenty ideas and helped me focus.
From: Greg Heath on
On Jun 14, 3:58 am, "Petros " <p3t...(a)gmail.com> wrote:
> Greg Heath <he...(a)alumni.brown.edu> wrote in message <dde7f674-e072-434d-8213-10ee9a1a9...(a)5g2000vbf.googlegroups.com>...
> > On Jun 13, 1:37 pm, "Petros " <p3t...(a)gmail.com> wrote:
> > > I try to run a one-variable optimization of a function that makes use of the heaviside function.
>
> > > I have:
> > > Q={700 if x(1)<5, 600 if 5<x(1)<10, 200 if 10<x(1)} or using heaviside functions,
> > > Q=700-100*heaviside(x(1)-5)-400*heaviside(x(1)-10)
>
> > > also I have
> > > P=100+100*heaviside(x(1)-6)+400*heaviside(x(1)-13)
>
> > > bound: x(1)>0
>
> > > I want to minimize f=Q-P
>
> > > I always get:
> > > Optimization completed because the objective function is non-decreasing in
> > > feasible directions, to within the default value of the function tolerance,
> > > and constraints were satisfied to within the default value of the constraint tolerance.
>
> > > and I get as solution the point I give as starting point. I believe the problem is the heavisides?
>
> > > Thanks.
>
> > If that, indeed, is your ONLY problem then you probably can
> > sneak up on the answer by replacing the Heaviside by a
> > sequence of logsigs (if you have the NN Toolbox otherwise
> > just use the definition)
>
> > logsig(a(n)*x) = 1/(1+exp(-a(n)*x))
>
> > a(n) > a(n-1) >= a(1) = 1
>
> > Hope this  helps.
>
> > Greg
>
> Sorry, didn't get that NN thing.

If you have the NN Tbx, then you can use the function "logsig".
Otherwise, just use the definition and "exp".


Greg
From: Petros on
I do have the NN toolbox (because I work at my university's pc which has all toolbox) but even if I use that, how do I solve the problem later?
From: Steven Lord on

"Petros " <p3tris(a)gmail.com> wrote in message
news:hv34vv$91u$1(a)fred.mathworks.com...
>I try to run a one-variable optimization of a function that makes use of
>the heaviside function.
>
> I have:
> Q={700 if x(1)<5, 600 if 5<x(1)<10, 200 if 10<x(1)} or using heaviside
> functions,
> Q=700-100*heaviside(x(1)-5)-400*heaviside(x(1)-10)
>
> also I have P=100+100*heaviside(x(1)-6)+400*heaviside(x(1)-13)
>
> bound: x(1)>0
>
> I want to minimize f=Q-P

So Q's behavior changes at x1 = 5 and x1 = 10, while P's behavior changes at
x1 = 6 and x1 = 13.

Sounds like you have several problems here:

f(1) = minimize Q-P on the interval (-Inf, 5)
f(2) = minimize Q-P on the interval (5, 6)
f(3) = minimize Q-P on the interval (6, 10)
f(4) = minimize Q-P on the interval (10, 13)
f(5) = minimize Q-P on the interval (13, Inf)

Now the minimum of your whole function is the minimum value among the f's.

*snip*

> and I get as solution the point I give as starting point. I believe the
> problem is the heavisides?

The problem is the discontinuitites, as Roger and John have said.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com