@@ -354,13 +354,13 @@ void Counter::td_decompose() {
354354 return ;
355355 }
356356
357- TWD ::Graph primal (nVars ());
357+ auto primal = std::make_unique< TWD ::Graph> (nVars ());
358358 all_lits (i) {
359359 Lit l (i/2 , i%2 == 0 );
360360 for (const auto & l2: watches[l].binaries ) {
361361 if (!l2.red () && l < l2.lit ()) {
362362 debug_print (" bin cl: " << l.var () << " " << l2.lit ().var ());
363- primal. addEdge (l.var ()-1 , l2.lit ().var ()-1 );
363+ primal-> addEdge (l.var ()-1 , l2.lit ().var ()-1 );
364364 }
365365 }
366366 }
@@ -370,7 +370,7 @@ void Counter::td_decompose() {
370370 for (uint32_t i = 0 ; i < cl.sz ; i++) {
371371 for (uint32_t i2 = i+1 ; i2 < cl.sz ; i2++) {
372372 debug_print (" long cl: " << cl[i].var () << " " << cl[i2].var ());
373- primal. addEdge (cl[i].var ()-1 , cl[i2].var ()-1 );
373+ primal-> addEdge (cl[i].var ()-1 , cl[i2].var ()-1 );
374374 }
375375 }
376376 }
@@ -379,22 +379,22 @@ void Counter::td_decompose() {
379379 if (!conf.do_td_use_opt_indep ) nodes = indep_support_end-1 ;
380380 if (conf.do_td_contract ) {
381381 for (uint32_t i = nodes; i < nVars (); i++) {
382- primal. contract (i, conf.td_max_edges *100 );
383- if (primal. numEdges () > conf.td_max_edges *100 ) break ;
382+ primal-> contract (i, conf.td_max_edges *100 );
383+ if (primal-> numEdges () > conf.td_max_edges *100 ) break ;
384384 }
385385 }
386- verb_print (1 , " [td] nodes: " << nodes << " nvars: " << nVars () << " edges: " << primal. numEdges ());
386+ verb_print (1 , " [td] nodes: " << nodes << " nvars: " << nVars () << " edges: " << primal-> numEdges ());
387387
388388 const uint64_t n = (uint64_t )nVars ()*(uint64_t )nVars ();
389- const double density = (double )primal. numEdges ()/(double )n;
390- const double edge_var_ratio = (double )primal. numEdges ()/(double )nVars ();
389+ const double density = (double )primal-> numEdges ()/(double )n;
390+ const double edge_var_ratio = (double )primal-> numEdges ()/(double )nVars ();
391391 verb_print (1 , " [td] Primal graph "
392- << " nodes: " << primal. numNodes ()
393- << " edges: " << primal. numEdges ()
392+ << " nodes: " << primal-> numNodes ()
393+ << " edges: " << primal-> numEdges ()
394394 << " density: " << std::fixed << setprecision (3 ) << density
395395 << " edge/var: " << std::fixed << setprecision (3 ) << edge_var_ratio);
396- if (primal. numEdges () > conf.td_max_edges ) {
397- verb_print (1 , " [td] Too many edges, " << primal. numEdges () << " skipping TD" );
396+ if (primal-> numEdges () > conf.td_max_edges ) {
397+ verb_print (1 , " [td] Too many edges, " << primal-> numEdges () << " skipping TD" );
398398 return ;
399399 }
400400 if (density > conf.td_max_density ) {
@@ -406,21 +406,22 @@ void Counter::td_decompose() {
406406 return ;
407407 }
408408
409- TWD ::Graph* primal_alt = nullptr ;
409+ std::unique_ptr< TWD ::Graph> primal_alt = nullptr ;
410410 if (conf.do_td_contract ) {
411- primal_alt = new TWD::Graph (nodes);
411+ primal_alt = std::make_unique< TWD ::Graph> (nodes);
412412 for (uint32_t i = 0 ; i < nodes; i++) {
413- const auto & k = primal. get_adj_list ()[i];
413+ const auto & k = primal-> get_adj_list ()[i];
414414 for (const auto & i2: k) {
415415 if (i2 < (int )nodes)
416416 primal_alt->addEdge (i, i2);
417417 }
418418 }
419- } else primal_alt = & primal;
419+ } else primal_alt = std::move ( primal) ;
420420
421421 if (!primal_alt->isConnected ()) {
422- verb_print (1 , " ERROR: Primal graph is not connected, this is NOT going to go well!" );
423- verb_print (1 , " ERROR: Counter should NOT be fed a disconnected CNF" );
422+ cerr << " ERROR: Primal graph is not connected, this is NOT going to go well!" << endl;
423+ cerr << " ERROR: Counter should NOT be fed a disconnected CNF" << endl;
424+ assert (false );
424425 exit (-1 );
425426 }
426427
@@ -434,7 +435,6 @@ void Counter::td_decompose() {
434435
435436 compute_td_score (td, conf.do_td_contract ? nodes : nVars (), true );
436437 verb_print (1 , " [td] decompose time: " << cpu_time () - my_time);
437- if (conf.do_td_contract ) delete primal_alt;
438438}
439439
440440// Self-check count without restart with CMS only
@@ -831,7 +831,7 @@ FF Counter::do_appmc_count() {
831831
832832 mpz_class num_sols (2 );
833833 mpz_pow_ui (num_sols.get_mpz_t (), num_sols.get_mpz_t (), appmc_cnt.hashCount );
834- num_sols *= appmc_cnt.cellSolCount ;
834+ num_sols *= mpz_class ( static_cast < unsigned long >( appmc_cnt.cellSolCount )) ;
835835 verb_print (1 , " [appmc] ApproxMC count: " << num_sols);
836836 return std::make_unique<ArjunNS::FMpz>(num_sols);
837837}
@@ -1222,9 +1222,7 @@ double Counter::score_of(const uint32_t v, bool ignore_td) const {
12221222 double act_score = 0 ;
12231223 double td_score = 0 ;
12241224 double freq_score = 0 ;
1225- vector<uint32_t > occ_cnt; // number of occurrences of a variable in the component
12261225
1227- // TODO Yash idea: let's cut this into activities and incidence
12281226 if (!tdscore.empty () && !ignore_td) td_score = td_weight*tdscore[v];
12291227 act_score = var_act (v)/conf.act_score_divisor ;
12301228 freq_score = (double )comp_manager->freq_score_of (v)/conf.freq_score_divisor ;
0 commit comments