屏幕输出相关结果分散在多个.c文件中

一个典型的求解输出:

 
  1 Administrator@PC-20170726RROZ /cygdrive/d/SATceshi2021-11
  2 $ ./kissat.exe dist8.c.cnf
  3 c ---- [ banner ] ------------------------------------------------------------
  4 c
  5 c KISSAT SAT Solver
  6 c Copyright (c) 2019-2021 Armin Biere JKU Linz
  7 c
  8 c Version sc2021 98f4776480362089afe283c49c7f67dfb87b89dc
  9 c gcc (GCC) 7.3.0 -W -Wall -O3 -DNDEBUG
 10 c Sat, Nov 20, 2021 4:27:01 PM CYGWIN_NT-6.1 PC-20170726RROZ 2.11.1(0.329/5/3) x86_64
 11 c
 12 c ---- [ parsing ] -----------------------------------------------------------
 13 c
 14 c opened and reading DIMACS file:
 15 c
 16 c   dist8.c.cnf
 17 c
 18 c parsed 'p cnf 15276 68149' header
 19 c closing input after reading 1254214 bytes (1 MB)
 20 c finished parsing after 0.09 seconds
 21 c
 22 c ---- [ solving ] -----------------------------------------------------------
 23 c
 24 c  seconds switched rate      trail      variables
 25 c         MB reductions conflicts glue        remaining
 26 c          level restarts redundant irredundant
 27 c
 28 c *  0.09  8 0 0 0  0 0   0   0 0% 0 68129 14716 96%
 29 c {  0.09  8 0 0 0  0 0   0   0 0% 0 68129 14716 96%
 30 c i  0.09  8 8 0 0  0 5   3   2 1% 1 68129 14712 96%
 31 c -  0.14  9 43 0 1 140 23 300 231 16% 5 67564 14712 96%
 32 c i  0.17  9 81 0 1 199 15 713 628 24% 5 67564 14710 96%
 33 c i  0.17  9 78 0 1 199 15 744 656 23% 5 67564 14707 96%
 34 c }  0.19  9 71 1 1 239 13 1000 902 22% 5 67564 14707 96%
 35 c [  0.19  9 0 1 1 239 0 1000 902 0% 0 67564 14707 96%
 36 c i  0.19  9 105 1 1 239 28 1002 903 20% 0 67564 14704 96%
 37 c a  0.20  9 105 1 1 239 28 1002 886 20% 0 66864 14700 96%
 38 c O  0.20  9 105 1 1 239 28 1002 886 20% 0 66864 14700 96%
 39 c -  0.22 10 41 1 2 239 2 1301 980 44% 5 66864 14700 96%
 40 c i  0.23 10 40 1 2 239 2 1388 1055 36% 7 66864 14699 96%
 41 c I  0.28 10 49 1 2 239 3 2005 1639 35% 9 66848 14699 96%
 42 c i  0.30 10 49 1 2 239 3 2008 1639 35% 9 66848 14698 96%
 43 c i  0.30 10 51 1 2 240 3 2060 1676 35% 8 66848 14695 96%
 44 c ]  0.31 10 50 2 2 240 3 2287 1874 37% 8 66848 14695 96%
 45 c {  0.31 10 71 2 2 240 13 2287 1874 22% 5 66848 14695 96%
 46 c i  0.33 10 71 2 2 242 14 2296 1882 22% 5 66848 14685 96%
 47 c d  0.33 10 70 2 2 253 14 2338 1918 22% 5 66451 14684 96%
 48 c
 49 c  seconds  switched   rate         trail      variables
 50 c         MB reductions conflicts      glue         remaining
 51 c          level restarts    redundant  irredundant
 52 c
 53 c b  0.34 10 70 2 2 253 14 2338 1918 22% 5 66451 14471 95%
 54 c 3  0.36 10 70 2 2 253 14 2338 6008 22% 5 66451 14471 95%
 55 c t  0.36 10 70 2 2 253 14 2338 6008 22% 5 66419 14471 95%
 56 
 57 
 58 
 59 s UNSATISFIABLE
 60 c
 61 c ---- [ profiling ] ---------------------------------------------------------
 62 c
 63 c          77.89   93.25 %  search
 64 c          41.88   50.15 %  stable
 65 c          36.00   43.10 %  focused
 66 c           5.54    6.64 %  simplify
 67 c           5.22    6.24 %  probe
 68 c           4.56    5.45 %  vivify
 69 c           0.43    0.52 %  reduce
 70 c           0.28    0.34 %  ternary
 71 c           0.25    0.30 %  substitute
 72 c           0.22    0.26 %  eliminate
 73 c           0.09    0.11 %  failed
 74 c           0.09    0.11 %  parse
 75 c           0.08    0.09 %  autarky
 76 c           0.03    0.04 %  walking
 77 c           0.02    0.02 %  backbone
 78 c           0.02    0.02 %  subsume
 79 c           0.02    0.02 %  transitive
 80 c =============================================
 81 c          83.52  100.00 %  total
 82 c
 83 c ---- [ statistics ] --------------------------------------------------------
 84 c
 85 c clauses_learned:                    1100408               95 %  conflicts
 86 c conflicts:                          1156127            13839.53 per second
 87 c decisions:                          1816185                1.57 per conflict
 88 c propagations:                     210594360          2520941    per second
 89 c reductions:                             144             8029    interval
 90 c rephased:                                25            46245    interval
 91 c restarts:                             34389               33.62 interval
 92 c strengthened:                         26394                1 %  checks
 93 c substituted:                           3032               20 %  variables
 94 c subsumption_checks:                 3159812
 95 c subsumed:                            432998               14 %  checks
 96 c walks:                                    8           144516    interval
 97 c
 98 c ---- [ resources ] ---------------------------------------------------------
 99 c
100 c maximum-resident-set-size:          8261632 bytes          8 MB
101 c process-time:                         1m 24s              83.52 seconds
102 c
103 c ---- [ shutting down ] -----------------------------------------------------
104 c
105 c exit 20

 

   

 

1.求解结果的输出在application.h之中函数run_application代码,可以输出求解器运行的结果:SATISFIABLE or UNSATISFIABLE

2.运行过程中屏幕上滚动的的信息相关代码在report.c文件之中

 

 

#define REPORTS \
REP("seconds", "5.2f", kissat_time (solver)) \
REP("MB", "2.0f", MB) \
REP("level", ".0f", AVERAGE (level)) \
REP("switched", "1" PRIu64, statistics->switched_modes) \
REP("reductions", "1" PRIu64, statistics->reductions) \
REP("restarts", "2" PRIu64, statistics->restarts) \
REP("rate", ".0f", AVERAGE (decision_rate)) \
REP("conflicts", "3" PRIu64, CONFLICTS) \
REP("redundant", "3" PRIu64, REDUNDANT_CLAUSES) \
REP("trail", ".0f%%", AVERAGE (trail)) \
REP("glue", ".0f", AVERAGE (slow_glue)) \
REP("irredundant", "2" PRIu64, IRREDUNDANT_CLAUSES) \
REP("variables", "2u", solver->active) \
REP("remaining", "1.0f%%" , REMAINING_VARIABLES) \

 
 1 c ---- [ solving ] -----------------------------------------------------------
 2 c
 3 c  seconds switched rate      trail      variables
 4 c         MB reductions conflicts glue        remaining
 5 c          level restarts redundant irredundant
 6 c
 7 c *  0.09  8 0 0 0  0 0   0   0 0% 0 68129 14716 96%
 8 c {  0.09  8 0 0 0  0 0   0   0 0% 0 68129 14716 96%
 9 c i  0.09  8 8 0 0  0 5   3   2 1% 1 68129 14712 96%
10 c -  0.14  9 43 0 1 140 23 300 231 16% 5 67564 14712 96%
11 c i  0.17  9 81 0 1 199 15 713 628 24% 5 67564 14710 96%
12 c i  0.17  9 78 0 1 199 15 744 656 23% 5 67564 14707 96%
13 c }  0.19  9 71 1 1 239 13 1000 902 22% 5 67564 14707 96%
14 c [  0.19  9 0 1 1 239 0 1000 902 0% 0 67564 14707 96%
15 c i  0.19  9 105 1 1 239 28 1002 903 20% 0 67564 14704 96%
16 c a  0.20  9 105 1 1 239 28 1002 886 20% 0 66864 14700 96%
17 c O  0.20  9 105 1 1 239 28 1002 886 20% 0 66864 14700 96%
18 c -  0.22 10 41 1 2 239 2 1301 980 44% 5 66864 14700 96%
19 c i  0.23 10 40 1 2 239 2 1388 1055 36% 7 66864 14699 96%
20 c I  0.28 10 49 1 2 239 3 2005 1639 35% 9 66848 14699 96%
21 c i  0.30 10 49 1 2 239 3 2008 1639 35% 9 66848 14698 96%
22 c i  0.30 10 51 1 2 240 3 2060 1676 35% 8 66848 14695 96%
23 c ]  0.31 10 50 2 2 240 3 2287 1874 37% 8 66848 14695 96%
24 c {  0.31 10 71 2 2 240 13 2287 1874 22% 5 66848 14695 96%
25 c i  0.33 10 71 2 2 242 14 2296 1882 22% 5 66848 14685 96%
26 c d  0.33 10 70 2 2 253 14 2338 1918 22% 5 66451 14684 96%
27 c
28 c  seconds  switched   rate         trail      variables
29 c         MB reductions conflicts      glue         remaining
30 c          level restarts    redundant  irredundant
31 c
32 c b  0.34 10 70 2 2 253 14 2338 1918 22% 5 66451 14471 95%
33 c 3  0.36 10 70 2 2 253 14 2338 6008 22% 5 66451 14471 95%

 

3.求解完毕后相关统计信息的代码在statistics.h文件中

 

代码有些复杂对C的宏定义需要非常熟悉

 1 #define PRINT_STAT(NAME,PRIMARY,SECONDARY,UNITS,TYPE) \
 2 do { \
 3   printf ("c %-" SFW1 "s %"  SFW2 PRIu64 " ", NAME ":", (uint64_t) PRIMARY); \
 4   const double SAVED_SECONDARY = (double) (SECONDARY); \
 5   const char * SAVED_UNITS = (const char*) (UNITS); \
 6   const char * SAVED_TYPE = (const char *) (TYPE); \
 7   if (SAVED_TYPE && SAVED_SECONDARY >= 0) \
 8     { \
 9       if (SAVED_UNITS) \
10     printf ("%" SFW34 ".0f %-2s", SAVED_SECONDARY, SAVED_UNITS); \
11       else \
12     printf ("%" SFW34EXTENDED ".2f", SAVED_SECONDARY); \
13       fputc (' ', stdout); \
14       fputs (SAVED_TYPE, stdout); \
15     } \
16   fputc ('\n', stdout); \
17 } while (0)

 

 
 1 c ---- [ statistics ] --------------------------------------------------------
 2 c
 3 c clauses_learned:                    1100408               95 %  conflicts
 4 c conflicts:                          1156127            13839.53 per second
 5 c decisions:                          1816185                1.57 per conflict
 6 c propagations:                     210594360          2520941    per second
 7 c reductions:                             144             8029    interval
 8 c rephased:                                25            46245    interval
 9 c restarts:                             34389               33.62 interval
10 c strengthened:                         26394                1 %  checks
11 c substituted:                           3032               20 %  variables
12 c subsumption_checks:                 3159812
13 c subsumed:                            432998               14 %  checks
14 c walks:                                    8           144516    interval

 

4.求解样例所用的时间及占用内存资源情况见文件resources.c。

 
 1 void
 2 kissat_print_resources (kissat * solver)
 3 {
 4   uint64_t rss = kissat_maximum_resident_set_size ();
 5   double t = kissat_time (solver);
 6   printf ("c "
 7       "%-" SFW1 "s "
 8       "%" SFW2 PRIu64 " "
 9       "%-" SFW3 "s "
10       "%" SFW4 ".0f "
11       "MB\n",
12       "maximum-resident-set-size:",
13       rss, "bytes", rss / (double) (1 << 20));
14 #ifdef METRICS
15   statistics *statistics = &solver->statistics;
16   uint64_t max_allocated = statistics->allocated_max + sizeof (kissat);
17   printf ("c "
18       "%-" SFW1 "s "
19       "%" SFW2 PRIu64 " "
20       "%-" SFW3 "s "
21       "%" SFW4 ".0f "
22       "%%\n",
23       "max-allocated:",
24       max_allocated, "bytes", kissat_percent (max_allocated, rss));
25 #endif
26   printf ("c process-time: %30s %18.2f seconds\n", FORMAT_TIME (t), t);
27   fflush (stdout);
28 }

 

 
1 c ---- [ resources ] ---------------------------------------------------------
2 c
3 c maximum-resident-set-size:          8261632 bytes          8 MB
4 c process-time:                         1m 24s              83.52 seconds
5 c

 

posted on 2021-11-20 18:49  海阔凭鱼跃越  阅读(315)  评论(0编辑  收藏  举报