Example #1
0
        //! Start Pseudo BruteForce method

        /*!
         *  /param SChedulerInterface scheduler to run
         *  /param SchedulingProblem to solve
         *  /param Main mainform to update Information
         *  Currently can only be called with the greedy scheduler
         */
        public static void startBruteForce(SchedulerInterface scheduler, SchedulingProblem problem, Main mainform)
        {
            if (scheduler.GetType() == typeof(GreedyScheduler))
            {
                TimeMeasurement tm          = new TimeMeasurement();
                GreedyScheduler greedy      = (GreedyScheduler)scheduler;
                double          bestFitness = 0.0;
                for (int iteration = 0; iteration < problem.getContactWindows().Count(); iteration++)
                {
                    tm.activate();
                    greedy.BruteForceSchedule(problem, iteration);
                    mainform.updateCalculationTime(tm.getValueAndDeactivate());
                    ObjectiveFunction obj = problem.getObjectiveFunction();
                    obj.calculateValues(greedy.getFinischedSchedule());
                    mainform.updateCalculationTime(tm.getValueAndDeactivate());
                    mainform.setNumberOfGeneration(iteration);
                    if (bestFitness <= obj.getObjectiveResults())
                    {
                        bestFitness = obj.getObjectiveResults();
                        displayResults(mainform, scheduler, iteration);
                    }
                }
            }
            //else do nothing
        }
Example #2
0
        public bool runThisRun()
        {
            results = new List <string>();
            DataBase.DataBase db = new DataBase.DataBase();
            bool status          = true;
            List <Ground.Station> stationData = new List <Ground.Station>();

            for (int i = 0; i < stationList.Count; i++)
            {
                Ground.Station station = db.getStationFromDB(stationList[i]);
                stationData.Add(station);
                //updateLog(logfile, "Adding Station: " + station.getName());
            }
            System.Windows.Forms.Application.DoEvents();
            List <One_Sgp4.Tle> tleData = new List <Tle>();

            for (int i = 0; i < satelliteList.Count; i++)
            {
                One_Sgp4.Tle sattle = db.getTleDataFromDB(satelliteList[i]);
                tleData.Add(sattle);
                //updateLog(logfile, "Adding Satellite: " + sattle.getName());
            }
            System.Windows.Forms.Application.DoEvents();
            ContactWindowsVector contactsVector = MainFunctions2.calculateContactWindows(tleData, stationData, startTime, stopTime);

            System.Windows.Forms.Application.DoEvents();
            scheduler = null;
            switch (schedulerName)
            {
            case "Genetic":
                string[] settString = settings.Split(';');
                scheduler = new GeneticScheduler(Convert.ToInt32(settString[0]), Convert.ToInt32(settString[1]),
                                                 Convert.ToInt32(settString[2]), Convert.ToInt32(settString[4]), Convert.ToBoolean(settString[5]),
                                                 Convert.ToDouble(settString[6]), Convert.ToBoolean(settString[7]), Convert.ToBoolean(settString[8]));
                break;

            case "Greedy":
                scheduler = new GreedyScheduler();
                break;

            case "EFT-Greedy":
                scheduler = new EftGreedyScheduler();
                break;

            case "Hill-Climber":
                string[] settString2 = settings.Split(';');
                scheduler = new HillClimberScheduler(Convert.ToBoolean(settString2[0]), Convert.ToBoolean(settString2[2]),
                                                     Convert.ToInt32(settString2[1]));
                break;
            }
            ObjectiveFunction objective = new ObjectiveFunction(Forms.ObjectiveBuilderForm.getObjectiveEnumsByName(objectiveFunction));

            System.Windows.Forms.Application.DoEvents();
            SchedulingProblem problem = new SchedulingProblem();

            problem.setContactWindows(contactsVector);
            problem.removeUnwantedContacts(Properties.Settings.Default.orbit_Minimum_Contact_Duration_sec);
            problem.setObjectiveFunction(objective);
            problem.getContactWindows().randomize(Properties.Settings.Default.global_Random_Seed);
            getScenario(problem, scenario);
            System.Windows.Forms.Application.DoEvents();
            TimeMeasurement tm = new TimeMeasurement();

            tm.activate();
            scheduler.CalculateSchedule(problem);
            string time = tm.getValueAndDeactivate();

            System.Windows.Forms.Application.DoEvents();
            contactsVector = scheduler.getFinischedSchedule();
            System.Windows.Forms.Application.DoEvents();


            if (scheduler != null)
            {
                ObjectiveFunction objfunc = scheduler.getObjectiveFunction();
                if (objfunc == null)
                {
                    objfunc = new ObjectiveFunction();
                }
                objfunc.calculateValues(scheduler.getFinischedSchedule());

                double fitness = objfunc.getObjectiveResults();

                int    _H  = scheduler.getFinischedSchedule().getNrOfScheduled();
                double _H1 = objfunc.getScheduledContactsValue();
                int    _H2 = GeneralMeasurments.getNrOfConflicts(scheduler.getFinischedSchedule());
                double _H3 = objfunc.getStationFairnessValue();
                double _H4 = objfunc.getSatelliteFairnessValue();
                double _H5 = GeneralMeasurments.getDurationOfScheduledContacts(scheduler.getFinischedSchedule());

                results.Add("Run: " + schedulerName);
                results.Add("Fitness Value:" + objfunc.getObjectiveResults().ToString());
                results.Add("Scheduled Contacts: " + scheduler.getFinischedSchedule().getNrOfScheduled().ToString() + " / " + contactsVector.Count().ToString());
                results.Add("Collisions: " + GeneralMeasurments.getNrOfConflicts(scheduler.getFinischedSchedule()).ToString());
                results.Add("Fairnes Stations: " + objfunc.getStationFairnessValue().ToString());
                results.Add("Fairnes Satellites: " + objfunc.getSatelliteFairnessValue().ToString());
                results.Add("Duration: " + GeneralMeasurments.getDurationOfScheduledContacts(scheduler.getFinischedSchedule()).ToString() + " sec.");
                results.Add("Calculation Time: " + time);
                results.Add("Scheduled By Priority: " + GeneralMeasurments.getNrOfPrioritysScheduled(scheduler.getFinischedSchedule()));
                results.Add("Scheduled UWE-3: " + GeneralMeasurments.getNrOfUweContacts(scheduler.getFinischedSchedule()).ToString());

                //Log.writeResults(logfile, schedulerName, results);
                if (results == null)
                {
                    status = false;
                }
            }
            else
            {
                status = false;
            }
            cancel = false;
            return(status);
        }