Exemple #1
0
        public void ExportGradients()
        {
            MultiResValue <int[], int[]> av = (MultiResValue <int[], int[]>)agent._actionValue;

            StateManagement.intStateTree tree = new StateManagement.intStateTree();


            System.IO.StreamWriter xWriter   = new System.IO.StreamWriter("C:\\Users\\Eric\\Google Drive\\Lethbridge Projects\\gradientsX.csv");
            System.IO.StreamWriter yWriter   = new System.IO.StreamWriter("C:\\Users\\Eric\\Google Drive\\Lethbridge Projects\\gradientsY.csv");
            System.IO.StreamWriter valWriter = new System.IO.StreamWriter("C:\\Users\\Eric\\Google Drive\\Lethbridge Projects\\gradientsVal.csv");
            for (int i = 0; i < map.GetLength(0); i++)
            {
                double[] thisXLine   = new double[map.GetLength(1)];
                double[] thisYLine   = new double[map.GetLength(1)];
                double[] thisValLine = new double[map.GetLength(1)];
                for (int j = 0; j < map.GetLength(1); j++)
                {
                    int[] thisState = tree.GetParentState(new int[2] {
                        i, j
                    }, 0);
                    double[] actionVals = av.models[0].value(thisState, availableActions);
                    thisXLine[j]   = actionVals[2] - actionVals[0];
                    thisYLine[j]   = actionVals[3] - actionVals[1];
                    thisValLine[j] = actionVals.Max();
                }
                xWriter.WriteLine(string.Join(",", thisXLine));
                yWriter.WriteLine(string.Join(",", thisYLine));
                valWriter.WriteLine(string.Join(",", thisValLine));
            }
            xWriter.Flush(); xWriter.Close();
            yWriter.Flush(); yWriter.Close();
            valWriter.Flush(); valWriter.Close();
        }
Exemple #2
0
        public void ExportGradients(int level)
        {
            MultiResValue<int[], int[]> av = (MultiResValue<int[], int[]>)agent._actionValue;
            StateManagement.intStateTree tree = new StateManagement.intStateTree();

            System.IO.StreamWriter xWriter = new System.IO.StreamWriter("C:\\Users\\Eric\\Google Drive\\Lethbridge Projects\\gradientsX.csv");
            System.IO.StreamWriter yWriter = new System.IO.StreamWriter("C:\\Users\\Eric\\Google Drive\\Lethbridge Projects\\gradientsY.csv");
            System.IO.StreamWriter valWriter = new System.IO.StreamWriter("C:\\Users\\Eric\\Google Drive\\Lethbridge Projects\\gradientsVal.csv");
            for (int i=0; i< map.GetLength(0); i++)
            {
                double[] thisXLine = new double[map.GetLength(1)];
                double[] thisYLine = new double[map.GetLength(1)];
                double[] thisValLine = new double[map.GetLength(1)];
                for (int j = 0; j < map.GetLength(1); j++)
                {
                    int[] thisState = tree.GetParentState(new int[2] { i, j }, 0);
                    double[] actionVals = av.models[level].value(thisState, availableActions);
                    thisXLine[j] = actionVals[2] - actionVals[0];
                    thisYLine[j] = actionVals[3] - actionVals[1];
                    thisValLine[j] = actionVals.Max();
                }
                xWriter.WriteLine(string.Join(",", thisXLine));
                yWriter.WriteLine(string.Join(",", thisYLine));
                valWriter.WriteLine(string.Join(",", thisValLine));
            }
            xWriter.Flush(); xWriter.Close();
            yWriter.Flush(); yWriter.Close();
            valWriter.Flush(); valWriter.Close();
        }