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:
Setting options for fminsearch

Subject: Setting options for fminsearch

From: MC

Date: 1 Sep, 2007 23:59:44

Message: 1 of 6

I'm using Matlab 2007 R14.

I'm trying to solve a function using fminsearch. The
function takes 4 variables which should searched for to
minimize the result. How do I change the step size for the
variables when using fminsearch?
Say the 1st variable is x1. Currently fminsearch changes x1
by 0.001 with every iteration but I would like the step size
to be 1 and not 0.001. For all the variables.

I've tried:

Options = optimset('DiffMinChange', 1);
Result = fminsearch('FUN', [x1 x2 x3 x4], Options);

My function looks like this:

[AvgDistance] = ChamferTransformPixels(TransformParameters,
DistanceImage, ContourPixels)

Transformparameters is a 1x4 matrix containing the 4
variables to be searched for.

And I call the function:

InitialParameters = [1 0 0 1];

[Transformation Distance] =
fminsearch('ChamferTransformPixels', InitialParameters,
Options, VIDTPyramid{Level}, IRPixels{Level});

Please help

Subject: Setting options for fminsearch

From: John D'Errico

Date: 2 Sep, 2007 01:00:46

Message: 2 of 6

"MC " <mc@fusion-technology.net> wrote in message <fbcudg$2en
$1@fred.mathworks.com>...
> I'm using Matlab 2007 R14.
>
> I'm trying to solve a function using fminsearch. The
> function takes 4 variables which should searched for to
> minimize the result. How do I change the step size for the
> variables when using fminsearch?
> Say the 1st variable is x1. Currently fminsearch changes x1
> by 0.001 with every iteration but I would like the step size
> to be 1 and not 0.001. For all the variables.
>
> I've tried:


You can't set the stepsize.

John

Subject: Setting options for fminsearch

From: MC

Date: 2 Sep, 2007 01:49:41

Message: 3 of 6

"John D'Errico" <woodchips@rochester.rr.com> wrote in
message <fbd1vu$i86$1@fred.mathworks.com>...
> "MC " <mc@fusion-technology.net> wrote in message <fbcudg$2en
> $1@fred.mathworks.com>...
> > I'm using Matlab 2007 R14.
> >
> > I'm trying to solve a function using fminsearch. The
> > function takes 4 variables which should searched for to
> > minimize the result. How do I change the step size for the
> > variables when using fminsearch?
> > Say the 1st variable is x1. Currently fminsearch changes x1
> > by 0.001 with every iteration but I would like the step size
> > to be 1 and not 0.001. For all the variables.
> >
> > I've tried:
>
>
> You can't set the stepsize.
>
> John

Hi John

Thanks for the reply. Do you have any suggestions for
something else that I can try? I'm trying to solve an affine
transformation.

Regards

Subject: Setting options for fminsearch

From: John D'Errico

Date: 2 Sep, 2007 02:04:41

Message: 4 of 6

"MC " <mc@fusion-technology.net> wrote in message <fbd4rl$o8e
$1@fred.mathworks.com>...
> Thanks for the reply. Do you have any suggestions for
> something else that I can try? I'm trying to solve an affine
> transformation.

I'm still not sure what you need. Usually when people
want to set a stepsize to 1, they really are asking how
to solve an integer programming problem. Sometimes
it is because they have something that quantizes the
problem inside their objective function. In either of
these scenarios, fminsearch is the wrong way to
proceed.

As far as I recall about affine transformations, there
is no reason for an affine transformation to require
some minimum step size, so I'm still not sure what
is the reason for your problem.

You might look into the GADS toolbox (genetic
algorithm and direct search.)

http://www.mathworks.com/products/gads/

John

Subject: Setting options for fminsearch

From: MC

Date: 2 Sep, 2007 04:29:40

Message: 5 of 6

"John D'Errico" <woodchips@rochester.rr.com> wrote in
message <fbd5np$61j$1@fred.mathworks.com>...
> "MC " <mc@fusion-technology.net> wrote in message <fbd4rl$o8e
> $1@fred.mathworks.com>...
> > Thanks for the reply. Do you have any suggestions for
> > something else that I can try? I'm trying to solve an affine
> > transformation.
>
> I'm still not sure what you need. Usually when people
> want to set a stepsize to 1, they really are asking how
> to solve an integer programming problem. Sometimes
> it is because they have something that quantizes the
> problem inside their objective function. In either of
> these scenarios, fminsearch is the wrong way to
> proceed.
>
> As far as I recall about affine transformations, there
> is no reason for an affine transformation to require
> some minimum step size, so I'm still not sure what
> is the reason for your problem.
>
> You might look into the GADS toolbox (genetic
> algorithm and direct search.)
>
> http://www.mathworks.com/products/gads/
>
> John
>

Its not about a minimum step size but an increased step size
to increase the search speed and obtaining a rough estimate
of the transformation parameters. The step size can
therefore be anything >= 1. But thanks anyways. I will have
a look GADS.

Subject: Setting options for fminsearch

From: John D'Errico

Date: 2 Sep, 2007 11:49:47

Message: 6 of 6

"MC " <mc@fusion-technology.net> wrote in message <fbde7j$jm3
$1@fred.mathworks.com>...

> Its not about a minimum step size but an increased step size
> to increase the search speed and obtaining a rough estimate
> of the transformation parameters. The step size can
> therefore be anything >= 1. But thanks anyways. I will have
> a look GADS.

Fminsearch uses a proportional stepsize to
start the simplex. It looks like it moves out 5%
in each parameter. When a parameter is zero,
it uses a different step.

So, while fminsearch does not allow a user
specified step that overrides its default, you
can do it yourself. Merely fudge your
parameters a bit. Add 20 to them. Inside
your objective function, subtract 20 before
using them. I chose 20 of course, so that
when it takes 5% of that value, it will get a
step of 1.

This should work as long as your parameters
are all positive numbers, but it will not be
difficult to patch if some parameters are
negative. Subtract 20 for those parameters.

John

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