Пример #1
0
#include <random>
#include <iomanip>
#include "DifferentialEvolution.h"
#include "RunManagerAbstract.h"
#include "ModelRunPP.h"
#include "RestartController.h"

mt19937_64 DifferentialEvolution::rand_engine = mt19937_64(1);

ParameterInfoDE::ParameterInfoDE(double _lower_bnd, double _upper_bnd,
	bool _log_transform)
	: lower_bnd(_lower_bnd), upper_bnd(_upper_bnd), log_transform(_log_transform)
{
}

ParameterInfoDE::ParameterInfoDE(const ParameterInfoDE &rhs)
{
	*this = rhs;
}
ParameterInfoDE& ParameterInfoDE::operator=(const ParameterInfoDE &rhs)
{
	lower_bnd = rhs.lower_bnd;
	upper_bnd = rhs.upper_bnd;
	log_transform = rhs.log_transform;
	return *this;
}

ParameterInfoDE::~ParameterInfoDE()
{

}
Пример #2
0
int main(void)
{
  FILE *fd;
  int length = 4;

  uint32_t j;
  uint32_t init32[4] = { UINT32_C(0x123), UINT32_C(0x234),
                         UINT32_C(0x345), UINT32_C(0x456) };
#ifdef UINT64_C
  uint64_t k;
  uint64_t init64[4] = { UINT64_C(0x12345), UINT64_C(0x23456),
                         UINT64_C(0x34567), UINT64_C(0x45678) };
#endif /* ifdef UINT64_C */

  /* Test the 32-bit Mersenne Twister generator. */
  init_mt19937ar_by_array(init32, length);

  fd = fopen(EXPECTED_OUTPUT_32, "r");
  if (fd == NULL)
  {
    log_error("Unable to open '%s'.", EXPECTED_OUTPUT_32);
    return EXIT_FAILURE;
  }

  /* Check for the correct first 1000 output values. */
  for (int i = 0; i < 1000; i++)
  {
    if (fscanf(fd, "%"PRIu32"", &j) != 1)
    {
      log_error("Error on line %d while reading '%s'.",
        i+1, EXPECTED_OUTPUT_32);
      return EXIT_FAILURE;
    }

    assert(mt19937ar() == j);
  }

  fclose(fd);

#ifdef UINT64_C

  /* Test the 64-bit Mersenne Twister generator. */
  init_mt19937_64_by_array(init64, length);

  fd = fopen(EXPECTED_OUTPUT_64, "r");
  if (fd == NULL)
  {
    log_error("Unable to open '%s'.", EXPECTED_OUTPUT_64);
    return EXIT_FAILURE;
  }

  /* Check for the correct first 1000 output values. */
  for (int i = 0; i < 1000; i++)
  {
    if (fscanf(fd, "%"PRIu64"", &k) != 1)
    {
      log_error("Error on line %d while reading '%s'.\n",
        i+1, EXPECTED_OUTPUT_64);
      return EXIT_FAILURE;
    }

    assert(mt19937_64() == k);
  }

  fclose(fd);

#endif /* ifdef UINT64_C */

  return EXIT_SUCCESS;
}