public spM2DE(int nVec, int nIter, int nNB, double Fmax, double Fmin, double croRx, double croRn, int dim, JSPdata jd, int maxE, int moveStr, ArrayList vm, double te, double be, double gap) : base(nIter, nNB, Fmax, Fmin, croRx, croRn, dim, jd, maxE, moveStr, vm) { JD = new JSPdata(jd.NoJob, jd.NoMc, jd.NoOp, jd.Job, jd.NoOpPerMc, jd.Machine); int nObj = 2; //bool constr = false; base.SetParameters(nVec, dim, nObj, te, be, gap); //number of vectors, dimension, //number of objective (+1 if ms6 is used, and +1 more if there are constraints in the model //and constraint activator (true if there are any constrains in the model //define problem }
//Evaluate Multi Objective Function public void ScheduleGJSP(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]; } PositionAdjust.SortingListRuleOnPosition(JD.NoJob, JD.NoOp, Dimension, ref Position); DecodeActiveSchedule.OprBasedDecodeActiveSchd(NoJob, NoMc, Position, Job, Dimension, NoOpPerMc, Machine); }
public static void DE(double[] DEparas, int strategy, bool aniEnable, out double[] index, out ArrayList Pareto, out ArrayList Ani, out ArrayList AniS, out ArrayList Average) { // modification = criterion to join unexplored group is the range > 0.01*maxrange (excel) // trap=100 steps #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 #region Animation Storage ArrayList PFront; ArrayList sAni; ArrayList sAni2; ArrayList[] AvgVal; ArrayList vMix = new ArrayList(); string oFile = "MyDE_strategy" + strategy.ToString() + ".xls"; PFront = new ArrayList(); sAni = new ArrayList(); sAni2 = new ArrayList(); #endregion #region set DE parameters //parameter setting int noIter = Convert.ToInt32(DEparas[0]); int noVec = Convert.ToInt32(DEparas[1]); double FMin = DEparas[2]; double FMax = DEparas[3]; int noNB = Convert.ToInt32(DEparas[4]); double COx = DEparas[5]; double COn = DEparas[6]; double cL = DEparas[7]; double cN = DEparas[8]; int maxE = Convert.ToInt32(DEparas[9]); double TopEp = DEparas[10] / 100; double BotEp = DEparas[11] / 100; double GapUnexplore = DEparas[12] / 100; int moveStrategy = strategy; int rSeed = (int)DEparas[17]; int noRep = (int)DEparas[18]; // end parameter setting if (moveStrategy == 5) { vMix.Add(0); vMix.Add((double)DEparas[13] / 100); vMix.Add(1); vMix.Add((double)DEparas[14] / 100); vMix.Add(2); vMix.Add((double)DEparas[15] / 100); vMix.Add(3); vMix.Add((double)DEparas[16] / 100); } #endregion // starting time and finish time using DateTime datatype DateTime start, finish; // elapsed time using TimeSpan datatype TimeSpan elapsed; #region Write parameter to text // opening output file TextWriter tw = new StreamWriter(oFile); tw.WriteLine("{0} Number of Vectors ", 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 crox ", COx); tw.WriteLine("{0} Parameter cron ", COn); tw.WriteLine("{0} Parameter cl ", cL); tw.WriteLine("{0} Parameter cn ", cN); tw.WriteLine("{0} Output File Name ", oFile); tw.WriteLine("Number of replications" + "\t" + "{0}", noRep); tw.WriteLine(""); #endregion AvgVal = new ArrayList[noRep]; for (int i = 0; i < noRep; i++) { rSeed++; AvgVal[i] = new ArrayList(); Console.WriteLine("Replication {0}", i + 1); tw.WriteLine("Replication {0}", i + 1); // get the starting time from CPU clock start = DateTime.Now; // main program ... M2DE GlobalPop = new spM2DE(noVec, noIter, noNB, FMax, FMin, COx, COn, Dimension, JD, maxE, moveStrategy, vMix, TopEp, BotEp, GapUnexplore); GlobalPop.SetRSeed(rSeed); GlobalPop.Run(tw, true, aniEnable, AvgVal[i], out sAni, out sAni2); // 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()); tw.WriteLine(""); if (i == 0) { PFront = GlobalPop.ElististP; } } tw.Close(); #region Finalize animation data Average = new ArrayList(); index = new double[AvgVal[0].Count]; for (int i = 0; i < AvgVal[0].Count; i++) { index[i] = (double)i; } for (int o = 0; o < ((double[])(AvgVal[0])[0]).Length; o++) { double[] Avg = new double[AvgVal[0].Count]; for (int i = 0; i < AvgVal[0].Count; i++) { Avg[i] = (double)(((double[])(AvgVal[0])[i])[o]); } Average.Add(Avg); } Pareto = PFront; Ani = sAni; AniS = sAni2; #endregion }