Esempio n. 1
0
        public override void DisplayResult(TextWriter t)
        {
            double obj = 0;

            t.WriteLine("");
            t.WriteLine("Result:");
            t.WriteLine("-------");
            for (int i = 0; i < this.Pop.Vector[this.Pop.posBest].Dimension; i++) // foreach dimension of best vector
            {
                t.WriteLine("x({0}) = {1}", i, this.Pop.Vector[this.Pop.posBest].CurrentVector[i]);
            }
            t.WriteLine("f(x) = {0}", this.Pop.Vector[this.Pop.posBest].Objective);

            for (int i = 0; i < this.Pop.Member; i++)//display assigned machine for each operation of the best vector
            {
                if (i == this.Pop.posBest)
                {
                    FitnessValue.FitnessValueScheduleGJSP(JD.NoJob, JD.NoMc, JD.NoOp, this.Pop.Vector[i].CurrentVector, JD.Job, this.Pop.Vector[i].Dimension, JD.NoOpPerMc, JD.Machine, JD);
                    for (int j = 0; j < JD.NoJob; j++)
                    {
                        t.WriteLine("");
                        t.WriteLine("J{0}\t Start\t End\n", j + 1);
                        for (int k = 0; k < JD.NoOp[j]; k++)
                        {
                            t.WriteLine("{0} \t {1} \t {2} ", k + 1, JD.Job[j].Operation[k].StartTime, JD.Job[j].Operation[k].EndTime);
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        public override double Objective(DecisionVector P, int trial)
        {
            double obj = 0;

            if (trial == 0)
            {
                obj = FitnessValue.FitnessValueScheduleGJSP(JD.NoJob, JD.NoMc, JD.NoOp, P.CurrentVector, JD.Job, P.Dimension, JD.NoOpPerMc, JD.Machine, JD);
            }
            if (trial == 1)
            {
                obj = FitnessValue.FitnessValueScheduleGJSP(JD.NoJob, JD.NoMc, JD.NoOp, P.TrialVector, JD.Job, P.Dimension, JD.NoOpPerMc, JD.Machine, JD);
            }

            return(obj);
        }
Esempio n. 3
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);
        }