0001 classdef sgvm_SolnStash < handle
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 properties
0016 size
0017 inds
0018 ids
0019 count
0020 maxobj
0021 end
0022 methods
0023 function obj = sgvm_SolnStash(n)
0024 obj.size = n;
0025 obj.inds = cell(1,n);
0026 obj.ids = cell(1,n);
0027 obj.count = 0;
0028 obj.maxobj = Inf;
0029 end
0030
0031 function update(obj, inds)
0032 for k = 1:length(inds)
0033 if (inds{k}.mpc.f < obj.maxobj) && ~ismember(inds{k}.id, obj.ids(1:obj.count))
0034 if obj.count < obj.size
0035 obj.count = obj.count + 1;
0036 end
0037 obj.inds{obj.count} = inds{k};
0038 obj.ids{obj.count} = inds{k}.id;
0039 end
0040 obj.sort();
0041 if obj.count == obj.size
0042 obj.maxobj = obj.inds{end}.mpc.f;
0043 end
0044 end
0045 end
0046
0047 function obj = sort(obj)
0048 [~, tmp] = sort(cellfun(@(x) x.mpc.f, obj.inds(1:obj.count)));
0049 obj.inds(1:obj.count) = obj.inds(tmp);
0050 obj.ids(1:obj.count) = obj.ids(tmp);
0051 end
0052
0053 function stats(obj)
0054 sgvm_collection_stats(obj, 'inds');
0055 end
0056 end
0057 end