Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -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
}
]
}
35 changes: 23 additions & 12 deletions ConsoleAI/AINetClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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<double> vdTmpValues = this->vecValues;
Expand Down Expand Up @@ -726,15 +725,15 @@ 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);
for (size_t j = 0; j < this->getNumberOfNodesInLayer(iSort); j++)
{
jNode = jBegin + j;
this->vecWeights.at(iNode).at(jNode) = vdTmpWeights[iBegin + viSortList.at(i)][jNode];
//todo continue
//todo continue, but what?
}
}
}
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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)
Expand All @@ -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();
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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())
{
Expand Down
5 changes: 4 additions & 1 deletion ConsoleAI/AINetClass.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -107,6 +108,7 @@ class AINetClass
// Constants

double E = 2.71828;
double dVersion = 0.20190422;

// variables
std::vector<double> vecValues = { 0.0 }; // vector containing values including input
Expand Down Expand Up @@ -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();
Expand Down
Loading