コード例 #1
0
 //------------------------------------------------------------------------------
 // WARNING!!! - This function can overwrite information. PLEASE READ
 //
 // This makes the list of classes available over successive years. Current data
 // being used is for the duration of one year, therefore this function sets up
 // the machineNodes in such a way they work off the assumption that classes
 // will be held at the same time, on the same days, year after year.
 //------------------------------------------------------------------------------
 void normalizeMachines()
 {   //transfer all the same classes to the set of machine nodes
     if (quarters >= yearlength)
     {
         for (int i = yearlength; i < quarters; i++)
         {
             MachineNode oldMn = Quarters[i % yearlength];
             MachineNode newMn = Quarters[i];
             for (int j = 0; j < oldMn.GetMachines().Count; j++)
             {
                 Machine oldMachine = oldMn.GetMachines()[j];
                 Machine newMachine = new Machine(oldMachine);
                 newMachine.SetYear(i / yearlength);
                 newMn.AddMachine(newMachine);
             }
         }
         return;
     }
     else
     {
         return;
     }
 }
コード例 #2
0
        protected void ScheduleCourse(Job j)
        {
            if (IsScheduled(j))
            {
                return;
            }
            //we're always being called in order, no need to check for prereqs
            for (int i = 0; i < Quarters.Count; i++)
            {
                MachineNode mn = Quarters[i];
                // Check the number of credits scheduled per quarter make sure it does not exceed preference.
                // Check the number of core credits scheduled per quarter make sure it does not exceed preference.
                // TODO:    Add a default case. What if they dont have a preference should we assign all their classes in one quarter?
                //          Probably not...
                //System.Diagnostics.Debug.WriteLine("NUM OF CREDITS FOR JOB: " + j.GetNumCredits() + " CORE COURSE: " + j.GetCoreCourse());
                if (mn.GetCreditsScheduled() + j.GetNumCredits() > StudentPreferences.getCreditsPerQuarter() ||
                    (j.GetCoreCourse() && j.GetNumCredits() + mn.GetMajorCreditsScheduled() > StudentPreferences.getCoreCredits()))
                {
                    continue;
                }
                List <Machine> machines = mn.GetMachines();

                for (int k = 0; k < machines.Count; k++)
                {
                    //<<----------------------------INSERT DAY/TIME PREFERENCE AND CHECK AGAINST IT
                    Machine m = machines[k];
                    if (m.CanDoJob(j) && !m.CheckInUse())
                    {     //if not in use and it can do the job
                        if (Overlap(j, m, mn))
                        { //can't schedule it if the times overlap even if machine found
                            continue;
                        }
                        m.SetCurrentJobProcessing(j);
                        m.SetInUse(true);
                        j.SetScheduled(true);
                        j.SetQuarterScheduled(m.GetQuarter());
                        j.SetYearScheduled(m.GetYear());
                        // Need to update the machine node such that it reflects the new amount of credits, core credits, etc.
                        //mn.AddClassesScheduled(1);
                        mn.AddClassesScheduled(j);
                        Schedule.Add(m);
                        return;
                    }
                }
            }
        }
コード例 #3
0
        //------------------------------------------------------------------------------
        // HELPER FUNCTION FOR INITMACHINES()
        //
        // Adds a machine to the machine list for offered courses by first doing a search
        // amongst the machineNodes if the Course already exists there and acts
        // accordingly.
        //------------------------------------------------------------------------------
        void addMachine(Machine dummyMachine, Job job)
        {
            dummyMachine.AddJob(job); //adds job
            for (int i = 0; i < Quarters.Count; i++)
            {
                MachineNode    mn       = Quarters[i];
                List <Machine> machines = mn.GetMachines();
                if (machines.Count > 0)
                {
                    for (int j = 0; j < machines.Count; j++)
                    {
                        Machine m = machines[j];
                        if (m == dummyMachine)
                        { //found the machine, just add job
                            m.AddJob(job);
                            break;
                        }
                        else if (dummyMachine.GetYear().Equals(mn.GetYear()) && dummyMachine.GetQuarter().Equals(mn.GetQuarter()))
                        { //machine does not exist, add it in
                            machines.Add(dummyMachine);
                            break;
                        }
                    }
                }
                else if (dummyMachine.GetYear().Equals(mn.GetYear()) && dummyMachine.GetQuarter().Equals(mn.GetQuarter()))
                {
                    machines.Add(dummyMachine);
                    break;
                }
                else //in the instance that machines == 0 and either year or quarter were different
                {
                    //NOTE: This isn't so much an error as a bookkeeping check. Because CourseTime contains only 1 year
                    //      machines dated beyond the first year throw this error. So this is a database issue.

                    /*
                     * Console.WriteLine("Dummy Machine Year: " + dummyMachine.GetYear());
                     * Console.WriteLine("Dummy Machine Quarter: " + dummyMachine.GetQuarter());
                     * Console.WriteLine("Dummy Course ID: " + course);
                     * Console.WriteLine("mn Year: " + mn.GetYear());
                     * Console.WriteLine("mn Quarter: " + mn.GetQuarter());
                     * Console.WriteLine('\n');
                     */
                }
            }
        }