-
Notifications
You must be signed in to change notification settings - Fork 1
/
SetGeneric.m
executable file
·202 lines (175 loc) · 7.4 KB
/
SetGeneric.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
% PAL (Pareto Active Learning) Algorithm
%
% Copyright (c) 2014 ETH Zurich
%
% This program is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation; either version 2 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program; if not, write to the Free Software
% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
classdef SetGeneric
properties
num_entries=0;
all_data = [];
num_features;
prediction = 0;
real_data = 1; %there is real obj array
features_index=0;
real_obj_index=0;
mu_index=0;
sigma_index=0;
rt_mu_index=0;
rt_sigma_index=0;
pareto_index=0;
end % properties
methods
function self = SetGeneric(num_features_in,prediction_in,real_data_in)
self.num_features = num_features_in;
self.prediction = prediction_in;
self.real_data = real_data_in;
self.features_index = 1;
if self.real_data==1
self.real_obj_index = self.features_index + self.num_features;
next_index = self.real_obj_index + 2;
else
next_index = self.features_index + self.num_features;
end
if self.prediction==1
self.mu_index = next_index;
self.sigma_index = next_index + 2;
self.rt_mu_index = next_index + 4;
self.rt_sigma_index = next_index + 6;
next_index = next_index + 8;
end
self.pareto_index = next_index;
end
function self = add_entry(self,all_data_in)
len_in = size(all_data_in);
% Number of rows. size( A ) returns a row vector whose elements
% contain the length of the corresponding dimension of A
len_in = len_in(1);
% Append all_data_in to the self.all_data
self.all_data = [self.all_data;all_data_in];
self.num_entries = self.num_entries + len_in;
end
function cell_out = remove_entry(self,remove_index)
%save removed entry
self.num_entries = self.num_entries - 1;
if self.real_data==1
remove_entry_out = self.all_data(remove_index,1:self.num_features+2);
else
remove_entry_out = self.all_data(remove_index,1:self.num_features);
end
self.all_data = removerows(self.all_data,'ind',remove_index);
cell_out = {self,remove_entry_out};
end
function self = remove_entries(self,remove_index)
self.all_data = removerows(self.all_data,'ind',remove_index);
len_tmp = size(self.all_data);
self.num_entries = len_tmp(1);
end
function entry_out = get_entry(self,index_in)
entry_out = self.all_data(index_in,:);
end
function features_out = get_features(self,index_in)
features_out = self.all_data(index_in,self.features_index:self.features_index+self.num_features-1);
end
function self = set_features(self,index_in,features_in)
self.all_data(index_in,self.features_index:self.features_index+self.num_features-1) = features_in;
end
function real_obj_out = get_real_obj(self,index_in,sel_in)
tmp_index = self.real_obj_index+sel_in-1;
real_obj_out = self.all_data(index_in,tmp_index);
end
function self = set_real_obj(self,index_in,real_obj_in,sel_in)
tmp_index = self.real_obj_index+sel_in+1;
self.all_data(index_in,tmp_index) = real_obj_in;
end
function mu_out = get_mu(self,index_in,sel_in)
tmp_index = self.mu_index+sel_in-1;
mu_out = self.all_data(index_in,tmp_index);
end
function self = set_mu(self,index_in,mu_in,sel_in)
tmp_index = self.mu_index+sel_in-1;
self.all_data(index_in,tmp_index) = mu_in;
end
function sigma_out = get_sigma(self,index_in,sel_in)
tmp_index = self.sigma_index+sel_in-1;
sigma_out = self.all_data(index_in,tmp_index);
end
function self = set_sigma(self,index_in,sigma_in,sel_in)
tmp_index = self.sigma_index+sel_in-1;
self.all_data(index_in,tmp_index) = sigma_in;
end
function rt_mu_out = get_rt_mu(self,index_in,sel_in)
tmp_index = self.rt_mu_index+sel_in-1;
rt_mu_out = self.all_data(index_in,tmp_index);
end
function self = set_rt_mu(self,index_in,rt_mu_in,sel_in)
tmp_index = self.rt_mu_index+sel_in-1;
self.all_data(index_in,tmp_index) = rt_mu_in;
end
function rt_sigma_out = get_rt_sigma(self,index_in,sel_in)
tmp_index = self.rt_sigma_index+sel_in-1;
rt_sigma_out = self.all_data(index_in,tmp_index);
end
function self = set_rt_sigma(self,index_in,rt_sigma_in,sel_in)
tmp_index = self.rt_sigma_index+sel_in-1;
self.all_data(index_in,tmp_index) = rt_sigma_in;
end
function pareto_out = get_pareto(self,index_in)
pareto_out = self.all_data(index_in,self.pareto_index);
end
function self = set_pareto(self,index_in,pareto_in)
self.all_data(index_in,self.pareto_index) = pareto_in;
end
% function pp_out = get_pp(self,index_in)
% pp_out = self.all_data(index_in,self.pp_index);
% end
% function self = set_pp(self,index_in,pp_in)
% self.all_data(index_in,self.pp_index) = pp_in;
% end
% function no_class_out = get_no_class(self,index_in)
% no_class_out = self.all_data(index_in,self.no_class_index);
% end
% function self = set_no_class(self,index_in,no_class_in)
% self.all_data(index_in,self.no_class_index) = no_class_in;
% end
% function duplicates_out = get_duplicates(self,index_in)
% duplicates_out = self.all_data(index_in,self.duplicates_index);
% end
% function self = set_duplicates(self,index_in,duplicates_in)
% self.all_data(index_in,self.duplicates_index) = duplicates_in;
% end
% function found_hash_out = get_found_hash(self,index_in,hash_index)
% tmp_index = self.found_hash_index+hash_index-1;
% found_hash_out = self.all_data(index_in,tmp_index);
% end
% function self = set_found_hash(self,index_in,hash_index,found_hash_in)
% tmp_index = (self.found_hash_index+hash_index-1);
% self.all_data(index_in,tmp_index) = found_hash_in;
% end
function self = clear_data(self)
if self.real_data==1
tmp_index = self.real_obj_index + 2;
else
tmp_index = self.features_index + self.num_features;
end
tmp = size(self.all_data);
tmp = tmp(2);
self.all_data(:,tmp_index:end)=zeros(self.num_entries,tmp-tmp_index+1);
self.all_data(:,self.no_class_index)=ones(self.num_entries,1);
end
function entries_out = get_entries(self,indexes_in)
entries_out = self.all_data(indexes_in,:);
end
end% methods
end% classdef