Percy++
A C++ implementation of Private Information Retrieval (PIR) protocols
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
portfolio.h
1 // Percy++ Copyright 2007,2012,2013,2014
2 // Ian Goldberg <iang@cs.uwaterloo.ca>,
3 // Casey Devet <cjdevet@uwaterloo.ca>
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of version 2 of the GNU General Public License as
7 // published by the Free Software Foundation.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // There is a copy of the GNU General Public License in the COPYING file
15 // packaged with this plugin; if you cannot find it, write to the Free
16 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 // 02110-1301 USA
18 
19 /* This file defines the algorithm that is chosen for the portfolio algorithm.
20  * To get the result for (k, t, h), use portfolio_table[k-3][t+1][h-t-1].
21  */
22 
23 #ifndef __PORTFOLIO_H__
24 #define __PORTFOLIO_H__
25 
26 #include <string>
27 #include <map>
28 
29 // This file is used by the portfolio algorithm in RSDecoder to choose the best
30 // single-polynomial decoding algorithm to use. The results are based off of
31 // timing tests, the results of which are stored in the portfolio_table array.
32 // The portfolio algorithm only works for k<=20 (as these are the only timing
33 // results that are stored here).
34 
35 // A type for the different RS decoding algorithms. (Maybe TestType should be
36 // changed to something more suitable).
37 enum TestType {
38  UNDEFINED = 0,
39  UNKNOWN,
40  EASY,
41  BEST,
42  BRUTE,
43  KOTTER,
44  CH_MS,
45  BW,
46  CH_MULTI,
47  CH_TK1,
48  DP,
49  MAX_TESTTYPE
50 };
51 const std::string testTypeStrings[MAX_TESTTYPE] = {
52  "undefined",
53  "unknown",
54  "easy",
55  "best",
56  "brute",
57  "kotter",
58  "ch_ms",
59  "bw",
60  "ch_multi",
61  "ch_tk1",
62  "dp"
63 };
64 
65 // A type for the flavour of the dynamic programming decoding algorithm
66 enum DPType {
67  UNDEFINED_DPTYPE = 0,
68  ASSUME_CORRECT,
69  ASSUME_WRONG,
70  ASSUME_SHARES,
71  MAX_DPTYPE
72 };
73 const std::string DPTypeStrings[MAX_DPTYPE] = {
74  "undefined",
75  "assume_correct",
76  "assume_wrong",
77  "assume_shares"
78 };
79 
80 // Defaults for findpolys
81 //static TestType defaultTestType = KOTTER;
82 //static DPType defaultDPType = UNDEFINED_DPTYPE;
83 //static int defaultGord = 1;
84 
85 
86 struct Choice {
87  TestType testType;
88  double time;
89  DPType dpType;
90  int gord;
91 };
92 
93 const int max_k = 25;
94 
95 extern const Choice portfolio_table[max_k - 2][max_k + 1][max_k + 1];
96 
97 // Function used by RSDecoder to get the best algorithm to run.
98 bool portfolioChoice (int k, int t, int h,
99  TestType &testType, DPType &dpType, int &gord);
100 
101 #endif
102 
Definition: portfolio.h:86