Esempio n. 1
0
        static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                //  There is input, processing it
                actionSelection(args[0]);
            }
            else
            {
                // No input, presenting the tool and then asking for instruction
                actionSelection("--information");
                // Asking for an option
                string option;

                do
                {
                    MyConsole.display("Please, enter a commande : ");
                    option = MyConsole.readInput().Replace(" ", string.Empty);

                    // Processing the option
                    actionSelection(option);
                }while (!option.Equals("--quit"));
                MyConsole.readInput();
            }
        }
Esempio n. 2
0
        private int fitnessUpdate = 0;                                  // Variable for number of fitness save


        // Class constructor using the excelfile path to call excel
        // application and read / write excel file
        public ExcelFile(string path)
        {
            this.path = path;                                           // Initialize workbook path
            try                                                         // try to open an excel application
            {
                excel = new Microsoft.Office.Interop.Excel.Application();
            }
            catch (Exception e)
            {
                MyConsole.displayError(e.ToString());
            }
        }
Esempio n. 3
0
        static public void applySecMethod(Model model, ExcelFile excelFile, string methodChoice)
        {
            switch (methodChoice)
            {
            case "--GRAS":
                GRAS methodGRAS = new GRAS(1f, model, excelFile);
                methodGRAS.apply();
                break;

            case "--SPT":
                SPT methodSPT = new SPT(model, excelFile);
                methodSPT.apply();
                break;

            case "--LPT":
                LPT methodLPT = new LPT(model, excelFile);
                methodLPT.apply();
                break;

            case "--EDD":
                EDD methodEDD = new EDD(model, excelFile);
                methodEDD.apply();
                break;

            case "--CR":
                CR methodCR = new CR(model, excelFile);
                methodCR.apply();
                break;

            case "--SES":
                SES methodSES = new SES(model, excelFile);
                methodSES.apply();
                break;

            case "--SLACK":
                SES methodSLACK = new SES(model, excelFile);
                methodSLACK.apply();
                break;

            case "A":
                MyConsole.displayError("Aborting operation...\n");
                break;

            default:
            {
                MyConsole.displayError("Input invalid, applying GRAS anyway... \n");
                GRAS methodDefault = new GRAS(1f, model, excelFile);
                methodDefault.apply();
            }
            break;
            }
        }
Esempio n. 4
0
 public void write(String value, int sheetIndex, int row, int colomn)
 {
     if (wb != null)
     {
         wb.Worksheets[sheetIndex].Cells[row, colomn].Value2 = value;
         wb.Save();
     }
     else
     {
         MyConsole.displayError("ERROR : ");
         MyConsole.displayError("Can't read a cell, the workbook couldn't be initilized or excel file is not open");
         MyConsole.displayError("Use instruction excelFile.open()");
     }
 }
Esempio n. 5
0
        public static void actionSelection(String option)
        {
            String mainMessage = "JOBSEC V" + version + "--------------------------------------------------\n" +
                                 "Designed by Ismail EL MOUANI- all rights reserved-----------\n\n\n" +


                                 "List of commands" +
                                 "--information  : display information regarding the tool.....\n" +
                                 "--schedule     : applying one of the method to schedule jobs\n" +
                                 "                 selection is done in a second time.........\n" +
                                 "--changeIO     : changing the IO Excel file.................\n" +
                                 "--readIOFile   : reding Input-Output file. Mandatory before.\n" +
                                 "                 scheduling\n" +
                                 "--quit         : Quiting JOBSEC.............................\n";

            switch (option)
            {
            case "--schedule":
                schedule();
                break;

            case "--information":
                MyConsole.displayMain(mainMessage);
                break;

            case "--changeIO":
                MyConsole.displayResult("changingIO");
                break;

            case "--readIOFile":
                string outPutDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase);
                string excelFilePath   = Path.Combine(outPutDirectory, "res\\ExcelFile.xlsx");
                excelFile = new ExcelFile(excelFilePath);
                model     = new Model(excelFile);
                if (excelFile == null || model == null)
                {
                    MyConsole.displayError("Couldn't red input file and/or initialize scheduling schema....");
                }
                break;


            case "--quit":
                MyConsole.displayResult("quiting, press a key...");
                break;

            default:
                MyConsole.displayResult("input parameter not identified !\n");
                break;
            }
        }
Esempio n. 6
0
        protected Solution buildSolution()
        {
            // Variables 
            Solution    solution        = new Solution(model);          // Initializing a new solution structure solution(vector x, vector y)    
            ArrayList   jobsToAssign    = new ArrayList();              // Array containing non assigned jobs ordered using Critical Ratio index
            int[]       RCL;                                            // Reduced Candidate List 
            int         selOrder;
            bool        constructOK     = true;

            

            // Iterative construction of solution 
           do
           {
                // Using the model and the precedure CR (Critical Ratio), the procedure orderJobs reorders the jobs ....
                // ...using CR. CR is defined under the Model class. Only not assigned job are considered ..............
                jobsToAssign = getJobsToAssign(solution);
               // Console.WriteLine($"-----job to assign : {jobsToAssign.Count}");
                if(jobsToAssign.Count >0)
                {
                    // Creating a Candidate list 
                    RCL = new int[(int)Math.Truncate(jobsToAssign.Count * pRCL)];
                    for (int i = 0; i < RCL.Length; i++)
                        RCL[i] = (int)jobsToAssign[i];

                    // Selecting at random a job to assign 
                    selOrder = RCL[rn.Next(RCL.Length)];
                    constructOK = model.assignJob(solution, selOrder,0);
                }
               

            }
            while (jobsToAssign.Count>0 && constructOK);

            if (constructOK)
            {
                model.finalize(solution);
                //Console.WriteLine($"-----solution fitness : {model.fitness(solution)}");
                return solution;
            }
            else
            {
                MyConsole.displayError("ERROR : Couldn't construct solution ");
                return null;
            }
           
           
        }
Esempio n. 7
0
                        f;                          // Stressors level induced by a reference processing



        // Constructor : initializing the indices limits ...
        // ...and input variables values
        public Model(ExcelFile excelFile)
        {
            readInputs(excelFile);
            if (checkInputConstraints())
            {
                MyConsole.displayResult("Do you wish to show the input read ? Yes(Y)/ No (N)");
                if (MyConsole.readInput().Equals("Y") || MyConsole.readInput().ToLower().Equals("yes"))
                {
                    showInputs();
                }
            }
            else
            {
                MyConsole.displayError("ERROR : input are not consitent ");
            }
        }
Esempio n. 8
0
 public void open()
 {
     if (excel == null)
     {
         MyConsole.displayError("Error ! couldn't create an excel application instance");
     }
     else
     {
         try
         {
             wb       = excel.Workbooks.Open(path);
             wbIsOpen = true;
         }
         catch (Exception e)
         {
             MyConsole.displayError("ERROR :");
             MyConsole.displayError(e.ToString());
         }
     }
 }
Esempio n. 9
0
        public double read(int sheetIndex, int row, int colomn)
        {
            if (wb != null)
            {
                try
                {
                    return(wb.Worksheets[sheetIndex].Cells[row, colomn].Value2);
                }
                catch (Exception e)
                {
                    MyConsole.displayError($"can't read sheet {sheetIndex}, cell {row},{colomn}");
                    MyConsole.displayError(e.ToString());
                    return(READ_OPERATION_FAILED);
                }
            }

            else
            {
                MyConsole.displayError("ERROR : ");
                MyConsole.displayError("Can't read a cell, the workbook couldn't be initilized or excel file is not open");
                MyConsole.displayError("Use instruction excelFile.open()");
                return(READ_OPERATION_FAILED);
            }
        }
Esempio n. 10
0
        public static void schedule()
        {
            if (excelFile == null || model == null)
            {
                MyConsole.displayError("model and/or IO file are not initialized yet\n" +
                                       "Please type --readIOFile");
            }

            else
            {
                MyConsole.display("Select the scheduling method : --GRAS\n" +
                                  "                               --SPT\n" +
                                  "                               --LPT\n" +
                                  "                               --EDD\n" +
                                  "                               --CR\n" +
                                  "                               --SES\n" +
                                  "                               --SALCK\n" +
                                  "                                Abort(A)");

                string methodChoice = MyConsole.readInput().Replace(" ", string.Empty);

                applySecMethod(model, excelFile, methodChoice);
            }
        }
Esempio n. 11
0
        // Reading input variables
        public void readInputs(ExcelFile excelFile)
        {
            // Reading input from the excel file
            MyConsole.displayMain("Reading input file ....");


            excelFile.open();

            I  = Convert.ToInt32(excelFile.read(ExcelFile.MAIN_SHEET_INDEX, 1, 2));
            K  = Convert.ToInt32(excelFile.read(ExcelFile.MAIN_SHEET_INDEX, 2, 2));
            J  = Convert.ToInt32(excelFile.read(ExcelFile.MAIN_SHEET_INDEX, 3, 2));
            T  = Convert.ToInt32(excelFile.read(ExcelFile.MAIN_SHEET_INDEX, 4, 2));
            dt = excelFile.read(ExcelFile.MAIN_SHEET_INDEX, 5, 2);
            C  = excelFile.read(ExcelFile.MAIN_SHEET_INDEX, 6, 2);
            numOfIterations = Convert.ToInt32(excelFile.read(ExcelFile.MAIN_SHEET_INDEX, 7, 2));
            S = Convert.ToInt32(excelFile.read(ExcelFile.MAIN_SHEET_INDEX, 8, 2));

            MyConsole.display("\nReading job batch sizes 'q'.... \n");
            q = new int[K];
            for (int compt = 0; compt < K; compt++)
            {
                q[compt] = Convert.ToInt32(excelFile.read(ExcelFile.QUANTITY_PER_ORDER_SHEET_INDEX, compt + 1, 1));
            }

            MyConsole.display("\nRelease dates 'a'.... \n");
            a = new int[K];
            for (int compt = 0; compt < K; compt++)
            {
                a[compt] = Convert.ToInt32(excelFile.read(ExcelFile.REFERENCE_RELASE_DATE_SHEET_INDEX, compt + 1, 1));
            }

            MyConsole.display("\nRelease dates 'l'.... \n");
            l = new int[K];
            for (int compt = 0; compt < K; compt++)
            {
                l[compt] = Convert.ToInt32(excelFile.read(ExcelFile.l_SHEET_INDEX, compt + 1, 1));
            }
            MyConsole.display("\nReading absolute due time 'd'.....\n");
            d = new int[I];
            for (int compt = 0; compt < I; compt++)
            {
                d[compt] = Convert.ToInt32(excelFile.read(ExcelFile.REFERENCE_DUE_DATE_SHEET_INDEX, compt + 1, 1));
            }

            Console.WriteLine("\nProcessing times 'p'.....\n");
            p = new int[I];
            for (int compt = 0; compt < I; compt++)
            {
                p[compt] = Convert.ToInt32(excelFile.read(ExcelFile.REFERENCE_PROCESSING_SHEET_INDEX, compt + 1, 1));
            }

            MyConsole.display("\nSetup times 's'....\n");
            s = new int[I];
            for (int compt = 0; compt < I; compt++)
            {
                s[compt] = Convert.ToInt32(excelFile.read(ExcelFile.REFERENCE_SETTING_TIME_SHEET_INDEX, compt + 1, 1));
            }

            MyConsole.display("\nReading references fitness weights 'alpha'\n");
            alpha = new float[I][];

            for (int compt = 0; compt < I; compt++)
            {
                alpha[compt] = new float[3];
            }

            for (int compt = 0; compt < I; compt++)
            {
                alpha[compt][0] = (float)excelFile.read(ExcelFile.REFERENCE_PRIORITY_SHEET_INDEX, compt + 1, 1);
                alpha[compt][1] = (float)excelFile.read(ExcelFile.REFERENCE_PRIORITY_SHEET_INDEX, compt + 1, 2);
                alpha[compt][2] = (float)excelFile.read(ExcelFile.REFERENCE_PRIORITY_SHEET_INDEX, compt + 1, 3);
            }

            MyConsole.display("\nReading task difficulties 'deta'....\n");
            deta = new float[I];
            for (int compt = 0; compt < I; compt++)
            {
                deta[compt] = (float)excelFile.read(ExcelFile.REFERENCE_DIFFICULTY_SHEET_INDEX, compt + 1, 1);
            }


            MyConsole.display("\nReading fatigue rate 'lamda'....\n");
            lamda = new float[I];
            mu    = new float[I];
            FatigueParametersGenerators fpg = new FatigueParametersGenerators();

            for (int compt = 0; compt < I; compt++)
            {
                float[] stressFactors = new float[S];
                for (int sfi = 0; sfi < S; sfi++)                 // sfi : Stress Factor Index
                {
                    stressFactors[sfi] = Convert.ToSingle(excelFile.read(ExcelFile.REFERENCE_STRESS_FACTORS_SHEET_INDEX, sfi + 2, compt + 2));
                }

                lamda[compt] = fpg.genFatigueRate(stressFactors)[FatigueParametersGenerators.IFATIGUE_RATE];
                mu[compt]    = fpg.genFatigueRate(stressFactors)[FatigueParametersGenerators.IRECOVERY_RATE];
            }

            /*MyConsole.display("\nReading recovery rate 'mu'....\n");
             *
             * for (int compt = 0; compt < I; compt++)
             * {
             *  mu[compt] = excelFile.read(ExcelFile.REFERENCE_RECOVERY_RATE_SHEET_INDEX, compt + 1, 1);
             *
             * }*/

            MyConsole.display("\nReading machine states 'v'....\n");
            v = new int[T][];
            for (int compt = 0; compt < T; compt++)
            {
                v[compt] = new int[J];
            }

            ProgressBar progress = new ProgressBar();

            {
                for (int compt = 0; compt < T; compt++)
                {
                    for (int compt2 = 0; compt2 < J; compt2++)
                    {
                        v[compt][compt2] = Convert.ToInt32(excelFile.read(ExcelFile.MACHINE_LOAD_SHEET_INDEX, compt + 1, compt2 + 1));
                    }
                    progress.Report((double)compt / T);
                }

                progress.Dispose();
            }


            MyConsole.display("\nReading job's references 'z'....\n");
            z = new int[K][];
            for (int compt = 0; compt < K; compt++)
            {
                z[compt] = new int[I];
            }

            for (int compt = 0; compt < K; compt++)
            {
                for (int compt2 = 0; compt2 < I; compt2++)
                {
                    z[compt][compt2] = Convert.ToInt32(excelFile.read(ExcelFile.REFERENCE_PER_ORDER_SHEET_INDEX, compt + 1, compt2 + 1));
                }
            }

            excelFile.close();
        }
Esempio n. 12
0
        public void showInputs()
        {
            MyConsole.display("Inputs ................");
            MyConsole.display($"Number of references I = {I}");
            MyConsole.display($"Number of orders K = {K}");
            MyConsole.display($"Number of workstations J = {J}");
            MyConsole.display($"Horizon T = {T}");
            MyConsole.display($"HEP coefficient C = {C}");

            MyConsole.display(" Quantity per order : ");
            for (int compt = 0; compt < K; compt++)
            {
                MyConsole.display($" q({compt}) = {q[compt]} ");
            }


            MyConsole.display(" release dates : ");
            for (int compt = 0; compt < K; compt++)
            {
                MyConsole.display($" a({compt}) = {a[compt]} ");
            }

            MyConsole.display(" time in queue at rescheduling : ");
            for (int compt = 0; compt < K; compt++)
            {
                MyConsole.display($" l({compt}) = {l[compt]} ");
            }


            MyConsole.display(" References' due date : ");
            for (int compt = 0; compt < I; compt++)
            {
                MyConsole.display($" d({compt}) = {d[compt]} ");
            }

            MyConsole.display(" References' processing times : ");
            for (int compt = 0; compt < I; compt++)
            {
                MyConsole.display($" p({compt}) = {p[compt]} ");
            }

            MyConsole.display(" References' setting times : ");
            for (int compt = 0; compt < I; compt++)
            {
                MyConsole.display($" s({compt}) = {s[compt]} ");
            }


            MyConsole.display(" References' priorities : ");
            for (int compt = 0; compt < I; compt++)
            {
                MyConsole.display($" alpha({compt},1) = {alpha[compt][0]} ");
                MyConsole.display($" alpha({compt},2) = {alpha[compt][1]} ");
            }

            MyConsole.display(" References' difficulties : ");
            for (int compt = 0; compt < I; compt++)
            {
                MyConsole.display($" deta({compt}) = {deta[compt]} ");
            }


            MyConsole.display(" References' fatigue rate  : ");
            for (int compt = 0; compt < I; compt++)
            {
                MyConsole.display($" lamda({compt}) = {lamda[compt]} ");
            }


            MyConsole.display(" References' recovery rate : ");
            for (int compt = 0; compt < I; compt++)
            {
                MyConsole.display($" mu({compt}) = {mu[compt]} ");
            }


            MyConsole.display(" Machine initial load : ");
            for (int compt = 0; compt < T; compt++)
            {
                MyConsole.display("\n");
                for (int compt2 = 0; compt2 < J; compt2++)
                {
                    MyConsole.display($" v({compt}, {compt2}) = {v[compt][compt2]}\t");
                }
            }

            MyConsole.display("\n Reference per order : ");
            for (int compt = 0; compt < K; compt++)
            {
                MyConsole.display("\n");
                for (int compt2 = 0; compt2 < I; compt2++)
                {
                    MyConsole.display($" z({compt}, {compt2}) = {z[compt][compt2]}\t");
                }
            }
        }