当前位置: 首页>>代码示例>>C++>>正文


C++ PRNG::setSeed方法代码示例

本文整理汇总了C++中PRNG::setSeed方法的典型用法代码示例。如果您正苦于以下问题:C++ PRNG::setSeed方法的具体用法?C++ PRNG::setSeed怎么用?C++ PRNG::setSeed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PRNG的用法示例。


在下文中一共展示了PRNG::setSeed方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main


//.........这里部分代码省略.........
      }
      else if (strcmp(av[i], "--rp2") == 0) {
        rp2P = true;
      }
      else if (strcmp(av[i], "--si") == 0) {
        cpP = false;
        siP = true;
      }
      else if (strcmp(av[i], "--cp") == 0) {
        siP = false;
        cpP = true;
      }
      else if (strcmp(av[i], "--help") == 0) {
        runP = false;
      }
      else {
        runP = false;
        printf("Unrecognized argument: %s\n", av[i]);
      }
    }
  }
  else {
    runP = false;
  }

  if (!runP) {
    showHelp();
    return 0;
  }


  if (0 == seed) {
    PRNG * rng = new PRNG();
    seed = rng->setSeed(0); // 0 == get a random number
    delete rng;
    rng = nullptr;
  }
  LOG(INFO) << KBase::getFormattedString("Using PRNG seed:  %020llu", seed);
  LOG(INFO) << KBase::getFormattedString("Same seed in hex:   0x%016llX", seed);
  // Unix correctly prints all digits with lu, lX, llu, and llX.
  // Windows only prints part, with lu, lX, llu, and llX.


  const bool parP = KBase::testMultiThreadSQLite(false, KBase::ReportingLevel::Medium);  
    if (parP) {
      LOG(INFO) << "Can continue with multi-threaded execution";
    }
    else {
      LOG(INFO) << "Must continue with single-threaded execution";
    }

  if (rp2P) {
    RfrmPri2::rp2Creation(seed);
    return 0;
  }

  auto rpm = new RPModel("", seed);
  if (xmlP) {
    rpm->readXML(inputXML);
    LOG(INFO) << "done reading XML";
  }
  else {
    switch (sNum) {
    case 0:
    case 1:
      rpm->initScen(sNum);
开发者ID:ambah,项目名称:KTAB,代码行数:67,代码来源:reformpriorities.cpp

示例2: main

int main(int ac, char ** av) {
    using std::cout;
    using std::endl;
    using std::string;
    using KBase::PRNG;

    auto sTime = KBase::displayProgramStart();
    uint64_t seed = KBase::dSeed;
    bool testP = false;
    bool run = true;
    auto showHelp = []() {
        printf("\n");
        printf("Usage: specify one or more of these options\n");
        printf("--help            print this message\n");
        printf("--test            test some basic utilities\n");
        printf("--seed <n>        set a 64bit seed\n");
        printf("                  0 means truly random\n");
        printf("                  default: %020llu \n", KBase::dSeed);
    };
    if (ac > 1) {
        for (int i = 1; i < ac; i++) {
            if (strcmp(av[i], "--seed") == 0) {
                i++;
                seed = std::stoull(av[i]);
            }
            else if (strcmp(av[i], "--test") == 0) {
                testP = true;
            }
            else if (strcmp(av[i], "--help") == 0) {
                run = false;
            }
            else {
                run = false;
                printf("Unrecognized argument %s\n", av[i]);
            }
        }
    }

    if (!run) {
        showHelp();
        return 0;
    }

    PRNG * rng = new PRNG();
    seed = rng->setSeed(seed); // 0 == get a random number
    printf("Using PRNG seed:  %020llu \n", seed);
    printf("Same seed in hex:   0x%016llX \n", seed);

    unsigned int n = 1000;
    printf("\nTesting %i ... ", n);
    QuadMap::testX(n);
    printf("done \n");

    printf("\nFilling occurance matrix ...");
    auto om = QuadMap::fillOccuranceMatrix(1000, 1000,  0.0, 4.0);
    printf("done \n");

    auto t = new QuadMap::QMApp(seed);
    t->run();

    delete t;
    t = nullptr;
    KBase::displayProgramEnd(sTime);
    return 0;
}
开发者ID:KAPSARC,项目名称:KTAB,代码行数:65,代码来源:qmmain.cpp

示例3: main

int main(int ac, char **av) {
  using KBase::ReportingLevel;
  using KBase::PRNG;
  using KBase::MtchPstn;
  using KBase::dSeed;
  using RfrmPri::RPModel;
  using RfrmPri::RPState;
  using RfrmPri::RPActor;
  using RfrmPri::printPerm;

  auto sTime = KBase::displayProgramStart(RfrmPri::appName, RfrmPri::appVersion);
  uint64_t seed = dSeed; // arbitrary;
  bool siP = true;
  bool cpP = false;
  bool runP = true;
  unsigned int sNum = 1;
  bool xmlP = false;
  bool rp2P = false;
  string inputXML = "";

  auto showHelp = [sNum]() {
    printf("\n");
    printf("Usage: specify one or more of these options\n");
    printf("\n");
    printf("--cp              start all actors from the central position \n");
    printf("--rp2             create RP2 objects \n");
    printf("--si              start each actor from their most self-interested position \n");
    printf("                  If neither si nor cp are specified, it will use si. \n");
    printf("                  If both si and cp are specified, it will use second specified. \n");
    printf("--help            print this message and exit \n");
    printf("--seed <n>        set a 64bit seed \n");
    printf("                  0 means truly random \n");
    printf("                  default: %020llu \n", dSeed);
    printf("--sNum <n>        choose a scenario number \n");
    printf("                  default: %u \n", sNum);
    printf("--xml <f>         read XML scenario from a given file \n");
    printf("\n");
    printf("For example, rpdemo --si  --xml rpdata.xml, would read the file rpdata.xml \n");
    printf("and start all actors from self-interested positions.\n");
    printf("\n");
    printf("If both scenario number and XML file are specified, it will use only the XML.\n");
    printf("\n");
    printf("If neither scenario number nor XML file are specified, \n");
    printf("it will run a hard-coded example, as if --sNum 1 had been specified.\n");
    printf("\n");
  };

  // a list of <keyword, description, λ-fn>
  // might be enough to do this - except for the arguments to options.
  if (ac > 1) {
    for (int i = 1; i < ac; i++) {
      if (strcmp(av[i], "--seed") == 0) {
        i++;
        seed = std::stoull(av[i]);
      }
      else if (strcmp(av[i], "--sNum") == 0) {
        i++;
        sNum = atoi(av[i]);
      }
      else if (strcmp(av[i], "--xml") == 0) {
        xmlP = true;
        i++;
        inputXML = av[i];
      }
      else if (strcmp(av[i], "--rp2") == 0) {
        rp2P = true;
      }
      else if (strcmp(av[i], "--si") == 0) {
        cpP = false;
        siP = true;
      }
      else if (strcmp(av[i], "--cp") == 0) {
        siP = false;
        cpP = true;
      }
      else if (strcmp(av[i], "--help") == 0) {
        runP = false;
      }
      else {
        runP = false;
        printf("Unrecognized argument: %s\n", av[i]);
      }
    }
  }
  else {
    runP = false;
  }

  if (!runP) {
    showHelp();
    return 0;
  }


  if (0 == seed) {
    PRNG * rng = new PRNG();
    seed = rng->setSeed(0); // 0 == get a random number
    delete rng;
    rng = nullptr;
  }
//.........这里部分代码省略.........
开发者ID:KAPSARC,项目名称:KTAB,代码行数:101,代码来源:reformpriorities.cpp


注:本文中的PRNG::setSeed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。