GANN/0000755000175000000040000000000010433000472010223 5ustar qtgeoadmGANN/ReadMe.txt0000644000175000000040000001000610432773332012131 0ustar qtgeoadm------------------------------------------------------------------------------ Geeks Artificial Neural Network (G.A.N.N) ------------------------------------------------------------------------------ * This Text File Contains The Latest Updates On G.A.N.N * Version History --------------- Version 1.1 - Geeks Generate Data (Reconstruction) - Geeks Sockets And Neural Map Creator (Neural Map Optimizer Fixation) - Geeks Runtime Manager Console (Upgrade) - Geeks Neural Map Simulator (Upgrade) - Geeks Neuron (Upgrade) - Geeks Socket (Upgrade) - Geeks Error Correction (Upgrade) Version 1.0 - Geeks Sockets And Neural Map Creator (Upgrade) - Geeks Neural Map Simulator (Upgrade) - Geeks Prototypes Library (Upgrade) - Geeks Distribution And Map Loader (Optimize) Pre-R3: - Geeks Neural Map Simulator (Registration Serial Number Fixation) - Geeks Exit (Exit Codes And Messages) - Replace rand()/srand With random()/srandom() (Better Randomization) Pre-R2: - Geeks Main File (Upgrade) - Geeks Runtime Manager Console (Upgrade) - Geeks Neural Map Simulator (Upgrade) - Geeks Sockets And Neural Map Creator (Upgrade) - Geeks Socket (Upgrade) - Geeks Error Statistics (Upgrade) - Geeks Generate Data (Upgrade) - Geeks Remove Data (Finalization) - Geeks Prototypes Library (Upgrade) - Serious Bug Fixations - Several Optimizations Pre-R1: - Geeks Main File (Upgrade) - Geeks Runtime Manager Console (Upgrade) - Geeks Neural Map Simulator (Upgrade - Entropy Optimization) - Geeks Remove Data (Reconstruction) - Geeks Prototypes Library (Upgrade) Beta-1.6: - Geeks Main File (Upgrade) - Geeks Read Data (Upgrade) - Geeks Save Data (Upgrade) - Geeks Remove Data (Upgrade) - Geeks I/O Distribution And Map Loader (Upgrade) - Geeks Runtime Manager Console (Upgrade) - Geeks Neural Map Simulator (Upgrade) - Geeks Hash Table (Upgrade) - Geeks Registrations Serial Numbers (Construction) - Install Script Update Beta-1.5: - Geeks Main File (Upgrade) - Geeks Remove Data (Finalization) - Geeks Unified Messaging System (Removal) - Geeks Error Statistics (Percentage Counters - Fix) - Geeks Error Correction (Upgrade) - Geeks Neural Map Simulator (Upgrade) - Geeks Sockets And Neural Map Creator (Upgrade) - Geeks Global Declarations (Upgrade) - Several Optimizations Beta-1.4: - Geeks Neural Map Simulator (Upgrade) - Geeks Read Data (Upgrade) - Geeks Save Data (Upgrade) - Geeks Neuron (Upgrade) - Geeks Runtime Manager Console (Finalization) - Geeks Hash Table (Reconstruction) - Geeks Prototypes Library (Upgrade) - Geeks Global Declarations (Upgrade) - Update &&,|| Symbols With The Equivalent Ones (AND,OR) Beta-1.3: - Increase Randomization During Learning Mode - Geeks Hash Table (Finalization) - Minor Bug Fixes Beta-1.2: - Geeks Neural Map Simulator (Upgrade) - Geeks Save Data (Finalization) - Geeks Read Data (Initialization) - Geeks Neuron (Upgrade) - Geeks Prototypes Library (Upgrade) - Geeks Hash Table For GKDB (Initialization) - Geeks Runtime Manager Console (Initialization) Beta-1.1: - Exclude Random Numbers Data Base From Main Program - Optimizations Beta-1.0: - Random Numbers Data Base (Almost Done) - Random Numbers Generator (rndb/) [random.org] - Geeks Random Numbers Libraries To Random Numbers Data Base (rndb/) - Many Optimizations - Bug Fixes Beta-0.9: - Geeks Save Data To Geeks Knowledge Data Base (Almost Done) - Full Routing (Done) - Memory Leaks Fixation - Optimizations - Serious Bug Fixes Beta-0.8: - Geeks Neural Map Simulator (Finalization) - Geeks Statistics (Initiation) - Geeks Error Correction (Initialization) - Bug Fixes Beta-0.7: - Geeks Socket And Neural Map Creator (Finalization) - Geeks Distribution And Map Loader (Done) - Geeks Neural Map Simulator (Almost Done) - Several Optimizations - Many Bug Fixes Beta-0.6: - Geeks Socket And Neural Map Creator (Upgrade) - Geeks Distibution And Map Loader (Almost Done) - Several Optimizations - Bug Fixes Beta-0.5: - Geeks Socket And Neural Map Creator (Initialization) - Optimizations - Bug Fixes ------------------------------------------------------------------------------ GANN/src/0000755000175000000040000000000010433000337011012 5ustar qtgeoadmGANN/src/gexit.cpp0000644000175000000040000000211510426065261012646 0ustar qtgeoadm/* Geeks Artificial Neural Network (G.A.N.N) - Exit Copyright GNU/GPL 2005-2006 George Delaportas (qtgeo) 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. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ //Geeks Exit (Function) void GExit(int ExitCode,char *ExitMsg) { printf("%s\n",ExitMsg); printf("G.A.N.N Terminated (Code:%i)\n",ExitCode); exit(ExitCode); } /* ------------------------------------------------------------------------ */ GANN/src/gsnmc.cpp0000644000175000000040000002745310432774232012653 0ustar qtgeoadm/* Geeks Artificial Neural Network (G.A.N.N) - Sockets And Neural Map Creator Copyright GNU/GPL 2005-2006 George Delaportas (qtgeo) 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. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ //Geeks Sockets And Neural Map Creator (Function) void GSNMC() { //Variables int i,j,k; //Counters int *APT; //All Pins Types APT=new int[MAX_PIN*2]; float v,n,m; //Float Values FILE *FileToOpen; //A File Pointer //Get User Values To Create The I/O GSockets printf("# Geeks Sockets And Neural Map Creator #\n"); printf("New I/O GSockets Have To Be Created\n"); printf("Please Make Your Choices To Set Up The New GSockets\n\n"); printf("# Input GSocket #\n"); InSocket.SetST(0); printf("Please Specify Input GPins Number\n"); printf("(Min:1,Max:%i)\n",MAX_PIN); printf("Choice:"); scanf("%i",&i); printf("\n"); InSocket.SetPins(i); printf("Now Please Specify Type And State Of Every GPin\n"); printf("(Types Binary:0,Real:1)\n"); printf("(States Off:0,On:1)\n\n"); for (j=0;j1) GExit(1,"Error:Wrong Simulation Type Specified!\n"); //Get GSockets I/O Inputs=InSocket.GetPins(); Outputs=OutSocket.GetPins(); //Automatically Check GSockets Data Types To Set The Simulation Type for (i=0;i1) GExit(1,"Error:Wrong GMap Connections Type!\n"); printf("\n"); printf("Please Specify An Estimation Of GNeurons\n"); printf("(GNeurons Must Be Equal Or More Than The Outputs)\n"); printf("(Min:1,Max:%i)\n",MAX_GN); printf("Choice:"); scanf("%i",&GNNum); //Check For Problematic GNNum if (GNNum>MAX_GN) GExit(1,"Error:Too Many GNeurons!\n"); //Check For Problematic GMap if (GNNum100.0) GExit(1,"Error:Threshold Value Must Be Between 1-100%!\n"); printf("\n"); //Initialize GMap FileToOpen=fopen("GMap","w"); //Set Starting Header fprintf(FileToOpen,"%i\n%i\n%i\n%i\n%i\n%i\n%f\n",\ SimNum,ECT,GMSType,GMCType,Inputs,Outputs,LearnTH); //GMap Creation And Optimization j=GNNum/(Inputs+Outputs); //Layers k=GNNum-(Inputs+Outputs); //Free GNeurons (Not Used For I/O) printf("Creating And Optimizing GMap...\n"); //Reset GNNum GNNum=0; //Keep Fixated Layers Layers=j; //Check Maximum Layers if (Layers>MAX_LAYERS) GExit(1,"Error:Too Many Layers Allocated For GMap!\n"); //Fixate Free GNeurons if (k==0) k++; //Store Layers fprintf(FileToOpen,"%i\n",Layers); //Rectangle (Orthogonal) if (Inputs==Outputs) { for (i=0;iOutputs) { for (i=0;i1) GExit(1,"Error:Wrong Statistics Type Specified!\n"); else if (StatType==0) { for (i=0;iOutSocket.GetPV(i,1)) Faults++; } } //Statistics (%) OK=((Outputs-Faults)/Outputs)*100.0; Error=100.0-OK; //User Messages printf("Correct:%.1f%%\n",OK); printf("Error:%.1f%%\n\n",Error); return Error; } /* ------------------------------------------------------------------------ */ GANN/src/gdmloader.cpp0000644000175000000040000000615510432307333013470 0ustar qtgeoadm/* Geeks Artificial Neural Network (G.A.N.N) - GIOD And GMap Loader Copyright GNU/GPL 2005-2006 George Delaportas (qtgeo) 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. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ //Geeks [I/O] Distribution And Map Loader (Function) void GDMLoader() { //Variables int i,j; //Counters float Val; //A Float Value float Tmp; //Temp Values FILE *FileToOpen; //A File Pointer //Initialize GIOD FileToOpen=fopen("GIOD","r"); //Read Starting Header fscanf(FileToOpen,"%i\n%i\n",&Inputs,&Outputs); //Set Values To The Inputs GSocket for (i=0;i=GNFB) { //Statistically Weighted Neurons if (CheckType==0) { //Random e if (Err<=25.0) e=random()%(int)Err; else e=random()%(int)(50.0-Err+1); //Make Summary Smaller Than NFunc Base (Output:--->0) GMatrix[GNIndex].Mod=e; } //Statically Weighted Neurons else if (CheckType==1) { //Make Summary Smaller Than GNFB (Output:0) GMatrix[GNIndex].Mod=1.0; } else GExit(1,"Error:Wrong Check Type Specified!\n"); } else { //Statistically Weighted Neurons if (CheckType==0) { //Random e if (Err>=25.0) e=random()%(int)Err; else e=random()%(int)(100.0-Err); //Make Summary Bigger Than NFunc Base (Output:--->1) GMatrix[GNIndex].Mod=e; } //Statically Weighted Neurons else if (CheckType==1) { //Make Summary Bigger Than NFunc Base (Output:1) GMatrix[GNIndex].Mod=-1.0; } else GExit(1,"Error:Wrong Check Type Specified!\n"); } } /* ------------------------------------------------------------------------ */ GANN/src/ggendata.cpp0000644000175000000040000000303710432266676013316 0ustar qtgeoadm/* Geeks Artificial Neural Network (G.A.N.N) - Generate Random Data Copyright GNU/GPL 2005-2006 George Delaportas (qtgeo) 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. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ //Common Varialbe static float RandomData; //Random Values //Geeks Generate Data (Function) float GGenData(int FuncType,float Val1,float Val2) { //Randomize GRand(); if (FuncType==0) RandomData=random()%2; else if (FuncType==1) { //Produce Random Real Data - Single Value Or Specified Range if (Val2==0.0) RandomData=Val1*random()/(RAND_MAX+1.0); else RandomData=(Val2-Val1)*random()/(RAND_MAX+1.0); } else GExit(1,"Error:Wrong Function Type Specified!\n"); //Resutls return RandomData; } /* ------------------------------------------------------------------------ */ GANN/src/grmc.cpp0000644000175000000040000001023110432264510012447 0ustar qtgeoadm/* Geeks Artificial Neural Network (G.A.N.N) - Runtime Manager Console Copyright GNU/GPL 2005-2006 George Delaportas (qtgeo) 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. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ //Geeks Runtime Manager Console (Function) void GRMC(int RMCFunc) { //Variables int i,j,k; int *REGS,*OFFSETS; REGS=new int[MAX_REG]; OFFSETS=new int[MAX_REG]; FILE *FileToCheck; //Reset i=0; j=0; k=0; //Initialize GKDB FileToCheck=fopen("GKDB","r"); //Error Check if (FileToCheck==NULL) GExit(1,"Error:GKDB Was Not Found!\n"); //Close GKDB fclose(FileToCheck); //Initialize GRegs FileToCheck=fopen("GRegs","r"); //Get GRegs while ((i=feof(FileToCheck))==FALSE) { fscanf(FileToCheck,"%i\n",®S[j]); j++; } //Close GRegs fclose(FileToCheck); //Show Registrations printf("-----------------------------------------\n\n"); for (i=0;ij) GExit(1,"Error:The Registration You Specified Does Not Exist!\n"); else RegSerNum=REGS[i-1]; printf("\n"); //Reset j j=0; //Initialize GHT FileToCheck=fopen("GHT","r"); //Get The Right Offset By Searching With RegSerNum while ((i=feof(FileToCheck))==FALSE) { fscanf(FileToCheck,"%i\n",&k); fscanf(FileToCheck,"%i\n",&OFFSETS[j]); if (k==RegSerNum) break; j++; } //Close GHT fclose(FileToCheck); //Fixate Offset if (RegSerNum==REGS[0]) Offset=0; else Offset=OFFSETS[j-1]; //Check Function if (RMCFunc==0) { printf("Please Specify Running Mode Threshold\n"); printf("(Threshold Must Be A Positive Value Between 1-100%%)\n"); printf("Choice:"); scanf("%f",&RunTH); if (RunTH<1.0 OR RunTH>100.0) GExit(1,"Error:Threshold Value Must Be Between 1-100%!\n"); printf("\n"); printf("Please Specify How Many Values Do You Want To Input\n"); printf("(Input Number May Be A Positive Integer Between 1-%i)\n",MAX_PIN); printf("Choice:"); scanf("%i",&i); if (i<1 OR i>MAX_PIN) GExit(1,"Error:Wrong Input Number Specified!\n"); printf("\n"); for (j=0;j #include #include #include #include //Set Global Symbols Definitions #define TRUE 1 #define FALSE 0 #define AND && #define OR || #define NOT ! //Set Global Constants const int AUTO=0; //Automatic Definition const int MAX_LAYERS=24; //Maximum Layers const int MAX_GN=32; //Maximum GNeurons In Each Layer const int MAX_MATRIX=\ MAX_LAYERS*MAX_GN; //Maximum Matrix const int MAX_PIN=MAX_GN/2; //Maximum Pins const int MAX_REG=1000; //Maximum Database Registrations //Set Global Variables int SimNum; //Simulations Number int ECT; //Error Correction Type int GMSType; //GMap Simulation Type int GMCType; //GMap Connections Type int GNNum; //GNeurons Number int Inputs,Outputs; //GSockets I/O int Layers; //GMap Layers int RegSerNum; //Registration Serial Number int UserInp; //User Inputs (GRMC) int GMap[MAX_LAYERS]; //Default GMap long Offset; //GHT Offset float GMinData[MAX_PIN]; //Minimum Data float GMaxData[MAX_PIN]; //Maximum Data float LearnTH; //Learning Threshold float RunTH; //Running Threshold float UserVal[MAX_PIN]; //User Values //Include Prototypes - Functions - Classes #include "gptl.h" #include "../gsleep.cpp" #include "../grand.cpp" #include "../gsocket.cpp" #include "../gneuron.cpp" #include "../gerrstat.cpp" #include "../gerrc.cpp" #include "../gdmloader.cpp" #include "../ggendata.cpp" #include "../greaddata.cpp" #include "../gsavedata.cpp" #include "../gremdata.cpp" #include "../gsnmc.cpp" #include "../gnms.cpp" #include "../grmc.cpp" #include "../gexit.cpp" /* ------------------------------------------------------------------------ */ GANN/src/gremdata.cpp0000644000175000000040000001450410432264275013322 0ustar qtgeoadm/* Geeks Artificial Neural Network (G.A.N.N) - Remove Data From GKDB Copyright GNU/GPL 2005-2006 George Delaportas (qtgeo) 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. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ //Geeks Remove Data (Function) void GRemData(int GRegSerNum,long GOffset) { //Variables int i,j,k,n,m; int Tmp; int *iTmp,*iTemp; iTmp=new int[MAX_REG+1]; iTemp=new int[MAX_REG]; float *fTmp,*fTemp; fTmp=new float[MAX_REG+1]; fTemp=new float[MAX_REG]; FILE *FileToUpdate; //Reset i=0; j=0; k=0; n=0; m=0; Tmp=-1; //Initialize GKDB FileToUpdate=fopen("GKDB","r"); //Error Check if (FileToUpdate==NULL) GExit(1,"Error:GKDB Was Not Found!\n"); //Close GKDB fclose(FileToUpdate); //Initialize GHT FileToUpdate=fopen("GHT","r"); while ((n=feof(FileToUpdate))==FALSE) { //Read GHT fscanf(FileToUpdate,"%i\n",&iTmp[i]); if (GRegSerNum==iTmp[i] AND Tmp==-1) Tmp=i; i++; } //Close GHT fclose(FileToUpdate); //Remove Specified Registration for (j=Tmp;j2) GExit(1,"Error:Wrong Simulation Mode Specified!\n"); //Reset Registration Serial Number RegSerNum=0; RSN=0; //Learn if (SimFunc==0) { //Get I/O From GSockets Loaded In Memory Inputs=InSocket.GetPins(); Outputs=OutSocket.GetPins(); //Compute Acceptable Error AccErr=100.0-LearnTH; //Fill NData With Inputs GSocket Data (Only For Uniform Checks) for (i=0;iGMax) { if (GMSType==0 OR GMSType==1) GErrC(GANN,j,GErr,1); else GErrC(GANN,j,GErr,0); k=1; } } if (k==0) printf("* All The GNeurons Are Correct *\n\n"); } goto ReRoute; } //Unload G.A.N.N From Memory delete []GANN; } //Initialize GRegs FileToCheck=fopen("GRegs","a"); //Save G.A.N.N Registrations fprintf(FileToCheck,"%i\n",RegSerNum); //Close GRegs fclose(FileToCheck); } //Run else if (SimFunc==1) { //Create A New G.A.N.N In Memory (G.A.N.N Matrix) GNeuron *GANN; GANN=new GNeuron[MAX_MATRIX]; //Run GRMC (User Interaction - Load Offset And RegSerNum) GRMC(0); //Initialize GSims FileToCheck=fopen("GSims","r"); //Get Simulations Number while ((i=feof(FileToCheck))==FALSE) { fscanf(FileToCheck,"%i\n",&RSN); fscanf(FileToCheck,"%i\n",&Sims); if (RegSerNum==RSN) break; } //Close GSims fclose(FileToCheck); //Reset n n=0; //Escape Caption ReRun:; //Start Simulation printf("Running...\n\n"); //Increase Simulations Pointer n++; //Read GKDB GReadData(GANN,RegSerNum,Offset,n); //Compare User Inputs With G.A.N.N Inputs if (UserInp>Inputs) GExit(1,"Error:Too Many Inputs For This Registration!\n"); //Check GMap Simulation Type So As To Set GNeurons Function Type if (GMSType==0) GNFT=0; else if (GMSType==1) GNFT=1; else GNFT=2; //Reset GNC GNC=-1; //Reset NLH NLH=0; //Reset NLE NLE=0; //Start Routing Through The Layers for (i=0;i=GMinData[i-NLH]\ AND GANN[i].OutData()*GMaxData[i-NLH]<=GMaxData[i-NLH]) { if (RunTH=Base) Out=1.0; else Out=0.0; printf("Out:%i\n",int(Out)); } else if (FType==1) { //Sign Function if (Summary>=Base) Out=1.0; else Out=-1.0; printf("Out:%i\n",int(Out)); } else if (FType==2) { //Sigmoid Function (Real Systems Sequence) SigFunc=1/(1+expf(-1*Summary)); if (Summary>=Base) Out=SigFunc; else Out=-SigFunc; printf("Out:%.1f\n",Out); } else GExit(1,"Error:Wrong Neuron Function Type Specified!\n"); } //Enable Neuron void GNeuron::Enable(int NFType) { //Set Neuron Function Type Globally NFT=NFType; //Run Functions RandWeights(); Sum(); NFunc(NFT); } //Run Neuron void GNeuron::Run(int NFType) { //Set Neuron Function Type Globally NFT=NFType; //Run Functions Sum(); NFunc(NFT); } //Input Data void GNeuron::InData(int InputPin,float Data) { InSlot[InputPin]=Data; ISPins=InputPin+1; printf("Input %i:%.1f\n",ISPins,InSlot[InputPin]); } //Output Data float GNeuron::OutData() { return Out; } //Set Neuron Function Type void GNeuron::SetNFT(int NewNFT) { NFT=NewNFT; } //Set Weights void GNeuron::SetWeights(int WPin,float Weight) { Weights[WPin]=Weight; } //Get Neuron Function Type int GNeuron::GetNFT() { return NFT; } //Get Sum float GNeuron::GetSum() { return Summary; } //Get Base float GNeuron::GetBase() { return Base; } //Get Input Slot Pins int GNeuron::GetISPins() { return ISPins; } //Get Weights float GNeuron::GetWeights(int WIndex) { return Weights[WIndex]; } /* ------------------------------------------------------------------------ */ GANN/src/gsocket.cpp0000644000175000000040000000750110433000251013153 0ustar qtgeoadm/* Geeks Artificial Neural Network (G.A.N.N) - I/O Socket Copyright GNU/GPL 2005-2006 George Delaportas (qtgeo) 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. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ //Constructor GSocket::GSocket() { //Private Variables int SockType=-1; int SockPins=0; //Load Pins Matrix Pins=new GPin[MAX_PIN]; } //Destructor GSocket::~GSocket() { //Unload Pins Matrix delete []Pins; } //Set Socket Type (I/O) void GSocket::SetST(int SType) { //Check Socket Type (0:Input,1:Output) if (SType<0 OR SType>1) GExit(1,"Error:Wrong Socket Type Specified!\n"); SockType=SType; } //Set Pins Number void GSocket::SetPins(int Num) { //Check Socket Pins (Not Less Than 1 Or Not More Than MAX_PIN) if (Num<1 OR Num>MAX_PIN) GExit(1,"Error:Wrong Number Of Pins Specifed!\n"); SockPins=Num; } //Set Pin Type void GSocket::SetPT(int Pin,int PinType) { //Check Socket Pins if (Pin<0 OR Pin>SockPins) GExit(1,"Error:Wrong Pin Specified!\n"); //Socket Pin Type (0:Binary,1:Real) if (PinType<0 OR PinType>1) GExit(1,"Error:Wrong Pin Type Specified!\n"); Pins[Pin].Type=PinType; } //Set Pin State void GSocket::SetPS(int Pin,int PinState) { //Check Socket Pins if (Pin<0 OR Pin>SockPins) GExit(1,"Error:Wrong Pin Specified!\n"); //Socket Pin State (0:Off,1:On) if (PinState<0 OR PinState>1) GExit(1,"Error:Wrong Pin State Specified!\n"); Pins[Pin].State=PinState; } //Set Pin Single Value Or Value With Range void GSocket::SetPV(int Pin,float Val1,float Val2) { //Check Socket Pins And Values if (Pin<0 OR Pin>SockPins) GExit(1,"Error:Wrong Pin Specified!\n"); if (Pins[Pin].Type==1 AND Val2<=Val1 AND Val2!=0.0) GExit(1,"Error:Wrong Range Specified!\n"); if (Pins[Pin].Type==0) { if (Val1<0.0 OR ((Val1>0.0 AND Val1<1.0)) OR Val1>1.0) GExit(1,"Error:Not A Binary Number!\n"); } Pins[Pin].MinVal=Val1; Pins[Pin].MaxVal=Val2; } //Get Socket Type (I/O) int GSocket::GetST() { return SockType; } //Get Pins Number int GSocket::GetPins() { return SockPins; } //Get Pin Type int GSocket::GetPT(int Pin) { if (Pin<0 OR Pin>SockPins) GExit(1,"Error:Wrong Pin Specified!\n"); return Pins[Pin].Type; } //Get Pin State int GSocket::GetPS(int Pin) { if (Pin<0 OR Pin>SockPins) GExit(1,"Error:Wrong Pin Specified!\n"); return Pins[Pin].State; } //Get Pin Value Or Pin Value With Range float GSocket::GetPV(int Pin,int Choice) { if (Pin<0 OR Pin>SockPins) GExit(1,"Error:Wrong Pin Specified!\n"); if (Choice==0) { if (Pins[Pin].State==1) return Pins[Pin].MinVal; else return 0.0; } else if (Choice==1) { if (Pins[Pin].State==1) return Pins[Pin].MaxVal; else return 0.0; } else GExit(1,"Error:Wrong Choice Specified!\n"); } /* ------------------------------------------------------------------------ */ GANN/src/gann.cpp0000644000175000000040000000613610432263623012457 0ustar qtgeoadm/* Geeks Artificial Neural Network (G.A.N.N) - Main File Copyright GNU/GPL 2005-2006 George Delaportas (qtgeo) 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. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ //Include Global Declarations #include "headers/gglobdec.h" //Main Function int main(int argc,char **argv) { //Variables int i; //A Counter //Graphical Menu printf("-------------------------\n"); printf("****** G.A.N.N ******\n"); printf("-------------------------\n"); printf("Version:1.1\n"); printf("=========================\n"); printf("George Delaportas\n"); printf("Dimitris Vlachos\n"); printf("Copyright GNU/GPL 2006\n"); printf("=========================\n\n"); printf("Please Select An Option\n"); printf("1.Create A G.A.N.N And Teach It\n"); printf("2.Run An Existing G.A.N.N From GKDB\n"); printf("3.Create A G.A.N.N - Teach It And Run It\n"); printf("4.Remove Registrations From GKDB\n"); printf("5.Exit\n"); printf("Choice:"); scanf("%i",&i); printf("\n"); //Check Choices if (i==1) { //Create New G.A.N.N GSNMC(); printf("Loading Data...\n"); //Load GIOD And GMap Data GDMLoader(); printf("Done!\n\n"); //Simulate G.A.N.N At Learning Mode GNMS(0); } else if (i==2) { //Simulate G.A.N.N At Running Mode GNMS(1); } else if (i==3) { //Create New G.A.N.N GSNMC(); printf("Loading Data...\n"); //Load GIOD And GMap Data GDMLoader(); printf("Done!\n\n"); //Simulate G.A.N.N At Learning Mode GNMS(0); //Simulate G.A.N.N At Running Mode GNMS(1); } else if (i==4) { //Remove Specified Registration GRMC(1); printf("Done!\n"); } else if (i==5) { printf("Thank You For Using G.A.N.N\n"); printf("Goodbye!\n"); GExit(0,""); } else GExit(1,"Error:Wrong Choice Specified!\n"); GExit(0,""); } /* ------------------------------------------------------------------------ */ GANN/src/greaddata.cpp0000644000175000000040000000550510432303013013433 0ustar qtgeoadm/* Geeks Artificial Neural Network (G.A.N.N) - Read Data From GKDB Copyright GNU/GPL 2005-2006 George Delaportas (qtgeo) 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. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ //Geeks Read Data (Function) void GReadData(GNeuron *GMatrix,int GRegSerNum,long GOffset,int GSimNum) { //Variables int i,j,k,n; int RSN; float d; FILE *FileToOpen; //Reset i=0; j=0; k=0; n=0; SimNum=0; //Error Checks if (GOffset<0) GExit(1,"Error:Wrong Offset Specified!\n"); //Initialize GKDB FileToOpen=fopen("GKDB","r"); //Set Pointer To The Right Offset fseek(FileToOpen,GOffset,SEEK_SET); while ((i=feof(FileToOpen))==FALSE) { //if (GSimNum==SimNum) // break; //Read Registration Serial Number fscanf(FileToOpen,"%i\n",&RSN); //Read The Rest Of The Starting Header fscanf(FileToOpen,"%i\n%i\n%i\n%i\n%f\n%i\n%i\n%i\n%i\n",&SimNum,&ECT,\ &GMSType,&GMCType,&LearnTH,&GNNum,&Layers,&Inputs,&Outputs); //Read GMap Layers for (i=0;i Copyright (C) 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. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License.