www.gusucode.com > mbcdesign 工具箱 matlab 源码程序 > mbcdesign/@xregdesign/addConstraint.m
function des = addConstraint(des,cons) %ADDCONSTRAINT Add some constraints to the design space % % DES = ADDCONSTRAINT(DES,{CONSTRAINTLIST}) % Copyright 2000-2005 The MathWorks, Inc. and Ford Global Technologies, Inc. NewC=0; if builtin('isempty',des.constraints) % build constraint object f= factors(des); des.constraints= des_constraints(f); NewC=1; end % add new constraint to constraint object if ~iscell(cons) cons={cons}; end for n=1:length(cons) des.constraints=add(des.constraints,cons{n}); end if NewC || isempty(interiorPoints(des.constraints)) % need to evalulate whole candidate space the first time through des= EvalConstraints(des); else usewait=0; if waitbars(des) usewait=1; h=xregGui.waitdlg('title','MBC Toolbox', ... 'message','Evaluating new constraints. Please wait...'); end % only need to look in existing interior points ind= interiorPoints(des.constraints); if usewait h.waitbar.value=.05; end % generate points Xc= indexcand(des,ind,'unconstrained'); if usewait h.waitbar.value=.35; end % evaluate constraints (need to reset first) c = reset(des.constraints); if usewait h.waitbar.value=.4; end c = isInside(c,invcode( model( des ), Xc ) ); if usewait h.waitbar.value=.9; end % interior points are a subset of the old IP's ind= ind(interiorPoints(c)); if usewait h.waitbar.value=.95; end % set the new interior points des.constraints= interiorPoints(c,ind); if usewait h.waitbar.value=1; end end des.candstate=des.candstate+1; des.constraintsflag=des.candstate;