Path: news.mathworks.com!not-for-mail
From: "Stuart Kozola" <skozola@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Is it possible to optimize a spline function?
Date: Wed, 1 Oct 2008 15:13:36 -0400
Organization: The MathWorks, Inc.
Lines: 51
Message-ID: <gc0i54$5c6$1@fred.mathworks.com>
References: <gbug8e$2ae$1@fred.mathworks.com> <gbvk24$a2m$1@fred.mathworks.com>
Reply-To: "Stuart Kozola" <skozola@mathworks.com>
NNTP-Posting-Host: kozolas.dhcp.mathworks.com
X-Trace: fred.mathworks.com 1222888420 5510 172.31.57.172 (1 Oct 2008 19:13:40 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 1 Oct 2008 19:13:40 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579
Xref: news.mathworks.com comp.soft-sys.matlab:493173


fmincon will get you a local minima.  If your surface is highly nonlinear 
(has many local minima, or no true global minima) you need to take that into 
account when you run the optimizer.  Your choice of starting point can be 
important in getting you to the global minima if there is one.  You might 
want to run fmincon with multiple start points to ensure that you find the 
true global and don't get stuck in a local minima.  You could also try 
Genetic Algorithm or Simulated Annealing which are better at getting out of 
local minima.

"John D'Errico" <woodchips@rochester.rr.com> wrote in message 
news:gbvk24$a2m$1@fred.mathworks.com...
> "Hailey Yang" <haileyyang@hotmail.com> wrote in message 
> <gbug8e$2ae$1@fred.mathworks.com>...
>> As an example, if I use function csapi to approximate the space which are 
>> defined by some sample points and I let cs=csapi(...), then after I get 
>> this, is it possible to use some of the optimization functions, such as 
>> fmincon, to optimize this function and get the optimum? Or, if not using 
>> those optimization functions, are there other ways to optimize the spline 
>> function cs?
>
>
> Why not? Try it!
>
> x = sort(randn(20,1));
> y = -cos(x);
>
> Obviously, a local minimum will occur at x = 0.
>
> Can an optimizer find that point, off of an
> interpolated spline? Remember that the spline
> is actually only an approximation to the true
> curve, so it might not always be perfect.
>
> spl = csapi(x,y);
> fun = @(X) fnval(spl,X);
>
> LB = min(x);
> UB = max(x);
> Xstart = 0.5;
> opts = optimset('Largescale','off','Display','off');
> Xmin = fmincon(fun,Xstart,[],[],[],[],LB,UB,[],opts)
>
> Xmin =
>  -5.1909e-06
>
> HTH,
> John
>
>