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()); } }
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; } }
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()"); } }
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; } }
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; } }
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 "); } }
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()); } } }
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); } }
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); } }