Exemplo n.º 1
0
        public static double[] InterExchangeCirticalPath(int NoJob, int NoMc, int[] NoOp, int[] NoOpPerMc,
                                                         int Dimension, double[] Position, double FitValue, machine[] Machine, job[] Job, ref Random RandomNum, ref JSPdata JD)
        {
            ArrayList Pair1   = new ArrayList(); //forward
            ArrayList Pair2   = new ArrayList();
            ArrayList Pair1BW = new ArrayList(); //backward
            ArrayList Pair2BW = new ArrayList();

            FitValue = FitnessValue.FitnessValueScheduleGJSP(NoJob, NoMc, NoOp, Position, Job, Dimension, NoOpPerMc, Machine, JD);
            CirticalPath(NoJob, NoMc, NoOp, NoOpPerMc, Machine, Job, ref Pair1, ref Pair2, ref Pair1BW, ref Pair2BW, ref RandomNum); //get possible pairs by defining a path (blocks)

            double[] AdjPosition    = new double[Dimension];
            double[] MinAdjPosition = new double[Dimension];
            double   AdjFitValue    = 0;
            double   MinAdjFitValue = FitValue;

            for (int i = 0; i < Dimension; i++)
            {
                MinAdjPosition[i] = Position[i];
            }

            int NoPair = Pair1.Count; //forward

            for (int l = 0; l < NoPair; l++)
            {
                int Locate1 = (int)Pair1[l];
                int Locate2 = (int)Pair2[l];
                if (Locate1 < Locate2) //"Locate1>Locate2" means leaps frogging Locate1 over Locate2 (Active Schedule)//
                {
                    for (int i = 0; i < Dimension; i++)
                    {
                        AdjPosition[i] = Position[i];
                    }
                    InterExchangeAPair(Dimension, ref AdjPosition, Locate1, Locate2);//InterExchange one pair to the position
                    AdjFitValue = FitnessValue.FitnessValueScheduleGJSP(NoJob, NoMc, NoOp, AdjPosition, Job, Dimension, NoOpPerMc, Machine, JD);

                    if (AdjFitValue < MinAdjFitValue)
                    {
                        MinAdjFitValue = AdjFitValue;
                        for (int i = 0; i < Dimension; i++)
                        {
                            MinAdjPosition[i] = AdjPosition[i];
                        }
                    }
                }
            }

            int NoPairBW = Pair1BW.Count; //backward

            for (int l = 0; l < NoPairBW; l++)
            {
                int Locate1 = (int)Pair1BW[l];
                int Locate2 = (int)Pair2BW[l];
                if (Locate1 < Locate2) //"Locate1>Locate2" means leaps frogging Locate1 over Locate2 (Active Schedule)//
                {
                    for (int i = 0; i < Dimension; i++)
                    {
                        AdjPosition[i] = Position[i];
                    }
                    InterExchangeAPairBW(Dimension, ref AdjPosition, Locate1, Locate2);//InterExchange one pair to the position
                    AdjFitValue = FitnessValue.FitnessValueScheduleGJSP(NoJob, NoMc, NoOp, AdjPosition, Job, Dimension, NoOpPerMc, Machine, JD);

                    if (AdjFitValue < MinAdjFitValue)
                    {
                        MinAdjFitValue = AdjFitValue;
                        for (int i = 0; i < Dimension; i++)
                        {
                            MinAdjPosition[i] = AdjPosition[i];
                        }
                    }
                }
            }

            return(MinAdjPosition);
        }
Exemplo n.º 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();
        }
Exemplo n.º 3
0
 public JSPdata JD; // JD, new object of newDE,in class JSPdata
 public newDE(int nVec, int nIter, int nNB, double Fmax, double Fmin, double croRx, double croRn, double dcg, double dcl, double dcn, JSPdata jd, int dim, int sRi, int Rii, int sLS, int LSi)
     : base(nIter, nNB, Fmax, Fmin, croRx, croRn, dcg, dcl, dcn, sRi, Rii, sLS, LSi)
 {
     base.SetDimension(nVec, dim);
     JD = new JSPdata(jd.NoJob, jd.NoMc, jd.NoOp, jd.Job, jd.NoOpPerMc, jd.Machine);
 }
Exemplo n.º 4
0
        //Evaluate Multi Objective Function
        public static double FitnessValueScheduleGJSP(int NoJob, int NoMc, int[] NoOp, double[] rPosition, job[] Job, int Dimension, int[] NoOpPerMc, machine[] Machine, JSPdata JD)
        {
            double[] Position = new double[Dimension];
            for (int i = 0; i < Dimension; i++)
            {
                Position[i] = rPosition[i]; // assign value of each dimension to Position array
            }
            PositionAdjust.SortingListRuleOnPosition(JD.NoJob, JD.NoOp, Dimension, ref Position);
            DecodeActiveSchedule.OprBasedDecodeActiveSchd(NoJob, NoMc, Position, Job, Dimension, NoOpPerMc, Machine);
            double ObjFn  = 0;
            double ObjFn2 = 0;
            double ObjFn3 = 0;
            double ObjFn4 = 0;
            double ObjFn5 = 0;

            ObjFn  = Cmax2(NoMc, NoOpPerMc, Machine);
            ObjFn2 = MaxWeightTardiness(NoJob, NoOp, Job);
            ObjFn3 = MaxWeightEarliness(NoJob, NoOp, Job);
            ObjFn4 = 0.4 * ObjFn + 0.3 * ObjFn2 + 0.3 * ObjFn3;
            ObjFn5 = TotalTardiness(NoJob, NoOp, Job);
            return //ObjFn;
                   //ObjFn2;
                   //ObjFn3;
                   //ObjFn4;
                   (ObjFn5);
        }