| 1 | %
|
|---|
| 2 | % constructor for the nonlinear_inequality_constraint class.
|
|---|
| 3 | %
|
|---|
| 4 | % [nic]=nonlinear_inequality_constraint(varargin)
|
|---|
| 5 | %
|
|---|
| 6 | % where the required varargin are:
|
|---|
| 7 | % descriptor (char, description, '')
|
|---|
| 8 | % lower (double, lower bound, -Inf)
|
|---|
| 9 | % upper (double, upper bound, 0.)
|
|---|
| 10 | % and the optional varargin and defaults are:
|
|---|
| 11 | % scale_type (char, scaling type, 'none')
|
|---|
| 12 | % scale (double, scaling factor, 1.)
|
|---|
| 13 | %
|
|---|
| 14 | % note that zero arguments constructs a default instance; one
|
|---|
| 15 | % argument of the class copies the instance; and three or more
|
|---|
| 16 | % arguments constructs a new instance from the arguments.
|
|---|
| 17 | %
|
|---|
| 18 | % "Copyright 2009, by the California Institute of Technology.
|
|---|
| 19 | % ALL RIGHTS RESERVED. United States Government Sponsorship
|
|---|
| 20 | % acknowledged. Any commercial use must be negotiated with
|
|---|
| 21 | % the Office of Technology Transfer at the California Institute
|
|---|
| 22 | % of Technology. (J. Schiermeier, NTR 47078)
|
|---|
| 23 | %
|
|---|
| 24 | % This software may be subject to U.S. export control laws.
|
|---|
| 25 | % By accepting this software, the user agrees to comply with
|
|---|
| 26 | % all applicable U.S. export laws and regulations. User has the
|
|---|
| 27 | % responsibility to obtain export licenses, or other export
|
|---|
| 28 | % authority as may be required before exporting such information
|
|---|
| 29 | % to foreign countries or providing access to foreign persons."
|
|---|
| 30 | %
|
|---|
| 31 | classdef nonlinear_inequality_constraint
|
|---|
| 32 | properties
|
|---|
| 33 | descriptor='';
|
|---|
| 34 | lower =-Inf;
|
|---|
| 35 | upper = 0.;
|
|---|
| 36 | scale_type='none';
|
|---|
| 37 | scale = 1.;
|
|---|
| 38 | end
|
|---|
| 39 |
|
|---|
| 40 | methods
|
|---|
| 41 | function [nic]=nonlinear_inequality_constraint(varargin)
|
|---|
| 42 |
|
|---|
| 43 | switch nargin
|
|---|
| 44 |
|
|---|
| 45 | % create a default object
|
|---|
| 46 |
|
|---|
| 47 | case 0
|
|---|
| 48 |
|
|---|
| 49 | % copy the object
|
|---|
| 50 |
|
|---|
| 51 | case 1
|
|---|
| 52 | if isa(varargin{1},'nonlinear_inequality_constraint')
|
|---|
| 53 | nic=varargin{1};
|
|---|
| 54 | else
|
|---|
| 55 | error('Object ''%s'' is a ''%s'' class object, not ''%s''.',...
|
|---|
| 56 | inputname(1),class(varargin{1}),'nonlinear_inequality_constraint');
|
|---|
| 57 | end
|
|---|
| 58 |
|
|---|
| 59 | % not enough arguments
|
|---|
| 60 |
|
|---|
| 61 | case 2
|
|---|
| 62 | error('Construction of ''%s'' class object requires at least %d inputs.',...
|
|---|
| 63 | 'nonlinear_inequality_constraint',3)
|
|---|
| 64 |
|
|---|
| 65 | % create the object from the input
|
|---|
| 66 |
|
|---|
| 67 | otherwise
|
|---|
| 68 | asizec=num2cell(array_size(varargin{1:min(nargin,5)}));
|
|---|
| 69 | nic(asizec{:})=nonlinear_inequality_constraint;
|
|---|
| 70 | clear asizec
|
|---|
| 71 |
|
|---|
| 72 | if ischar(varargin{1})
|
|---|
| 73 | varargin{1}=cellstr(varargin{1});
|
|---|
| 74 | end
|
|---|
| 75 | for i=1:numel(nic)
|
|---|
| 76 | if (numel(varargin{1}) > 1)
|
|---|
| 77 | nic(i).descriptor=varargin{1}{i};
|
|---|
| 78 | else
|
|---|
| 79 | nic(i).descriptor=[char(varargin{1}) string_dim(nic,i,'vector')];
|
|---|
| 80 | end
|
|---|
| 81 | if (numel(varargin{2}) > 1)
|
|---|
| 82 | nic(i).lower =varargin{2}(i);
|
|---|
| 83 | else
|
|---|
| 84 | nic(i).lower =varargin{2};
|
|---|
| 85 | end
|
|---|
| 86 | if (numel(varargin{3}) > 1)
|
|---|
| 87 | nic(i).upper =varargin{3}(i);
|
|---|
| 88 | else
|
|---|
| 89 | nic(i).upper =varargin{3};
|
|---|
| 90 | end
|
|---|
| 91 | end
|
|---|
| 92 |
|
|---|
| 93 | if (nargin >= 4)
|
|---|
| 94 | if ischar(varargin{4})
|
|---|
| 95 | varargin{4}=cellstr(varargin{4});
|
|---|
| 96 | end
|
|---|
| 97 | for i=1:numel(nic)
|
|---|
| 98 | if (numel(varargin{4}) > 1)
|
|---|
| 99 | nic(i).scale_type=varargin{4}{i};
|
|---|
| 100 | else
|
|---|
| 101 | nic(i).scale_type=char(varargin{4});
|
|---|
| 102 | end
|
|---|
| 103 | end
|
|---|
| 104 | if (nargin >= 5)
|
|---|
| 105 | for i=1:numel(nic)
|
|---|
| 106 | if (numel(varargin{5}) > 1)
|
|---|
| 107 | nic(i).scale =varargin{5}(i);
|
|---|
| 108 | else
|
|---|
| 109 | nic(i).scale =varargin{5};
|
|---|
| 110 | end
|
|---|
| 111 | end
|
|---|
| 112 |
|
|---|
| 113 | if (nargin > 5)
|
|---|
| 114 | warning('objective_function:extra_arg',...
|
|---|
| 115 | 'Extra arguments for object of class ''%s''.',...
|
|---|
| 116 | class(nic));
|
|---|
| 117 | end
|
|---|
| 118 | end
|
|---|
| 119 | end
|
|---|
| 120 | end
|
|---|
| 121 |
|
|---|
| 122 | end
|
|---|
| 123 |
|
|---|
| 124 | function []=disp(nic)
|
|---|
| 125 |
|
|---|
| 126 | % display the object
|
|---|
| 127 |
|
|---|
| 128 | disp(sprintf('\n'));
|
|---|
| 129 | for i=1:numel(nic)
|
|---|
| 130 | disp(sprintf('class ''%s'' object ''%s%s'' = \n',...
|
|---|
| 131 | class(nic),inputname(1),string_dim(nic,i)));
|
|---|
| 132 | disp(sprintf(' descriptor: ''%s''' ,nic(i).descriptor));
|
|---|
| 133 | disp(sprintf(' lower: %g' ,nic(i).lower));
|
|---|
| 134 | disp(sprintf(' upper: %g' ,nic(i).upper));
|
|---|
| 135 | disp(sprintf(' scale_type: ''%s''' ,nic(i).scale_type));
|
|---|
| 136 | disp(sprintf(' scale: %g\n' ,nic(i).scale));
|
|---|
| 137 | end
|
|---|
| 138 |
|
|---|
| 139 | end
|
|---|
| 140 |
|
|---|
| 141 | function [desc] =prop_desc(nic,dstr)
|
|---|
| 142 | desc=cell(1,numel(nic));
|
|---|
| 143 | for i=1:numel(nic)
|
|---|
| 144 | if ~isempty(nic(i).descriptor)
|
|---|
| 145 | desc(i)=cellstr(nic(i).descriptor);
|
|---|
| 146 | elseif ~isempty(inputname(1))
|
|---|
| 147 | desc(i)=cellstr([inputname(1) string_dim(nic,i,'vector')]);
|
|---|
| 148 | elseif exist('dstr','var')
|
|---|
| 149 | desc(i)=cellstr([dstr string_dim(nic,i,'vector')]);
|
|---|
| 150 | else
|
|---|
| 151 | desc(i)=cellstr(['nic' string_dim(nic,i,'vector')]);
|
|---|
| 152 | end
|
|---|
| 153 | end
|
|---|
| 154 | desc=allempty(desc);
|
|---|
| 155 | end
|
|---|
| 156 | function [stype] =prop_stype(nic)
|
|---|
| 157 | stype=cell(size(nic));
|
|---|
| 158 | for i=1:numel(nic)
|
|---|
| 159 | stype(i)=cellstr(nic(i).scale_type);
|
|---|
| 160 | end
|
|---|
| 161 | stype=allequal(stype,'none');
|
|---|
| 162 | end
|
|---|
| 163 | function [scale] =prop_scale(nic)
|
|---|
| 164 | scale=zeros(size(nic));
|
|---|
| 165 | for i=1:numel(nic)
|
|---|
| 166 | scale(i)=nic(i).scale;
|
|---|
| 167 | end
|
|---|
| 168 | scale=allequal(scale,1.);
|
|---|
| 169 | end
|
|---|
| 170 | function [weight]=prop_weight(nic)
|
|---|
| 171 | weight=[];
|
|---|
| 172 | end
|
|---|
| 173 | function [lower] =prop_lower(nic)
|
|---|
| 174 | lower=zeros(size(nic));
|
|---|
| 175 | for i=1:numel(nic)
|
|---|
| 176 | lower(i)=nic(i).lower;
|
|---|
| 177 | end
|
|---|
| 178 | lower=allequal(lower,-Inf);
|
|---|
| 179 | end
|
|---|
| 180 | function [upper] =prop_upper(nic)
|
|---|
| 181 | upper=zeros(size(nic));
|
|---|
| 182 | for i=1:numel(nic)
|
|---|
| 183 | upper(i)=nic(i).upper;
|
|---|
| 184 | end
|
|---|
| 185 | upper=allequal(upper,0.);
|
|---|
| 186 | end
|
|---|
| 187 | function [target]=prop_target(nic)
|
|---|
| 188 | target=[];
|
|---|
| 189 | end
|
|---|
| 190 | end
|
|---|
| 191 |
|
|---|
| 192 | methods (Static)
|
|---|
| 193 | function [rdesc]=dakota_write(fidi,dresp,rdesc)
|
|---|
| 194 |
|
|---|
| 195 | % collect only the responses of the appropriate class
|
|---|
| 196 |
|
|---|
| 197 | nic=struc_class(dresp,'nonlinear_inequality_constraint');
|
|---|
| 198 |
|
|---|
| 199 | % write responses
|
|---|
| 200 |
|
|---|
| 201 | [rdesc]=rlist_write(fidi,'nonlinear_inequality_constraints','nonlinear_inequality',nic,rdesc);
|
|---|
| 202 | end
|
|---|
| 203 |
|
|---|
| 204 | function []=dakota_rlev_write(fidi,dresp,params)
|
|---|
| 205 | end
|
|---|
| 206 | end
|
|---|
| 207 | end
|
|---|