www.gusucode.com > mbcdata 工具箱 matlab 源码程序 > mbcdata/@cgoptimextoptions/loadOldSettings.m

    function obj = loadOldSettings(obj, lblVar, lblObj, lblCon, lblOp, lblOpVar, modes)
%LOADOLDSETTINGS Cosntruct default data from old information
%
%  OBJ = LOADOLDSETTINGS(OBJ, LBLVAR, LBLOBJ, LBLCON, LBLOP, LBLOPVAR, MODES) 
%  is used to load old optimization object setup data into a new
%  cgoptimoptions object.  This method should only be used to upgrade old
%  optimizations into their new structure.

%  Copyright 2000-2004 The MathWorks, Inc. and Ford Global Technologies, Inc.


if nargin<7
    modeStr = {'any', 'fixed', 'any', 'default'};
else
    % Convert Mode codes into correct strings
    modeOpts = {'fixed', 'any', 'multiple'};
    modeStr = modeOpts(modes+1);
    if modes(end)==2;
        modeStr{end} = 'default';
    end
end

% Set the correct modes
obj = setFreeVariablesMode(obj, modeStr{1});
obj = setObjectivesMode(obj, modeStr{2});
obj = setConstraintsMode(obj, modeStr{3});
obj = setOperatingPointsMode(obj, modeStr{4});

% Add default objects as needed, one for each label.
for n = 1:length(lblVar)
    obj = addFreeVariable(obj, lblVar{n});
end

for n = 1:length(lblObj)
    obj = addObjective(obj, lblObj{n}, 'min/max');
end

for n = 1:length(lblCon)
    obj = addModelConstraint(obj, lblCon{n}, 'lessthan', 0);
end

for n = 1:length(lblOp)
    obj = addOperatingPointSet(obj, lblOp{n}, lblOpVar{n});
end

obj = fixForModes(obj);