Example #1
0
void NLOPT_STDCALL nlopt_srand_time(void) {
     nlopt_srand(nlopt_time_seed() + my_gettid() * 314159);
}
Example #2
0
int main(int argc, char **argv)
{
  int c;
  
  nlopt_srand_time();
  testfuncs_verbose = 0;
  
  if (argc <= 1)
    usage(stdout);

#if USE_FEENABLEEXCEPT
  feenableexcept(FE_INVALID);
#endif
  
  while ((c = getopt(argc, argv, "hLvCc0:r:a:o:i:e:t:x:X:f:F:m:b:")) != -1)
    switch (c) {
    case 'h':
      usage(stdout);
      return EXIT_SUCCESS;
    case 'L':
      listalgs(stdout);
      listfuncs(stdout);
      return EXIT_SUCCESS;
    case 'v':
      testfuncs_verbose = 1;
      break;
    case 'C':
      force_constraints = 1;
      break;
    case 'r':
      nlopt_srand((unsigned long) atoi(optarg));
      break;
    case 'a':
      c = atoi(optarg);
      if (c < 0 || c >= NLOPT_NUM_ALGORITHMS) {
	fprintf(stderr, "testopt: invalid algorithm %d\n", c);
	listalgs(stderr);
	return EXIT_FAILURE;
      }
      algorithm = (nlopt_algorithm) c;
      break;
    case 'o':
      if (!test_function(atoi(optarg)))
	return EXIT_FAILURE;
      break;
    case 'e':
      maxeval = atoi(optarg);
      break;
    case 'i':
      iterations = atoi(optarg);
      break;
    case 't':
      maxtime = atof(optarg);
      break;
    case 'x':
      xtol_rel = atof(optarg);
      break;
    case 'X':
      xtol_abs = atof(optarg);
      break;
    case 'f':
      ftol_rel = atof(optarg);
      break;
    case 'F':
      ftol_abs = atof(optarg);
      break;
    case 'm':
      minf_max_delta = atof(optarg);
      break;
    case 'c':
      center_start = 1;
      break;
    case '0':
      center_start = 0;
      xinit_tol = atof(optarg);
      break;
    case 'b': {
      const char *s = optarg;
      while (s && *s) {
	int b = atoi(s);
	if (b < 0 || b >= 100) { 
	  fprintf(stderr, "invalid -b argument");
	  return EXIT_FAILURE;
	}
	fix_bounds[b] = 1;
	s = strchr(s, ','); if (s) ++s;
      }
      break;
    }
    default:
      fprintf(stderr, "harminv: invalid argument -%c\n", c);
      usage(stderr);
      return EXIT_FAILURE;
    }
  
  return EXIT_SUCCESS;
}