Пример #1
0
// Determine the minimum useful population size
int bisection(Random& rand, Configuration& config, evaluation::pointer problem,
              optimize::pointer solver) {
  int runs = config.get<int>("runs");
  float good_enough = config.get<int>("fitness_limit");
  vector<Record> records;
  // initial bounds
  int min = 0;
  int max = 1;
  size_t failed_on = 0;
  bool success;
  // Double the maximum size until a successful run is found
  do {
    // double the bounds each time
    min = max;
    max *= 2;
    config.set("pop_size", max);
    std::cout << "Pop size: " << max << std::endl;
    success = true;
    // Perform multiple runs, stopping as soon as one of the runs failed to find
    // the global optimum
    for (int i = 0; success and i < runs; i++) {
      int problem_number = ((i + failed_on) % runs);
      std::cout << "\tTrying problem: " << problem_number << std::endl;
      auto results = single_run(rand, config, problem, solver, problem_number);
      if (results.best().first < good_enough) {
        failed_on = problem_number;
        success = false;
      }
    }
  } while (!success);

  // Bisect between the min (unsuccessful) and max (successful) until they meet
  int guess;
  while (min + 1 < max) {
    guess = (max + min) / 2;
    std::cout << "Pop size: " << guess << std::endl;
    config.set("pop_size", guess);
    success = true;
    // Perform multiple runs, stopping as soon as one of the runs failed to find
    // the global optimum
    for (int i = 0; success and i < runs; i++) {
      int problem_number = ((i + failed_on) % runs);
      std::cout << "\tTrying problem: " << problem_number << std::endl;
      auto results = single_run(rand, config, problem, solver, problem_number);
      if (results.best().first < good_enough) {
        failed_on = problem_number;
        success = false;
      }
    }
    // update the bound
    if (success) {
      max = guess;
    } else {
      min = guess;
    }
  }
  return max;
}
Пример #2
0
// Recursively drills down from a given size until either it finds the correct
// population size, or you discover that max isn't big enough
int recurse(Random& rand, Configuration& config, evaluation::pointer problem,
            optimize::pointer solver, int min, int max) {
  int runs = config.get<int>("runs");
  float good_enough = config.get<float>("fitness_limit");
  vector<Record> records;
  int result;
  for (int i = 0; i < runs; i++) {
    config.set("pop_size", max);
    std::cout << "Pop size: " << max << " Trying problem: " << i << std::endl;
    auto results = single_run(rand, config, problem, solver, i);
    if (results.best().first < good_enough) {
      // fail this size, you have to get bigger
      std::cout << "\tfailed" << std::endl;
      return -1;
    } else {
      int guess = (max + min) / 2;
      if (min != guess) {
        result = recurse(rand, config, problem, solver, min, guess);
        // If you found the correct population size
        if (result != -1) {
          return result;
        } else {
          // You failed, increase the minimum
          min = guess;
        }
      }
    }
  }
  return max;
}
Пример #3
0
int
main (int argc, char ** argv)
{	double freq ;

	memset (input, 0, sizeof (input)) ;
	freq = 0.01 ;
	gen_windowed_sines (1, &freq, 1.0, input, BUFFER_LEN) ;

	if (argc == 1)
		single_run () ;
	else if (argc == 3 && strcmp (argv [1], "--best-of") == 0)
	{	int run_count = atoi (argv [2]) ;

		if (run_count < 1 || run_count > 20)
		{	printf ("Please be sensible. Run count should be in range (1, 10].\n") ;
			exit (1) ;
			} ;

		multi_run (run_count) ;
		}
	else
		usage_exit (argv [0]) ;

	puts (
		"            Duration is in seconds.\n"
		"            Throughput is in frames/sec (more is better).\n"
		) ;

	return 0 ;
} /* main */
Пример #4
0
void do_single_crack(struct db_main *db)
{
	struct rpp_context ctx;

	single_db = db;
	rule_ctx = &ctx;
	single_init();
	single_run();
	single_done();
}
Пример #5
0
void do_single_crack(struct db_main *db)
{
    struct rpp_context ctx;

    single_db = db;
    rule_ctx = &ctx;
    single_init();
    single_run();
    single_done();
    rule_ctx = NULL; /* Just for good measure */
}
Пример #6
0
int main(int argc, char *argv[])
{
    errval_t err;

    // initialization
    vfs_init();
    bench_init();

    // mount nfs
    err = vfs_mkdir("/nfs");
    assert(err_is_ok(err));
    err = vfs_mount("/nfs", "nfs://10.110.4.4/local/nfs");
    assert(err_is_ok(err));

    // argument processing
    if (argc == 3) {
        printf("Started vfs_bench in command-line mode\n");

        int32_t chunksize = atol(argv[1]);
        int32_t repetitions = atol(argv[2]);

        single_run(chunksize, repetitions);
    } else {
        printf("Started vfs_bench.\n");

        for (int32_t i = 1; i < 20; i++) {
            single_run(4096, i * 2000);
        }
    }

    //err = vfs_unmount("/nfs"); // unmount is NYI
    //assert(err_is_ok(err));
    err = vfs_rmdir("/nfs");
    assert(err_is_ok(err));

    return 0;
}
Пример #7
0
// Performs multiple runs of optimization
vector<Record> multirun(Random& rand, Configuration& config,
                        evaluation::pointer problem, optimize::pointer solver) {
  int runs = config.get<int>("runs");
  int verbosity = config.get<int>("verbosity");
  vector<Record> records;
  // perform the desired number of runs
  for (int run = 0; run < runs; run++) {
    records.push_back(single_run(rand, config, problem, solver, run));
    // output partial summaries
    if (verbosity > 0) {
      auto summary = Record::summarize(records, config);
      std::cout << "Run: " << run << " Evals: "
                << records[records.size() - 1].best().second << " MES: "
                << summary[MES] << " MAD: " << summary[MAD] << " FAILURES: "
                << summary[FAILURES] << std::endl;
    }
  }
  return records;
}