コード例 #1
0
        public List <PrimitiveTriple <float, float, float> > GenerateGroundPositions(int numPositions, Platform2DLaydown laydown)
        {
            laydown.numMean   = numPositions;
            laydown.numStdDev = 0;
            laydown.numMin    = 0;
            laydown.numMax    = numPositions;

            return(laydown.Generate(trialGenerator.GetGridMath(), trialGenerator.GetRand()));
        }
コード例 #2
0
        public void GenerateConfigFiles()
        {
            // Find out trial number formatting
            int    numTrialDigits = numMCTrials.ToString().Length;
            string toStringFormat = "D" + numTrialDigits.ToString();

            // Generate each trial
            SoaConfig soaConfig;
            List <PrimitiveTriple <float, float, float> > randomizedPositions;

            for (int trial = 1; trial <= numMCTrials; trial++)
            {
                // Status message
                Log.debug("Generating config file " + soaConfigFileHeader + trial.ToString(toStringFormat) + ".xml");

                // Initialize remote platform ID assignment
                availableRemoteID = remoteStartID;

                // Create a new SoaConfig object
                soaConfig = new SoaConfig();

                // Populate network
                soaConfig.networkRedRoom  = networkRedRoomHeader + trial.ToString(toStringFormat);
                soaConfig.networkBlueRoom = networkBlueRoomHeader + trial.ToString(toStringFormat);

                // Logger configuration
                soaConfig.loggerOutputFile        = soaLoggerFileHeader + trial.ToString(toStringFormat) + ".xml";
                soaConfig.enableLogToFile         = true;
                soaConfig.enableLogEventsToFile   = logEvents;
                soaConfig.enableLogToUnityConsole = logToUnityConsole;

                // Simulation configuration
                soaConfig.simulationRandomSeed     = simulationRandomSeed;
                soaConfig.gameDurationHr           = gameDurationHr;
                soaConfig.probRedDismountHasWeapon = probRedDismountHasWeapon;
                soaConfig.probRedTruckHasWeapon    = probRedTruckHasWeapon;
                soaConfig.probRedTruckHasJammer    = probRedTruckHasJammer;

                // Populate fuel defaults
                soaConfig.defaultSmallUAVFuelTankSize_s = defaultSmallUAVFuelTankSize_s;
                soaConfig.defaultHeavyUAVFuelTankSize_s = defaultHeavyUAVFuelTankSize_s;

                // Populate storage defaults
                soaConfig.defaultHeavyUAVNumStorageSlots    = defaultHeavyUAVStorageSlots;
                soaConfig.defaultRedDismountNumStorageSlots = defaultRedDismountStorageSlots;
                soaConfig.defaultRedTruckNumStorageSlots    = defaultRedTruckStorageSlots;

                // Set sensor and classifier defaults
                SetSensorDefaults(soaConfig);
                SetClassifierDefaults(soaConfig);

                // Set comms and jammer defaults
                SetCommsDefaults(soaConfig);
                SetJammerDefaults(soaConfig);

                // Initialize and set site locations
                SetSiteLocations(soaConfig);

                // Initialize platform laydown
                InitializeLocalLaydown();
                InitializeRemoteLaydown();

                // Local units: Red Dismount
                randomizedPositions = redDismountLaydown.Generate(gridMath, rand);
                for (int i = 0; i < randomizedPositions.Count; i++)
                {
                    soaConfig.localPlatforms.Add(new RedDismountConfig(
                                                     randomizedPositions[i].first,  // x
                                                     randomizedPositions[i].second, // y
                                                     randomizedPositions[i].third,  // z
                                                     new Optional <int>(),          // id
                                                     new Optional <float>(),        // sensorBeamwidth_deg
                                                     new Optional <string>(),       // initialWaypoint
                                                     new Optional <bool>(),         // hasWeapon
                                                     new Optional <float>(),        // commsRange_km
                                                     new Optional <int>()           // numStorageSlots
                                                     ));
                }

                // Local units: Red Truck
                randomizedPositions = redTruckLaydown.Generate(gridMath, rand);
                for (int i = 0; i < randomizedPositions.Count; i++)
                {
                    soaConfig.localPlatforms.Add(new RedTruckConfig(
                                                     randomizedPositions[i].first,  // x
                                                     randomizedPositions[i].second, // y
                                                     randomizedPositions[i].third,  // z
                                                     new Optional <int>(),          // id
                                                     new Optional <float>(),        // sensorBeamwidth_deg
                                                     new Optional <string>(),       // initialWaypoint
                                                     new Optional <bool>(),         // hasWeapon
                                                     new Optional <bool>(),         // hasJammer
                                                     new Optional <float>(),        // commsRange_km
                                                     new Optional <float>(),        // jammerRange_km
                                                     new Optional <int>()           // numStorageSlots
                                                     ));
                }

                // Local units: Neutral Dismount
                randomizedPositions = neutralDismountLaydown.Generate(gridMath, rand);
                for (int i = 0; i < randomizedPositions.Count; i++)
                {
                    soaConfig.localPlatforms.Add(new NeutralDismountConfig(
                                                     randomizedPositions[i].first,  // x
                                                     randomizedPositions[i].second, // y
                                                     randomizedPositions[i].third,  // z
                                                     new Optional <int>(),          // id
                                                     new Optional <float>()         // sensorBeamwidth_deg
                                                     ));
                }

                // Local units: Neutral Truck
                randomizedPositions = neutralTruckLaydown.Generate(gridMath, rand);
                for (int i = 0; i < randomizedPositions.Count; i++)
                {
                    soaConfig.localPlatforms.Add(new NeutralTruckConfig(
                                                     randomizedPositions[i].first,  // x
                                                     randomizedPositions[i].second, // y
                                                     randomizedPositions[i].third,  // z
                                                     new Optional <int>(),          // id
                                                     new Optional <float>()         // sensorBeamwidth_deg
                                                     ));
                }

                // Local units: Blue Police
                randomizedPositions = bluePoliceLaydown.Generate(gridMath, rand);
                for (int i = 0; i < randomizedPositions.Count; i++)
                {
                    soaConfig.localPlatforms.Add(new BluePoliceConfig(
                                                     randomizedPositions[i].first,  // x
                                                     randomizedPositions[i].second, // y
                                                     randomizedPositions[i].third,  // z
                                                     new Optional <int>(),          // id
                                                     new Optional <float>(),        // sensorBeamwidth_deg
                                                     new Optional <float>()         // commsRange_km
                                                     ));
                }

                // Remote units: Heavy UAV
                randomizedPositions = heavyUAVLaydown.Generate(gridMath, rand);
                for (int i = 0; i < randomizedPositions.Count; i++)
                {
                    soaConfig.remotePlatforms.Add(new HeavyUAVConfig(
                                                      randomizedPositions[i].first,  // x
                                                      randomizedPositions[i].second, // y
                                                      randomizedPositions[i].third,  // z
                                                      availableRemoteID++,           // id
                                                      new Optional <float>(),        // sensorBeamwidth_deg
                                                      new Optional <float>(),        // commsRange_km
                                                      new Optional <float>(),        // fuelTankSize_s
                                                      new Optional <int>()           // numStorageSlots
                                                      ));
                }

                // Remote units: Small UAV
                randomizedPositions = smallUAVLaydown.Generate(gridMath, rand);
                for (int i = 0; i < randomizedPositions.Count; i++)
                {
                    soaConfig.remotePlatforms.Add(new SmallUAVConfig(
                                                      randomizedPositions[i].first,  // x
                                                      randomizedPositions[i].second, // y
                                                      randomizedPositions[i].third,  // z
                                                      availableRemoteID++,           // id
                                                      new Optional <float>(),        // sensorBeamwidth_deg
                                                      new Optional <float>(),        // commsRange_km
                                                      new Optional <float>()         // fuelTankSize_s
                                                      ));
                }

                // Remote units: Blue Balloon
                List <PrimitivePair <float, float> > balloonWaypoints = new List <PrimitivePair <float, float> >();
                balloonWaypoints.Add(new PrimitivePair <float, float>(-28, 0));
                balloonWaypoints.Add(new PrimitivePair <float, float>(29, 0));
                soaConfig.remotePlatforms.Add(new BlueBalloonConfig(
                                                  availableRemoteID++,    // id
                                                  new Optional <float>(), // sensorBeamwidth_deg
                                                  balloonWaypoints,
                                                  true
                                                  ));

                // Create output directory if it does not already exist and Write SoaConfig contents to a config file
                Directory.CreateDirectory(soaConfigOutputPath);
                SoaConfigXMLWriter.Write(soaConfig, Path.Combine(soaConfigOutputPath, soaConfigFileHeader + trial.ToString(toStringFormat) + ".xml"));
            } // End current trial
        }