Is it possible to have fmincon terminate once a function value of a certain number is reached?

1 view (last 30 days)
I have a function of 6 variables that returns a sum of squares differences from some ideal values. I would like fmincon to find me a local minimum that has a function value lower than a STATIC sum of squared differences value. Is this possible? From what I understand, the 'TolFun' and 'TolX' options will not do this for me. Here is what my function call looks like. The function, optimize_myfunc, is the function that returns a sum of squared differences.
lb = [x1_min, x2_min, x3_min, x4_min, x5_min, x6_min];
ub = [x1_max, x2_max, x3_max, x4_max, x5_max, x6_max];
anon_func = @(x)optimize_myfunc(x, other_var1, other_var2, other_var3);
options = optimset('Display','iter');
x_opt = fmincon(anon_func, [x1_0; x2_0; x3_0; x4_0; x5_0; x6_0], [], [], [], [], lb, ub, [], options);

Answers (1)

Walter Roberson
Walter Roberson on 13 Mar 2014
Yes, you can add termination criteria by adding an options structure that has OutputFcn set
Structure of the Output Function
The function definition line of the output function has the following form:
stop = outfun(x, optimValues, state)
stop is a flag that is true or false depending on whether the optimization routine should quit or continue. See Stop Flag for more information.
  1 Comment
Nikolai
Nikolai on 13 Mar 2014
Thank you for the response, Walter.
I have a follow up question: To which field in the optimValues structure should I assign my additional termination criteria, and how would I keep fmincon from terminating before my additional criteria is met?
-Nikolai

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!