예제 #1
0
        public static void ReadfromFile(out int NoJob, out int NoMc, out int[] NoOp, out job[] Job)
        {
            //Reading input data from a file
            char[]       Dividers = { ',', ' ' };
            StreamReader InputSR;

            ReadInput.OpenFile(out InputSR);
            ReadInput.ReadFile1NoJobMc(InputSR, Dividers, out NoJob, out NoMc);
            NoOp = new int[NoJob];
            Job  = new job[NoJob];
            ReadInput.ReadFile2ProcessTimeMachineNo(InputSR, NoJob, ref NoOp, ref Job, Dividers);

            //For MaxWeightedTardiness & MaxWeightedEaeliness
            ReadInput.ReadFile3ReadyTime(InputSR, ref Job, Dividers);
            //For MaxWeightedTardiness & MaxWeightedEaeliness
            ReadInput.ReadFile4DueDate(InputSR, ref Job, Dividers, NoJob);
            //For MaxWeightedTardiness & MaxWeightedEaeliness
            ReadInput.ReadFile5WeightTardy1Line(InputSR, ref Job, Dividers, NoJob);
            InputSR.Close();
            //Ending for reading input data from a file
        }
예제 #2
0
        public static void Main(string[] args)
        {
            #region Read input from file
            int   NoJob;
            int   NoMc;
            int[] NoOp;
            job[] Job;
            ReadInput.ReadfromFile(out NoJob, out NoMc, out NoOp, out Job);
            #endregion
            #region calculateDimension
            int[]     NoOpPerMc = new int[NoMc];
            machine[] Machine   = new machine[NoMc];
            ReadInput.MachineInfo(NoJob, NoOp, ref NoOpPerMc, Job);
            JSPdata JD        = new JSPdata(NoJob, NoMc, NoOp, Job, NoOpPerMc, Machine);
            int     Dimension = 0;
            //To calculate Dimension = Sum of all NoOp
            for (int j = 0; j < NoJob; j++)
            {
                Dimension += NoOp[j];
            }
            #endregion

            About.showAbout();
            int    noVec  = 500;
            int    noIter = 500;
            int    noNB   = 4;
            double FMax   = 2;
            double FMin   = 1.5;
            //double F = 2; // amplify
            double CRx   = 0.5; //max crossover rate
            double CRn   = 0.1; //min crossover rate
            double Wmax  = 1;   // max weight
            double Wmin  = 0;   // min weight
            double cN    = 0;   // coefficient neighbor
            string oFile = "MyDE.xls";
            int    noRep = 2;

            int startReinit   = 501;  // inidicate reinitial
            int ReInitIterval = 501;  // indicate reinitial interval
            int startLS       = 101;  // indicate LS
            int LSinterval    = 101;  // indicate LS interval

            // starting time and finish time using DateTime datatype
            DateTime start, finish;

            // elapsed time using TimeSpan datatype
            TimeSpan elapsed;

            // opening output file
            TextWriter tw = new StreamWriter(oFile);
            tw.WriteLine("{0} Number of Vector  ", noVec);
            tw.WriteLine("{0} Number of Iteration ", noIter);
            tw.WriteLine("{0} Number of Neighbor  ", noNB);
            tw.WriteLine("{0} Parameter Fmax      ", FMax);
            tw.WriteLine("{0} Parameter Fmin      ", FMin);
            //tw.WriteLine("{0} Parameter F        ", F);
            tw.WriteLine("{0} Parameter CRmax        ", CRx);
            tw.WriteLine("{0} Parameter CRmin        ", CRn);
            tw.WriteLine("{0} Parameter cl        ", Wmin);
            tw.WriteLine("{0} Parameter cn        ", cN);
            tw.WriteLine("{0} Output File Name    ", oFile);
            tw.WriteLine("");


            for (int i = 0; i < noRep; i++)
            {
                Console.WriteLine("Replication {0}", i + 1);
                tw.WriteLine("Replication {0}", i + 1);
                // get the starting time from CPU clock
                start = DateTime.Now;

                // main program ...
                DE myDE = new newDE(noVec, noIter, noNB, FMax, FMin, CRx, CRn, Wmax, Wmin, cN, JD, Dimension, startReinit, ReInitIterval, startLS, LSinterval);
                myDE.Run(tw, true);

                myDE.DisplayResult(tw);
                Console.WriteLine("Obj = {0}", myDE.Pop.Vector[myDE.Pop.posBest].Objective);

                // get the finishing time from CPU clock
                finish  = DateTime.Now;
                elapsed = finish - start;

                // display the elapsed time in hh:mm:ss.milli
                tw.WriteLine("{0} is the computational time", elapsed.Duration());
                Console.WriteLine("{0} is the computational time", elapsed.Duration());
                tw.WriteLine("");
            }

            tw.Close();
        }