// A few setup methods
 public void CreateClustersFromTemplate1()
 {
     // The first position in the integer array corresponds to the number of commands.
     // In the int staggered array, in the second+ arrays, the 0th index is the number of doubles needed, 1st is the number of booleans
     // 2nd is the number of ints, 3rd is the number of preset options
     if (IDT != null)
     {
         NC = new NodeCluster[intArgs[0][0]];
         for (int i = 1; i <= intArgs[0][0]; i++)
         {
             int count = intArgs[i][0] + intArgs[i][1] + intArgs[i][2];
             if (count != 0)
             {
                 int   pos   = 0;
                 int[] types = new int[count];
                 for (int j = 0; j < 3; j++)
                 {
                     for (int k = 0; k < intArgs[i][j]; k++)
                     {
                         types[pos] = j + 1;
                         pos++;
                     }
                 }
                 NC[i - 1] = new NodeCluster(false, count, 0, types, IDT, LowEnd, UpEnd, "" + (i - 1));
             }
             else
             {
                 NC[i - 1] = new NodeCluster(false, 0, IDT, LowEnd, UpEnd, "" + (i - 1));
             }
             SubNodeCluster(NC[i - 1]);
             NC[i - 1].CreatePresetCluster(intArgs[i][3]);
         }
     }
     DecisionCount = NC.Length;
 }
Beispiel #2
0
 public void CreatePresetCluster(int count)
 {
     if (count > 0)
     {
         PresetClusters = new NodeCluster[count];
         for (int i = 0; i < count; i++)
         {
             PresetClusters[i] = new NodeCluster(true, 4, IDT, upperBound, lowerBound, "" + i);
         }
     }
 }
Beispiel #3
0
 public NodeCluster(bool IsSubCluster, int subClusterCount, int returnType, int[] SubClusterReturnTypes, InternalDataTransfer IDT, int lowerEnd, int upperEnd, string ID)
 {
     subCluster = IsSubCluster;
     Oper       = new Operator();
     this.IDT   = IDT;
     lowerBound = lowerEnd;
     upperBound = upperEnd;
     this.ID    = ID;
     if (!subCluster)
     {
         SubClusters = new NodeCluster[subClusterCount];
         for (int i = 0; i < subClusterCount; i++)
         {
             SubClusters[i] = new NodeCluster(true, SubClusterReturnTypes[i], IDT, lowerEnd, upperEnd, "" + i);
         }
     }
     this.returnType = returnType;
 }
Beispiel #4
0
 private void LogIt(NodeCluster m, string e)
 {
     OtherLogBox.AppendText(e);
     OtherLogBox.AppendText(Environment.NewLine);
 }
Beispiel #5
0
 public void Subscribe(NodeCluster m)
 {
     m.UILog += new NodeCluster.LogCommand(LogIt);
 }
Beispiel #6
0
 public void LogNodeCluster(NodeCluster ChosenCluster, object[] RunData)
 {
     Round1.Add(ChosenCluster);
     Round1.Add(ChosenCluster.ReturnNodeDecisions());
     Round1.Add(RunData);
 }
 public void IndividualCalculation(NodeCluster n)
 {
     n.NodeCalculations();
 }
Beispiel #8
0
 public void StepOpposite(bool Dir, double weight, NodeCluster e, bool Increment)
 {
     // Fix this so that it works with an array of weights
     // Also so it adjusts in the correct direction
     if (Dir)
     {
         if (currentOperators[0] == 1 || currentOperators[0] == 2)
         {
             if (DataSources.Length > 1)
             {
                 double TempWeight = 0;
                 for (int i = 0; i < DataSources.Length - InternalBool.Length; i++)
                 {
                     if (!(DataSources[i] >= doubleLength && DataSources[i] < doubleLength + InternalBool.Length))
                     {
                         if (DataSources[i] < doubleLength)
                         {
                             TempWeight = (double)(e.IDT.getItem(4, 0, DataSources[i]));
                         }
                         else
                         {
                             TempWeight = (int)(e.IDT.getItem(4, 0, DataSources[i]));
                         }
                         TempWeight += weight; // Double check this at some point
                         IncorporateNewWeight(TempWeight, i, false);
                     }
                 }
                 IncorporateNewWeight(Increment);
             }
             else
             {
                 double TempWeight = (int)(e.IDT.getItem(4, 0, DataSources[0]));
                 TempWeight += weight;
                 IncorporateNewWeight(TempWeight, Increment);
             }
         }
         else if (currentOperators[0] == 3 || currentOperators[0] == 4)
         {
             if (DataSources.Length > 1)
             {
                 double TempWeight = 0;
                 for (int i = 0; i < DataSources.Length - InternalBool.Length; i++)
                 {
                     if (!(DataSources[i] >= doubleLength && DataSources[i] < doubleLength + InternalBool.Length))
                     {
                         if (DataSources[i] < doubleLength)
                         {
                             TempWeight = (double)(e.IDT.getItem(4, 0, DataSources[i]));
                         }
                         else
                         {
                             TempWeight = (int)(e.IDT.getItem(4, 0, DataSources[i]));
                         }
                         TempWeight -= weight; // Double check this at some point
                         IncorporateNewWeight(TempWeight, i, false);
                     }
                 }
                 IncorporateNewWeight(Increment);
             }
             else
             {
                 double TempWeight = (int)(e.IDT.getItem(4, 0, DataSources[0]));
                 TempWeight -= weight;
                 IncorporateNewWeight(TempWeight, Increment);
             }
         }
     }
     else
     {
         if (currentOperators[0] == 1 || currentOperators[0] == 2)
         {
             if (DataSources.Length > 1)
             {
                 double TempWeight = 0;
                 for (int i = 0; i < DataSources.Length - InternalBool.Length; i++)
                 {
                     if (!(DataSources[i] >= doubleLength && DataSources[i] < doubleLength + InternalBool.Length))
                     {
                         if (DataSources[i] < doubleLength)
                         {
                             TempWeight = (double)(e.IDT.getItem(4, 0, DataSources[i]));
                         }
                         else
                         {
                             TempWeight = (int)(e.IDT.getItem(4, 0, DataSources[i]));
                         }
                         TempWeight -= weight; // Double check this at some point
                         IncorporateNewWeight(TempWeight, i, false);
                     }
                 }
                 IncorporateNewWeight(Increment);
             }
             else
             {
                 double TempWeight = (int)(e.IDT.getItem(4, 0, DataSources[0]));
                 TempWeight -= weight;
                 IncorporateNewWeight(TempWeight, Increment);
             }
         }
         else if (currentOperators[0] == 3 || currentOperators[0] == 4)
         {
             if (DataSources.Length > 1)
             {
                 double TempWeight = 0;
                 for (int i = 0; i < DataSources.Length - InternalBool.Length; i++)
                 {
                     if (!(DataSources[i] >= doubleLength && DataSources[i] < doubleLength + InternalBool.Length))
                     {
                         if (DataSources[i] < doubleLength)
                         {
                             TempWeight = (double)(e.IDT.getItem(4, 0, DataSources[i]));
                         }
                         else
                         {
                             TempWeight = (int)(e.IDT.getItem(4, 0, DataSources[i]));
                         }
                         TempWeight += weight; // Double check this at some point
                         IncorporateNewWeight(TempWeight, i, false);
                     }
                 }
                 IncorporateNewWeight(true);
             }
             else
             {
                 double TempWeight = (int)(e.IDT.getItem(4, 0, DataSources[0]));
                 TempWeight += weight;
                 IncorporateNewWeight(TempWeight, true);
             }
         }
     }
 }
Beispiel #9
0
 // Learning Functions
 public void StepTowardsTrue(bool Dir, double weight, NodeCluster e, bool Increment)
 {
     // Fix this so that it works with an array of weights
     if (Dir)
     {
         IncorporateNewWeight(Increment);
     }
     else
     {
         if (currentOperators[0] == 1 || currentOperators[0] == 2)
         {
             if (DataSources.Length > 1)
             {
                 double TempWeight = 0;
                 for (int i = 0; i < DataSources.Length - InternalBool.Length; i++)
                 {
                     if (!(DataSources[i] >= doubleLength && DataSources[i] < doubleLength + InternalBool.Length))
                     {
                         if (DataSources[i] < doubleLength)
                         {
                             TempWeight = (double)(e.IDT.getItem(4, 0, DataSources[i]));
                         }
                         else
                         {
                             TempWeight = (int)(e.IDT.getItem(4, 0, DataSources[i]));
                         }
                         TempWeight += weight;                       // Double check this at some point
                         IncorporateNewWeight(TempWeight, i, false); // This is false so it doesn't increase the increment count each time
                     }
                 }
                 IncorporateNewWeight(Increment); // This happens so that the increment count is increased by just 1 after it is trained
             }
             else
             {
                 double TempWeight = (int)(e.IDT.getItem(4, 0, DataSources[0]));
                 TempWeight += weight;
                 IncorporateNewWeight(TempWeight, Increment);
             }
         }
         else if (currentOperators[0] == 3 || currentOperators[0] == 4)
         {
             if (DataSources.Length > 1)
             {
                 double TempWeight = 0;
                 for (int i = 0; i < DataSources.Length - InternalBool.Length; i++)
                 {
                     if (!(DataSources[i] >= doubleLength && DataSources[i] < doubleLength + InternalBool.Length))
                     {
                         if (DataSources[i] < doubleLength)
                         {
                             TempWeight = (double)(e.IDT.getItem(4, 0, DataSources[i]));
                         }
                         else
                         {
                             TempWeight = (int)(e.IDT.getItem(4, 0, DataSources[i]));
                         }
                         TempWeight -= weight; // Double check this at some point
                         IncorporateNewWeight(TempWeight, i, false);
                     }
                 }
                 IncorporateNewWeight(Increment);
             }
             else
             {
                 double TempWeight = (int)(e.IDT.getItem(4, 0, DataSources[0]));
                 TempWeight -= weight;
                 IncorporateNewWeight(TempWeight, Increment);
             }
         }
     }
 }
Beispiel #10
0
        public void Calculate(int doubleLength, int boolLength, bool RemoveRedundantCalculations, NodeCluster e, bool WeightDeltaDecisions)
        {
            // This will need to really be fixed
            int  DeltaScale = 81;
            bool Continue   = false;

            if (RemoveRedundantCalculations)
            {
                for (int i = 0; i < DataSources.Length; i++)
                {
                    if (e.DeltaData(DataSources[i]))
                    {
                        Continue = true;
                        break;
                    }
                }
            }
            else
            {
                Continue = true;
            }

            if (Continue)
            {
                if (NodeType != 4)
                {
                    bool[] Results = new bool[DataSources.Length];
                    if (NodeType == 3)
                    {
                        for (int i = 0; i < DataSources.Length; i++)
                        {
                            // Never ending screams
                            if (DataSources[i] < doubleLength)
                            {
                                Results[i] = (bool)e.Oper.CallFunction(currentOperators[0], e.getItem(4, 0, DataSources[i]), InternalWeight[i]);
                            }
                            else if (DataSources[i] < doubleLength + boolLength)
                            {
                                Results[i] = (bool)e.Oper.CallFunction(currentOperators[1], e.getItem(4, 0, DataSources[i]), InternalBool[i - doubleLength]);
                            }
                            else
                            {
                                Results[i] = (bool)e.Oper.CallFunction(currentOperators[0], e.getItem(4, 0, DataSources[i]), InternalWeight[i - boolLength]);
                            }
                        }
                    }
                    else if (NodeType == 2)
                    {
                        for (int i = 0; i < DataSources.Length; i++)
                        {
                            Results[i] = (bool)e.Oper.CallFunction(currentOperators[0], e.getItem(4, 0, DataSources[i]), InternalBool[i]);
                        }
                    }
                    else
                    {
                        for (int i = 0; i < DataSources.Length; i++)
                        {
                            Results[i] = (bool)e.Oper.CallFunction(currentOperators[0], e.getItem(4, 0, DataSources[i]), InternalWeight[i]);
                        }
                    }
                    int temp = 0;
                    for (int i = 0; i < Results.Length; i++)
                    {
                        if (Results[i])
                        {
                            temp++;
                        }
                        else
                        {
                            temp--;
                        }
                    }
                    SelfDecision = temp;
                    neutral      = false;
                    if (SelfDecision > 0)
                    {
                        SelfDecision = DataSources.Length;
                    }
                    else if (SelfDecision < 0)
                    {
                        SelfDecision = -1 * DataSources.Length;
                    }
                    else
                    {
                        neutral = true;
                    }
                    if (WeightDeltaDecisions)
                    {
                        SelfDecision *= DeltaScale;
                    }
                    Delta = true;
                }
                else
                {
                    double temp = 0;
                    for (int i = 0; i < DataSources.Length; i++)
                    {
                        temp += (double)e.Oper.CallFunction(currentOperators[0], e.IDT.getItem(4, 0, DataSources[i]), InternalWeight[i]);
                    }
                    SelfValue = temp;
                }
            }
            else
            {
                //if (WeightDeltaDecisions)
                //   SelfDecision = 0;
                if (Delta && WeightDeltaDecisions)
                {
                    SelfDecision /= DeltaScale;
                }
                Delta = false;
            }
        }