コード例 #1
0
        protected override void Reset()
        {
            List <String> actions = Target.GetActionLabels();

            m_StringDeviceBuffer = new CudaDeviceVariable <float>(1000);
            m_StringDeviceBuffer.Memset(0);

            if (numOfActions < actions.Count)
            {
                if (m_actionLabels != null)
                {
                    m_actionLabels.Dispose();
                }

                m_actionLabels = new CudaDeviceVariable <uint>(actions.Count * LABEL_PIXEL_WIDTH * LABEL_PIXEL_WIDTH);
                m_actionLabels.Memset(0);

                for (int i = 0; i < actions.Count; i++)
                {
                    MyDrawStringHelper.String2Index(actions[i], m_StringDeviceBuffer);
                    MyDrawStringHelper.DrawStringFromGPUMem(
                        m_StringDeviceBuffer, i * LABEL_PIXEL_WIDTH + 5, 8, 0, 0xFFFFFFFF,
                        m_actionLabels.DevicePointer, LABEL_PIXEL_WIDTH * actions.Count, LABEL_PIXEL_WIDTH, 0, actions[i].Length);
                }

                numOfActions = actions.Count;
            }
            Target.ReadTwoDimensions(ref m_qMatrix, ref m_qMatrixActions, XAxisVariableIndex, YAxisVariableIndex, ApplyInnerScaling);

            if (MatrixSizeOK())
            {
                DrawDataToGpu();
            }
        }
コード例 #2
0
        protected override void Execute()
        {
            m_kernel_drawEdges.GridDimensions  = new dim3(Target.PatchesNum);
            m_kernel_drawEdges.BlockDimensions = new dim3(Target.PatchesNum);
            m_kernel_fillImWhite.SetupExecution(Target.MaskCount);
            m_kernel_fillImFromIm.SetupExecution(Target.MaskCount);

            m_kernel_fillImFromIm.Run(VBODevicePointer, Target.OutMask, TextureWidth * TextureHeight, 5);//(int)Target.PatchesNum /5);



            switch (ObserverMode)
            {
            case MyJoinPatObsMode.Graph:
                //. print edges
                m_kernel_drawEdges.Run(VBODevicePointer, TextureWidth, Target.AdjMatrix, Target.Patches, Target.PatchesNum, Target.PatchesDim, Target.Desc, Target.Desc.ColumnHint, 0);
                break;

            case MyJoinPatObsMode.GraphWeights:
                //. print weight of graph's edges
                m_kernel_fillImWhite.Run(VBODevicePointer, TextureWidth, TextureHeight);
                m_kernel_drawEdges.Run(VBODevicePointer, TextureWidth, Target.AdjMatrix, Target.Patches, Target.PatchesNum, Target.PatchesDim, Target.Desc, Target.Desc.ColumnHint, 1);
                break;

            case MyJoinPatObsMode.MaskId:
                //. print ids to objects
                Target.OutPatches.SafeCopyToHost();
                for (int i = 0; i < Math.Min(Target.PatchesNum, 10); i++)
                {
                    int x = (int)Target.OutPatches.Host[i * Target.PatchesDim];
                    int y = (int)Target.OutPatches.Host[i * Target.PatchesDim + 1];
                    MyDrawStringHelper.String2Index(i.ToString(), m_StringDeviceBuffer);
                    MyDrawStringHelper.DrawStringFromGPUMem(m_StringDeviceBuffer, x, y, (uint)Color.White.ToArgb(), (uint)Color.Black.ToArgb(), VBODevicePointer, TextureWidth, TextureHeight, 0, i.ToString().Length);
                }
                break;

            case MyJoinPatObsMode.Desc:
                // find the max value
                Target.Desc.SafeCopyToHost();
                float maxValue = float.MinValue;
                float minValue = float.MaxValue;
                for (int i = 0; i < Target.Desc.Count; i++)
                {
                    maxValue = (Target.Desc.Host[i] > maxValue) ? Target.Desc.Host[i] : maxValue;
                    minValue = (Target.Desc.Host[i] < minValue) ? Target.Desc.Host[i] : minValue;
                }
                maxValue = maxValue - minValue;
                // draw first row in desc :)
                m_kernel_drawDesc.SetupExecution(Target.MaskCount);
                m_kernel_drawDesc.Run(VBODevicePointer, Target.Mask, TextureWidth * TextureHeight, Target.Desc, maxValue, minValue);
                break;
            }
        }
コード例 #3
0
        protected override void Execute()
        {
            m_kernel.SetupExecution(Target.AttentionMap.Count);
            m_kernel.Run(Target.AttentionMap, Target.Centroids, Target.CentroidsCount, TextureWidth, TextureHeight, VBODevicePointer);

            for (int i = 0; i < Target.CentroidsCount; i++)
            {
                int   x   = (int)((Target.Centroids.Host[i * MyPupilControl.CENTROID_FIELDS] + 1) * 0.5f * TextureWidth);
                int   y   = (int)((Target.Centroids.Host[i * MyPupilControl.CENTROID_FIELDS + 1] + 1) * 0.5f * TextureHeight);
                float DBI = Target.Centroids.Host[i * MyPupilControl.CENTROID_FIELDS + 5];
                MyDrawStringHelper.String2Index(i + " ", m_StringDeviceBuffer);
                MyDrawStringHelper.DrawStringFromGPUMem(m_StringDeviceBuffer, x - 4, y - 14, 0, 0xFF69A5FF, VBODevicePointer, TextureWidth, TextureHeight, 0, (i + " ").Length);
                //MyDrawStringHelper.DrawDecimalString(DBI.ToString("0.0000") , x - 10, y + 2, 0, 0xFF69A5FF, VBODevicePointer, TextureWidth, TextureHeight);
            }
        }
コード例 #4
0
        protected override void Execute()
        {
            if (m_qMatrix != null)
            {
                m_kernel.SetupExecution(TextureWidth * TextureHeight);
                m_kernel.Run(m_plotValues.DevicePointer, m_actionIndices.DevicePointer, m_actionLabels.DevicePointer, numOfActions, LABEL_PIXEL_WIDTH, LABEL_PIXEL_WIDTH, 0f, MaxUtilityValue, m_qMatrix.GetLength(0), m_qMatrix.GetLength(1), VBODevicePointer);

                if (ViewMode == ViewMethod.Orbit_3D)
                {
                    m_vertexKernel.SetupExecution(m_qMatrix.Length);
                    m_vertexKernel.Run(m_plotValues.DevicePointer, 0.1f, m_qMatrix.GetLength(0), m_qMatrix.GetLength(1), MaxUtilityValue, VertexVBODevicePointer);
                }
            }

            float[,] lastQMatrix = m_qMatrix;

            MyStochasticReturnPredictor srp = null;

            srp = (MyStochasticReturnPredictor)Target.Vis.GetPredictorNo(AbstractActionIndex);

            if (srp != null)
            {
                Target.ReadTwoDimensions(ref m_qMatrix, ref m_qMatrixActions, XAxisVariableIndex, YAxisVariableIndex, ApplyInnerScaling, AbstractActionIndex);
            }

            if (lastQMatrix != m_qMatrix)
            {
                TriggerReset();
            }
            else if (m_qMatrix != null && MatrixSizeOK())
            {
                m_plotValues.CopyToDevice(m_qMatrix);
                m_actionIndices.CopyToDevice(m_qMatrixActions);

                if (ShowSRPNames && srp != null)
                {
                    //Set texture size, it will trigger texture buffer reallocation
                    TextureWidth  = LABEL_PIXEL_WIDTH * m_qMatrix.GetLength(0);
                    TextureHeight = LABEL_PIXEL_WIDTH * m_qMatrix.GetLength(1);

                    String label = srp.GetLabel() + " M:" + srp.GetMyTotalMotivation();

                    MyDrawStringHelper.String2Index(label, m_StringDeviceBuffer);
                    MyDrawStringHelper.DrawStringFromGPUMem(m_StringDeviceBuffer, 0, 0, 0, 0x999999, VBODevicePointer, TextureWidth, TextureHeight, 0, label.Length);
                    //MyDrawStringHelper.DrawString(label, 0, 0, 0, 0x999999, VBODevicePointer, TextureWidth, TextureHeight);
                }
            }
        }
コード例 #5
0
        protected override void Reset()
        {
            m_StringDeviceBuffer = new CudaDeviceVariable <float>(1000);
            m_StringDeviceBuffer.Memset(0);

            List <String> actions = Target.GetActionLabels();

            if (numOfActions < actions.Count)
            {
                if (m_actionLabels != null)
                {
                    m_actionLabels.Dispose();
                }

                m_actionLabels = new CudaDeviceVariable <uint>(actions.Count * LABEL_PIXEL_WIDTH * LABEL_PIXEL_WIDTH);
                m_actionLabels.Memset(0);

                for (int i = 0; i < actions.Count; i++)
                {
                    MyDrawStringHelper.String2Index(actions[i], m_StringDeviceBuffer);
                    MyDrawStringHelper.DrawStringFromGPUMem(m_StringDeviceBuffer, i * LABEL_PIXEL_WIDTH + 5, 8, 0, 0xFFFFFFFF, m_actionLabels.DevicePointer, LABEL_PIXEL_WIDTH * actions.Count, LABEL_PIXEL_WIDTH, 0, actions[i].Length);
                }

                numOfActions = actions.Count;
            }

            MyStochasticReturnPredictor srp = null;

            srp = (MyStochasticReturnPredictor)Target.Vis.GetPredictorNo(AbstractActionIndex);

            if (srp == null)
            {
                m_qMatrix     = null;
                TextureWidth  = 0;
                TextureHeight = 0;
            }
            else
            {
                Target.ReadTwoDimensions(ref m_qMatrix, ref m_qMatrixActions, XAxisVariableIndex, YAxisVariableIndex, ApplyInnerScaling, AbstractActionIndex);

                if (MatrixSizeOK())
                {
                    DrawDataToGpu();
                }
            }
        }
コード例 #6
0
        private void drawCoordinates()
        {
            m_canvas.Memset(COLOR_BACKGROUND);

            // Ordinates
            double range            = m_plotCurrentValueMax - m_plotCurrentValueMin;
            double scale            = Math.Floor(Math.Log10(range));
            double unit             = Math.Pow(10, scale) / 2;
            int    displayPrecision = (scale >= 1) ? 0 : (1 - (int)scale);
            double firstOrdinate    = Math.Ceiling(m_plotCurrentValueMin / unit) * unit;

            for (int n = 0; firstOrdinate + n * unit < m_plotCurrentValueMax; n++)
            {
                double value    = firstOrdinate + n * unit;
                string valueStr = string.Format("{0,8:N" + displayPrecision + "}", value);
                double y        = TextureHeight - m_plotAreaOffsetY - m_plotAreaHeight * (value - m_plotCurrentValueMin) / range - MyDrawStringHelper.CharacterHeight / 2;
                MyDrawStringHelper.String2Index(valueStr, m_StringDeviceBuffer);
                MyDrawStringHelper.DrawStringFromGPUMem(m_StringDeviceBuffer, 0, (int)y, COLOR_BACKGROUND, COLOR_FONT, VBODevicePointer, TextureWidth, TextureHeight, 0, valueStr.Length);
            }
        }