Esempio n. 1
0
        static void Main(string[] args)
        {
            string stratName   = args.Length < 1 ? "" : args[0];
            int    gamesToPlay = args.Length < 2 ? 100 : int.Parse(args[1]);

            Strategy strat;

            switch (stratName)
            {
            case "-random":
                strat = new RandomStrategy();
                break;

            case "-smart":
                strat = new SmartStrategy();
                break;

            case "-tracking":
                strat = new TrackingStrategy();
                break;

            default:
                strat = new RandomStrategy();
                break;
            }

            PlayGames(strat, gamesToPlay);
        }
Esempio n. 2
0
 public void SetSeekStrategy(TrackingStrategy trackingStrategy)
 {
     m_trackingStrategy = trackingStrategy;
 }
Esempio n. 3
0
        /// <summary>
        /// Sets the tracking strategy of the mailing with the provided id.
        /// </summary>
        /// <param name="mailingId"></param>
        /// <param name="strategy"></param>
        /// <returns></returns>
        public void SetTrackingStrategy(long mailingId, TrackingStrategy strategy)
        {
            string body = SerializationUtils <TrackingStrategy> .ToXmlString(strategy, "tracking_strategy");

            Post("mailings/" + mailingId.ToString() + "/settings/trackingstrategy", null, body);
        }
        public ShiftCollection(int aFrameCount, int aMaxTileCountX, int aMaxTileCountY, int aReferenceIndex, TrackingStrategy aStrategy, int aBlockSize, CudaContext ctx)
        {
            strategy       = aStrategy;
            referenceIndex = aReferenceIndex;
            frameCount     = aFrameCount;
            if (aBlockSize >= aFrameCount)
            {
                blockSize = aFrameCount - 1;
            }
            else
            {
                blockSize = aBlockSize;
            }

            blas = new CudaBlas(PointerMode.Device, AtomicsMode.Allowed);
            one  = 1.0f;
            zero = 0.0f;

            shiftPairs = new List <ShiftPair>();
            int shiftCount = GetShiftCount();

            FillShiftPairs();
            FillIndexTable();


            if (shiftPairs.Count != shiftCount)
            {
                throw new Exception("Ooups, something went wrong with my math...");
            }

            shifts = new List <NPPImage_32fC2>(shiftCount);

            int[]         shiftPitches_h = new int[shiftCount];
            CUdeviceptr[] ptrList        = new CUdeviceptr[shiftCount];
            for (int i = 0; i < shiftCount; i++)
            {
                NPPImage_32fC2 devVar = new NPPImage_32fC2(aMaxTileCountX, aMaxTileCountY);
                shifts.Add(devVar);
                shiftPitches_h[i] = devVar.Pitch;
                ptrList[i]        = devVar.DevicePointer;
            }
            shiftPitches     = shiftPitches_h;
            AllShifts_d      = new CudaDeviceVariable <float2>(aMaxTileCountX * aMaxTileCountY * shiftCount);
            shiftsOneToOne_d = new CudaDeviceVariable <float2>(aMaxTileCountX * aMaxTileCountY * (frameCount - 1));
            shifts_d         = ptrList;



            status               = new CudaDeviceVariable <int>(aMaxTileCountX * aMaxTileCountY);
            infoInverse          = new CudaDeviceVariable <int>(aMaxTileCountX * aMaxTileCountY);
            shiftMatrixArray     = new CudaDeviceVariable <CUdeviceptr>(aMaxTileCountX * aMaxTileCountY);
            shiftMatrixSafeArray = new CudaDeviceVariable <CUdeviceptr>(aMaxTileCountX * aMaxTileCountY);
            matrixSquareArray    = new CudaDeviceVariable <CUdeviceptr>(aMaxTileCountX * aMaxTileCountY);
            matrixInvertedArray  = new CudaDeviceVariable <CUdeviceptr>(aMaxTileCountX * aMaxTileCountY);
            solvedMatrixArray    = new CudaDeviceVariable <CUdeviceptr>(aMaxTileCountX * aMaxTileCountY);
            shiftOneToOneArray   = new CudaDeviceVariable <CUdeviceptr>(aMaxTileCountX * aMaxTileCountY);
            shiftMeasuredArray   = new CudaDeviceVariable <CUdeviceptr>(aMaxTileCountX * aMaxTileCountY);
            shiftOptimArray      = new CudaDeviceVariable <CUdeviceptr>(aMaxTileCountX * aMaxTileCountY);
            shiftMatrices        = new CudaDeviceVariable <float>(aMaxTileCountX * aMaxTileCountY * shiftCount * (frameCount - 1));
            shiftSafeMatrices    = new CudaDeviceVariable <float>(aMaxTileCountX * aMaxTileCountY * shiftCount * (frameCount - 1));
            matricesSquared      = new CudaDeviceVariable <float>(aMaxTileCountX * aMaxTileCountY * (frameCount - 1) * (frameCount - 1));
            matricesInverted     = new CudaDeviceVariable <float>(aMaxTileCountX * aMaxTileCountY * (frameCount - 1) * (frameCount - 1));
            solvedMatrices       = new CudaDeviceVariable <float>(aMaxTileCountX * aMaxTileCountY * shiftCount * (frameCount - 1));
            shiftsOneToOne       = new CudaDeviceVariable <float2>(aMaxTileCountX * aMaxTileCountY * (frameCount - 1));
            pivotArray           = new CudaDeviceVariable <int>(aMaxTileCountX * aMaxTileCountY * (frameCount - 1));
            shiftsMeasured       = new CudaDeviceVariable <float2>(aMaxTileCountX * aMaxTileCountY * shiftCount);
            shiftsOptim          = new CudaDeviceVariable <float2>(aMaxTileCountX * aMaxTileCountY * shiftCount);
            buffer               = new CudaDeviceVariable <byte>(status.SumGetBufferSize());
            statusSum            = new CudaDeviceVariable <int>(1);



            CUmodule mod = ctx.LoadModulePTX("ShiftMinimizerKernels.ptx");

            concatenateShifts     = new concatenateShiftsKernel(ctx, mod);
            separateShifts        = new separateShiftsKernel(ctx, mod);
            getOptimalShifts      = new getOptimalShiftsKernel(ctx, mod);
            copyShiftMatrixKernel = new copyShiftMatrixKernel(ctx, mod);
            setPointers           = new setPointersKernel(ctx, mod);
            checkForOutliers      = new checkForOutliersKernel(ctx, mod);
            transposeShifts       = new transposeShiftsKernel(ctx, mod);

            setPointers.RunSafe(shiftMatrixArray, shiftMatrixSafeArray, matrixSquareArray, matrixInvertedArray, solvedMatrixArray,
                                shiftOneToOneArray, shiftMeasuredArray, shiftOptimArray, shiftMatrices, shiftSafeMatrices, matricesSquared,
                                matricesInverted, solvedMatrices, shiftsOneToOne, shiftsMeasured, shiftsOptim, aMaxTileCountX * aMaxTileCountY, frameCount, shiftCount);



            Reset();
        }