1 | package tuffy.util; |
2 | |
3 | import java.lang.management.ManagementFactory; |
4 | |
5 | |
6 | /** |
7 | * Container for global configuration parameters. |
8 | */ |
9 | public class Config { |
10 | |
11 | public static String product_line = "tuffy"; |
12 | public static String product_name = "Tuffy 0.3"; |
13 | public static String path_conf = "./tuffy.conf"; |
14 | |
15 | public static boolean snapshot_mode = false; |
16 | public static boolean snapshoting_so_do_not_do_init_flip = false; |
17 | public static int currentSampledNumber = 0; |
18 | |
19 | public static boolean gp = false; |
20 | |
21 | /** |
22 | * Runtime |
23 | */ |
24 | public static boolean exiting_mode = false; |
25 | public static boolean learning_mode = false; |
26 | |
27 | public static String display_marker; |
28 | |
29 | /** |
30 | * DB |
31 | */ |
32 | public static String relConstants = "constants"; |
33 | |
34 | public static String db_url = "jdbc:postgresql://localhost:5439/gp"; |
35 | public static String db_username = "czhang"; |
36 | |
37 | // public static String db_url = "jdbc:postgresql://localhost:5432/lmn"; |
38 | // public static String db_username = "tuffer"; |
39 | |
40 | public static String db_password = "strongPasswoRd"; |
41 | public static String db_schema = "tuffy_testing"; |
42 | |
43 | /** |
44 | * File System |
45 | */ |
46 | public static String dir_working = "/tmp/tuffy-workspace"; |
47 | public static String dir_out = "."; |
48 | public static boolean output_files_in_gzip = false; |
49 | public static String dir_tests = "/tmp/tuffy-tests"; |
50 | public static String file_stats = "tuffy_stats.txt"; |
51 | |
52 | /** |
53 | * System |
54 | */ |
55 | public static boolean disable_partition = false; |
56 | public static int max_threads = 0; |
57 | public static boolean build_predicate_table_indexes = false; |
58 | public static int evidence_file_chunk_size = 1<<22; |
59 | public static double partition_size_bound = 1 << 30; |
60 | public static double ram_size = 1 << 30; |
61 | |
62 | public static String evidDBSchema = null; |
63 | public static boolean dbNeedTranslate = false; |
64 | |
65 | /** |
66 | * Inference |
67 | */ |
68 | public static boolean use_atom_blocking = false; |
69 | public static boolean mark_all_atoms_active = false; |
70 | public static boolean stop_samplesat_upon_sat = false; |
71 | |
72 | public static double soft_evidence_activation_threshold = 0.25; |
73 | public static double samplesat_sa_coef = 10; |
74 | public static double mcsat_sample_para = 1; |
75 | public static double hard_weight = 5.2E7; |
76 | public static double hard_threshold = 1E7; |
77 | public static double walksat_random_step_probability = 0.5; |
78 | public static double sweepsat_greedy_probability = 0.5; |
79 | public static boolean avoid_breaking_hard_clauses = false; |
80 | public static boolean apply_greedy_throttling = true; |
81 | |
82 | public static enum TUFFY_INFERENCE_TASK {MAP, MARGINAL}; |
83 | |
84 | public static int gauss_seidel_infer_rounds = 5; |
85 | |
86 | /** |
87 | * UI |
88 | */ |
89 | public static int verbose_level = 0; |
90 | public static String console_line_header = null; |
91 | public static boolean clause_display_multiline = true; |
92 | |
93 | public static enum MCSAT_OUTPUT_TUPLE_ORDER {PROBABILITY, PRED_ARGS}; |
94 | public static MCSAT_OUTPUT_TUPLE_ORDER mcsat_output_order = |
95 | MCSAT_OUTPUT_TUPLE_ORDER.PROBABILITY; |
96 | |
97 | public static double marginal_output_min_prob = 0; |
98 | public static boolean mcsat_output_hidden_atoms = false; |
99 | |
100 | |
101 | /** |
102 | * Helper |
103 | */ |
104 | public static int mcsatDumpPeriodSamples = 20; |
105 | public static int mcsatDumpPeriodSeconds = 0; |
106 | |
107 | public static boolean output_prolog_format = false; |
108 | public static boolean output_prior_with_marginals = true; |
109 | public static boolean throw_exception_when_dying = false; |
110 | |
111 | public static boolean keep_db_data = false; |
112 | |
113 | public static boolean track_clause_provenance = false; |
114 | public static boolean reorder_literals = false; |
115 | |
116 | public static double timeout = Double.MAX_VALUE; |
117 | public static int num_tries_per_periodic_flush = 0; |
118 | |
119 | |
120 | /** |
121 | * Research |
122 | */ |
123 | public static boolean checkNumCriticalNodes = false; |
124 | public static boolean focus_on_critical_atoms = false; |
125 | |
126 | |
127 | |
128 | |
129 | |
130 | |
131 | public static int getNumThreads(){ |
132 | if(max_threads > 0) return max_threads; |
133 | return Runtime.getRuntime().availableProcessors(); |
134 | } |
135 | |
136 | |
137 | public static String getLoadingDir(){ |
138 | String path = dir_working + "/loading"; |
139 | FileMan.ensureExistence(path); |
140 | return path; |
141 | } |
142 | |
143 | public static String getWorkingDir(){ |
144 | return dir_working; |
145 | } |
146 | |
147 | public static int globalCounter = 0; |
148 | |
149 | public static int getNextGlobalCounter(){ |
150 | synchronized(Config.class) { |
151 | globalCounter = globalCounter + 1; |
152 | return globalCounter; |
153 | } |
154 | } |
155 | |
156 | public static String getProcessID(){ |
157 | return ManagementFactory.getRuntimeMXBean().getName(); |
158 | } |
159 | |
160 | } |