private float[] RecursiveRead(int[] indexes, int depth, MyDimList d)
        {
            if (depth == this.m_maxDimensions - 2)
            {
                int     noActions = m_dimensionSizes[ACTIONS] - m_disabledActions.Count;
                float[] utils     = new float[noActions];

                // fill the utils array with the utilities of actions that are not disabled
                int pos = 0;

                for (int i = 0; i < m_dimensionSizes[ACTIONS]; i++)
                {
                    MyDimList tmp = d.GetChildNo(i);

                    if (!d.GetChildNo(i).IsLast())
                    {
                        MyLog.ERROR.WriteLine("Expexcted last dimension!");
                        utils[i] = MyDimList.DEF_VAL;
                    }
                    if (!m_disabledActions.ContainsKey(i))
                    {
                        utils[pos++] = d.GetChildNo(i).GetValue();
                    }
                }
                return(utils);
            }
            else
            {
                MyDimList child = d.GetChildNo(indexes[depth]);
                return(RecursiveRead(indexes, depth + 1, child));
            }
        }
        private void RecursiveSet(int[] stateValues, int action, int depth, MyDimList d, float value)
        {
            if (depth == this.m_maxDimensions - 2)
            {
                MyDimList last = d.GetChildNo(action);
                last.SetValue(value);
                return;
            }
            MyDimList child = d.GetChildNo(stateValues[depth]);

            this.RecursiveSet(stateValues, action, depth + 1, child, value);
        }
        public MyQSAMemory(int maxStateVariables, int initNoActions)
        {
            m_maxDimensions = maxStateVariables + 1;
            ACTIONS         = m_maxDimensions - 1;

            m_dimensionSizes  = new int[m_maxDimensions];
            m_disabledActions = new Dictionary <int, bool>();

            m_d = new MyDimList(m_maxDimensions, 0);
            MyDimList tmp = m_d;

            // recursively init all dimensions
            for (int i = 1; i < m_maxDimensions; i++)
            {
                m_dimensionSizes[i] = 1;  // all constants by default

                tmp = tmp.GetChildNo(0);
                tmp = new MyDimList(m_maxDimensions, i);
            }

            this.m_dimensionSizes[ACTIONS] = initNoActions;
        }
Ejemplo n.º 4
0
        public MyQSAMemory(int maxStateVariables, int initNoActions)
        {
            m_maxDimensions = maxStateVariables + 1;
            ACTIONS = m_maxDimensions - 1;

            m_dimensionSizes = new int[m_maxDimensions];
            m_disabledActions = new Dictionary<int, bool>();

            m_d = new MyDimList(m_maxDimensions, 0);
            MyDimList tmp = m_d;

            // recursively init all dimensions
            for (int i = 1; i < m_maxDimensions; i++)
            {
                m_dimensionSizes[i] = 1;  // all constants by default

                tmp = tmp.GetChildNo(0);
                tmp = new MyDimList(m_maxDimensions, i);
            }

            this.m_dimensionSizes[ACTIONS] = initNoActions;
        }
Ejemplo n.º 5
0
 private void RecursiveSet(int[] stateValues, int action, int depth, MyDimList d, float value)
 {
     if (depth == this.m_maxDimensions - 2)
     {
         MyDimList last = d.GetChildNo(action);
         last.SetValue(value);
         return;
     }
     MyDimList child = d.GetChildNo(stateValues[depth]);
     this.RecursiveSet(stateValues, action, depth+1, child, value);
 }
Ejemplo n.º 6
0
        private float[] RecursiveRead(int[] indexes, int depth, MyDimList d)
        {
            if (depth == this.m_maxDimensions - 2)
            {
                int noActions = m_dimensionSizes[ACTIONS] - m_disabledActions.Count;
                float[] utils = new float[noActions];

                // fill the utils array with the utilities of actions that are not disabled
                int pos = 0;

                for (int i = 0; i < m_dimensionSizes[ACTIONS]; i++)
                {
                    MyDimList tmp = d.GetChildNo(i);

                    if (!d.GetChildNo(i).IsLast())
                    {
                        MyLog.ERROR.WriteLine("Expexcted last dimension!");
                        utils[i] = MyDimList.DEF_VAL;
                    }
                    if (!m_disabledActions.ContainsKey(i))
                    {
                        utils[pos++] = d.GetChildNo(i).GetValue();
                    }
                }
                return utils;
            }
            else
            {
                MyDimList child = d.GetChildNo(indexes[depth]);
                return RecursiveRead(indexes, depth + 1, child);
            }
        }