Is it possible to have fmincon terminate once a function value of a certain number is reached?
6 次查看(过去 30 天)
显示 更早的评论
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);
0 个评论
回答(1 个)
Walter Roberson
2014-3-13
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Problem-Based Optimization Setup 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!