www.gusucode.com > mbcdata 工具箱 matlab 源码程序 > mbcdata/@cgoptimrunner/getLinearConstraints.m
function [A, b] = getLinearConstraints(obj) %GETLINEARCONSTRAINTS return the linear constraint matrices % % [A, B] = GETLINEARCONSTRAINTS(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 2005-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 Run = obj.RunIndices(obj.CurrentRun); else error(message('mbc:cgoptimrunner:InvalidState4')); end AllInputLen = obj.InputDataLengths; Data = obj.InputData; XFixed = zeros(size(obj.LinearConstraints.A2,2) , 1); Start = 1; for n = 1:length(AllInputLen) if ~ismember(n, obj.FreeVariableIndices) XFixed(Start:Start+AllInputLen(n)-1) = Data{n}(Run, :).'; Start = Start+AllInputLen(n); end end b = b - obj.LinearConstraints.A2*XFixed; end end