demo

PURPOSE ^

% Method of optiGTest class

SYNOPSIS ^

function hh=demo(obj)

DESCRIPTION ^

% Method of optiGTest class
 L. LAURENT --  15/04/2018 -- luc.laurent@lecnam.net

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %% Method of optiGTest class
0002 % L. LAURENT --  15/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) 2018  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 %% run demo mode (only for 1D or 2D function)
0025 % OUTPUT:
0026 %  - hh: handles of figures stored in cells
0027 
0028 function hh=demo(obj)
0029 if isinf(obj.dimAvailable);obj.dim=2;end
0030 Xmin=obj.xMin;
0031 Xmax=obj.xMax;
0032 % plot 1D or 2D
0033 if obj.dim==1
0034     stepM=100;
0035     %
0036     xx=linspace(Xmin(1),Xmax(1),stepM)';
0037     %evaluation of objective function(s)
0038     [ZZobj,GZobj]=obj.evalObj(xx);
0039     %display
0040     hh(1)=obj.show1D(xx,ZZobj,GZobj,[obj.namePb ': Objective'],obj.funObj);
0041     %constraint(s)
0042     if obj.nbCons>1
0043         %evaluation of constraint function(s)
0044         [ZZcons,GZcons]=obj.evalCons(xx);
0045         %display
0046         hh(2)=obj.show1D(xx,ZZcons,GZcons,[obj.namePb ': Constraint'],obj.funCons);
0047     end
0048     %store figure handle
0049     obj.figureHandle=hh;
0050 elseif any(ismember(obj.dimAvailable,2))||isinf(obj.dimAvailable)
0051     obj.dim=2;
0052     stepM=100;
0053     %
0054     xL=linspace(Xmin(1),Xmax(1),stepM);
0055     yL=linspace(Xmin(2),Xmax(2),stepM);
0056     [x,y]=meshgrid(xL,yL);
0057     xx=zeros(stepM,stepM,2);
0058     xx(:,:,1)=x;xx(:,:,2)=y;
0059     %evaluation of objective function(s)
0060     [ZZobj,GZobj]=obj.evalObj(xx);
0061     %display
0062     hh(1)=obj.show2D(x,y,ZZobj,GZobj,[obj.namePb ': Objective'],obj.funObj);
0063     %constraint(s)
0064     if obj.nbCons>0
0065         %evaluation of constraint function(s)
0066         [ZZcons,GZcons]=obj.evalCons(xx);
0067         statusCons=obj.checkCons;
0068         %display
0069         hh(2)=obj.show2D(x,y,ZZcons,GZcons,[obj.namePb ': Constraint'],obj.funCons);
0070         hh(3)=obj.show2DCons(x,y,ZZobj,statusCons,[obj.namePb ': Objective function with Constraint'],obj.funObj);
0071     end
0072     %store figure handle
0073     obj.figureHandle=hh;
0074 else
0075     Ofprintf(['Too large dimension to be plotted (' mfilename ')\n']);
0076 end
0077 end

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