% Rosenbrock function constrained with a cubic and a line L. LAURENT -- 16/04/2018 -- luc.laurent@lecnam.net
0001 %% Rosenbrock function constrained with a cubic and a line 0002 %L. LAURENT -- 16/04/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 % 0025 %numerous local minima 0026 %1 global minimum : x=(1,1) >> f(x)=0 0027 % 0028 %design space -1.5<x1<1.5 0029 % -0.5<x2<2.5 0030 0031 function [p,g,dp,dg]=probRosenbrockCubicLine(xx) 0032 0033 %use the existing 2-dimenstion Rosenbrock's function 0034 if nargout>2 0035 [p,dp]=funRosenbrock(xx); 0036 else 0037 p=funRosenbrock(xx); 0038 end 0039 0040 % two contraints 0041 if nargout>1 0042 tmp1=(xx(:,:,1)-1).^3-xx(:,:,2)+1; 0043 tmp2=xx(:,:,1)+xx(:,:,2)-2; 0044 % 0045 g{1}=tmp1; 0046 g{2}=tmp2; 0047 end 0048 %and their derivatives 0049 if nargout>3 0050 nX=size(xx); 0051 % 0052 dtmp1(:,:,1)=3*(xx(:,:,1)-1).^2; 0053 dtmp1(:,:,2)=-ones(nX(1),nX(2)); 0054 % 0055 dtmp2=ones(nX(1),nX(2),2); 0056 % 0057 dg{1}=dtmp1; 0058 dg{2}=dtmp2; 0059 end 0060 end