MATLAB Answers


fminimax option iter not working

Asked by Ingrid
on 22 Dec 2015
Latest activity Commented on by Alan Weiss
on 28 Dec 2015
I want to be able to follow the iteration process of fminimax so that I can see if there is improvement or not since my function takes a very long time to calculate. I use the code below but I do not get any update of the iteration process in the command window. How can I follow the iteration process? Am I implementing this wrong or is there another method? I can see that it is iterating in the task manager (with peaks going up and down cyclical in the memory showing that the data required by the function is loaded and discarded) so there is no problem in the implementation of my function (for example eternal loop)
options = optimoptions(@fminimax,'Display','iter',...
% 'PlotFcns',@optimplotx);
x = fminimax(@myLongFunction,x0,[],[],[],[],[],[],[],options);


Sign in to comment.


1 Answer

Answer by Alan Weiss
on 22 Dec 2015

What are the number of elements in x0? If you have more than 49, then your function might never take even the first step because you limit the number of function evaluations to 50, and fminimax needs more than that number to begin its estimation of the local gradient.
If your function evaluations take a long time because you are running a simulation or solving a differential equation, see some suggestions in the documentation.
I think that you had a good idea to plot something. @optimplotfunccount might give you some idea of how many function counts are needed. Basically, I suggest that you get rid of the 'MaxFunEvals' option and try again.
Alan Weiss
MATLAB mathematical toolbox documentation


If x0 has 276 variables then you would not see any iterative display until at least 277 function evaluations, because it takes at least that many evaluations to approximate the gradient, a precursor to taking a step.
I am astounded that you can manually search through a 276-dimensional space and obtain a better answer. Unless maybe I misunderstand, and you actually have a problem with just one dimension, in which case I do not understand why x0 has 276 components.
Alan Weiss
MATLAB mathematical toolbox documentation
the values are all independent from each other. So x0(1) only influences goal(1) and so on so it does not really have 276 dimensions. I guess that is why my approach was flawed.
If I understand you correctly, you have only a one-dimensional control variable x, and you have 276 objective functions, and you want to find x that minimizes the maximum objective. Is that correct? If so, just reformulate your problem so that x0 is a scalar, and I think that fminimax will operate quickly enough for you, especially if you have a reasonably large DiffMinChange option and have reasonable bounds lb and ub. Though you might have already found that you can just make a fine enough search using linspace, it is probably the case that fminimax would be quicker if you ever again need to solve a similar problem.
Alan Weiss
MATLAB mathematical toolbox documentation

Sign in to comment.