示例#1
0
文件: nct.cpp 项目: smkhossain/cirkit
bool nct_command::execute()
{
  auto& circuits = env->store<circuit>();

  auto settings = make_settings();
  auto mapped = nct_mapping( circuits.current(), settings, statistics );
  print_runtime();

  extend_if_new( circuits );

  circuits.current() = mapped;

  return true;
}
示例#2
0
文件: rec.cpp 项目: sterin/cirkit
bool rec_command::execute()
{
  const auto& circuits = env->store<circuit>();

  auto settings = make_settings();
  settings->set( "name_mapping", is_set( "name_mapping" ) );
  result = xorsat_equivalence_check( circuits[id1], circuits[id2], settings, statistics );

  print_runtime();

  if ( result )
  {
    std::cout << "[i] circuits are \033[1;32mequivalent\033[0m" << std::endl;
  }
  else
  {
    std::cout << "[i] circuits are \033[1;31mnot equivalent\033[0m" << std::endl;
  }

  return true;
}
示例#3
0
int main(int argc, char** argv)
{ if (no_terminal(stdin)) redirected_input=true;
  cur_in=stdin; cur_out=stdout; /* these cannot be initialised statically */

  
  { int nr=1;  argc--; infofil[0]='\0';
    if (argc > 0)
    {
        strcpy(initfil,argv[nr++]);
        argc--;
    }
    if (argc > 0)
    {
        strcpy(infofil,argv[nr++]);
        strcat(infofil,"/");
        argc--;
    }
    if (argc!=0)
    {
        printf("Illegal number of arguments.\n");
        exit(1);
    }
  }
  init();

    ignore_intr();
    (void) signal(SIGINT, handle);
    (void) setjmp(envbuf);

 /* Finished  signal handling and environment set  */

    while (init_loop(),init_loop_gettype(),yyparse(),!stop)
    {	if (feof(cur_in))
	  stop=exit_input_file(false); /* close file when fully read */
	if (runtime) print_runtime();
    }
    if (!redirected_input) Printf("end program\n");
    return 0;
}
示例#4
0
文件: score.c 项目: JMCQ87/MyPA
void calc_score (MYSQL *mysql)
{
  MYSQL_RES *res;
  MYSQL_ROW row;

  char q_fleet[] = "SELECT planet_id,"\
    "CEILING(SUM(units.num * (uc.metal+uc.crystal+uc.eonium)/10)) " \
    "FROM fleet,units, unit_class as uc WHERE units.id=fleet.fleet_id " \
    "AND units.unit_id=uc.id GROUP BY planet_id";

  char q_pds[] ="SELECT planet_id,"\
    "CEILING(SUM(pds.num * (uc.metal+uc.crystal+uc.eonium)/10)) " \
    "FROM pds, unit_class as uc WHERE pds.pds_id=uc.id "\
    "GROUP BY planet_id";

  char q_scan[] = "SELECT planet_id, "\
    "CEILING(SUM(scan.num * (sc.metal+sc.crystal+sc.eonium)/10)) " \
    "FROM scan,scan_class as sc WHERE scan.wave_id=sc.id " \
    "GROUP BY planet_id";

  char q_rc[] = "SELECT planet_id, "\
    "CEILING(SUM((rc_class.metal+rc_class.crystal+rc_class.eonium)/10)) " \
    "FROM rc, rc_class WHERE rc.status=3 AND rc.rc_id=rc_class.id "\
    "GROUP BY planet_id";

  char update[256];
  char upd_fmt[] = "UPDATE planet set score=%llu+(metal+crystal+eonium)/100" \
    "+(metalroids+crystalroids+eoniumroids)*1500 WHERE id=%d";

  table *prc, *pscan, *ppds, *pfleet;
  table *pprc, *ppscan, *pppds, *ppfleet;
  struct timeval start;

  debug (1, "calc_score");
  gettimeofday (&start, NULL);

  ppfleet = pfleet = get_score_table (mysql, q_fleet);
  print_runtime (&start); 
  ppscan  = pscan  = get_score_table (mysql, q_scan );
  print_runtime (&start);
  pppds   = ppds   = get_score_table (mysql, q_pds  );
  print_runtime (&start);
  pprc    = prc    = get_score_table (mysql, q_rc   );
  print_runtime (&start);
  
  res = do_query (mysql,"SELECT id FROM planet ORDER BY id");
  debug (2, "calc_score selects");
  print_runtime (&start);

  if (res && mysql_num_rows(res)) {
/*
    do_query (mysql, "LOCK TABLES planet WRITE");
  */
    while ((row = mysql_fetch_row (res))) {
      unsigned long long score = 0;
      int id = atoi(row[0]);

      if (ppfleet && ppfleet->id == id) {
	score += ppfleet->score;
	ppfleet++;
      }

      if (ppscan && ppscan->id == id) {
	score += ppscan->score;
	ppscan++;
      }

      if (pppds && pppds->id == id) {
	score += pppds->score;
	pppds++;
      }

      if (pprc && pprc->id == id) {
	score += pprc->score;
	pprc++;
      }


      sprintf (update, upd_fmt, score, id);
      do_query (mysql, update);
    }
  /*
    do_query (mysql, "UNLOCK TABLES");
   */
    check_error (mysql);
    mysql_free_result(res);
  }
  debug (2, "calc_score end");
  print_runtime (&start); 
}