diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..9833637 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,19 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "(Windows) Launch", + "type": "cppvsdbg", + "request": "launch", + "program": "enter program name, for example ${workspaceFolder}/a.exe", + "args": [], + "stopAtEntry": false, + "cwd": "${workspaceFolder}", + "environment": [], + "externalConsole": true + } + ] +} \ No newline at end of file diff --git a/ConsoleAI/AINetClass.cpp b/ConsoleAI/AINetClass.cpp index dfb1afe..7125a65 100644 --- a/ConsoleAI/AINetClass.cpp +++ b/ConsoleAI/AINetClass.cpp @@ -143,12 +143,11 @@ size_t AINetClass::Counter(bool bIncrease ) size_t AINetClass::CurrentTrainingDataRow() { // returns current Training Data Row - size_t tmpReturn; + size_t tmpReturn = 0; size_t tmpMaxRows = this->getTrainingDataRowsMax(); if (tmpMaxRows == 0) { this->throwFailure("division by 0 iTrainingDataRowsUseMax", true); - tmpReturn= 0; } else { @@ -659,10 +658,10 @@ void AINetClass::calculateLine(size_t iTmpRow) void AINetClass::sortNetwork() { - // this function sorts the network - + /** This function is meant to sort the network, so multiple networks can be combined */ + // begin sorting at the end of the network (of course we won't sort output) - for (size_t iSort = this->getNumberOfLayers(); iSort > 1; iSort--) + for (size_t iSort = this->getNumberOfLayers(); iSort > 1; --iSort) { // reload network variables to tmp variables each layer. std::vector vdTmpValues = this->vecValues; @@ -726,7 +725,7 @@ void AINetClass::sortNetwork() { jNode = jBegin + j; this->vecWeights.at(jNode).at(iNode) = vdTmpWeights[jNode][iBegin + viSortList.at(i)]; - //todo continue + //todo continue, but what? } // sort weights from previous layer jBegin = this->getLayerStart(iSort); @@ -734,7 +733,7 @@ void AINetClass::sortNetwork() { jNode = jBegin + j; this->vecWeights.at(iNode).at(jNode) = vdTmpWeights[iBegin + viSortList.at(i)][jNode]; - //todo continue + //todo continue, but what? } } } @@ -974,7 +973,8 @@ void AINetClass::saveResultingNetwork(size_t iNumber) } catch (...) { fileResultingNetwork.close(); - this->throwFailure("Error while saving data." + strerror_s(clocalerror, errno), false); + //TODO This is in conflict with Windows UWP App. + //this->throwFailure("Error while saving data." + strerror_s(clocalerror, errno), false); } } @@ -1022,7 +1022,7 @@ void AINetClass::connectNodes(bool bFullyConnected, size_t iRandSeed, bool bDele /** This function is used to create the initial connection of nodes. \param bFullyConnected is used to link al nodes from one layer with all nodes from the previous layer. \param iRandSeed is the seed for the random number generator. - \param deleteExisting (optional) delete existing connections and reset all values. + \param bDeleteExisting (optional) delete existing connections and reset all values. */ if (!this->initializationDone) @@ -1035,13 +1035,13 @@ void AINetClass::connectNodes(bool bFullyConnected, size_t iRandSeed, bool bDele this->bHasBeenConnected = true; // first do the auto-generation if parameter is set this->autoGenerateInternalNetwork(); + // TODO allow smart connected network by removing next line of code bFullyConnected = true; //variables size_t tmpTotalNumberNodes = 0; - // seeding random number generator - srand(iRandSeed); + srand((unsigned int)iRandSeed); // problems with conversion don't matter because it's random //function tmpTotalNumberNodes = this->NUMNODES(); @@ -1439,6 +1439,14 @@ double AINetClass::updateWeights() return sumOfSquaredErrors; } +double AINetClass::getVersion() +{ + /** this function returns the Version of the AINetClass + \return double Version + */ + return this->dVersion; +} + double AINetClass::getNodeValue(size_t tmpNode) { // returns value of node @@ -1519,7 +1527,10 @@ bool AINetClass::autoGenerateInternalNetwork() double AINetClass::getTrainingDataValue(size_t row, size_t column) { - // safeAccesstoTrainingData + /** This function is used to access the training data in a safe way + \param row select this row + \param column select this column + */ double tmpReturn=0; if (row < this->ptrAINDataContainer->getTrainingDataRowsMax()) { diff --git a/ConsoleAI/AINetClass.h b/ConsoleAI/AINetClass.h index e1e1389..1e7d75f 100644 --- a/ConsoleAI/AINetClass.h +++ b/ConsoleAI/AINetClass.h @@ -29,7 +29,7 @@ class AINetClass size_t getNumberOfNodesInLayer(signed int iTmpLayer); size_t getNumberOfNodesInLayer(size_t tmpLayer); size_t getNumberOfLayers(bool bOnlyHidden = false); - size_t getLayerStart(int iTmpLayer, bool falseForLayerEnd = true); + size_t getLayerStart(int tmpLayer, bool falseForLayerEnd = true); double LearningRate(); size_t TrainingDataColumns(); @@ -53,6 +53,7 @@ class AINetClass bool IsNetworkReady(); bool autoGenerateInternalNetwork(); double updateWeights(); + double getVersion(); double getNodeValue(size_t tmpNode); void TrainingDataColumnPush_Back(std::string tmpString); void activateNetwork(); @@ -107,6 +108,7 @@ class AINetClass // Constants double E = 2.71828; + double dVersion = 0.20190422; // variables std::vector vecValues = { 0.0 }; // vector containing values including input @@ -164,6 +166,7 @@ class AINetClass // functions std::string generateFileOutput(std::string& strFileContents); std::string generateFileInput(std::string& strFileContents); + bool IsDoubleCritical(double dToBeClassified); std::string IsDoubleCritical(double dToBeClassified, std::string sText); bool recalculateInputDataPullList(); diff --git a/ConsoleAI/AINetTrainingData.cpp b/ConsoleAI/AINetTrainingData.cpp index d06a1b0..2006914 100644 --- a/ConsoleAI/AINetTrainingData.cpp +++ b/ConsoleAI/AINetTrainingData.cpp @@ -1,5 +1,6 @@ #include "pch.h" #include "stdafx.h" +#include #include // std::random_shuffle #include #include @@ -18,7 +19,9 @@ AINetTrainingData::AINetTrainingData() AINetTrainingData::~AINetTrainingData() { - this->vvTrainingDataMatrix.clear(); + this->vvLoadedData.clear(); + this->vvTimingData.clear(); + this->vvCalculationData.clear(); this->vdNetworkTopology.clear(); } @@ -33,7 +36,7 @@ size_t AINetTrainingData::getTrainingDataRowsMax(bool bReload) if (this->intTrainingDataRowsMax == 0 || bReload) { - this->intTrainingDataRowsMax = llround((this->vvTrainingDataMatrix.size() - this->intTimeNextRows - this->intTimePreviousRows)*(1 - this->dPercentVerificationData)); + this->intTrainingDataRowsMax = llround((this->vvCalculationData.size() - this->intTimeNextRows - this->intTimePreviousRows)*(1 - this->dPercentVerificationData)); } return this->intTrainingDataRowsMax; @@ -51,9 +54,9 @@ size_t AINetTrainingData::getTrainingDataColumnsMax(bool bRecount) if ((this->intTrainingDataColumsMax == 0) || bRecount) { // crawl all date for longest column - for (size_t i = 0; i < this->vvTrainingDataMatrix.size(); ++i) + for (size_t i = 0; i < this->vvCalculationData.size(); ++i) { - size_t intTempSize = this->vvTrainingDataMatrix.at(i).size(); + size_t intTempSize = this->vvCalculationData.at(i).size(); if (intTempSize > intMaxColumns) { intMaxColumns = intTempSize; @@ -71,6 +74,7 @@ size_t AINetTrainingData::getTrainingDataBegin() { /** This function is used to calculate the start of the training data. It will skip the number of defined previous rows, which will be used in calculation. Data has to be in ascending order. */ + return (size_t)this->intTimePreviousRows; } @@ -78,6 +82,7 @@ size_t AINetTrainingData::getTrainingDataEnd() { /** This function is used to calculate the end of the training data. It will skip the number of defined next rows, which will be used in calculation. Data has to be in ascending order. */ + return (size_t)this->vdNetworkTopology.size() - (size_t)this->intTimeNextRows; } @@ -91,7 +96,13 @@ size_t AINetTrainingData::getNumberOfInputNodes() /** This returns the number of input nodes from the network topology \return Number of input nodes. */ - return this->vdNetworkTopology.front(); + + size_t iReturn = this->iNumberOfInputNodes; + if (this->bHasTiming) + { + iReturn = this->iNumberOfInputNodes + this->vvTimingData.size(); + } + return iReturn; } size_t AINetTrainingData::getNumberOfOutputNodes() @@ -99,33 +110,64 @@ size_t AINetTrainingData::getNumberOfOutputNodes() /** This function returns the number of output nodes from network topology of training data file \return The number of output nodes. */ - return this->vdNetworkTopology.back(); + + size_t iReturn = this->iNumberOfOutputNodes; + if (this->bHasTiming) + { + // no changes + } + return iReturn; } size_t AINetTrainingData::getTimeMode() { /** Function returns AINetTrainingData->intTimeDataMode \return 1 for none\n 2 for date \n 3 for time \n 4 for date and time */ + return this->intTimeDataMode; } -double AINetTrainingData::getTrainingDataValue(size_t column, size_t row) +double AINetTrainingData::getTrainingDataValue(size_t column, size_t row, bool bRaw) { /** This function returns the value of the training data in \p colum of \p row. \param column The colum to be returned. \param row The row to be retrned. + \param bRaw (optional) use raw data \return Value of \p column and \p row. */ + double dReturn = 0.0; - if (row < this->vvTrainingDataMatrix.size()) + if (row < this->vvCalculationData.size()) { - if (column < this->vvTrainingDataMatrix.at(row).size()) + if(bHasTiming) { - dReturn= this->vvTrainingDataMatrix.at(row).at(column); + size_t iTmpTDSize= this->vvTimingData.at(row).size(); + if (column < this->vvCalculationData.at(row).size() + iTmpTDSize) // add the timing data rows + { + if (row < iTmpTDSize) // check for timing data first + { + dReturn = this->vvTimingData.at(row).at(column); // use timing data + } + else + { + dReturn = this->vvTimingData.at(row).at(column - iTmpTDSize); // find column is iTmpTDSize too big. + } + } + else + { + std::cerr << "column out of range: " << column; + } } else { - std::cerr << "column out of range: " << column; + if (column < this->vvCalculationData.at(row).size()) + { + dReturn = this->vvCalculationData.at(row).at(column); + } + else + { + std::cerr << "column out of range: " << column; + } } } else @@ -135,6 +177,68 @@ double AINetTrainingData::getTrainingDataValue(size_t column, size_t row) return dReturn; } +std::vector AINetTrainingData::getInputDateTime(size_t row) +{ + /** This function is used to convert the date and/or time to input nodes for the network. + Date and time is splitted into nodes + \param row fetch data from this line. + */ + + struct tm tmTimeTemp; + tmTimeTemp.tm_year = 2019; + std::vector vdTime; + vdTime.clear(); + + if (row < this->vvLoadedData.size()) // check if column is in valid range + { + if (this->intTimeDataMode == 2 || this->intTimeDataMode == 4) + { + tmTimeTemp.tm_year = (int)this->vvLoadedData.at(row).at(1); + tmTimeTemp.tm_mon = (int)this->vvLoadedData.at(row).at(2); + tmTimeTemp.tm_mday = (int)this->vvLoadedData.at(row).at(3); + } + if (this->intTimeDataMode == 3 || this->intTimeDataMode == 4) + { + size_t iTimeOff = 0; + if (this->intTimeDataMode == 4) + { + // date is stored before time therefore time is with offset 3 + iTimeOff = 3; + } + tmTimeTemp.tm_hour = (int)this->vvLoadedData.at(row).at(iTimeOff + 1); + tmTimeTemp.tm_min = (int)this->vvLoadedData.at(row).at(iTimeOff + 2); + tmTimeTemp.tm_sec = (int)this->vvLoadedData.at(row).at(iTimeOff + 3); + } + mktime(&tmTimeTemp); + if (this->intTimeDataMode == 2 || this->intTimeDataMode == 4) + { + // this is to expand the date + vdTime.push_back(1.0); // year as dummy + vdTime.push_back(tmTimeTemp.tm_mon / 12.0); // month as value from 0-1 + vdTime.push_back(tmTimeTemp.tm_mday / 31.0); // day as value from 0-1 + vdTime.push_back(tmTimeTemp.tm_wday / 6.0); // wday as value from 0-1 + vdTime.push_back(tmTimeTemp.tm_yday / 366.0); // day of year (+1 for longer switching years) + vdTime.push_back(tmTimeTemp.tm_wday != 1 ? 0 : 1); // monday + vdTime.push_back(tmTimeTemp.tm_wday != 2 ? 0 : 1); // tuesday + vdTime.push_back(tmTimeTemp.tm_wday != 3 ? 0 : 1); // wednesday + vdTime.push_back(tmTimeTemp.tm_wday != 4 ? 0 : 1); //thursday + vdTime.push_back(tmTimeTemp.tm_wday != 5 ? 0 : 1); // friday + vdTime.push_back(tmTimeTemp.tm_wday != 6 ? 0 : 1); // saturday + vdTime.push_back(tmTimeTemp.tm_wday != 0 ? 0 : 1); // sunday 0=false 1=true + } + if (this->intTimeDataMode == 3 || this->intTimeDataMode == 4) + { + // now expand the time over the day + vdTime.push_back(tmTimeTemp.tm_hour / 24.0); + vdTime.push_back(tmTimeTemp.tm_min / 60.0); + vdTime.push_back(tmTimeTemp.tm_sec / 60.0); + vdTime.push_back((tmTimeTemp.tm_hour / 24) * (tmTimeTemp.tm_min / 60.0) * (tmTimeTemp.tm_sec / 60.0)); // time as seconds of day + vdTime.push_back(tmTimeTemp.tm_hour <= 11 ? 0 : 1); // morning or evening + } + } + return vdTime; +} + size_t AINetTrainingData::getTrainingRowSizeT(size_t row) { /** This will return the size of the specified \p row. @@ -143,35 +247,41 @@ size_t AINetTrainingData::getTrainingRowSizeT(size_t row) */ size_t intReturn = 0; - if (row < this->vvTrainingDataMatrix.size()) + if (row < this->vvCalculationData.size()) { - intReturn = this->vvTrainingDataMatrix.at(row).size(); + intReturn = this->vvCalculationData.at(row).size(); } return intReturn; } -std::vector AINetTrainingData::getNetworkTopology() +std::vector AINetTrainingData::getNetworkTopology(bool bFromData) { /** This function will return the topology from training data file. + \param bFromData to be set if the network topology should be loaded from the training data and not be altered by other means. \return The topology of the network from training data file. */ - return this->vdNetworkTopology; + std::vector vecTmpTopology = this->vdNetworkTopology; + if(!bFromData && this->bHasTiming) + { + vecTmpTopology.at(0) = this->vdNetworkTopology.at(0) + this->vvTimingData.size(); + } + return vecTmpTopology; } std::vector> AINetTrainingData::getTrainingDataMatrix() { - /** This function returns the training data as new object. This should not be used. TODO: Check and delete. - \return a new training data object. + /** This function returns the training data as new object. + \return std::vector> a new training data object. */ - return this->vvTrainingDataMatrix; + return this->vvCalculationData; } std::vector>* AINetTrainingData::ptrTrainingDataMatix() { - /** This function returns the training data as new object. This should not be used. TODO: Check and delete. - \return a new training data object. + /** This function returns a pointer to training data. + \return std::vector>* pointer to training data. */ - return &this->vvTrainingDataMatrix; + return &this->vvCalculationData; } std::string AINetTrainingData::getTrainingDataFileName() @@ -187,6 +297,7 @@ std::string AINetTrainingData::setTrainingDataFileName(std::string strFileName) /** This will set the file name of the training data file. \return String of file name. */ + // TODO: add some verification here. this->strAIDataFileName; return this->strAIDataFileName; @@ -198,6 +309,7 @@ bool AINetTrainingData::setOptionCSVGermanStyle(bool bGerStyle) \param bGerStyle if a german csv file is to be loaded this has to be set to true \return returns input parameter if set correctly. */ + this->bOptionCSVGER = bGerStyle; return this->bOptionCSVGER; } @@ -237,6 +349,7 @@ bool AINetTrainingData::setPreferredNetworkTopology(std::vector vsPref) \param vsPref is a vector with the topology as integer values from input (lowest) to output (highest) \return returns true if successfull */ + this->vdNetworkTopology = vsPref; return (this->vdNetworkTopology == vsPref); } @@ -248,6 +361,7 @@ std::vector AINetTrainingData::splitStringToSizeT(const std::string & st \param strDelimiter is string, which is used to split \p strInput into pieces. \return is returning the content of \p strInput converted into a vector of integers. */ + std::vector strElements; for (size_t stStart = 0, stEnd; stStart < strInput.length(); stStart = stEnd + strDelimiter.length()) @@ -279,6 +393,7 @@ std::vector AINetTrainingData::splitStringToDouble(const std::string & s \param strDelimiter is string, which is used to split \p strInput into pieces. \return is returning the content of \p strInput converted into a vector of doubles. */ + std::vector strElements; for (size_t stStart = 0, stEnd; stStart < strInput.length(); stStart = stEnd + strDelimiter.length()) @@ -300,6 +415,59 @@ std::vector AINetTrainingData::splitStringToDouble(const std::string & s return strElements; } +bool AINetTrainingData::createTimingData() +{ + /** This function is used to perform the creation of timing data. + It will load the date value from the training data. + Then it will convert these data do input data for the network. + The resulting data may have a variable size. + The network topology is to be reset afterwards. + */ + + this->vvTimingData.clear(); + this->vvCalculationData.clear(); + this->bHasTiming = false; + + this->vvTimingData.reserve(this->vvLoadedData.size()); + + if (this->intTimeDataMode > 1) + { + // there is timing data present + for (size_t i = 0; i < this->vvLoadedData.size(); ++i) + { + this->vvTimingData.push_back(this->getInputDateTime(i)); + } + } + + if (this->vvTimingData.size() == this->vvLoadedData.size()) // check if all elements have been converted. + { + std::vector vdTmp; + for (size_t i = 0; i < this->vvTimingData.size(); ++i) + { + vdTmp = this->vvTimingData.at(i); // put timing-data up front + for (size_t j = 0; j < this->vvLoadedData.at(i).size(); ++j) + { + vdTmp.push_back(this->vvLoadedData.at(i).at(j)); // add loaded data + } + this->vvCalculationData.push_back(vdTmp); // now put the glued timing and loaded data into storage + } + + if (this->vvLoadedData.size() == this->vvCalculationData.size()) + { + this->bHasTiming = true; + } + else + { + //something went wrong during copy operation. + } + } + else + { + //something went wrong during copy operation. + } + return this->bHasTiming; +} + void AINetTrainingData::closeTrainingDataFile(std::ifstream &ptrDataFile) { /** This function is used to close the training data file after reading. @@ -348,8 +516,8 @@ size_t AINetTrainingData::loadTrainingDataFile() /** This function is used to load all the training data. * \return the number of unreadable lines. */ - std::string theLine = "no open file."; - int theFirstElement = 0; + std::string theLine = "no open file."; // line of text loaded from file. + size_t theFirstElement = 0; unsigned int iNumberOfLines = 0; unsigned int iNumberOfFalseLines = 0; int iTimePreviousElements = 0; // How many previous rows for calculation? @@ -359,7 +527,7 @@ size_t AINetTrainingData::loadTrainingDataFile() this->openTrainingDataFile(theAIDataFile); // clear old training data - this->vvTrainingDataMatrix.clear(); + this->vvLoadedData.clear(); if (theAIDataFile.is_open()) { @@ -381,8 +549,10 @@ size_t AINetTrainingData::loadTrainingDataFile() } this->vdNetworkTopology = this->splitStringToSizeT(theLine, ","); + this->iNumberOfInputNodes = this->vdNetworkTopology.front(); + this->iNumberOfOutputNodes = this->vdNetworkTopology.back(); - std::vector vdLocalVector(1 + this->vdNetworkTopology.front() + this->vdNetworkTopology.back()); + std::vector vdLocalVector(1 + this->iNumberOfInputNodes + this->iNumberOfOutputNodes); std::string loadedNumber = ""; std::string tmpIsTimeData = ""; // now start looking for maxiterations in aidatafile @@ -415,7 +585,7 @@ size_t AINetTrainingData::loadTrainingDataFile() break; case 5: // Todo change this - this->dPercentVerificationData = std::min(0.0,std::max(1.0,atof(theLine.substr(0, theFirstElement).c_str()))); + this->dPercentVerificationData = min(0.0, max(1.0, atof(theLine.substr(0, theFirstElement).c_str()))); break; case 6: tmpIsTimeData = theLine.substr(0, theFirstElement); @@ -463,7 +633,7 @@ size_t AINetTrainingData::loadTrainingDataFile() // clear vector vdLocalVector.clear(); theFirstElement = 0; - vdLocalVector.push_back(1.0); // first element is base/threshold value and always set to 1.0 + vdLocalVector.push_back((double)this->intTimeDataMode); // first element is base/threshold value and always set to 1.0 // looking for first element if (theLine.find_first_of(",") != theLine.npos) theFirstElement = (int)theLine.find_first_of(","); @@ -487,7 +657,7 @@ size_t AINetTrainingData::loadTrainingDataFile() if (vdLocalVector.size() >= 1 + this->vdNetworkTopology.front() + this->vdNetworkTopology.back()) { // counting number of lines and copying whole row to vector - this->vvTrainingDataMatrix.push_back(vdLocalVector); + this->vvLoadedData.push_back(vdLocalVector); iNumberOfLines += 1; } else @@ -496,9 +666,11 @@ size_t AINetTrainingData::loadTrainingDataFile() iNumberOfFalseLines += 1; } } + theLine = ""; } this->closeTrainingDataFile(theAIDataFile); + this->vvCalculationData = this->vvLoadedData; return iNumberOfFalseLines; } @@ -599,7 +771,7 @@ std::string AINetTrainingData::TrainingDataColumnName(size_t tmpColumn, bool sho } else { - if ((tmpColumn >= 0) && (tmpColumn < vStrTrainingDataColumns.size())) + if ((tmpColumn >= 0) && (tmpColumn < this->vStrTrainingDataColumns.size())) { // read a value if it is within valid range. tmpString = this->vStrTrainingDataColumns.at(tmpColumn); diff --git a/ConsoleAI/AINetTrainingData.h b/ConsoleAI/AINetTrainingData.h index 6fb2efa..ab9fc75 100644 --- a/ConsoleAI/AINetTrainingData.h +++ b/ConsoleAI/AINetTrainingData.h @@ -1,13 +1,23 @@ #pragma once #include "CodeFromWeb.h" +/** WORKAROUND FOR WinGUI */ +#ifndef max +#define max(a,b) (((a) > (b)) ? (a) : (b)) +#endif + +#ifndef min +#define min(a,b) (((a) < (b)) ? (a) : (b)) +#endif + +/** END WORKAROUND FOR WinGUI */ + class AINetTrainingData { public: AINetTrainingData(); ~AINetTrainingData(); - size_t getTrainingDataRowsMax(bool bReload=false); size_t getTrainingDataColumnsMax(bool bRecount=false); size_t getTrainingDataBegin(); @@ -16,15 +26,15 @@ class AINetTrainingData size_t getNumberOfInputNodes(); size_t getNumberOfOutputNodes(); size_t getTimeMode(); - double getTrainingDataValue(size_t column, size_t row); + double getTrainingDataValue(size_t column, size_t row, bool bRaw = false); + std::vector getInputDateTime(size_t row); size_t getTrainingRowSizeT(size_t row); - std::vector getNetworkTopology(); + std::vector getNetworkTopology(bool bFromData = false); std::vector> getTrainingDataMatrix(); std::vector>* ptrTrainingDataMatix(); std::string getTrainingDataFileName(); std::string setTrainingDataFileName(std::string strFileName); - bool setOptionCSVGermanStyle(bool bGerStyle); bool setPreferredNetworkTopology(std::string strPref); bool setPreferredNetworkTopology(std::vector vsPref); @@ -39,13 +49,12 @@ class AINetTrainingData private: - /* data file variables */ bool bOptionCSVGER = false; - std::string strAIDataFileHeader = ""; std::string strAIDataFileName = ""; - size_t intTimeDataMode = 1; // 1= no specific time data mode; 2=Date; 3=Time; 4=Date and Time + + /* calculation variables */ size_t intMaxIterations = 1000; size_t intTimePreviousRows = 0; size_t intTimeNextRows = 0; @@ -55,15 +64,24 @@ class AINetTrainingData size_t intLinesRead = 4; size_t intTrainingDataColumsMax = 0; size_t intTrainingDataRowsMax = 0; - std::vector vStrTrainingDataColumns = { "unused", "Value A", "Value B", "A OR B"}; + + /* data storage */ + std::vector> vvLoadedData = { {1.0,0.0,0.0,0.0},{1.0,0.0,1.0,1.0},{1.0,1.0,0.0,1.0},{1.0,1.0,1.0,1.0} }; // standard xor training data + std::vector> vvCalculationData = { {1.0,0.0,0.0,0.0},{1.0,0.0,1.0,1.0},{1.0,1.0,0.0,1.0},{1.0,1.0,1.0,1.0} }; + std::vector> vvTimingData = { {0.0} }; // this is used for expanding training data to timing data. + + /* data information */ + bool bHasTiming = false; // if true timing data has to be considered + size_t intTimeDataMode = 1; // 1= no specific time data mode; 2=Date; 3=Time; 4=Date and Time + std::vector vStrTrainingDataColumns = { "unused", "Value A", "Value B", "A OR B" }; std::vector vdNetworkTopology = { 2,2,1 }; // standard xor training data network topology - std::vector> vvTrainingDataMatrix = { {1.0,0.0,0.0,0.0},{1.0,0.0,1.0,1.0},{1.0,1.0,0.0,1.0},{1.0,1.0,1.0,1.0} }; // standard xor training data + size_t iNumberOfInputNodes = 2; // this should only be change while loading of training data + size_t iNumberOfOutputNodes = 1; // this should only be change while loading of training data /* functions */ - std::vector splitStringToSizeT(const std::string & strInput, const std::string & strDelimiter); std::vector splitStringToDouble(const std::string & strInput, const std::string & strDelimiter); - + bool createTimingData(); std::string convertFromCSVGermanStyle(std::string & strFileContents); std::string convertToCSVStandardStyle(std::string & strFileContents); diff --git a/ConsoleAI/ConsoleAI.cpp b/ConsoleAI/ConsoleAI.cpp index 737c57d..3ca604c 100644 Binary files a/ConsoleAI/ConsoleAI.cpp and b/ConsoleAI/ConsoleAI.cpp differ diff --git a/ConsoleAI/ConsoleAI.vcxproj b/ConsoleAI/ConsoleAI.vcxproj index 7c7b8ca..c8087a5 100644 --- a/ConsoleAI/ConsoleAI.vcxproj +++ b/ConsoleAI/ConsoleAI.vcxproj @@ -23,32 +23,32 @@ {4232F9C0-3D4E-4818-BF3C-DBCDFF0FA4FC} Win32Proj ConsoleAI - 10.0.17134.0 + 10.0 Application true - v141 + v142 Unicode Application false - v141 + v142 true Unicode Application true - v141 + v142 Unicode Application false - v141 + v142 true Unicode diff --git a/WinGUI/WinGUI.cpp b/WinGUI/WinGUI.cpp index 5a2f213..b9fbcf4 100644 Binary files a/WinGUI/WinGUI.cpp and b/WinGUI/WinGUI.cpp differ diff --git a/WinGUI/WinGUI.rc b/WinGUI/WinGUI.rc index 40d29ac..58d694e 100644 Binary files a/WinGUI/WinGUI.rc and b/WinGUI/WinGUI.rc differ diff --git a/WinGUI/WinGUI.vcxproj b/WinGUI/WinGUI.vcxproj index ba22f6e..b120c5f 100644 --- a/WinGUI/WinGUI.vcxproj +++ b/WinGUI/WinGUI.vcxproj @@ -23,32 +23,32 @@ {5F59811A-E077-4C97-A055-882CB10B6115} Win32Proj WinGUI - 10.0.17134.0 + 10.0 Application true - v141 + v142 Unicode Application false - v141 + v142 true Unicode Application true - v141 + v142 Unicode Application false - v141 + v142 true Unicode diff --git a/WinGUI/resource.h b/WinGUI/resource.h index 0c97b3e..90947e5 100644 Binary files a/WinGUI/resource.h and b/WinGUI/resource.h differ