www.gusucode.com > globaloptim 案例源码程序 matlab代码 > globaloptim/PatternSearchwithNonlinearConstraintsExample.m

    %% Pattern Search with Nonlinear Constraints  
% Find the minimum of a function subject to a nonlinear inequality constraint.   

%% 
% Create the following two-variable objective function. On your MATLAB(R)
% path, save the following code to a file named |psobj.m|. 
%
% <include>psobj.m</include>
%
%% 
% Set the objective function to |@psobj|. 
fun = @psobj;  

%% 
% Create the nonlinear constraint
%
% $$ \frac{{xy}}{2} + {\left( {x + 2} \right)^2} + \frac{{{{\left( {y - 2}
% \right)}^2}}}{2} \le 2. $$
%
% To do so, on your MATLAB path, save the following code to a file named
% |ellipsetilt.m|.
%
% <include>ellipsetilt.m</include>
%
%% 
% Start |patternsearch| from the initial point |[-2,-2]|. 
x0 = [-2,-2];
A = [];
b = [];
Aeq = [];
beq = [];
lb = [];
ub = [];
nonlcon = @ellipsetilt;
x = patternsearch(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon)