www.gusucode.com > mbcdesign 工具箱 matlab 源码程序 > mbcdesign/@des_respsurf/designproperties.m
function p = designproperties(des,p,varargin) %DESIGNPROPERTIES properties for command-line % % p = designproperties(c,p) % Copyright 2007-2011 The MathWorks, Inc. tp = DesignType(des); switch tp case 1 CLSID = mfilename('class'); p.ExtraArguments = {npoints(des)}; [p,OK] = PersistentStore(p,CLSID); if ~OK; p = iOptimalProps(des,p); PersistentStore(p,CLSID); end otherwise p = designproperties(getdesign(des),p); end function p = iOptimalProps(des,p) %#ok<INUSL> p = addprop(p,'InitialPoints',... @iGetInitialPoints,... @iSetInitialPoints,... 'matrix','',... 'Initial design points'); p = addprop(p,'NumberOfPoints',... @iGetNumberOfPoints,... @iSetNumberOfPoints,... 'int',[0 Inf],... 'Number of points'); % optimal designs are different p = addprop(p,'CandidateSet',... @iGetCandSpace,@iSetCandSpace,... 'mbcdoe.candidateset',{},... 'Candidate set'); p = addprop(p,'AllowReplicates',... @iGetAllowReplicates,@iSetAllowReplicates,... 'boolean',[],... 'Allow replicate points'); p = addprop(p,'AugmentMethod',... @iGetAddMethod,@iSetAddMethod,... 'enum',{'random','optimal'},... 'Method to augment points'); p = addprop(p,'Tolerance',... @iGetTolerance,@iSetTolerance,... 'numeric','positive',... 'Tolerance (Delta) '); p = addprop(p,'MaxIterations',... @iGetMaxIterations,@iSetMaxIterations,... 'int','positive',... 'Maximum Iterations'); p = addprop(p,'NumberOfPointsToAlter',... @iGetNumPointsToAdd,@iSetNumPointsToAdd,... 'int','positive',... 'Number of points to alter per iteration using the random augment method (p)'); p = addprop(p,'NoImprovement',... @iGetNoImprovement,@iSetNoImprovement,... 'int','positive',... 'Number of iterations with no improvement using the random augment method (q)'); function v = iGetAllowReplicates(des,nInitial) v= allowreps(des); function des = iSetAllowReplicates(des,v,nInitial) des = allowreps(des,v); function v = iGetCandSpace(des,nInitial) % make designproperties object for candidate set v = mbcdoe.candidateset(candspace(des),model(des)); %v.ExtraArguments = {model(des)}; function des = iSetCandSpace(des,v,nInitial) c = candspace(des); if ~isequal(c,v) if npoints(v)>=flintmax % throw error if the candidate set is too large for indexing error(message('mbc:doe:CandidateSetTooLarge', sprintf( '%10.5g', flintmax))); end des = candspace(des,v); % Reinitialize points from old canidate space Mode = NextDesignMode(des); n= npoints(des); if strcmp(Mode,'add') des = safechange(des,@(des) delete(des,'indexed',nInitial+1:n)); n = n-nInitial; end des = InitializeDesign(des,n,Mode); end function v = iGetAddMethod(des,nInitial) %#ok<*INUSD> v = des.augmentmethod; function des = iSetAddMethod(des,v,nInitial) des.augmentmethod = v; if strcmp(v,'optimal') % set des.p = 1; des.q = 1; elseif des.p==1 && des.q==1 des.p = 50; des.q = 50; end function v = iGetTolerance(des,nInitial) v = des.delta; function des = iSetTolerance(des,v,nInitial) des.delta = v; function v = iGetMaxIterations(des,nInitial) v = des.maxiter; function des = iSetMaxIterations(des,v,nInitial) des.maxiter = v; function v = iGetNumPointsToAdd(des,nInitial) v = des.p; function des = iSetNumPointsToAdd(des,v,nInitial) des.p = v; if strcmp(des.augmentmethod,'optimal') && v~=1 error(message('mbc:doe:InvalidValue37')) end function v = iGetNoImprovement(des,nInitial) v = des.q; function des = iSetNoImprovement(des,v,nInitial) des.q = v; if strcmp(des.augmentmethod,'optimal') && v~=1 error(message('mbc:doe:InvalidValue38')) end function v = iGetNumberOfPoints(des,nInitial) % this is total number of points switch NextDesignMode(des) case 'replace' v = npoints(des); case 'replacefree' v = npoints(des) - length(fixpoints); case 'add' v = npoints(des) - nInitial; end function des = iSetNumberOfPoints(des,Ndes,nInitial) if Ndes==0 % number of points change des= safechange(des,@clear); elseif Ndes ~= npoints(des) || ~strcmp(NextDesignMode(des),'replace') % number of points change des = InitializeDesign(des,Ndes,NextDesignMode(des)); end function v = iGetInitialPoints(des,nInitial) switch NextDesignMode(des) case 'replace' X = factorsettings(des); case 'replacefree' X = freepoints(des); case 'add' X = factorsettings(des); X = X(nInitial+1:end,:); end v = invcode(model(des),X); function des = iSetInitialPoints(des,X,nInitial) if ~isnumeric(X) || size(X,2)~=nfactors(des) error(message('mbc:doe:InvalidDesign2', nfactors( des ))) end Xc = iGetInitialPoints(des,nInitial); if ~isequal(X,Xc) X = code(model(des),X); [tp,info] = DesignType(des); switch NextDesignMode(des) case 'replace' des = clear(des); case 'replacefree' des = deletefreepoints(des); case 'add' n = npoints(des); if n>nInitial des = delete(des,'indexed',nInitial:n); end end des= augment(des,X,'points'); des = DesignType(des,tp,info); if npoints(des)>0 && ~rankcheck(des) error(message('mbc:doe:InvalidDesign3')) end end