funConsTownsend

PURPOSE ^

% Constraint function used in problems: Townsend

SYNOPSIS ^

function [g,dg]=funConsTownsend(xx)

DESCRIPTION ^

% Constraint function used in problems: Townsend
L. LAURENT -- 02/05/2018 -- luc.laurent@lecnam.net

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %% Constraint function used in problems: Townsend
0002 %L. LAURENT -- 02/05/2018 -- luc.laurent@lecnam.net
0003 
0004 % sources available here:
0005 % https://bitbucket.org/luclaurent/optigtest/
0006 % https://github.com/luclaurent/optigtest/
0007 
0008 % optiGTest - set of testing functions    A toolbox to easy manipulate functions.
0009 % Copyright (C) 2017  Luc LAURENT <luc.laurent@lecnam.net>
0010 %
0011 % This program is free software: you can redistribute it and/or modify
0012 % it under the terms of the GNU General Public License as published by
0013 % the Free Software Foundation, either version 3 of the License, or
0014 % (at your option) any later version.
0015 %
0016 % This program is distributed in the hope that it will be useful,
0017 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0018 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0019 % GNU General Public License for more details.
0020 %
0021 % You should have received a copy of the GNU General Public License
0022 % along with this program.  If not, see <http://www.gnu.org/licenses/>.
0023 
0024 function [g,dg]=funConsTownsend(xx)
0025 
0026 %constants
0027 a=2;
0028 b=1/2;
0029 c=1/4;
0030 d=1/8;
0031 e=3;
0032 f=4;
0033 
0034 % contraint
0035 xxx=xx(:,:,1);
0036 yyy=xx(:,:,2);
0037 %
0038 t=atan2(xxx,yyy);
0039 st=sin(t);
0040 ct=cos(t);
0041 cat=cos(a*t);
0042 cet=cos(e*t);
0043 cft=cos(f*t);
0044 %
0045 td=a*ct-b*cat-c*cet-d*cft;
0046 %
0047 g=xxx.^2+yyy.^2-f*st.^2-td.^2;
0048 
0049 %and their derivatives
0050 if nargout>1
0051     dtx=yyy./(xxx.^2+yyy.^2);
0052     dty=-xxx./(xxx.^2+yyy.^2);
0053     %
0054     sat=sin(a*t);
0055     set=sin(e*t);
0056     sft=sin(f*t);
0057     %
0058     dg(:,:,1)=2*xxx-2*f*dtx.*ct.*st-2*dtx.*(-a*st+sat+e*c*set+b*sft).*td;
0059     dg(:,:,2)=2*yyy-2*f*dty.*ct.*st-2*dty.*(-a*st+sat+e*c*set+b*sft).*td;
0060 end
0061 end

Generated on Tue 28-May-2019 16:00:34 by m2html © 2005