Пример #1
0
        //! returns the fitness value of current set

        /*!
         *  /param Contact Windows Vector
         *  /return double fitnessValue
         */
        private double getFitness(ContactWindowsVector contacts)
        {
            objective.calculateValues(contacts);
            return(objective.getObjectiveResults());
        }
Пример #2
0
        //! Calculate scheduling solution from certain startpoint

        /*!
         *  calculate a schedule from a certain starting point
         *  if iterating trhough every contact window can be used to brute force
         *  the scheduling solution
         *  \param ScheduleProblemInterface to solve scheduling problem
         *  \param int point from which to start from
         */
        public void BruteForceSchedule(ScheduleProblemInterface problem, int step)
        {
            objective = problem.getObjectiveFunction();
            set       = problem.getContactWindows();
            int nrOfAllContacts = set.Count();

            ContactWindowsVector set1 = new ContactWindowsVector();
            ContactWindowsVector set2 = new ContactWindowsVector();

            //double maxFitness = 0.0;
            int count = 0;

            set1.add(set.getAt(step));
            set.deleteAt(step);

            while (!isComplete())
            {
                int    pos        = -1;
                double maxFitness = 0.0;
                for (int i = 0; i < set.Count(); i++)
                {
                    objective.calculateValues(set1, set, nrOfAllContacts, set.getAt(i));
                    double fitness = objective.getObjectiveResults();
                    if (fitness > maxFitness)
                    {
                        maxFitness = fitness;
                        pos        = i;
                    }
                    if (Properties.Settings.Default.global_MaxPerf == false)
                    {
                        System.Windows.Forms.Application.DoEvents();
                    }
                }

                bool found = false;
                if (pos >= 0)
                {
                    for (int i = 0; i < set1.Count(); i++)
                    {
                        if (set.getAt(pos).checkConflikt(set1.getAt(i)))
                        {
                            if (set.getAt(pos).getSatName() == set1.getAt(i).getSatName() ||
                                set.getAt(pos).getStationName() == set1.getAt(i).getStationName())
                            {
                                set2.add(set.getAt(pos));
                                set2.getLast().unShedule();
                                set.deleteAt(pos);
                                found = true;
                                break;
                            }
                        }
                        if (Properties.Settings.Default.global_MaxPerf == false)
                        {
                            System.Windows.Forms.Application.DoEvents();
                        }
                    }
                    if (!found)
                    {
                        set1.add(set.getAt(pos));
                        set1.getLast().setSheduled();
                        set.deleteAt(pos);
                    }
                }
                else
                {
                    count++;
                }
            }
            set.add(set1);
            set.add(set2);
            schedule = set;
        }
Пример #3
0
        //! Checks the fitness of the current population

        /*!
         *  \param ContactWindowsVector contactwindows to check against
         *  \param int[] current population to check fitness
         *  \return double fittness of the current populus
         *  The Fitness is defined by the objective Function
         *  from 1.0 to 0 with 1.0 being optimal
         */
        private double checkFitness(int[] pop)
        {
            objective.calculateValues(set, pop);
            return(objective.getObjectiveResults());
        }