Optimization Where Both Objective and Non-Linear Constraint are Functions of a Function
1 view (last 30 days)
Show older comments
I am considering an optimization where both the objective and non-linear constraint and functions of a function, such as (excluding some details):
f = @(w,Y) Y*w;
g = @(w,Y) mean(f(w,Y));
h = @(w,Y) var(f(w,Y));
obj_con = @(w,Y) -g(w,Y);
nonl_con = @(w,Y) deal(h(w,Y)-K,[]);
options = optimset('Algorithm','active-set');
out = fmincon(@(x) obj_con(x,Y),x0,[],[],Aeq,beq,lb,ub,@(x) nonl_con(x,Y),options);
I have purposefully made this simpler than what I actually plan to do to get the general point across (in particular, f and h will be more complicated and the optimization may take place with functions other than fmincon).
Using the Matlab profiler, I determined that the function f is called twice at each iteration of the optimization (once for g and once for h).
Is there any way to set up the optimization of the functions so that it is only called once?
One approach I am not interested in is to remove f and make the calculation within g and h. That still does not resolve the issue of having to make such a calculation twice.
0 Comments
Accepted Answer
Alan Weiss
on 22 Aug 2013
Objective and Nonlinear Constraints in the Same Function has the information you seek.
Alan Weiss
MATLAB mathematical toolbox documentation
More Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!