Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Thread Subject: Find Minimum

Subject: Find Minimum

From: shapper

Date: 11 Feb, 2008 16:19:32

Message: 1 of 29

Hello,

I have a function as follows:

X = MyFun(A, B, C)

The only thing I know is to evaluate the function value.

I need the values of A, B and C that minimizes the value of X using
the following constraints:

- A must be an integer.
- B be a multiple of 10 between 0 and 200, i.e., 10, 20, 30, 40, ...
- C must be a multiple of 0.01 between 0 and 1, i.e, 0.01, 0.02, ... ,
0.98, 0.99, 1

I think the best way to solve this would be random search like genetic
algorithms.

Can I solve this problem in Matlab?

Could someone, please, provide me an example?

Thanks,
Miguel

Subject: Re: Find Minimum

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 11 Feb, 2008 16:34:31

Message: 2 of 29

In article <ac460e51-a1a5-4e93-9031-220be5a23e5a@f10g2000hsf.googlegroups.com>,
shapper <mdmoura@gmail.com> wrote:

>I have a function as follows:

>X = MyFun(A, B, C)

>The only thing I know is to evaluate the function value.

>I need the values of A, B and C that minimizes the value of X using
>the following constraints:

>- A must be an integer.
>- B be a multiple of 10 between 0 and 200, i.e., 10, 20, 30, 40, ...
>- C must be a multiple of 0.01 between 0 and 1, i.e, 0.01, 0.02, ... ,
>0.98, 0.99, 1

>I think the best way to solve this would be random search like genetic
>algorithms.

>Can I solve this problem in Matlab?

No you cannot. Although you have a limited number of B and C to try,
you have an infinite number of A to try. All you know about MyFun
is how to evaluate it, so you have no information about how smooth
it is or how many local minima it has or what its derivatives are,
so the only way to find the global minima under those constraints
would be to evaluate the function over all (countably-) infinite
number of combinations.

For example, the function might have a component which
looks like (A+34923217)^1062 -- a component which vanishes
for A = -34923217 but is very large elsewhere. Or perhaps
more subtly, sin((A+34923217)^1062) which will produce plenty
of small values along the way but only -one- A will minimize the
sine all the way to 0. Finding that particular A that minimizes
the value without knowing anything about the properties of the
function is effectively impossible (even if you did happen to
find A = -34923217 how would you know that there wasn't some
other A such as 670435238743202132191231275432943221794663243143213980218
that resulted in a function value 1E-9 lower?)
particular A
--
  "The beauties of conception are always superior to those of
   expression." -- Walter J. Phillips

Subject: Re: Find Minimum

From: Scott Seidman

Date: 11 Feb, 2008 16:45:10

Message: 3 of 29

roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in news:fopten$3j$1
@canopus.cc.umanitoba.ca:

> No you cannot. Although you have a limited number of B and C to try,
> you have an infinite number of A to try.

That's like saying that there's no solution for any unconstrained
optimization problem, no? People do this every day.

Yes, there's a way to solve it, but your discontinuities in parameters
might mean that matlab's "off the shelf" functions might not do it for you,
and in any case you need to be careful about falling into a local minima.

In general, the answer to "can matlab do this"-type problems is that if you
can do it in any programming language, you can do it in matlab.

--
Scott
Reverse name to reply

Subject: Re: Find Minimum

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 11 Feb, 2008 17:03:57

Message: 4 of 29

In article <Xns9A41778E37573scottseidmanmindspri@130.133.1.4>,
Scott Seidman <namdiesttocs@mindspring.com> wrote:
>roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in news:fopten$3j$1
>@canopus.cc.umanitoba.ca:

>> No you cannot. Although you have a limited number of B and C to try,
>> you have an infinite number of A to try.

>That's like saying that there's no solution for any unconstrained
>optimization problem, no?

No, it isn't. Unconstrained is not the same as not knowing anything
about the function.

>People do this every day.

>Yes, there's a way to solve it,

What way would that be? Recalling that the function in this case
is a "black box" that we are not permitted to examine and which has
an unknown complexity. For example, the original poster's MyFun(A,B,C)
could turn out to be an expression of a conjecture of a particular
set of zeros of the Zeta function, and knowing the minimum of the
function without having to evaluate all of infinity would prove
(or disprove) the conjecture.

>In general, the answer to "can matlab do this"-type problems is that if you
>can do it in any programming language, you can do it in matlab.

To my mind, you have not established that the unconstrained minima
of arbitrary black-box functions can be found in finite time in *any*
programming language.
--
   "I was very young in those days, but I was also rather dim."
   -- Christopher Priest

Subject: Re: Find Minimum

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 11 Feb, 2008 17:10:48

Message: 5 of 29

In article <Xns9A41778E37573scottseidmanmindspri@130.133.1.4>,
Scott Seidman <namdiesttocs@mindspring.com> wrote:
>roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in news:fopten$3j$1
>@canopus.cc.umanitoba.ca:

>> No you cannot. Although you have a limited number of B and C to try,
>> you have an infinite number of A to try.

>That's like saying that there's no solution for any unconstrained
>optimization problem, no? People do this every day.

>Yes, there's a way to solve it, but your discontinuities in parameters
>might mean that matlab's "off the shelf" functions might not do it for you,
>and in any case you need to be careful about falling into a local minima.

If your algorithm falls into a local minima and does not get out
by itself to continue on to the global minima, then the algorithm
is not guaranteed to find the global minima, contrary to the original
poster's requirements. The original poster requires an algorithm
which is guaranteed to find the global minima of an arbitrary
black-box function of three parameters. Is that something that
people do "every day" ?
--
  "Let me live in my house by the side of the road --
   It's here the race of men go by.
   They are good, they are bad, they are weak, they are strong
   Wise, foolish -- so am I;" -- Sam Walter Foss

Subject: Re: Find Minimum

From: Arthur G

Date: 11 Feb, 2008 18:12:10

Message: 6 of 29

On Mon, 11 Feb 2008 12:10:48 -0500, Walter Roberson =

<roberson@ibd.nrc-cnrc.gc.ca> wrote:
> In article <Xns9A41778E37573scottseidmanmindspri@130.133.1.4>,
> Scott Seidman <namdiesttocs@mindspring.com> wrote:
>> roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in news:fopten$3j=
$1
>> @canopus.cc.umanitoba.ca:
>
>>> No you cannot. Although you have a limited number of B and C to try,=

>>> you have an infinite number of A to try.
>
>> That's like saying that there's no solution for any unconstrained
>> optimization problem, no? People do this every day.
>
>> Yes, there's a way to solve it, but your discontinuities in parameter=
s
>> might mean that matlab's "off the shelf" functions might not do it fo=
r =

>> you,
>> and in any case you need to be careful about falling into a local =

>> minima.
>
> If your algorithm falls into a local minima and does not get out
> by itself to continue on to the global minima, then the algorithm
> is not guaranteed to find the global minima, contrary to the original
> poster's requirements. The original poster requires an algorithm
> which is guaranteed to find the global minima of an arbitrary
> black-box function of three parameters. Is that something that
> people do "every day" ?

If we are willing to accept an algorithm that is not *guaranteed* to
converge to the *global* minimum, then I would argue that genetic =

algorithms
are a viable option.

In addition, the GADS toolbox (Genetic Algorithms and Direct Search) als=
o
provides simulated annealing and direct search alogirthms that might be
acceptable.

Anyway, here's a simple implementation of a GA-based solution using the
GADS toolbox function "ga"

--Arthur

function [x, fval, exitflag] =3D MinimizeMyFun()
% Minimize MyFun using a genetic algorithm
% Note: We really minimize MyFun2, which calls MyFun

nvars =3D 2;
% Define lower and upper bounds
LB =3D [-inf 0 0];
UB =3D [inf 200 1];
% No other constraints
A =3D []; b =3D []; Aeq =3D []; beq =3D [];
[x, fval, exitflag] =3D ga(@MyFun2,nvars,A,b,Aeq,beq,LB,UB);

function X =3D MyFun2(ABC)
% Covert vector ABC to required A, B, and C
A =3D round(ABC(1));
B =3D round(ABC(2)/10)*10;
C =3D round(ABC(3)*100)/100;
X =3D MyFun(A,B,C);

Subject: Re: Find Minimum

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 11 Feb, 2008 18:40:01

Message: 7 of 29

In article <op.t6dgukul1g2ca1@whitaker-four-eighty-six.mit.edu>,
Arthur G <gorramfreak+news@gmail.com> wrote:

>If we are willing to accept an algorithm that is not *guaranteed* to
>converge to the *global* minimum,

The original poster's requirements were,

>>>The only thing I know is to evaluate the function value.

>>>I need the values of A, B and C that minimizes the value of X using
>>>the following constraints:

Not "find a minima" or "find a good minima" but "minimizes", which
means a global minima.

>then I would argue that genetic algorithms are a viable option.

Well, they will explore the state space, but an arbitrary
black-box function could have any number of sharp valleys
that genetic algorithms would only find by chance, especially if
the valleys were embedded in what are otherwise local maxima.
--
  "The art of storytelling is reaching its end because the epic
  side of truth, wisdom, is dying out." -- Walter Benjamin

Subject: Re: Find Minimum

From: Roger Stafford

Date: 11 Feb, 2008 18:57:04

Message: 8 of 29

shapper <mdmoura@gmail.com> wrote in message <ac460e51-
a1a5-4e93-9031-220be5a23e5a@f10g2000hsf.googlegroups.com>...
> Hello,
>
> I have a function as follows:
>
> X = MyFun(A, B, C)
>
> The only thing I know is to evaluate the function value.
>
> I need the values of A, B and C that minimizes the value of X using
> the following constraints:
>
> - A must be an integer.
> - B be a multiple of 10 between 0 and 200, i.e., 10, 20, 30, 40, ...
> - C must be a multiple of 0.01 between 0 and 1, i.e, 0.01, 0.02, ... ,
> 0.98, 0.99, 1
>
> I think the best way to solve this would be random search like genetic
> algorithms.
>
> Can I solve this problem in Matlab?
>
> Could someone, please, provide me an example?
>
> Thanks,
> Miguel
--------
  Miguel, it puzzles me that you say "The only thing I know is to evaluate the
function value," referring to 'MyFun(A,B,C)', and yet you envision the
possibility of matlab solving the problem! Is 'MyFun' some function already in
existence in matlab language or does it derive from some external black box
you know nothing about? Is it a function that was written by MathWorks? If it
is a preexisting matlab function for which you have the source code, then
surely there are things you can say about it by looking at this code such as, 1)
will it accept non-integer values for its A or B arguments or C values other
than multiples of .01, 2) will it accept out of range values, 3) is there some
likely limit to the size of A, 4) does it call on any pseudo-random functions
like 'rand' or 'randn', or 5) does it have comments in the source that hint at
the general nature of the function. I would think there should be a number of
other facts about it that could be discovered by studying the code. One
exceedingly important question to ask is whether the function is continuous
in its variables, (presuming of course that A, B, and C are allowed to vary
continuously.)

  Without any such information, that would make solving the problem a very
doubtful matter as Walter has indicated. On the other hand, it seems likely to
me that, one way or another, you should be able to determine enough about
the function that it might be solvable, as Scott asserts, by some standard
optimization methods in matlab.

  I think it is up to you, Miguel, to furnish much more information than you
have if you want useful help in this problem.

Roger Stafford


Subject: Re: Find Minimum

From: Scott Seidman

Date: 11 Feb, 2008 19:54:01

Message: 9 of 29

roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in news:fopvio$2l2$1
@canopus.cc.umanitoba.ca:

> The original poster requires an algorithm
> which is guaranteed to find the global minima of an arbitrary
> black-box function of three parameters. Is that something that
> people do "every day" ?

As a matter of fact, yes. One approach is to pick a handful of intial
guesses across the solution space, and perform the optimization starting
from each of them, and see which gives the best answer. This is done every
day (engineering vs. math), and its poor practice to assume that your error
function might not get stuck in a global minimum.

He doesn't need an algorithm guaranteed to find the global minumum, he
needs to find the global minimum. Again, many unconstrained optimization
problems are like this.

Of course, if you could evaluate the function you could also plot the
function, and get some idea of what it looks like.


--
Scott
Reverse name to reply

Subject: Re: Find Minimum

From: Scott Seidman

Date: 11 Feb, 2008 19:59:33

Message: 10 of 29

roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in news:fopv5t$1vg$1
@canopus.cc.umanitoba.ca:

> To my mind, you have not established that the unconstrained minima
> of arbitrary black-box functions can be found in finite time in *any*
> programming language.

Walter:

A mathematician and an engineer were placed equidistant from a pot of gold.
They were each given the same instructions. They were permitted to
approach the gold in increments of half their current distance from the
gold. The mathematician correctly pointed out that he would never get
there. The engineer knew he would get close enough.



--
Scott
Reverse name to reply

Subject: Re: Find Minimum

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 11 Feb, 2008 20:17:43

Message: 11 of 29

In article <Xns9A419793662B6scottseidmanmindspri@130.133.1.4>,
Scott Seidman <namdiesttocs@mindspring.com> wrote:
>roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in news:fopvio$2l2$1
>@canopus.cc.umanitoba.ca:

>> The original poster requires an algorithm
>> which is guaranteed to find the global minima of an arbitrary
>> black-box function of three parameters. Is that something that
>> people do "every day" ?

>As a matter of fact, yes. One approach is to pick a handful of intial
>guesses across the solution space, and perform the optimization starting
>from each of them, and see which gives the best answer. This is done every
>day (engineering vs. math), and its poor practice to assume that your error
>function might not get stuck in a global minimum.

And we have exactly what assurance that the original poster's
MyFun is not at heart the negative of a Dirac Delta Function?
Pick an integer at random for the location of the delta. The
probability that the magnitude of the integer is less than
any particular value (e.g, 2^63-1) is zero, since there are
a finite number of integers in that absolute value range but an
infinite number of values outside of that range. And yet you expect
that your routines would be able to locate that one integer?


>He doesn't need an algorithm guaranteed to find the global minumum, he
>needs to find the global minimum. Again, many unconstrained optimization
>problems are like this.

The original poster did not ask for an engineering "close enough"
solution: the original poster asked to find the parameters that minimize
(over an infinite domain) the un-examinable function. You can
graph all the finite subsets you want, but you cannot hide from
infinity.
--
  "To all, to each! a fair good-night,
   And pleasing dreams, and slumbers light" -- Sir Walter Scott

Subject: Re: Find Minimum

From: Scott Seidman

Date: 11 Feb, 2008 20:27:47

Message: 12 of 29

roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in news:foqah7$fds$1
@canopus.cc.umanitoba.ca:

>
> The original poster did not ask for an engineering "close enough"
> solution: the original poster asked to find the parameters that minimize
> (over an infinite domain) the un-examinable function. You can
> graph all the finite subsets you want, but you cannot hide from
> infinity.
>

So, once again you assert that there is no way to optimize an unconstrained
3-parameter problem with global minima. Many minimization problems are not
looking for a microscopic dirac in infinite 3D. I suppose we could assume
that's that kind of function the OP is presenting, or we could assume that
his problem is not of that sort, and is much more mundane.

The only way we'd know is to try, or to get more explanation from the OP.
Perhaps he could provide a "realistic" range for A. Even if A can be 2e6,
its still a finite problem.

--
Scott
Reverse name to reply

Subject: Re: Find Minimum

From: Scott Seidman

Date: 11 Feb, 2008 20:28:16

Message: 13 of 29

Scott Seidman <namdiesttocs@mindspring.com> wrote in
news:Xns9A419D4C96F57scottseidmanmindspri@130.133.1.4:

> with global minima.

ooops, "local" of course


--
Scott
Reverse name to reply

Subject: Re: Find Minimum

From: shapper

Date: 11 Feb, 2008 20:37:22

Message: 14 of 29

On Feb 11, 8:17 pm, rober...@ibd.nrc-cnrc.gc.ca (Walter Roberson)
wrote:
> In article <Xns9A419793662B6scottseidmanminds...@130.133.1.4>,
> Scott Seidman <namdiestt...@mindspring.com> wrote:
>
> >rober...@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in news:fopvio$2l2$1
> >@canopus.cc.umanitoba.ca:
> >> The original poster requires an algorithm
> >> which is guaranteed to find the global minima of an arbitrary
> >> black-box function of three parameters. Is that something that
> >> people do "every day" ?
> >As a matter of fact, yes. One approach is to pick a handful of intial
> >guesses across the solution space, and perform the optimization starting
> >from each of them, and see which gives the best answer. This is done every
> >day (engineering vs. math), and its poor practice to assume that your error
> >function might not get stuck in a global minimum.
>
> And we have exactly what assurance that the original poster's
> MyFun is not at heart the negative of a Dirac Delta Function?
> Pick an integer at random for the location of the delta. The
> probability that the magnitude of the integer is less than
> any particular value (e.g, 2^63-1) is zero, since there are
> a finite number of integers in that absolute value range but an
> infinite number of values outside of that range. And yet you expect
> that your routines would be able to locate that one integer?
>
> >He doesn't need an algorithm guaranteed to find the global minumum, he
> >needs to find the global minimum. Again, many unconstrained optimization
> >problems are like this.
>
> The original poster did not ask for an engineering "close enough"
> solution: the original poster asked to find the parameters that minimize
> (over an infinite domain) the un-examinable function. You can
> graph all the finite subsets you want, but you cannot hide from
> infinity.
> --
> "To all, to each! a fair good-night,
> And pleasing dreams, and slumbers light" -- Sir Walter Scott

Hi,

I was thinking about my problem and let me simplify it so I can solve
this.

Basically, the function does some calculation to evaluate a financial
report.

Please, consider the new problem:

1. All inputs will have a finite number or values, i.e:

   Input A: Integer value between 0 and 2000
   Input B: Zero or Multiple of 10 between 0 and 200 - 0, 10, 20,
30, ..., 190, 200
   Input C: Multiple of 0.01 between 0 and 1 - 0.01, 0.02, ... , 0.98,
0.99, 1

2. The problem might have more than one minimum.
   In this case I would like to get the global solution.
   If no global solution is found then it would be interesting to get
all local solutions to be compared ...

   Event getting the local solutions, when a global solution is found,
might be interesting in this case.

Anyway, by setting all inputs to be finite how should I do this?

I think that was the biggest problem.

Thank You,
Miguel


Subject: Re: Find Minimum

From: Scott Seidman

Date: 11 Feb, 2008 20:47:53

Message: 15 of 29

shapper <mdmoura@gmail.com> wrote in
news:fbffb731-d31b-4562-a193-2affe6006cf7@v17g2000hsa.googlegroups.com:

> On Feb 11, 8:17 pm, rober...@ibd.nrc-cnrc.gc.ca (Walter Roberson)
> wrote:
>> In article <Xns9A419793662B6scottseidmanminds...@130.133.1.4>,
>> Scott Seidman <namdiestt...@mindspring.com> wrote:
>>
>> >rober...@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in
>> >news:fopvio$2l2$1 @canopus.cc.umanitoba.ca:
>> >> The original poster requires an algorithm
>> >> which is guaranteed to find the global minima of an arbitrary
>> >> black-box function of three parameters. Is that something that
>> >> people do "every day" ?
>> >As a matter of fact, yes. One approach is to pick a handful of
>> >intial guesses across the solution space, and perform the
>> >optimization starting from each of them, and see which gives the
>> >best answer. This is done every day (engineering vs. math), and its
>> >poor practice to assume that your error function might not get stuck
>> >in a global minimum.
>>
>> And we have exactly what assurance that the original poster's
>> MyFun is not at heart the negative of a Dirac Delta Function?
>> Pick an integer at random for the location of the delta. The
>> probability that the magnitude of the integer is less than
>> any particular value (e.g, 2^63-1) is zero, since there are
>> a finite number of integers in that absolute value range but an
>> infinite number of values outside of that range. And yet you expect
>> that your routines would be able to locate that one integer?
>>
>> >He doesn't need an algorithm guaranteed to find the global minumum,
>> >he needs to find the global minimum. Again, many unconstrained
>> >optimization problems are like this.
>>
>> The original poster did not ask for an engineering "close enough"
>> solution: the original poster asked to find the parameters that
>> minimize (over an infinite domain) the un-examinable function. You
>> can graph all the finite subsets you want, but you cannot hide from
>> infinity.
>> --
>> "To all, to each! a fair good-night,
>> And pleasing dreams, and slumbers light" -- Sir Walter Scott
>
> Hi,
>
> I was thinking about my problem and let me simplify it so I can solve
> this.
>
> Basically, the function does some calculation to evaluate a financial
> report.
>
> Please, consider the new problem:
>
> 1. All inputs will have a finite number or values, i.e:
>
> Input A: Integer value between 0 and 2000
> Input B: Zero or Multiple of 10 between 0 and 200 - 0, 10, 20,
> 30, ..., 190, 200
> Input C: Multiple of 0.01 between 0 and 1 - 0.01, 0.02, ... , 0.98,
> 0.99, 1
>
> 2. The problem might have more than one minimum.
> In this case I would like to get the global solution.
> If no global solution is found then it would be interesting to get
> all local solutions to be compared ...
>
> Event getting the local solutions, when a global solution is found,
> might be interesting in this case.
>
> Anyway, by setting all inputs to be finite how should I do this?
>
> I think that was the biggest problem.
>
> Thank You,
> Miguel
>
>
>

There you go!

Depending on how complex your function is, and how fast you need an
answer, you might just choose to evaluate your function at all 4,000,000
some-odd values in your parameter space. That's a guaranteed solution.

--
Scott
Reverse name to reply

Subject: Re: Find Minimum

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 11 Feb, 2008 20:55:08

Message: 16 of 29

In article <Xns9A419D4C96F57scottseidmanmindspri@130.133.1.4>,
Scott Seidman <namdiesttocs@mindspring.com> wrote:
>roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in news:foqah7$fds$1
>@canopus.cc.umanitoba.ca:

>> The original poster did not ask for an engineering "close enough"
>> solution: the original poster asked to find the parameters that minimize
>> (over an infinite domain) the un-examinable function. You can
>> graph all the finite subsets you want, but you cannot hide from
>> infinity.

>So, once again you assert that there is no way to optimize an unconstrained
>3-parameter problem with global minima. Many minimization problems are not
>looking for a microscopic dirac in infinite 3D. I suppose we could assume
>that's that kind of function the OP is presenting, or we could assume that
>his problem is not of that sort, and is much more mundane.

Assuming that the original poster's problem is "not of that sort"
and to be globally optimizable with any fixed algorithm is to place
(mathematically) quite large restrictions on the details of the
black-box function, violating the original poster's assertion that
nothing was known of the function beyond how to evaluate it.

Your claim that the original poster's problem *as originally stated*
could be solved by a minimization algorithm was wrong.

Even if you had an algorithm that (for example) after five
function evaluations was able to predict a parameter combination that
was unsurpassed in another billion explorations of the parameter
space, then because of the black-box nature of the function,
you would never be sure that you had found the global minima
(which might take quadrillions of evaluations to find a better minima).
You might perhaps appear to converge very quickly, but if it is a
black box problem with no known constraints on its internal contents,
then you never know when to stop evaluating to be sure you had the
global minima.
--
  "You can't hit what you can't see." -- Walter "The Big Train" Johnson

Subject: Re: Find Minimum

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 11 Feb, 2008 21:09:33

Message: 17 of 29

In article <Xns9A41A0B561498scottseidmanmindspri@130.133.1.4>,
Scott Seidman <namdiesttocs@mindspring.com> wrote:
>shapper <mdmoura@gmail.com> wrote in
>news:fbffb731-d31b-4562-a193-2affe6006cf7@v17g2000hsa.googlegroups.com:


>> Please, consider the new problem:

>> 1. All inputs will have a finite number or values, i.e:

>> Input A: Integer value between 0 and 2000
>> Input B: Zero or Multiple of 10 between 0 and 200 - 0, 10, 20,
>> 30, ..., 190, 200
>> Input C: Multiple of 0.01 between 0 and 1 - 0.01, 0.02, ... , 0.98,
>> 0.99, 1


>There you go!

>Depending on how complex your function is, and how fast you need an
>answer, you might just choose to evaluate your function at all 4,000,000
>some-odd values in your parameter space. That's a guaranteed solution.

Yes, if the function can fluctuate faster than the intra-coordinate
distance, then evaluating at all of the coordinates might be the
only way to get a global minima. You could use ndgrid to
produce the coordinates to minimize at:

[Ag, Bg, Cg] = ndgrid(0:2000, 0:10:200, 0.01:0.01:1);

then R = MyFun(Ag, Bg, Cg); if you are fortunate enough that
the function has been written to accept vector arguments. If not
then

R = zeros(size(Ag));
for K=1:numels(Ag)
  R(K) = MyFun(Ag(K),Bg(K),Cg(K));
end

though if it did turn out that MyFun was not written to accept
vectors for all of its arguments, -possibly- it might handle
vectors for -some- of its arguments, in which case significant
time improvements could be made by only iterating over the arguments
that MyFun does not turn out to accept vectors for.
--
amazon.com's top 8 books about "walter" are Kotzwinkle/ Gundy/ Colman's
"Walter the Farting Dog"

Subject: Re: Find Minimum

From: Scott Seidman

Date: 11 Feb, 2008 21:10:43

Message: 18 of 29

roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in news:foqcnc$i3l$1
@canopus.cc.umanitoba.ca:

> Even if you had an algorithm that (for example) after five
> function evaluations was able to predict a parameter combination that
> was unsurpassed in another billion explorations of the parameter
> space, then because of the black-box nature of the function,

This is getting a little circular. To know any function as well as you
seem to assert you need to know it to do an optimization, it would seem
that you need to know the function value at every possible value of
parameter space.

Obviously, this must be a misunderstanding on my part, but it does be the
question of hat, exactly, are your requirements for a solvable
optimization?


--
Scott
Reverse name to reply

Subject: Re: Find Minimum

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 11 Feb, 2008 21:36:55

Message: 19 of 29

In article <Xns9A41A493EF475scottseidmanmindspri@130.133.1.4>,
Scott Seidman <namdiesttocs@mindspring.com> wrote:
>roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in news:foqcnc$i3l$1
>@canopus.cc.umanitoba.ca:

>> Even if you had an algorithm that (for example) after five
>> function evaluations was able to predict a parameter combination that
>> was unsurpassed in another billion explorations of the parameter
>> space, then because of the black-box nature of the function,

>This is getting a little circular. To know any function as well as you
>seem to assert you need to know it to do an optimization, it would seem
>that you need to know the function value at every possible value of
>parameter space.

Take a finite subset as an example: let
F(-2^52:2^52-1, 0:10:200, .01:.01:1) = rand(2^53,21,100);
where rand is the standard Matlab pseudo-random 'twister' function
with state initialized to any one integer you choose.

In classical mathematics, this defines a "function". A function
is a mapping between the domain and the range. Nothing more.
There need not be any "formula" for a function, just a list of tuples.
A nice formula can make describing the function tremendously more
compact, but the domain -> range value list is the essence of
functions, not the formulae.

Now, how are you going to find the minimum value of F over this
finite subset without evaluating F at every location?

There are an infinite number of formulae for which any particular
set of F values as described above would be the best approximation.
Some of them are continuously differentiable, some differentiable
only a few steps, some of them nowhere differentiable. And
2^53 is pretty small as the integers go.


>Obviously, this must be a misunderstanding on my part, but it does be the
>question of hat, exactly, are your requirements for a solvable
>optimization?

I would have to think about that more.

I was going to put in a few words about "frequency"
(if the frequency of the change is too high, any gradient deduced
around neighbouring points would not be usable to predict new points)
but then I recalled that the frequency of anything approaching
a flat plateau involves an infinite series of non-zero frequencies,
so "frequency" is probably not exactly the right idea.
--
  "Every intellectual product must be judged from the point of view
  of the age and the people in which it was produced."
                                              -- Walter Horatio Pater

Subject: Re: Find Minimum

From: Roger Stafford

Date: 11 Feb, 2008 21:39:02

Message: 20 of 29

roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in message <foqah7
$fds$1@canopus.cc.umanitoba.ca>...
> And we have exactly what assurance that the original poster's
> MyFun is not at heart the negative of a Dirac Delta Function?
> Pick an integer at random for the location of the delta. The
> probability that the magnitude of the integer is less than
> any particular value (e.g, 2^63-1) is zero, since there are
> a finite number of integers in that absolute value range but an
> infinite number of values outside of that range. And yet you expect
> that your routines would be able to locate that one integer?
>
> >He doesn't need an algorithm guaranteed to find the global minumum, he
> >needs to find the global minimum. Again, many unconstrained
optimization
> >problems are like this.
>
> The original poster did not ask for an engineering "close enough"
> solution: the original poster asked to find the parameters that minimize
> (over an infinite domain) the un-examinable function. You can
> graph all the finite subsets you want, but you cannot hide from
> infinity.
---------
  Walter, I think you need to be reminded that such questions as were
originally posed in this thread are often of such a nature that the questioner
ought to be challenged as to missing or misleading descriptions of a
problem. Very often the necessary additional information has to be gently (or
sometimes not so gently) teased out after multiple probing questions are put
back to the OP. In my opinion you should not be taking what this OP stated
as given, rock-hard facts, but should be inquiring further into what he may
be cajoled into revealing. You may even eventually get a chagrined response
such as, "Oh well, I didn't mean exactly that - I really had in mind such and
such," as so often happens on this newsgroup.

  Remember, we who undertake to answer questions here aren't referees for a
mathematical paper being reviewed for publication. Our standards should be
much, much lower. We are often dealing with people who are just learning
matlab and may not even understand exactly what it is they wish to solve.
They need to be responded to with kindness and tact - but not always
entirely believed.

  With the current problem, it is trivially obvious that, if the OP sticks by his
guns and can tell absolutely nothing further about 'MyFun', then it is quite
impossible for him ever to find a minimum using matlab or any other
computing system that can be mathematically proven to be valid. There are
infinitely many combinations of arguments to try. But I hold that Scott is
probably correct in implying that, in effect, the OP does in fact know much
more than he is telling, and that it is entirely possible that, when all the
necessary information is finally provided, he has a problem that is capable of
a practical solution - that is to say, one that he would be happy with.

  By the way, Scott. Watch out with those anecdotes about mathematicians
versus engineers! Some of us mathematical types know of many delicious
put-down tales in the reverse direction that we can retaliate with. :-)

Roger Stafford

Subject: Re: Find Minimum

From: Doug Schwarz

Date: 11 Feb, 2008 22:00:07

Message: 21 of 29

In article <foqf9l$998$1@fred.mathworks.com>,
 "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote:

[snip]

> With the current problem, it is trivially obvious that, if the OP sticks by
> his
> guns and can tell absolutely nothing further about 'MyFun', then it is quite
> impossible for him ever to find a minimum using matlab or any other
> computing system that can be mathematically proven to be valid. There are
> infinitely many combinations of arguments to try. But I hold that Scott is
> probably correct in implying that, in effect, the OP does in fact know much
> more than he is telling, and that it is entirely possible that, when all the
> necessary information is finally provided, he has a problem that is capable
> of
> a practical solution - that is to say, one that he would be happy with.


Roger,

I think your comments are spot on -- and made very politely. Well done!


> By the way, Scott. Watch out with those anecdotes about mathematicians
> versus engineers! Some of us mathematical types know of many delicious
> put-down tales in the reverse direction that we can retaliate with. :-)

So let's hear one! I'm an engineer, but I always enjoy a laugh, even at
my own expense.

--
Doug Schwarz
dmschwarz&ieee,org
Make obvious changes to get real email address.

Subject: Re: Find Minimum

From: shapper

Date: 11 Feb, 2008 22:28:51

Message: 22 of 29

On Feb 11, 8:55 pm, rober...@ibd.nrc-cnrc.gc.ca (Walter Roberson)
wrote:
> In article <Xns9A419D4C96F57scottseidmanminds...@130.133.1.4>,
> Scott Seidman <namdiestt...@mindspring.com> wrote:
>
> >rober...@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in news:foqah7$fds$1
> >@canopus.cc.umanitoba.ca:
> >> The original poster did not ask for an engineering "close enough"
> >> solution: the original poster asked to find the parameters that minimize
> >> (over an infinite domain) the un-examinable function. You can
> >> graph all the finite subsets you want, but you cannot hide from
> >> infinity.
> >So, once again you assert that there is no way to optimize an unconstrained
> >3-parameter problem with global minima. Many minimization problems are not
> >looking for a microscopic dirac in infinite 3D. I suppose we could assume
> >that's that kind of function the OP is presenting, or we could assume that
> >his problem is not of that sort, and is much more mundane.
>
> Assuming that the original poster's problem is "not of that sort"
> and to be globally optimizable with any fixed algorithm is to place
> (mathematically) quite large restrictions on the details of the
> black-box function, violating the original poster's assertion that
> nothing was known of the function beyond how to evaluate it.
>
> Your claim that the original poster's problem *as originally stated*
> could be solved by a minimization algorithm was wrong.
>
> Even if you had an algorithm that (for example) after five
> function evaluations was able to predict a parameter combination that
> was unsurpassed in another billion explorations of the parameter
> space, then because of the black-box nature of the function,
> you would never be sure that you had found the global minima
> (which might take quadrillions of evaluations to find a better minima).
> You might perhaps appear to converge very quickly, but if it is a
> black box problem with no known constraints on its internal contents,
> then you never know when to stop evaluating to be sure you had the
> global minima.
> --
> "You can't hit what you can't see." -- Walter "The Big Train" Johnson

Hi,

Evaluate my function at all 4,000,000? Now I am scared ... :-)

  How could I create such a script that would make it possible for me
to evaluate all the solutions.
  I need a flexible approach because MyFun can have 3 or MORE inputs
with their constraints.
  It would be great if I could use this in different functions.

It seems that the function being a Black Box is also a problem.

A new simplification which I hope it helps.

Basically, inside the Black Box I have a set or rules that:

  Decide when to Buy/Sell components for company's factory.
  Decide the sizes components for Buy/Sell.
  ...

The rules are based in Moving Averages, Oscillators maybe a few Fuzzy
rules.

So what I need is to "tune" the input parameters to get the optimal
value of my output.

When I said I didn't know what was going on in my function I meant
that inside my function I could have 3 or 10 rules and the rules could
include a simple Moving Average (Rule would use cross), an Oscillator
(rule would use cross a certain level), ...

The calculations inside the function are not very complex ...

Can't I do this with GA?
Enumeration would be a good solution to confirm the solution obtained
with GA on the first simulations.

Does this help?

Thanks,
Miguel






Subject: Re: Find Minimum

From: Bruno Luong

Date: 11 Feb, 2008 22:29:03

Message: 23 of 29

Doug Schwarz <see@sig.for.address.edu> wrote in message
<see-C4CECF.17000611022008@71-129-133-66.dollamir.com>...

>
> So let's hear one! I'm an engineer, but I always enjoy a
laugh, even at
> my own expense.
>

This is real a story:

My engineer co-worker: Bruno, do you know what is the RMS of
an error bracketing between 0 and m? My impression is the
RMS is m/2.

Me: Let's see, I believe you meant an error uniformly
distributed between 0 and m.... (I wrote a simple integral
on the board).. I believe it's actually m/sqrt(3).

My co-worker: pull out his calculator: so it's 0.57m. I was
right, it is indeed m/2!

Me: .........


Bruno

Subject: Re: Find Minimum

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 11 Feb, 2008 22:53:14

Message: 24 of 29

In article <59c7a60a-4c16-401e-a6a2-4a1cb1901c3d@z17g2000hsg.googlegroups.com>,
shapper <mdmoura@gmail.com> wrote:

>Evaluate my function at all 4,000,000? Now I am scared ... :-)

> How could I create such a script that would make it possible for me
>to evaluate all the solutions.
> I need a flexible approach because MyFun can have 3 or MORE inputs
>with their constraints.
> It would be great if I could use this in different functions.


If the parameters can be described by a list of discrete values,
especially ones at regular intervals, then you can put the
parameter value lists into a cell, construct an empty cell
of the right size to receive the arguments, and then use ndgrid.

>> bar = {1:3 2:5 8:11};foo = cell(1,length(bar)); [foo{:}] = ndgrid(bar{:})

foo =

    [3x4x4 double] [3x4x4 double] [3x4x4 double]

Then provided that MyFun has been written to accept vectorized
inputs, myFun(foo{:})


Wouldn't necessarily be fast, though!
--
  "There is nothing so bad but it can masquerade as moral."
                                              -- Walter Lippmann

Subject: Re: Find Minimum

From: Roger Stafford

Date: 11 Feb, 2008 23:28:02

Message: 25 of 29

Doug Schwarz <see@sig.for.address.edu> wrote in message <see-C4CECF.
17000611022008@71-129-133-66.dollamir.com>...
> Roger,
>
> I think your comments are spot on -- and made very politely. Well done!
>
> > By the way, Scott. Watch out with those anecdotes about
mathematicians
> > versus engineers! Some of us mathematical types know of many
delicious
> > put-down tales in the reverse direction that we can retaliate with. :-)
>
> So let's hear one! I'm an engineer, but I always enjoy a laugh, even at
> my own expense.
> --
> Doug Schwarz
---------
  Okay, Doug, this may not be quite what you are expecting, but here's a story
that actually happened at UC Berkeley. I was a young, idealistic
undergraduate math major seated, strangely enough, in an engineering class
- I can't remember why. The engineering professor, apparently wanting his
students to get over their phobias in their current calculus courses,
undertook to explain the concept of an integral. He said with eye balls rolling
appropriately, "Those guys over there in Wheeler Hall (the math department
stronghold) will give you all this baloney about what an integral is, with all
their fancy epsilons and deltas. But you know all it is?" At that point he
whipped out a planimeter he had stashed away, swept its point around a
great curve on his desk, and then proudly proclaimed, "You look at this little
wheel here with the numbers on it, see? That number next to the mark gives
you the integral of the curve! What could be simpler?"

  In one fell swoop this fellow had managed to discredit centuries of careful
and profound work by mathematicians in analysis. It all boiled down to a
number on a wheel! As one might imagine I sat there seething with rage, but
all my classmates looked very pleased to have had this "masquerade"
exposed, and the professor looked disgustingly smug. I had the feeling that
in those few moments he had managed to permanently bias all those poor
innocent young prospective engineers against all things mathematical. It
took a long while before I could see the humorous side of this absurd
episode.

Roger Stafford

Subject: Re: Find Minimum

From: Jack

Date: 12 Feb, 2008 00:44:28

Message: 26 of 29

On Feb 11, 3:28 pm, "Roger Stafford"
<ellieandrogerxy...@mindspring.com.invalid> wrote:
> Doug Schwarz <s...@sig.for.address.edu> wrote in message <see-C4CECF.
>
> 17000611022...@71-129-133-66.dollamir.com>...> Roger,
>
> > I think your comments are spot on -- and made very politely. Well done!
>
> > > By the way, Scott. Watch out with those anecdotes about
> mathematicians
> > > versus engineers! Some of us mathematical types know of many
> delicious
> > > put-down tales in the reverse direction that we can retaliate with. :-)
>
> > So let's hear one! I'm an engineer, but I always enjoy a laugh, even at
> > my own expense.
> > --
> > Doug Schwarz
>
> ---------
> Okay, Doug, this may not be quite what you are expecting, but here's a story
> that actually happened at UC Berkeley. I was a young, idealistic
> undergraduate math major seated, strangely enough, in an engineering class
> - I can't remember why. The engineering professor, apparently wanting his
> students to get over their phobias in their current calculus courses,
> undertook to explain the concept of an integral. He said with eye balls rolling
> appropriately, "Those guys over there in Wheeler Hall (the math department
> stronghold) will give you all this baloney about what an integral is, with all
> their fancy epsilons and deltas. But you know all it is?" At that point he
> whipped out a planimeter he had stashed away, swept its point around a
> great curve on his desk, and then proudly proclaimed, "You look at this little
> wheel here with the numbers on it, see? That number next to the mark gives
> you the integral of the curve! What could be simpler?"
>
> In one fell swoop this fellow had managed to discredit centuries of careful
> and profound work by mathematicians in analysis. It all boiled down to a
> number on a wheel! As one might imagine I sat there seething with rage, but
> all my classmates looked very pleased to have had this "masquerade"
> exposed, and the professor looked disgustingly smug. I had the feeling that
> in those few moments he had managed to permanently bias all those poor
> innocent young prospective engineers against all things mathematical. It
> took a long while before I could see the humorous side of this absurd
> episode.
>
> Roger Stafford

Hopefully the quality of technical education at Berkeley has improved
since those backwater days. ;^)

Jack Walker

Subject: Re: Find Minimum

From: Scott Seidman

Date: 12 Feb, 2008 01:01:01

Message: 27 of 29

shapper <mdmoura@gmail.com> wrote in news:59c7a60a-4c16-401e-a6a2-
4a1cb1901c3d@z17g2000hsg.googlegroups.com:

> Evaluate my function at all 4,000,000? Now I am scared ... :-)
>

I looped through 4,000,000 multiplies to test, and it took about 5
seconds.

Walter is offering some elegant vectorial solutions that would be a good
deal faster, but brute force is to go with loops nested three deep.
Evaluate the function, and if its lower than any previous value, replace
it

 
Amin=0
Bmin=0
Cmin=0
Fmin = 10^20 %Some big number

for A=0:2000
for B=0:10:200
for C=[0:0.01:1]

F= somefunc(A,B,C)

if F<Fmin
F=fmin
Amin=A; Bmin=B; Cmin=C;
end %if

end %Cloop
end %Bloop
end %Aloop

Fmin
Amin
Bmin
Cmin


--
Scott
Reverse name to reply

Subject: Re: Find Minimum

From: Roger Stafford

Date: 12 Feb, 2008 02:26:01

Message: 28 of 29

Jack <Jack.Walker951@gmail.com> wrote in message <560bda8c-b71b-4237-
be76-6bb4c65c1513@i29g2000prf.googlegroups.com>...
> Hopefully the quality of technical education at Berkeley has improved
> since those backwater days. ;^)
> Jack Walker
---------
Hi Jack,

  I didn't say all their professors were like that. Many of them were very sharp
indeed, (especially those in mathematics.) :-)

Roger Stafford

Subject: Re: Find Minimum

From: Marcus M. Edvall

Date: 14 Feb, 2008 23:35:14

Message: 29 of 29

glcDirect in the TOMLAB Base Module can most likely solve your problem
without too much trouble. After a registration here:
http://tomopt.com/scripts/register.php you can use the software for
free (3-4 weeks).

Best wishes, Marcus
Tomlab Optimization Inc.
http://tomopt.com/tomlab/

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

rssFeed for this Thread

envelope graphic E-mail this page to a colleague

Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.
Related Topics