Message Boards Message Boards

0
|
894 Views
|
13 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Unexpected solution from FindMinimum and NArgMin

Posted 1 month ago

I have a function of one argument that has some discontinuities, but when it's smooth, it is always decreasing to the "right", negative derivative. I can't seem to add a pic. For some reason FindMinimum (and NArgMin) give the right most constraint boundary as a solution. I tried explicitly telling it the method with simulated annealing and DifferentialEvolution, but no go. What else can I try? If you insist I can give you the code, but I am hoping not, because I will have to remove all the comments if I do.

POSTED BY: Iuval Clejan
13 Replies
Posted 1 month ago

I also have problems downloading the file

POSTED BY: Calvin Harper
Posted 1 month ago

OK, but this is a problem with the forum. They are doing some revisions. I've also had problems posting images.

POSTED BY: Iuval Clejan

The function you are minimizing is very bizarre. If I evaluate it in symbolic x I get a continuous function:

In[35]:= f1[fmin, masterfmin, x]

Out[35]= 0.236546 + 1/x^2

The following two inputs give different results:

f1[fmin, masterfmin, 1/2]
f1[fmin, masterfmin, x] /. x -> 1/2

I suppose that Minimize makes a symbolic evaluation of the function before inserting numbers, and this would explain the output we get.

You may want to redefine f1 so that it does not evaluate unless x is numerical.

POSTED BY: Gianluca Gorni
Posted 1 month ago

Gianluca, I am indebted to you. It worked! I specified the last argument of f1 to be Real. I have had this sort of problem before, with functions that can't be computed analytically, but still Mathematica tries and it leads to problems.

POSTED BY: Iuval Clejan
Posted 1 month ago

I don't know if the problem is with Minimize, because I don't call Minimize, I call NMInimize. I think the problem might be because NMimimize tries to take symbolic derivatives (even with methods such as simulated annealing or evolutionary algorithms). At least that was a previous problem I ran into a while ago.

POSTED BY: Iuval Clejan

Your code does not run on my system. NArgMin complains that the function to minimize contains an undefined variable fac00.

POSTED BY: Gianluca Gorni
Posted 1 month ago

I accidentally removed fac00 initialization when removing comments. This one should work, I quite the kernel and ran it to make sure.

POSTED BY: Iuval Clejan
Posted 1 month ago

I accidentally removed the fac00 initialization when removing comments. Sorry. Here is the original function (f1, getting badly minimized in f2)

POSTED BY: Iuval Clejan

Your function defaults to zero in 0.2 and 0.5. Try this:

f1[x_] := 
  1/x + Piecewise[{{100, 0 < x <= 0.1}, {40, 0.1 < x <= 0.2}, {80, 
      0.2 < x <= 0.3}, {70, 0.3 < x <= 0.4}, {90, 0.4 < x <= 0.5}}];
ArgMin[{f1[maxfacc], 0.5 > maxfacc > 0.01}, maxfacc]
POSTED BY: Gianluca Gorni
Posted 1 month ago

Thanks Gianluca. Unfortunately, I can't control the actual function (the one I gave was an example of the general behavior) with inequalities, or default values in Piecewise. It's not defined using Piecewise. I suppose I should post the real function.

POSTED BY: Iuval Clejan
Posted 1 month ago

OK, here is a simplified version.

POSTED BY: Iuval Clejan

Welcome to Wolfram Community!
Please provide your efforts in the form of the Wolfram Language code. This will make it easier for other members to help you. Check several methods available to include your code in the rules http://wolfr.am/READ-1ST

POSTED BY: EDITORIAL BOARD
Posted 1 month ago

I also tried RandomSearch. Why can't I upload a 7kB jpeg file, or a 22kB png file?

POSTED BY: Iuval Clejan
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract