static void Main(string[] args) { int status = 127; try { OplFactory.DebugMode = true; OplFactory oplF = new OplFactory(); OplErrorHandler errHandler = oplF.CreateOplErrorHandler(Console.Out); OplModelSource modelSource = oplF.CreateOplModelSourceFromString(GetModelText(), "carseq"); OplSettings settings = oplF.CreateOplSettings(errHandler); OplModelDefinition def = oplF.CreateOplModelDefinition(modelSource, settings); CP cp = oplF.CreateCP(); OplModel opl = oplF.CreateOplModel(def, cp); OplDataSource dataSource = new MyData(oplF); opl.AddDataSource(dataSource); opl.Generate(); if (cp.Solve()) { Console.Out.WriteLine("OBJECTIVE: " + opl.CP.ObjValue); opl.PostProcess(); opl.PrintSolution(Console.Out); status = 0; } else { Console.Out.WriteLine("No solution!"); status = 1; } oplF.End(); } catch (ILOG.OPL.OplException ex) { Console.WriteLine(ex.Message); status = 2; } catch (ILOG.Concert.Exception ex) { Console.WriteLine(ex.Message); status = 3; } catch (System.Exception ex) { Console.WriteLine(ex.Message); status = 4; } Environment.ExitCode = status; Console.WriteLine("--Press <Enter> to exit--"); Console.ReadLine(); }
static void Main(string[] args) { int status = 127; try { OplFactory.DebugMode = true; OplFactory oplF = new OplFactory(); OplErrorHandler errHandler = oplF.CreateOplErrorHandler(Console.Out); OplModelSource modelSource = oplF.CreateOplModelSourceFromString(GetModelText(), "carseq"); OplSettings settings = oplF.CreateOplSettings(errHandler); OplModelDefinition def = oplF.CreateOplModelDefinition(modelSource, settings); CP cp = oplF.CreateCP(); OplModel opl = oplF.CreateOplModel(def, cp); OplDataSource dataSource = new MyData(oplF); opl.AddDataSource(dataSource); opl.Generate(); if (cp.Solve()) { Console.Out.WriteLine("OBJECTIVE: " + opl.CP.ObjValue); opl.PostProcess(); opl.PrintSolution(Console.Out); status = 0; } else { Console.Out.WriteLine("No solution!"); status = 1; } oplF.End(); } catch (ILOG.OPL.OplException ex) { Console.WriteLine(ex.Message); status = 2; } catch (ILOG.Concert.Exception ex) { Console.WriteLine(ex.Message); status = 3; } catch (System.Exception ex) { Console.WriteLine(ex.Message); status = 4; } Environment.ExitCode=status; Console.WriteLine("--Press <Enter> to exit--"); Console.ReadLine(); }
public void RescheduleLotMachineAllocation() { // Clear scheduled lots foreach (Machine machine in LithographyArea.Machines) { ScheduledLotsPerMachine[machine.Name].Clear(); } // Set weight of each Lot for (int j = 0; j < Queue.Length; j++) { Lot peekLot = Queue.PeekAt(j); Queue.PeekAt(j).WeightDueDate = GetDueDateWeight(peekLot); Queue.PeekAt(j).WeightWIPBalance = GetWIPBalanceWeight(peekLot); } int status = 127; string solutionAsString = ""; try { OplFactory.DebugMode = false; OplFactory oplF = new OplFactory(); OplErrorHandler errHandler = oplF.CreateOplErrorHandler(Console.Out); OplModelSource modelSource = oplF.CreateOplModelSource($"{Directory.GetCurrentDirectory()}/Input/LithoFinal.mod"); OplSettings settings = oplF.CreateOplSettings(errHandler); OplModelDefinition def = oplF.CreateOplModelDefinition(modelSource, settings); // Change stream to be able to read solution as a string (probably not the correct way of doing) StringWriter strWriter = new StringWriter(); oplF.SetOut(strWriter); CP cp = oplF.CreateCP(); OplModel opl = oplF.CreateOplModel(def, cp); OplDataSource dataSource = new MyCustomDataSource(oplF, Queue, LithographyArea, this); opl.AddDataSource(dataSource); opl.Generate(); if (cp.Solve()) { Console.Out.WriteLine("OBJECTIVE: " + opl.CP.ObjValue); opl.PostProcess(); // Get solution as string solutionAsString = strWriter.ToString(); status = 0; } else { Console.Out.WriteLine("No solution!"); status = 1; this.LithographyArea.HandleDispatcherError(); ScheduleEndEvent(GetTime); return; } oplF.End(); } catch (OplException ex) { Console.WriteLine(ex.Message); status = 2; } catch (ILOG.Concert.Exception ex) { Console.WriteLine(ex.Message); status = 3; } catch (System.Exception ex) { Console.WriteLine(ex.Message); status = 4; } //Console.WriteLine("--Press <Enter> to exit--"); //Console.WriteLine(status); //Console.ReadLine(); //Console.WriteLine(solutionAsString); //Console.ReadLine(); ChangeLotMachineAllocation(solutionAsString); Console.WriteLine($"Scheduled for {LithographyArea.StartDate.AddSeconds(GetTime)}"); }