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


C++ Globals::initRandom方法代码示例

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


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

示例1: HyperNEAT_main

int HyperNEAT_main(int argc,char **argv) {
    CommandLineParser commandLineParser(argc,argv);

    // Quit if we don't have I/O/G
    if (!commandLineParser.HasSwitch("-I") ||
        !commandLineParser.HasSwitch("-O") ||
        !commandLineParser.HasSwitch("-G")) {
        cout << "./atari_generate [-R (seed)] -I (datafile) -O (outputfile) -G (ROMFile) [-P (populationfile) -F (fitnessprefix) [-E (evaluationFile)] ]\n";
        cout << "\t(datafile) experiment data file - typically data/AtariExperiment.dat\n";
        cout << "\t(outputfile) the next generation file to be created - typically generationXX.xml\n";
        cout << "\t(populationfile) the current generation file (required when outputfile is > generation0) - typically generationXX(-1).xml.gz\n";
        cout << "\t(fitnessprefix) used to locate the fitness files for individuals in the current generation (required for generation > 0) - typically fitness.XX.\n";
        cout << "\t(evaluationfile) populationfile + fitness + speciation (output only - not required for next cycle) - typicall generationXX(-1).eval.xml\n";
        return 0;
    }

    Globals *globals = Globals::init(commandLineParser.GetArgument("-I",0));

    // Setup the experiment
    int experimentType = int(globals->getParameterValue("ExperimentType") + 0.001);
    HCUBE::ExperimentRun experimentRun;
    string out_file = commandLineParser.GetArgument("-O",0);
    experimentRun.setupExperiment(experimentType, out_file);

    string rom_file = commandLineParser.GetArgument("-G",0);

    // Is this an experiment in progress? If so we should load the current experiment
    if (commandLineParser.HasSwitch("-P") &&
        commandLineParser.HasSwitch("-F")) {
        string populationFile = commandLineParser.GetArgument("-P",0);
        string fitnessFunctionPrefix = commandLineParser.GetArgument("-F",0);
        string evaluationFile = commandLineParser.GetSafeArgument("-E",0,"");
        cout << "[HyperNEAT core] Population for existing generation created from: " << populationFile << endl;
        experimentRun.createPopulationFromCondorRun(populationFile, fitnessFunctionPrefix, evaluationFile, rom_file);
    } else {
        cout << "[HyperNEAT core] Population for first generation created" << endl;
        shared_ptr<Experiment> e = experimentRun.getExperiment();        
        if (experimentType == 30 || experimentType == 35 || experimentType == 36) {
            shared_ptr<AtariExperiment> exp = static_pointer_cast<AtariExperiment>(e);
            exp->initializeExperiment(rom_file.c_str());
        } else if (experimentType == 31 || experimentType == 39 || experimentType == 40) {
            shared_ptr<AtariNoGeomExperiment> exp = static_pointer_cast<AtariNoGeomExperiment>(e);
            exp->initializeExperiment(rom_file.c_str());
        } else if (experimentType == 32 || experimentType == 37 || experimentType == 38) {
            shared_ptr<AtariFTNeatExperiment> exp = static_pointer_cast<AtariFTNeatExperiment>(e);
            exp->initializeExperiment(rom_file.c_str());
        } else if (experimentType == 33) {
            // This is the Hybrid experiment but always starts as HyperNEAT
            shared_ptr<AtariExperiment> exp = static_pointer_cast<AtariExperiment>(e);
            exp->initializeExperiment(rom_file.c_str());
        } else if (experimentType == 34) {
            shared_ptr<AtariIntrinsicExperiment> exp = static_pointer_cast<AtariIntrinsicExperiment>(e);
            exp->initializeExperiment(rom_file.c_str());
        } else if (experimentType == 41) {
            shared_ptr<AtariCMAExperiment> exp = static_pointer_cast<AtariCMAExperiment>(e);
            exp->setResultsPath(out_file);
            exp->initializeExperiment(rom_file.c_str());
        }
        experimentRun.createPopulation();
    }
    if (commandLineParser.HasSwitch("-R")) {
      double seed = stringTo<double>(commandLineParser.GetArgument("-R",0));
      globals->setParameterValue("RandomSeed",seed);
      globals->initRandom();
    }
    experimentRun.startCondor();

    NEAT::Globals::deinit();
}
开发者ID:chentiejian,项目名称:HyperNEAT,代码行数:69,代码来源:setup.cpp


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