Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
how to find local minima of a function with no obvious function form?

Subject: how to find local minima of a function with no obvious function form?

From: Kun

Date: 1 Jul, 2011 02:58:10

Message: 1 of 9

I have a local minimization problem for a function which has no obvious function form. I have read the methods in Mathwork. They all need some kind of function form. Does any one know some tool in Matlab to do that?

Thanks for your answers.

Subject: how to find local minima of a function with no obvious function form?

From: Kun

Date: 1 Jul, 2011 03:07:12

Message: 2 of 9

I point out that this is from a very complicated modeling problem. The function with multiple independent variables for optimization can never be obtained. It is also not in an implicit function form.

Subject: how to find local minima of a function with no obvious function form?

From: TideMan

Date: 1 Jul, 2011 04:00:28

Message: 3 of 9

"Kun" wrote in message <iujd42$shf$1@newscl01ah.mathworks.com>...
> I have a local minimization problem for a function which has no obvious function form. I have read the methods in Mathwork. They all need some kind of function form. Does any one know some tool in Matlab to do that?
>
> Thanks for your answers.

Please explain this:
"...a function which has no obvious function form"

Is it discrete?
If not, how can you have a function that has no form?
Give us an example.

Subject: how to find local minima of a function with no obvious function form?

From: Kun

Date: 1 Jul, 2011 06:50:27

Message: 4 of 9

"TideMan " <mulgor@gmail.com> wrote in message <iujgos$7lr$1@newscl01ah.mathworks.com>...
> "Kun" wrote in message <iujd42$shf$1@newscl01ah.mathworks.com>...
> > I have a local minimization problem for a function which has no obvious function form. I have read the methods in Mathwork. They all need some kind of function form. Does any one know some tool in Matlab to do that?
> >
> > Thanks for your answers.
>
> Please explain this:
> "...a function which has no obvious function form"
>
> Is it discrete?
> If not, how can you have a function that has no form?
> Give us an example.

Hi,
first, thanks for your quick response. An example is like this y(x)=F(r(x),x), which means F is function of r(x) and x. But the function r(x) can only be numerical obtained. However, given any x0, we can by the function y(x) get y0=y(x0) definitely. Could you consider this?

Subject: how to find local minima of a function with no obvious function form?

From: Krishna Kumar

Date: 1 Jul, 2011 07:43:09

Message: 5 of 9

"Kun" wrote in message <iujqnj$sk$1@newscl01ah.mathworks.com>...
> "TideMan " <mulgor@gmail.com> wrote in message <iujgos$7lr$1@newscl01ah.mathworks.com>...
> > "Kun" wrote in message <iujd42$shf$1@newscl01ah.mathworks.com>...
> > > I have a local minimization problem for a function which has no obvious function form. I have read the methods in Mathwork. They all need some kind of function form. Does any one know some tool in Matlab to do that?
> > >
> > > Thanks for your answers.
> >
> > Please explain this:
> > "...a function which has no obvious function form"
> >
> > Is it discrete?
> > If not, how can you have a function that has no form?
> > Give us an example.
>
> Hi,
> first, thanks for your quick response. An example is like this y(x)=F(r(x),x), which means F is function of r(x) and x. But the function r(x) can only be numerical obtained. However, given any x0, we can by the function y(x) get y0=y(x0) definitely. Could you consider this?

Hi Kun
It seems you have some code to get r from x. Would like to know what algorithms did you try? Did you try gradient based methods. I feel using metaheuristic algorithms could solve your problem

Subject: how to find local minima of a function with no obvious function form?

From: Matt J

Date: 1 Jul, 2011 08:36:24

Message: 6 of 9

"Kun" wrote in message <iujqnj$sk$1@newscl01ah.mathworks.com>...
>
> first, thanks for your quick response. An example is like this y(x)=F(r(x),x), which means F is function of r(x) and x. But the function r(x) can only be numerical obtained. However, given any x0, we can by the function y(x) get y0=y(x0) definitely. Could you consider this?
=====================

This is fine as long as you know y(x) to be twice continuously differentiable. The Optimization Toolbox functions don't require that you present y(x) in an explicit closed form. You just need to pass a function handle to an mfile that evaluates y(x).
 

Subject: how to find local minima of a function with no obvious function

From: Alan Weiss

Date: 1 Jul, 2011 12:06:06

Message: 7 of 9

On 7/1/2011 4:36 AM, Matt J wrote:
> "Kun" wrote in message <iujqnj$sk$1@newscl01ah.mathworks.com>...
>>
>> first, thanks for your quick response. An example is like this
>> y(x)=F(r(x),x), which means F is function of r(x) and x. But the
>> function r(x) can only be numerical obtained. However, given any x0,
>> we can by the function y(x) get y0=y(x0) definitely. Could you
>> consider this?
> =====================
>
> This is fine as long as you know y(x) to be twice continuously
> differentiable. The Optimization Toolbox functions don't require that
> you present y(x) in an explicit closed form. You just need to pass a
> function handle to an mfile that evaluates y(x).

Take a look at this example from the documentation:
http://www.mathworks.com/help/techdoc/math/bsgpq6p-12.html

As Matt said, all you need to do is give a MATLAB function that
calculates your objective function.

If you have Optimization Toolbox, you can probably get answers faster
and more reliably that by using fminsearch. I suggest you set
DiffMinChange to 1e-3 using optimset, since your objective function
sounds like it is evaluated via a simulation.

Good luck,

Alan Weiss
MATLAB mathematical toolbox documentation

Subject: how to find local minima of a function with no obvious function form?

From: Steven_Lord

Date: 1 Jul, 2011 13:55:37

Message: 8 of 9



"Kun " <kgou@math.tamu.edu> wrote in message
news:iujqnj$sk$1@newscl01ah.mathworks.com...
> "TideMan " <mulgor@gmail.com> wrote in message
> <iujgos$7lr$1@newscl01ah.mathworks.com>...
>> "Kun" wrote in message <iujd42$shf$1@newscl01ah.mathworks.com>...
>> > I have a local minimization problem for a function which has no obvious
>> > function form. I have read the methods in Mathwork. They all need some
>> > kind of function form. Does any one know some tool in Matlab to do
>> > that?
>> >
>> > Thanks for your answers.
>>
>> Please explain this:
>> "...a function which has no obvious function form"
>>
>> Is it discrete?
>> If not, how can you have a function that has no form?
>> Give us an example.
>
> Hi,
> first, thanks for your quick response. An example is like this
> y(x)=F(r(x),x), which means F is function of r(x) and x. But the function
> r(x) can only be numerical obtained. However, given any x0, we can by the
> function y(x) get y0=y(x0) definitely. Could you consider this?

Generally the optimization routines require that you provide it a function
that accepts an input x and returns the value of your objective function
evaluated at that input. They don't really care HOW you compute that value,
just that you do. Your objective function could simulate a Simulink model
using the input parameters. It could hand that input parameter to some
MEX-file to perform the computations. It could send that input parameter to
a machine using the SERIAL interface to be used to perform some experiment
to calculate the value of your objective "function". You could even just ask
the user to type in the answer themselves.


% begin optimizeWithUserInput.m
function x = optimizeWithUserInput
x = fmincon(@askUserForInput, 0, [], [], [], [], -1, 1);

function y = askUserForInput(x)
prompt = sprintf('\nThe input was %g. Please give me the corresponding
objective value. ', x);
y = input(prompt);
% end optimizeWithUserInput.m


--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: how to find local minima of a function with no obvious function form?

From: Kun

Date: 1 Jul, 2011 17:16:09

Message: 9 of 9

"Steven_Lord" <slord@mathworks.com> wrote in message <iukjkp$414$1@newscl01ah.mathworks.com>...
>
>
> "Kun " <kgou@math.tamu.edu> wrote in message
> news:iujqnj$sk$1@newscl01ah.mathworks.com...
> > "TideMan " <mulgor@gmail.com> wrote in message
> > <iujgos$7lr$1@newscl01ah.mathworks.com>...
> >> "Kun" wrote in message <iujd42$shf$1@newscl01ah.mathworks.com>...
> >> > I have a local minimization problem for a function which has no obvious
> >> > function form. I have read the methods in Mathwork. They all need some
> >> > kind of function form. Does any one know some tool in Matlab to do
> >> > that?
> >> >
> >> > Thanks for your answers.
> >>
> >> Please explain this:
> >> "...a function which has no obvious function form"
> >>
> >> Is it discrete?
> >> If not, how can you have a function that has no form?
> >> Give us an example.
> >
> > Hi,
> > first, thanks for your quick response. An example is like this
> > y(x)=F(r(x),x), which means F is function of r(x) and x. But the function
> > r(x) can only be numerical obtained. However, given any x0, we can by the
> > function y(x) get y0=y(x0) definitely. Could you consider this?
>
> Generally the optimization routines require that you provide it a function
> that accepts an input x and returns the value of your objective function
> evaluated at that input. They don't really care HOW you compute that value,
> just that you do. Your objective function could simulate a Simulink model
> using the input parameters. It could hand that input parameter to some
> MEX-file to perform the computations. It could send that input parameter to
> a machine using the SERIAL interface to be used to perform some experiment
> to calculate the value of your objective "function". You could even just ask
> the user to type in the answer themselves.
>
>
> % begin optimizeWithUserInput.m
> function x = optimizeWithUserInput
> x = fmincon(@askUserForInput, 0, [], [], [], [], -1, 1);
>
> function y = askUserForInput(x)
> prompt = sprintf('\nThe input was %g. Please give me the corresponding
> objective value. ', x);
> y = input(prompt);
> % end optimizeWithUserInput.m
>
>
> --
> Steve Lord
> slord@mathworks.com
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com


Thanks so much for all your answers. It works perfectly. This is my first tiem to use the optimization toolbox. Thanks

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us