www.gusucode.com > mbcdata 工具箱 matlab 源码程序 > mbcdata/@cgoptimrunner/getLinearConstraintsOverHelper.m
function [A, b] = getLinearConstraintsOverHelper(obj, datasetName, rowInd) %GETLINEARCONSTRAINTSOVERHELPER return the linear constraint matrices % % [A, B] = GETLINEARCONSTRAINTSOVERHELPER(OBJ) returns the A and B constraint % matrices that should be used during the optimization. A will be a % (NLINCON-by-NFREEVALS) and B will be (NLINCON-by-1). % Copyright 2006-2011 The MathWorks, Inc. A = obj.LinearConstraints.A; if nargout>1 % Compute the b values for the current fixed variable values b = obj.LinearConstraints.b; if ~isempty(obj.LinearConstraints.A2) if obj.CurrentRun == 0 error(message('mbc:cgoptimrunner:InvalidState5')); end % Retrieve the fixed and free data from the data set. Set up some % dummy free variables so we can use pCreateEvalInputs. nRows = numel(rowInd); [unused, nFree] = numFreeValues(obj); xfree = ones(nRows, sum(nFree)); dsidx = getOperatingPointSetIndex(obj.Setup, datasetName); Data = pCreateEvalInputs(obj, xfree, 'dataset', dsidx, rowInd); % Filter out the free variable data. Note it is assumed that % helper data sets can only be used with scalar data. nVar = length(Data); XFixed = [Data{:}]; FixedVariableIndices = setdiff(1:nVar, obj.FreeVariableIndices); XFixed = XFixed(:, FixedVariableIndices); b = repmat(b, 1, nRows) - obj.LinearConstraints.A2*XFixed'; end end