コード例 #1
0
        void Start()
        {
            const int           numOfSize   = 10;
            const int           numOfKernel = numOfSize * numOfSize;
            const int           stateDim    = 2;
            const float         lengthX     = 40.0f;    //length of area where the kernels are located
            const float         lengthY     = 40.0f;    //length of area where the kernels are located
            GaussianPolicyModel GPM         = new GaussianPolicyModel(numOfKernel, stateDim);

            //Set GPM Parameters
            for (int i = 0; i < numOfKernel; i++)
            {
                GPM.m_Mean[i] = 0.0f;
            }
            GPM.m_StandDev = 500d;

            //Set Kernels Parameters
            int iKernel = 0;

            for (int i = 0; i < numOfSize; i++)
            {
                float x = lengthX / (float)numOfSize * (float)i - lengthX / 2f;
                for (int j = 0; j < numOfSize; j++)
                {
                    float y = lengthY / (float)numOfSize * (float)j - lengthY / 2f;
                    GPM.m_GaussianKernel[iKernel].m_KernelCenter[0] = x;
                    GPM.m_GaussianKernel[iKernel].m_KernelCenter[1] = y;
                    //GPM.m_GaussianKernel[iKernel].m_KernelCenter[2] = 0.0f;
                    GPM.m_GaussianKernel[iKernel].m_Sigma = 2d;
                    iKernel++;
                }
            }
            GPM.OutputParamtersToXML("/GPMs/GPM_k100_40x40.xml");
        }
コード例 #2
0
        public void InputParametersFromXML(string file_path)
        {
            serializeDataPath = Application.dataPath + file_path;
            GaussianPolicyModel buf = XmlUtil.Deserialize <GaussianPolicyModel>(serializeDataPath);
            int num_of_kernel       = buf.m_GaussianKernel.Length;
            int state_dimension     = buf.m_GaussianKernel[0].m_KernelCenter.Length;

            Debug.LogFormat("loarding xml info... num: {0} / dim: {1}", num_of_kernel, state_dimension);
            m_Mean = new double[num_of_kernel];
            for (int i = 0; i < num_of_kernel; i++)
            {
                //Debug.LogFormat("i = [{0}]", i);
                m_Mean[i] = buf.m_Mean[i];
            }
            m_StandDev       = buf.m_StandDev;
            m_GaussianKernel = new GaussianKernel[num_of_kernel];
            for (int i = 0; i < num_of_kernel; i++)
            {
                m_GaussianKernel[i] = new GaussianKernel(state_dimension);
                m_GaussianKernel[i] = (GaussianKernel)buf.m_GaussianKernel[i];
            }
            //Debug.LogFormat("okok");
            //for (int i = 0; i < state_dimension; i++)
            //{
            //	double kc = m_GaussianKernel[1].m_KernelCenter[i];
            //	//Debug.LogFormat("kc: {0}", kc);
            //}
        }
コード例 #3
0
        /*----------------------------------------------------------*/
        /* ClickOn Save Parameter Template of Gaussian Policy Model */
        /*----------------------------------------------------------*/
        public void ClickOnMakeGaussianPolicyModelTemplate()
        {
            GaussianPolicyModel GPM = new GaussianPolicyModel(3, 3);

            GPM.OutputParamtersToXML("xmltemplate.xml");
        }