www.gusucode.com > mbcdata 工具箱 matlab 源码程序 > mbcdata/@cgtabgradconstraint/cgtabgradconstraint.m
function obj = cgtabgradconstraint(varargin) %CGTABGRADCONSTRAINT Constructor for cgtabgradconstraint class % % OBJ = CGTABGRADCONSTRAINT(NAME) constructs a new cgtabgradconstraint % with the given name. % % OBJ = CGTABGRADCONSTRAINT(NAME, AXISBPS, PAXIS, PVAR) constructs a new % cgtabgradconstraint which will constrain the variable pointed by PVAR % over the defined table breakpoints, AXISBPS, and the table axis % variables, PAXIS. % % OBJ = CGTABGRADCONSTRAINT(NAME, AXISBPS, PAXIS, PVAR, BOUNDS) % constructs the cgtabgradconstraint such that the gradient of the % variable is constrained to lie within BOUNDS. % % OBJ = CGTABGRADCONSTRAINT(NAME, AXISBPS, PAXIS, PVAR, BOUNDS, % SURFACEGRADFCN) constructs the object with a specific SURFACEGRADFCN % that will be used to interpolate the variable over the optimization % fixed points. % % OBJ = CGTABGRADCONSTRAINT(NAME, AXISBPS, PAXIS, PVAR, BOUNDS, % SURFACEGRADFCN, FILTERGRIDFCN) uses FILTERGRADFCN to filter out the % table breakpoints that are not required to form the gradient % constraint. FILTERGRIDFCN must be either 'CONVEXHULL', 'IDENTITY' or a % function handle. % % Note: All the error checking for this class is performed in the % generateEditorPages method. Command line users of this class must % perform their own error checking. % % See also CGSUMCONSTRAINT % Copyright 2006-2015 The MathWorks, Inc. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % FILTERING CURRENTLY SWITCHED OFF % % % % This is due to an assumption made by cgoptimrunners that the number % % of outputs that a cgoptimitem returns does not vary between runs and % % is only dependent on the lengths of the object's inputs. % % Furthermore, it is assumed that the number of outputs a cgoptimitems % % produce is returned in getNumOutputs. Breaking these assumptions, can % % have bad consequences, for example, plotting in the optim output node % % breaks. % % % % With filtering turned on, cgtabgradconstraint violates these % % assumptions % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Create class structure if nargin && isstruct(varargin{1}) ISNEWOBJ = false; s = varargin{1}; prnt = s.cgoptimconstraint; s = rmfield(s, 'cgoptimconstraint'); else ISNEWOBJ = true; if nargin < 1 || isempty(varargin{1}) superargs = {'TableGradientConstraint'}; else superargs = varargin(1); end % Minimal inputs for a working object are Axes Breakpoints, pointers to % Axes variables and the variable to constrain. if nargin < 4 || any(cellfun('isempty', varargin(2:4))) AxisBreakpoints = {}; pAxisVariables = mbcpointer(1, 0); pVariable = mbcpointer(1, 0); else AxisBreakpoints = varargin{2}; pAxisVariables = varargin{3}; pVariable = varargin{4}; end NAXES = length(pAxisVariables); if nargin < 5 || isempty(varargin{5}) Bounds = ones(NAXES, 3); Bounds(:, 1) = -Inf; Bounds(:, 2) = Inf; else Bounds = varargin{5}; end if nargin < 6 || isempty(varargin{6}) SurfaceGenFcn = @pRBFSurfaceGen; else SurfaceGenFcn = varargin{6}; end s = struct('AxisBreakpoints', {AxisBreakpoints}, ... 'pAxisVariables', pAxisVariables, ... 'Bounds', Bounds,... 'SurfaceGenFcn', SurfaceGenFcn, ... 'FilterGridFcn', @pIdentityGridFilter, ... 'DistanceScale', 1, ... 'Version', 4, ... 'WorkingStore', [], ... 'ScaledAxisBreakpoints', {{}},... 'pItem', pVariable, ... 'IsVariable',true); prnt = cgoptimconstraint(superargs{:}); end % Create the class obj = class(s, 'cgtabgradconstraint', prnt); % Post class creation tasks % Set the filter function if nargin > 6 && ~isempty(varargin{7}) obj = setFilterGridFcn(obj, varargin{7}); end % Scale the axis breakpoints onto [0, 1] if ~isempty(obj.AxisBreakpoints) obj.ScaledAxisBreakpoints = pScaleAxisPoints(obj, obj.AxisBreakpoints); end % If it is a newly created object, then update the ranges. We do not update % the range for old objects being loaded as the existing range should be % correct. if ISNEWOBJ obj = updateranges(obj); end