⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 clamygdala.cpp

📁 此代码经过大量使用
💻 CPP
字号:
/***************************************************************************                          clamygdala.cpp  -  description                             -------------------    copyright            : (C) 2001 by Matt Grover    email                : mpgrover@sourceforge.net ***************************************************************************//*************************************************************************** *                                                                         * *   This program is free software; you can redistribute it and/or modify  * *   it under the terms of the GNU General Public License as published by  * *   the Free Software Foundation; either version 2 of the License, or     * *   (at your option) any later version.                                   * ***************************************************************************/#ifdef HAVE_CONFIG_H#include <config.h>#endif#include <iostream.h>#include <stdlib.h>#include <string.h>#include <string>#include <amygdala/types.h>#include <amygdala/network.h>#include <amygdala/layer.h>#include <amygdala/basicneuron.h>#include <amygdala/alphaneuron.h>#include <amygdala/netloader.h>#include <amygdala/simplespikeinput.h>void Usage();int ParseCommandLine(int argc, char *argv[]);string dataDir;string inputFile;string layoutFile;bool spikeFreqFile = true;unsigned int runTime = 1;int main(int argc, char *argv[]){    if (argc < 2) {        Usage();        return 1;    }    // Watch for help request    if ((argc == 2) && !strcmp(argv[1], "--help")) {        Usage();        return 2;    }    int rc = ParseCommandLine(argc, argv);    if (rc) {        return rc;    }    dataDir = "/../../data";    // Load layoutFile    string output;    bool errors = false;    // turn on the output    Neuron::CaptureOutput(OUTPUT_LAYERS);    NetLoader* netLoad;    Network* testNetwork;    testNetwork = new Network;    SimpleSpikeInput spikeIn(testNetwork);    netLoad = new NetLoader(testNetwork);    cout << "Parsing " << layoutFile << endl;    try {        netLoad->LoadXML(layoutFile.c_str());    } catch (string e) {        cout << e << endl;        errors = true;    }    if (!errors) {        cout << "Parsing " << inputFile << endl;        if (spikeFreqFile) {            if (!spikeIn.ReadSpikeDef(inputFile.c_str())) {                errors = true;            }        }        else if (!spikeIn.ReadSpikeList(inputFile.c_str())) {            errors = true;        }    }    if (!errors) {        cout << "Running the network...\n";        runTime = runTime * 1000000;        testNetwork->Run(runTime);    }    delete netLoad;    delete testNetwork;    if (errors) {        cout << "Exiting with errors.\n";        return 1;    }    else {        cout << "Exiting." << endl;        return EXIT_SUCCESS;    }}int ParseCommandLine(int argc, char *argv[]){    int index;    for (index = 1; index < argc; index++)    {        // Break out on first parm not starting with a dash        if (argv[index][0] != '-')            break;        if (!strncmp(argv[index], "-t=", 3)) {            const char* const parm = &argv[index][3];            // test to make sure parm is numeric            if (!(runTime = atoi(parm))) {                cerr << parm << " is not a number.\n";                return 2;            }        }         else if (!strncmp(argv[index], "-x=", 3)) {            const char* const flag = &argv[index][3];            if (!strcmp(flag, "yes")) {                spikeFreqFile = true;            }            else if (!strcmp(flag, "no")) {                spikeFreqFile = false;            }            else {                cout << "Invalid option -x=" << flag << endl;            }        }        else {            cerr << "Unknown option '" << argv[index]                 << "', ignoring it\n" << endl;        }    }    if (index + 2 != argc)    {        Usage();        return 1;    }    layoutFile = argv[index];    inputFile = argv[index + 1];    return 0;}void Usage(){    cout <<  "\nUsage: cla [options] data_file input_file\n\n"             "Options:\n"             "    -t=xxx      Time in seconds to run the simulation [1]\n"             "    -x=[yes]    Use an XML input description file [yes | no]\n"             "    --help      Show this help\n\n"         <<  endl;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -