private void GetCostWeights(OplDataHandler handler) { // initialize the tuple set 'CostFunctionWeights' handler.StartElement("CostFunctionWeights"); handler.StartSet(); // Add tuple handler.StartTuple(); handler.AddStringItem("a"); handler.AddNumItem(LithographyArea.WeightA); handler.EndTuple(); // Add tuple handler.StartTuple(); handler.AddStringItem("b"); handler.AddNumItem(LithographyArea.WeightB); handler.EndTuple(); // Add tuple handler.StartTuple(); handler.AddStringItem("c"); handler.AddNumItem(LithographyArea.WeightC); handler.EndTuple(); handler.EndSet(); handler.EndElement(); }
private void GetProductAuxResources(OplDataHandler handler) { // initialize the tuple set 'Products' handler.StartElement("ProductAuxResources"); handler.StartSet(); List <Lot> allLots = new List <Lot>(); // Loop through queue for (int i = 0; i < Queue.Length; i++) { // Peek next lot in queue Lot peekLot = Queue.PeekAt(i); allLots.Add(peekLot); } foreach (Machine machine in LithographyArea.Machines) { if (machine.Queue.Length > 0) { Lot lotAtMachine = machine.Queue.PeekFirst(); allLots.Add(lotAtMachine); } } List <string> productNames = new List <string>(); // Loop through queue foreach (Lot lot in allLots) { string productName = lot.MasksetLayer_RecipeStepCluster; if (!productNames.Contains(productName)) { // Add tuple handler.StartTuple(); handler.AddIntItem(ProductNameToID[productName]); handler.AddStringItem(lot.ReticleID1); handler.EndTuple(); // Add tuple handler.StartTuple(); handler.AddIntItem(ProductNameToID[productName]); handler.AddStringItem(lot.IrdName); handler.EndTuple(); productNames.Add(productName); } } handler.EndSet(); handler.EndElement(); }
/// <summary> /// Reads a table and inject it as a tuple set in OPL. /// </summary> /// <param name="name">The name of the Data Set</param> /// <param name="reader">The SqlDataReader to read from</param> private void ReadTupleSet(String name, DbDataReader reader) { OplDataHandler handler = DataHandler; OplElement element = handler.getElement(name); ITupleSchema schema = element.AsTupleSet().Schema; int size = schema.Size; String[] oplFieldsName = new String[size]; OplElementDefinitionType.Type[] oplFieldsType = new OplElementDefinitionType.Type[size]; this.FillNamesAndTypes(schema, oplFieldsName, oplFieldsType); handler.StartElement(name); handler.StartSet(); while (reader.Read()) { handler.StartTuple(); for (int column = 0; column < oplFieldsName.Length; column++) { String columnName = oplFieldsName[column]; HandleColumnValue(handler, oplFieldsType[column], reader[columnName]); } handler.EndTuple(); } handler.EndSet(); }
/// <summary> /// Recursively load data into the tuple current being loaded. /// </summary> /// <param name="handler">The handler constructing the current element.</param> /// <param name="schema">Schema of tuple being constructed.</param> /// <param name="row">Data source for tuple to construct.</param> /// <param name="absIndex">Absolute index into <code>row</code> for the next column to process.</param> /// <returns>The updated absolute index.</returns> private int fillTuple(OplDataHandler handler, ITupleSchema schema, IRow row, int absIndex) { handler.StartTuple(); for (int i = 0; i < schema.Size; ++i) { if (schema.IsTuple(i)) { ILOG.Opl_Core.Cppimpl.IloTupleSchema s = (ILOG.Opl_Core.Cppimpl.IloTupleSchema)schema; absIndex = fillTuple(handler, s.getTupleColumn(i), row, absIndex); continue; } if (schema.IsNum(i)) { SET_FLOAT(handler, row, absIndex); } else if (schema.IsInt(i)) { SET_INT(handler, row, absIndex); } else if (schema.IsSymbol(i)) { SET_STRING(handler, row, absIndex); } else { throw new NotImplementedException("tuple element type not supported"); } ++absIndex; } handler.EndTuple(); return(absIndex); }
public override void CustomRead() { int _nbConfs = 7; int _nbOptions = 5; OplDataHandler handler = getDataHandler(); handler.StartElement("nbConfs"); handler.AddIntItem(_nbConfs); handler.EndElement(); handler.StartElement("nbOptions"); handler.AddIntItem(_nbOptions); handler.EndElement(); int[] _demand = { 5, 5, 10, 10, 10, 10, 5 }; handler.StartElement("demand"); handler.StartArray(); for (int i = 0; i < _nbConfs; i++) { handler.AddIntItem(_demand[i]); } handler.EndArray(); handler.EndElement(); int[,] _option = { { 1, 0, 0, 0, 1, 1, 0 }, { 0, 0, 1, 1, 0, 1, 0 }, { 1, 0, 0, 0, 1, 0, 0 }, { 1, 1, 0, 1, 0, 0, 0 }, { 0, 0, 1, 0, 0, 0, 0 } }; handler.StartElement("option"); handler.StartArray(); for (int i = 0; i < _nbOptions; i++) { handler.StartArray(); for (int j = 0; j < _nbConfs; j++) { handler.AddIntItem(_option[i, j]); } handler.EndArray(); } handler.EndArray(); handler.EndElement(); int[,] _capacity = { { 1, 2 }, { 2, 3 }, { 1, 3 }, { 2, 5 }, { 1, 5 } }; handler.StartElement("capacity"); handler.StartArray(); for (int i = 0; i < _nbOptions; i++) { handler.StartTuple(); for (int j = 0; j <= 1; j++) { handler.AddIntItem(_capacity[i, j]); } handler.EndTuple(); } handler.EndArray(); handler.EndElement(); }
private void GetOrders(OplDataHandler handler) { // initialize the tuple set 'Products' handler.StartElement("Orders"); handler.StartSet(); // Loop through queue for (int i = 0; i < Queue.Length; i++) { // Peek next lot in queue Lot peekLot = Queue.PeekAt(i); bool eligible = false; // Check if elible on any machine (not Down) foreach (Machine machine in LithographyArea.Machines) { // Check if machine is Down if (LithographyArea.MachineStates[machine.Name] == "Down") { continue; } // Get needed recipe for the lot string recipe = CPDispatcher.GetRecipe(peekLot, machine); string recipeKey = machine.Name + "__" + recipe; // Check if needed recipe is eligible on machine bool recipeEligible = CPDispatcher.CheckMachineEligibility(recipeKey); // Check if processingTime is known bool processingTimeKnown = CPDispatcher.CheckProcessingTimeKnown(peekLot, machine, recipe); if (recipeEligible && processingTimeKnown) { eligible = true; break; } } if (eligible) { // Add tuple handler.StartTuple(); handler.AddStringItem(peekLot.Id.ToString()); //handler.AddStringItem(peekLot.Id.ToString()); handler.AddIntItem(ProductNameToID[peekLot.MasksetLayer_RecipeStepCluster]); handler.AddIntItem(peekLot.LotQty); handler.AddNumItem(CPDispatcher.GetDueDateWeight(peekLot)); handler.AddNumItem(CPDispatcher.GetWIPBalanceWeight(peekLot)); handler.EndTuple(); } } handler.EndSet(); handler.EndElement(); }
private void GetProductIDs(OplDataHandler handler) { ProductNameToID = new Dictionary <string, int>(); // initialize the tuple set 'Products' handler.StartElement("Products"); handler.StartSet(); List <Lot> allLots = new List <Lot>(); // Loop through queue for (int i = 0; i < Queue.Length; i++) { // Peek next lot in queue Lot peekLot = Queue.PeekAt(i); allLots.Add(peekLot); } foreach (Machine machine in LithographyArea.Machines) { if (machine.Queue.Length > 0) { Lot lotAtMachine = machine.Queue.PeekFirst(); allLots.Add(lotAtMachine); } } int productID = 0; // Loop through queue foreach (Lot lot in allLots) { string productName = lot.MasksetLayer_RecipeStepCluster; if (!ProductNameToID.ContainsKey(productName)) { // Add tuple handler.StartTuple(); handler.AddIntItem(productID); handler.AddStringItem(productName); handler.EndTuple(); ProductNameToID.Add(productName, productID); productID += 1; } } handler.EndSet(); handler.EndElement(); }
private void GetComputationalSettings(OplDataHandler handler) { // initialize the tuple set handler.StartElement("ComputationalSettings"); handler.StartSet(); // Add tuple handler.StartTuple(); handler.AddStringItem("timeLimit"); handler.AddIntItem(CPDispatcher.TimeLimit); handler.EndTuple(); handler.EndSet(); handler.EndElement(); }
public override void CustomRead() { int beginTime = 1920; //need to initialized int endTime = 2100; //need to initialized String marketCity = "SHA"; //need to initialized /* * 1* FlightCode:{"1033538119", "1033538066"} * 2* FlightInfo:[<"738","D",1323,1800,0>,<"738","D",1341,1800,0>] * 3* StandCode:{"301","302"} * 4* StandInfo:[<"N",2>,<"N",2>] * 5* Stnd_fl_type:[0,1...] * 6* preflightcode:{"1033538119", "1033538066"} * 7* prestnd: * 8* SCAdjCon:[<"N207","N207L">,<"N207","N207R">,<"N206","N206L">] */ OplDataHandler handler = getDataHandler(); //1.FlightCode handler.StartElement("FlightCode"); handler.StartSet(); List <FlightInfo> FlightCode = new List <FlightInfo>(); for (int i = 0; i < FlightCode.Count; i++) { handler.AddStringItem(FlightCode[i].flightCode); } handler.EndSet(); handler.EndElement(); //2.FlightInfo handler.StartElement("FlightInfo"); handler.StartSet(); List <FlightInfo> FlightInfo = new List <FlightInfo>(); for (int i = 0; i < FlightInfo.Count; i++) { handler.StartTuple(); handler.AddStringItem(FlightInfo[i].flightType); handler.AddStringItem(FlightInfo[i].d_or_i); handler.AddIntItem(int.Parse(FlightInfo[i].startTime));//是否要转为int??居飞 handler.AddIntItem(int.Parse(FlightInfo[i].endTime)); handler.AddIntItem(int.Parse(FlightInfo[i].isTurnArround)); handler.EndTuple(); } handler.EndSet(); handler.EndElement(); //3.StandCode handler.StartElement("StandCode"); handler.StartSet(); List <StandInfo> StandCode = new List <StandInfo>(); for (int i = 0; i < StandCode.Count; i++) { handler.AddStringItem(StandCode[i].standCode); } handler.EndSet(); handler.EndElement(); //4.StandInfo handler.StartElement("StandInfo"); handler.StartSet(); List <StandInfo> StandInfo = new List <StandInfo>(); for (int i = 0; i < StandInfo.Count; i++) { handler.StartTuple(); handler.AddStringItem(StandInfo[i].near_or_far); handler.AddIntItem(int.Parse(StandInfo[i].priority)); handler.EndTuple(); } handler.EndSet(); handler.EndElement(); //5.Stnd_fl_type handler.StartElement("Stnd_fl_type"); handler.StartSet(); //6.preflightcode handler.StartElement("preflightcode"); handler.StartSet(); //7.prestnd handler.StartElement("prestnd"); handler.StartSet(); //8.SCAdjCon handler.StartElement("SCAdjCon"); handler.StartSet(); Console.WriteLine("Read Over"); }
public override void CustomRead() { OplDataHandler handler = DataHandler; // initialize the int 'simpleInt' handler.StartElement("anInt"); handler.AddIntItem(3); handler.EndElement(); // initialize the int array 'simpleIntArray' handler.StartElement("anIntArray"); handler.StartArray(); handler.AddIntItem(1); handler.AddIntItem(2); handler.AddIntItem(3); handler.EndArray(); handler.EndElement(); // initialize int array indexed by float 'anArrayIndexedByFloat' handler.StartElement("anArrayIndexedByFloat"); handler.StartIndexedArray(); handler.SetItemNumIndex(2.0); handler.AddIntItem(1); handler.SetItemNumIndex(2.5); handler.AddIntItem(2); handler.SetItemNumIndex(1.0); handler.AddIntItem(3); handler.SetItemNumIndex(1.5); handler.AddIntItem(4); handler.EndIndexedArray(); handler.EndElement(); // initialize int array indexed by string 'anArrayIndexedByString' handler.StartElement("anArrayIndexedByString"); handler.StartIndexedArray(); handler.SetItemStringIndex("idx1"); handler.AddIntItem(1); handler.SetItemStringIndex("idx2"); handler.AddIntItem(2); handler.EndIndexedArray(); handler.EndElement(); // initialize a tuple in the order the components are declared handler.StartElement("aTuple"); handler.StartTuple(); handler.AddIntItem(1); handler.AddNumItem(2.3); handler.AddStringItem("not named tuple"); handler.EndTuple(); handler.EndElement(); // initialize a tuple using tuple component names. handler.StartElement("aNamedTuple"); handler.StartNamedTuple(); handler.SetItemName("f"); handler.AddNumItem(3.45); handler.SetItemName("s"); handler.AddStringItem("named tuple"); handler.SetItemName("i"); handler.AddIntItem(99); handler.EndNamedTuple(); handler.EndElement(); // initialize the tuple set 'simpleTupleSet' handler.StartElement("aTupleSet"); handler.StartSet(); // first tuple handler.StartTuple(); handler.AddIntItem(1); handler.AddNumItem(2.5); handler.AddStringItem("a"); handler.EndTuple(); // second element handler.StartTuple(); handler.AddIntItem(3); handler.AddNumItem(4.1); handler.AddStringItem("b"); handler.EndTuple(); handler.EndSet(); handler.EndElement(); // initialize element 3 and 2 of the tuple array 'simpleTupleArray' in that particular order handler.StartElement("aTupleArray"); handler.StartIndexedArray(); // initialize 3rd cell handler.SetItemIntIndex(3); handler.StartTuple(); handler.AddIntItem(1); handler.AddNumItem(2.5); handler.AddStringItem("a"); handler.EndTuple(); // initialize second cell handler.SetItemIntIndex(2); handler.StartTuple(); handler.AddIntItem(3); handler.AddNumItem(4.1); handler.AddStringItem("b"); handler.EndTuple(); handler.EndIndexedArray(); handler.EndElement(); // initialize int array indexed by tuple set 'anArrayIndexedByTuple' handler.StartElement("anArrayIndexedByTuple"); handler.StartIndexedArray(); handler.StartItemTupleIndex(); handler.AddIntItem(3); handler.AddNumItem(4.1); handler.AddStringItem("b"); handler.EndItemTupleIndex(); handler.AddIntItem(1); handler.EndIndexedArray(); handler.EndElement(); // initialize a 2-dimension int array 'a2DIntArray' handler.StartElement("a2DIntArray"); handler.StartArray(); for (int i = 1; i <= 2; i++) { handler.StartArray(); for (int j = 1; j <= 3; j++) { handler.AddIntItem(i * 10 + j); } handler.EndArray(); } handler.EndArray(); handler.EndElement(); }
private void GetSetups(OplDataHandler handler) { // initialize the tuple set 'Products' handler.StartElement("Setups"); handler.StartSet(); List <Lot> allLots = new List <Lot>(); // Loop through queue for (int i = 0; i < Queue.Length; i++) { // Peek next lot in queue Lot peekLot = Queue.PeekAt(i); allLots.Add(peekLot); } foreach (Machine machine in LithographyArea.Machines) { if (machine.Queue.Length > 0) { Lot lotAtMachine = machine.Queue.PeekFirst(); allLots.Add(lotAtMachine); } } List <string> productNamesFrom = new List <string>(); // Loop through queue foreach (Lot lotFrom in allLots) { if (!productNamesFrom.Contains(lotFrom.MasksetLayer_RecipeStepCluster)) { List <string> productNamesTo = new List <string>(); // Loop through queue foreach (Lot lotTo in allLots) { if (!productNamesTo.Contains(lotTo.MasksetLayer_RecipeStepCluster)) { if (lotFrom.ReticleID1 == lotTo.ReticleID1) { // Add tuple handler.StartTuple(); handler.AddStringItem("MTRX_ARMS"); handler.AddIntItem(ProductNameToID[lotFrom.MasksetLayer_RecipeStepCluster]); handler.AddIntItem(ProductNameToID[lotTo.MasksetLayer_RecipeStepCluster]); handler.AddIntItem((int)LithographyArea.DeterministicNonProductiveTimesARMS["SameReticle"]); handler.EndTuple(); // Add tuple handler.StartTuple(); handler.AddStringItem("MTRX_RMS"); handler.AddIntItem(ProductNameToID[lotFrom.MasksetLayer_RecipeStepCluster]); handler.AddIntItem(ProductNameToID[lotTo.MasksetLayer_RecipeStepCluster]); handler.AddIntItem((int)LithographyArea.DeterministicNonProductiveTimesRMS["SameReticle"]); handler.EndTuple(); } else if (lotFrom.ReticleID1 != lotTo.ReticleID1 && lotFrom.IrdName == lotTo.IrdName) { // Add tuple handler.StartTuple(); handler.AddStringItem("MTRX_ARMS"); handler.AddIntItem(ProductNameToID[lotFrom.MasksetLayer_RecipeStepCluster]); handler.AddIntItem(ProductNameToID[lotTo.MasksetLayer_RecipeStepCluster]); handler.AddIntItem((int)LithographyArea.DeterministicNonProductiveTimesARMS["DifferentReticle"]); handler.EndTuple(); // Add tuple handler.StartTuple(); handler.AddStringItem("MTRX_RMS"); handler.AddIntItem(ProductNameToID[lotFrom.MasksetLayer_RecipeStepCluster]); handler.AddIntItem(ProductNameToID[lotTo.MasksetLayer_RecipeStepCluster]); handler.AddIntItem((int)LithographyArea.DeterministicNonProductiveTimesRMS["DifferentReticle"]); handler.EndTuple(); } else { // Add tuple handler.StartTuple(); handler.AddStringItem("MTRX_ARMS"); handler.AddIntItem(ProductNameToID[lotFrom.MasksetLayer_RecipeStepCluster]); handler.AddIntItem(ProductNameToID[lotTo.MasksetLayer_RecipeStepCluster]); handler.AddIntItem((int)LithographyArea.DeterministicNonProductiveTimesARMS["DifferentIRD"]); handler.EndTuple(); // Add tuple handler.StartTuple(); handler.AddStringItem("MTRX_RMS"); handler.AddIntItem(ProductNameToID[lotFrom.MasksetLayer_RecipeStepCluster]); handler.AddIntItem(ProductNameToID[lotTo.MasksetLayer_RecipeStepCluster]); handler.AddIntItem((int)LithographyArea.DeterministicNonProductiveTimesRMS["DifferentIRD"]); handler.EndTuple(); } productNamesTo.Add(lotTo.MasksetLayer_RecipeStepCluster); } } productNamesFrom.Add(lotFrom.MasksetLayer_RecipeStepCluster); } } handler.EndSet(); handler.EndElement(); }
private void GetModes(OplDataHandler handler) { // initialize the tuple set 'Products' handler.StartElement("Modes"); handler.StartSet(); List <Lot> allLots = new List <Lot>(); // Loop through queue for (int i = 0; i < Queue.Length; i++) { // Peek next lot in queue Lot peekLot = Queue.PeekAt(i); allLots.Add(peekLot); } foreach (Machine machine in LithographyArea.Machines) { if (machine.Queue.Length > 0) { Lot lotAtMachine = machine.Queue.PeekFirst(); allLots.Add(lotAtMachine); } } List <string> productNames = new List <string>(); // Loop through queue foreach (Lot lot in allLots) { if (!productNames.Contains(lot.MasksetLayer_RecipeStepCluster)) { int modeNr = 0; foreach (Machine machine in LithographyArea.Machines) { // Check if machine is Down if (LithographyArea.MachineStates[machine.Name] == "Down") { continue; } // Get needed recipe for the lot string recipe = CPDispatcher.GetRecipe(lot, machine); string recipeKey = machine.Name + "__" + recipe; // Check if needed recipe is eligible on machine bool recipeEligible = CPDispatcher.CheckMachineEligibility(recipeKey); // Check if processingTime is known bool processingTimeKnown = CPDispatcher.CheckProcessingTimeKnown(lot, machine, recipe); if (recipeEligible && processingTimeKnown) { int?processingTime = null; processingTime = (int)machine.GetDeterministicProcessingTimeFullLot(lot); // Add tuple handler.StartTuple(); handler.AddIntItem(ProductNameToID[lot.MasksetLayer_RecipeStepCluster]); handler.AddIntItem(modeNr); handler.AddStringItem(machine.Name); handler.AddIntItem((int)processingTime); handler.EndTuple(); modeNr += 1; } } productNames.Add(lot.MasksetLayer_RecipeStepCluster); } } handler.EndSet(); handler.EndElement(); }
private void GetAuxResources(OplDataHandler handler) { // initialize the tuple set 'Products' handler.StartElement("AuxResources"); handler.StartSet(); List <Lot> allLots = new List <Lot>(); // Loop through queue for (int i = 0; i < Queue.Length; i++) { // Peek next lot in queue Lot peekLot = Queue.PeekAt(i); allLots.Add(peekLot); } foreach (Machine machine in LithographyArea.Machines) { if (machine.Queue.Length > 0) { Lot lotAtMachine = machine.Queue.PeekFirst(); allLots.Add(lotAtMachine); } } // Get Reticles List <string> allReticles = new List <string>(); // Loop through queue foreach (Lot lot in allLots) { if (!allReticles.Contains(lot.ReticleID1)) { if (lot.ReticleID1 == "4106") { // Add tuple handler.StartTuple(); handler.AddStringItem(lot.ReticleID1); handler.AddIntItem(2); handler.EndTuple(); } else { // Add tuple handler.StartTuple(); handler.AddStringItem(lot.ReticleID1); handler.AddIntItem(1); handler.EndTuple(); } allReticles.Add(lot.ReticleID1); } } // Get IRDNames List <string> allIRDNames = new List <string>(); // Loop through queue foreach (Lot lot in allLots) { if (!allIRDNames.Contains(lot.IrdName)) { // Add tuple handler.StartTuple(); handler.AddStringItem(lot.IrdName); int capacity = 2; if (CPDispatcher.AvailableResources.ContainsKey(lot.IrdName)) { capacity = CPDispatcher.AvailableResources[lot.IrdName]; } handler.AddIntItem(capacity); handler.EndTuple(); allIRDNames.Add(lot.IrdName); } } handler.EndSet(); handler.EndElement(); }
private void GetResources(OplDataHandler handler) { // initialize the tuple set 'Products' handler.StartElement("Resources"); handler.StartSet(); // Loop through queue foreach (Machine machine in LithographyArea.Machines) { // Check if machine is Down if (LithographyArea.MachineStates[machine.Name] == "Down") { continue; } int initialProductID = -1; int endTimeInitialProductID = 0; // Check if a lot is loaded on the machine if (machine.Queue.Length > 0) { Lot lotAtMachine = machine.Queue.PeekFirst(); initialProductID = ProductNameToID[lotAtMachine.MasksetLayer_RecipeStepCluster]; double estimatedEndTime; if (machine.CurrentLot == lotAtMachine) { estimatedEndTime = machine.CurrentStartRun + machine.GetDeterministicProcessingTime(lotAtMachine); if (estimatedEndTime > LithographyArea.GetTime) { endTimeInitialProductID = (int)estimatedEndTime - (int)LithographyArea.GetTime; } } else { estimatedEndTime = machine.GetDeterministicProcessingTime(lotAtMachine); endTimeInitialProductID = (int)estimatedEndTime; } } if (machine.Name.Contains("#5") || machine.Name.Contains("#7") || machine.Name.Contains("#9")) { // Add tuple handler.StartTuple(); handler.AddStringItem(machine.Name); handler.AddStringItem("MTRX_RMS"); handler.AddIntItem(initialProductID); handler.AddIntItem(endTimeInitialProductID); handler.EndTuple(); } else { // Add tuple handler.StartTuple(); handler.AddStringItem(machine.Name); handler.AddStringItem("MTRX_ARMS"); handler.AddIntItem(initialProductID); handler.AddIntItem(endTimeInitialProductID); handler.EndTuple(); } } handler.EndSet(); handler.EndElement(); }