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.
I also tried RandomSearch. Why can't I upload a 7kB jpeg file, or a 22kB png file?
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
Your function defaults to zero in 0.2 and 0.5. Try this:
0.2
0.5
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]
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.
Your code does not run on my system. NArgMin complains that the function to minimize contains an undefined variable fac00.
NArgMin
fac00
I accidentally removed fac00 initialization when removing comments. This one should work, I quite the kernel and ran it to make sure.
I also have problems downloading the file
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.
OK, but this is a problem with the forum. They are doing some revisions. I've also had problems posting images.
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.