Doxygen Generated Documentation of Ben-Jose Trainable SAT Solver Library
ben_jose.h
Go to the documentation of this file.
1 
2 
3 /*************************************************************
4 
5 This file is part of ben-jose.
6 
7 ben-jose is free software: you can redistribute it and/or modify
8 it under the terms of the version 3 of the GNU General Public
9 License as published by the Free Software Foundation.
10 
11 ben-jose is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15 
16 You should have received a copy of the GNU General Public License
17 along with ben-jose. If not, see <http://www.gnu.org/licenses/>.
18 
19 ------------------------------------------------------------
20 
21 Copyright (C) 2007-2012, 2014-2016. QUIROGA BELTRAN, Jose Luis.
22 Id (cedula): 79523732 de Bogota - Colombia.
23 See https://github.com/joseluisquiroga/ben-jose
24 
25 ben-jose is free software thanks to The Glory of Our Lord
26  Yashua Melej Hamashiaj.
27 Our Resurrected and Living, both in Body and Spirit,
28  Prince of Peace.
29 
30 -------------------------------------------------------------- */
41 //--------------------------------------------------------------
42 
43 #ifndef BEN_JOSE_H
44 #define BEN_JOSE_H
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
50 //============================================================
60 #define RES_UNKNOWN_STR "unknown"
62 #define RES_YES_SATISF_STR "yes_satisf"
63 #define RES_NO_SATISF_STR "no_satisf"
64 #define RES_ERROR_STR "error"
65 
66 #define RESULT_FIELD_SEP "|"
67 #define RESULT_FIELD_SEP_CHAR '|'
68 
69 //=============================================================================
77 typedef enum {
83 
84 //=============================================================================
90 typedef enum {
110 } bj_error_t;
111 
112 //=============================================================================
118 typedef enum {
124 } bj_param_t;
125 
126 //=============================================================================
132 typedef struct {
133  bj_satisf_val_t bjo_result;
134 
135  double bjo_solve_time;
136  long bjo_num_vars;
137  long bjo_num_ccls;
138  long bjo_num_lits;
139 
140  double bjo_num_laps;
141  double bjo_num_recoils;
142 
143  double bjo_load_time;
144  double bjo_num_cnf_saved;
145  double bjo_num_cnf_finds;
146  double bjo_quick_discards;
147 
148  bj_error_t bjo_error;
149  char bjo_err_char;
150  long bjo_err_line;
151  long bjo_err_pos;
152  long bjo_err_num_decl_cls;
153  long bjo_err_num_decl_vars;
154  long bjo_err_num_read_cls;
155  long bjo_err_bad_lit;
156 
157  char bjo_dbg_enabled;
158  char bjo_dbg_never_write;
159  char bjo_dbg_never_find;
160  char bjo_dbg_min_trainable;
161  char bjo_dbg_as_release;
162 } bj_output_t;
163 
165 typedef void* bj_solver_t;
166 
168 #define bj_solver_is_null(bjs) (bjs == NULL)
169 
170 // TO USER: DO NOT FREE OUTPUT POINTERS when calling these functions
171 
172 
173 
178 void bj_init_output(bj_output_t* the_out);
179 
180 
181 
186 bj_solver_t bj_solver_create(const char* bjs_dir_path);
187 
188 
189 
193 void bj_solver_release(bj_solver_t bjs);
194 
195 
196 
202 void bj_set_param_char(bj_solver_t bjs, bj_param_t prm, char val);
203 
204 
205 
211 char bj_get_param_char(bj_solver_t bjs, bj_param_t prm);
212 //void bj_set_param_str(bj_solver_t bjs, bj_param_t prm, char* val);
213 
214 
215 
220 const char* bj_get_database_path(bj_solver_t bjs);
221 
222 
223 
231 bj_satisf_val_t bj_solve_file(bj_solver_t bjs, const char* f_path);
232 
233 
234 
243 bj_satisf_val_t bj_solve_data(bj_solver_t bjs, long dat_sz, const char* dat);
244 
245 
246 
257 bj_satisf_val_t bj_solve_literals(bj_solver_t bjs, long num_vars, long num_cls,
258  long lits_sz, long* lits);
259 
260 
261 
266 bj_satisf_val_t bj_get_result(bj_solver_t bjs);
267 
268 
269 
275 bj_output_t bj_get_output(bj_solver_t bjs);
276 
277 
278 
283 const char* bj_get_solve_file_path(bj_solver_t bjs);
284 
285 
286 
312 const long* bj_get_assig(bj_solver_t bjs);
313 
314 
315 
322 const char* bj_get_last_proof_path(bj_solver_t bjs);
323 
324 
325 
332 const char* bj_get_error_stack_str(bj_solver_t bjs);
333 
334 
335 
342 const char* bj_get_error_assert_str(bj_solver_t bjs);
343 
344 
345 
352 const char* bj_get_result_titles_string(bj_solver_t bjs);
353 
354 
355 
362 const char* bj_get_result_string(bj_solver_t bjs);
363 
364 
365 
372 void bj_parse_result_string(bj_solver_t bjs, const char* rslt_str);
373 
374 
375 
380 void bj_restart(bj_solver_t bjs);
381 
382 
383 
388 void bj_print_paths(bj_solver_t bjs);
389 
390 
391 
397 const char* bj_error_str(bj_error_t bje);
398 
399 // TO USER: DO NOT FREE OUTPUT POINTERS when calling these functions
400 
401 #ifdef __cplusplus
402 }
403 #endif
404 
405 #endif // BEN_JOSE_H
406 
407 
Bad DIMACS format. General format error.
Definition: ben_jose.h:105
char bj_get_param_char(bj_solver_t bjs, bj_param_t prm)
Definition: ben_jose.cpp:187
Path too long.
Definition: ben_jose.h:100
Error result.
Definition: ben_jose.h:81
void * bj_solver_t
A ben-jose solver object is of this tyoe.
Definition: ben_jose.h:165
bj_satisf_val_t bj_solve_literals(bj_solver_t bjs, long num_vars, long num_cls, long lits_sz, long *lits)
Definition: ben_jose.cpp:282
const char * bj_get_database_path(bj_solver_t bjs)
Definition: ben_jose.cpp:228
Invalid parameter.
Definition: ben_jose.h:119
Compare results to an existing .test file or write one if not found.
Definition: ben_jose.h:123
const char * bj_get_error_stack_str(bj_solver_t bjs)
Definition: ben_jose.cpp:365
const char * bj_error_str(bj_error_t bje)
Definition: ben_jose.cpp:400
Bad DIMACS format. Non existant cnf declaration line.
Definition: ben_jose.h:103
Run debug version of library as release version. Assumes linking with the debug version.
Definition: ben_jose.h:120
Can not load instance.
Definition: ben_jose.h:96
void bj_restart(bj_solver_t bjs)
Definition: ben_jose.cpp:383
Out of memory.
Definition: ben_jose.h:94
bj_solver_t bj_solver_create(const char *bjs_dir_path)
Definition: ben_jose.cpp:58
Run only deduction (do not use training). For debugging purposes only.
Definition: ben_jose.h:121
Bad DIMACS format. No variables found.
Definition: ben_jose.h:106
void bj_parse_result_string(bj_solver_t bjs, const char *rslt_str)
Definition: ben_jose.cpp:489
const long * bj_get_assig(bj_solver_t bjs)
Definition: ben_jose.cpp:336
bj_output_t bj_get_output(bj_solver_t bjs)
Definition: ben_jose.cpp:317
bj_param_t
Posible parameters for the solving process.
Definition: ben_jose.h:118
Bad DIMACS format. Invalid clause literal.
Definition: ben_jose.h:108
Bad DIMACS format. Inconsistent clause count with cnf declaration.
Definition: ben_jose.h:104
bj_error_t
Posible errors of the solving process.
Definition: ben_jose.h:90
bj_satisf_val_t
Posible final results of the solving process.
Definition: ben_jose.h:77
const char * bj_get_error_assert_str(bj_solver_t bjs)
Definition: ben_jose.cpp:374
const char * bj_get_result_titles_string(bj_solver_t bjs)
Definition: ben_jose.cpp:465
const char * bj_get_solve_file_path(bj_solver_t bjs)
Definition: ben_jose.cpp:327
Timeout.
Definition: ben_jose.h:95
Write a JSON proof if the CNF is unsatisfiable.
Definition: ben_jose.h:122
void bj_set_param_char(bj_solver_t bjs, bj_param_t prm, char val)
Definition: ben_jose.cpp:146
Invalid root (database) directory.
Definition: ben_jose.h:101
Bad DIMACS format. Clause too long.
Definition: ben_jose.h:109
bj_satisf_val_t bj_get_result(bj_solver_t bjs)
Definition: ben_jose.cpp:309
Corrupted file.
Definition: ben_jose.h:98
bj_satisf_val_t bj_solve_data(bj_solver_t bjs, long dat_sz, const char *dat)
Definition: ben_jose.cpp:259
void bj_print_paths(bj_solver_t bjs)
Definition: ben_jose.cpp:394
No error.
Definition: ben_jose.h:91
const char * bj_get_result_string(bj_solver_t bjs)
Definition: ben_jose.cpp:477
Too big file (must fit in memory)
Definition: ben_jose.h:99
Can not open file.
Definition: ben_jose.h:97
Internal with explanation.
Definition: ben_jose.h:93
Unsatisfiable CNF.
Definition: ben_jose.h:80
const char * bj_get_last_proof_path(bj_solver_t bjs)
Definition: ben_jose.cpp:352
Found a non number where a number is expected.
Definition: ben_jose.h:102
Bad DIMACS format. No clauses found.
Definition: ben_jose.h:107
void bj_solver_release(bj_solver_t bjs)
Definition: ben_jose.cpp:101
Unknown result.
Definition: ben_jose.h:78
Internal.
Definition: ben_jose.h:92
Satisfiable CNF.
Definition: ben_jose.h:79
bj_satisf_val_t bj_solve_file(bj_solver_t bjs, const char *f_path)
Definition: ben_jose.cpp:237
void bj_init_output(bj_output_t *the_out)
Definition: ben_jose.cpp:49