Skip to content

Commit a916373

Browse files
committed
Added safeness probability
1 parent a08f9f5 commit a916373

File tree

2 files changed

+28
-9
lines changed

2 files changed

+28
-9
lines changed

sbf.cpp

+23-9
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ void SBF::PrintFilter(int mode)
267267
printf("Filter sparsity: %.5f\n",this->GetFilterSparsity());
268268
printf("Filter a-priori fpp: %.5f\n", this->GetFilterAPrioriFpp());
269269
printf("Filter fpp: %.5f\n",this->GetFilterFpp());
270+
printf("Filter a-priori safeness probability: %.5f\n", this->safeness);
270271
printf("Number of mapped elements: %d\n",this->members);
271272
printf("Number of hash collisions: %d\n",this->collisions);
272273

@@ -302,7 +303,7 @@ void SBF::PrintFilter(int mode)
302303

303304
printf("\nEmersion, Fpp, Isep:\n");
304305
for(int j = 1; j < this->AREA_number+1; j++){
305-
printf("Area %d: expected emersion %.5f, emersion %.5f, a-priori fpp %.5f, fpp %.5f, a-priori isep %.5f, expected ise %.5f, isep %.5f",j,this->GetExpectedAreaEmersion(j),this->GetAreaEmersion(j),this->AREA_a_priori_fpp[j],this->AREA_fpp[j],this->AREA_a_priori_isep[j], this->AREA_a_priori_isep[j]*this->AREA_members[j], this->AREA_isep[j]);
306+
printf("Area %d: expected emersion %.5f, emersion %.5f, a-priori fpp %.5f, fpp %.5f, a-priori isep %.5f, expected ise %.5f, isep %.5f, a-priori safep %.5f",j,this->GetExpectedAreaEmersion(j),this->GetAreaEmersion(j),this->AREA_a_priori_fpp[j],this->AREA_fpp[j],this->AREA_a_priori_isep[j], this->AREA_a_priori_isep[j]*this->AREA_members[j], this->AREA_isep[j], this->AREA_a_priori_safep[j]);
306307
printf("\n");
307308
}
308309
printf("\n");
@@ -335,11 +336,12 @@ void SBF::SaveToDisk(std::string path, int mode)
335336
myfile << "sparsity" << ";" << this->GetFilterSparsity() << std::endl;
336337
myfile << "a-priori fpp" << ";" << this->GetFilterAPrioriFpp() << std::endl;
337338
myfile << "fpp" << ";" << this->GetFilterFpp() << std::endl;
339+
myfile << "a-priori safeness probability" << ";" << this->safeness << std::endl;
338340
// area-related parameters:
339-
// area,members,expected cells,self-collisions,cells,expected emersion,emersion,a-priori fpp,fpp,a-priori isep,expected ise,isep
340-
myfile << "area" << ";" << "members" << ";" << "expected cells" << ";" << "self-collisions" << ";" << "cells" << ";" << "expected emersion" << ";" << "emersion" << ";" << "a-priori fpp" << ";" << "fpp" << ";" << "a-priori isep" << ";" << "expected ise" << ";" << "isep" << std::endl;
341+
// area,members,expected cells,self-collisions,cells,expected emersion,emersion,a-priori fpp,fpp,a-priori isep,expected ise,isep,a-priori safep
342+
myfile << "area" << ";" << "members" << ";" << "expected cells" << ";" << "self-collisions" << ";" << "cells" << ";" << "expected emersion" << ";" << "emersion" << ";" << "a-priori fpp" << ";" << "fpp" << ";" << "a-priori isep" << ";" << "expected ise" << ";" << "isep" << ";" << "a-priori safep" << std::endl;
341343
for(int j = 1; j < this->AREA_number+1; j++){
342-
myfile << j << ";" << this->AREA_members[j] << ";" << this->AREA_expected_cells[j] << ";" << this->AREA_self_collisions[j] << ";" << this->AREA_cells[j] << ";" << this->GetExpectedAreaEmersion(j) << ";" << this->GetAreaEmersion(j) << ";" << this->AREA_a_priori_fpp[j] << ";" << this->AREA_fpp[j] << ";" << this->AREA_a_priori_isep[j] << ";" << (float)this->AREA_members[j] * this->AREA_a_priori_isep[j] << ";" << (float)this->AREA_isep[j] << std::endl;
344+
myfile << j << ";" << this->AREA_members[j] << ";" << this->AREA_expected_cells[j] << ";" << this->AREA_self_collisions[j] << ";" << this->AREA_cells[j] << ";" << this->GetExpectedAreaEmersion(j) << ";" << this->GetAreaEmersion(j) << ";" << this->AREA_a_priori_fpp[j] << ";" << this->AREA_fpp[j] << ";" << this->AREA_a_priori_isep[j] << ";" << (float)this->AREA_members[j] * this->AREA_a_priori_isep[j] << ";" << (float)this->AREA_isep[j] << ";" << this->AREA_a_priori_safep[j] << std::endl;
343345
}
344346

345347
}
@@ -489,11 +491,14 @@ int SBF::Check(char *string, int size)
489491

490492

491493
// Computes a-priori area-specific inter-set error probability (a_priori_isep)
494+
// Computes a-priori area-specific safeness probability (a_priori_safep) and
495+
// the overall safeness probability for the entire filter
492496
void SBF::SetAPrioriAreaIsep()
493497
{
494-
double p;
498+
double p1, p2, p3;
495499
int nfill;
496500

501+
p3 = 1;
497502

498503
for (int i = this->AREA_number; i>0; i--) {
499504
nfill = 0;
@@ -502,13 +507,22 @@ void SBF::SetAPrioriAreaIsep()
502507
nfill += this->AREA_members[j];
503508
}
504509

505-
p = (double)(1 - 1 / (double)this->cells);
506-
p = (double)(1 - (double)pow(p, this->HASH_number*nfill));
507-
p = (double)pow(p, this->HASH_number);
510+
p1 = (double)(1 - 1 / (double)this->cells);
511+
p1 = (double)(1 - (double)pow(p1, this->HASH_number*nfill));
512+
p1 = (double)pow(p1, this->HASH_number);
508513

509-
this->AREA_a_priori_isep[i] = (float)p;
514+
p2 = (double)(1 - p1);
515+
p2 = (double)pow(p2, this->AREA_members[i]);
516+
517+
p3 *= p2;
518+
519+
this->AREA_a_priori_isep[i] = (float)p1;
520+
this->AREA_a_priori_safep[i] = (float)p2;
510521

511522
}
523+
524+
this->safeness = (float)p3;
525+
512526
}
513527

514528

sbf.h

+5
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ namespace sbf {
6666
int HASH_digest_length;
6767
int members;
6868
int collisions;
69+
float safeness;
6970
int AREA_number;
7071
int *AREA_members;
7172
float *AREA_expected_cells;
@@ -75,6 +76,7 @@ namespace sbf {
7576
float *AREA_fpp;
7677
float *AREA_a_priori_isep;
7778
float *AREA_isep;
79+
float *AREA_a_priori_safep;
7880
int BIG_end;
7981

8082
// Private methods (commented in the sbf.cpp)
@@ -184,6 +186,7 @@ namespace sbf {
184186
this->AREA_isep = new float[this->AREA_number + 1];
185187
this->AREA_a_priori_fpp = new float[this->AREA_number + 1];
186188
this->AREA_a_priori_isep = new float[this->AREA_number + 1];
189+
this->AREA_a_priori_safep = new float[this->AREA_number + 1];
187190

188191
// Parameter initializations
189192
this->members = 0;
@@ -197,6 +200,7 @@ namespace sbf {
197200
this->AREA_isep[a] = -1;
198201
this->AREA_a_priori_fpp[a] = -1;
199202
this->AREA_a_priori_isep[a] = -1;
203+
this->AREA_a_priori_safep[a] = -1;
200204
}
201205
}
202206

@@ -213,6 +217,7 @@ namespace sbf {
213217
delete[] AREA_isep;
214218
delete[] AREA_a_priori_fpp;
215219
delete[] AREA_a_priori_isep;
220+
delete[] AREA_a_priori_safep;
216221
for (int j = 0; j<this->HASH_number; j++) {
217222
delete[] HASH_salt[j];
218223
}

0 commit comments

Comments
 (0)