public void AddDeliveryPoint(CLSCOBO_DeliveryPoint po_DeliveryPoint) { bool vb_Found = false; foreach (CLSCOBO_DeliveryPoint vo_DeliveryPoint in ao_deliveries) { if (vo_DeliveryPoint.ZipCode == po_DeliveryPoint.ZipCode) vb_Found = true; } if (!vb_Found) ao_deliveries.Add(po_DeliveryPoint); }
private bool IsSameQuadrant(CLSCOBO_BasePoint po_OriginPoint, CLSCOBO_DeliveryPoint po_DeliveryPointFrom, CLSCOBO_DeliveryPoint po_DeliveryPointTo) { bool vb_SameQuadrant; if(CLSCOBO_FunctionsRepository.CalculateCuadrant(po_OriginPoint,po_DeliveryPointFrom)==CLSCOBO_FunctionsRepository.CalculateCuadrant(po_OriginPoint,po_DeliveryPointTo)) vb_SameQuadrant=true; else vb_SameQuadrant=false; return vb_SameQuadrant; }
public static CLSCOBO_ConsolidationProblem ReadFile(ref String ps_FileName) { string vs_Line; string vi_OriginDestinationIndicator=""; TextReader vs_TextReader; CLSCOBO_DeliveryPoint vo_DeliveryPoint; CLSCOBO_OriginPoint vo_OriginPoint; CLSCOBO_ConsolidationProblem vo_ConsolidationProblem; try { if(string.IsNullOrEmpty(ps_FileName)) { vo_ConsolidationProblem=ReadDemoData(ref ps_FileName); } else { vo_ConsolidationProblem=new CLSCOBO_ConsolidationProblem(); ps_FileName=System.AppDomain.CurrentDomain.BaseDirectory+(string.IsNullOrEmpty(ps_FileName)?cs_DEMO_DEFAULT_FILE:ps_FileName); vs_TextReader=new StreamReader(ps_FileName); while((vs_Line=vs_TextReader.ReadLine())!=null) { vi_OriginDestinationIndicator=vs_Line.Substring(0, vs_Line.IndexOf(",")); vs_Line=vs_Line.Remove(0, vs_Line.IndexOf(",")+1); if(vi_OriginDestinationIndicator.ToUpper()=="O") { vo_OriginPoint=new CLSCOBO_OriginPoint(vs_Line.Substring(0, vs_Line.IndexOf(","))); vo_ConsolidationProblem.OriginPoint=vo_OriginPoint; } else { vo_DeliveryPoint=new CLSCOBO_DeliveryPoint(vs_Line.Substring(0, vs_Line.IndexOf(","))); vo_DeliveryPoint.Weight=double.Parse(vs_Line.Remove(0, vs_Line.IndexOf(",")+1)); vo_ConsolidationProblem.Deliveries.Add(vo_DeliveryPoint); } } vs_TextReader.Close(); } } catch { vo_ConsolidationProblem=null; } return vo_ConsolidationProblem; }
public static CLSCOBO_ConsolidationProblem ReadDemoData(ref string ps_FileName) { string vs_Line; string vs_FileName; string vs_State=""; string vs_FirstZip=""; string vs_SecondZip=""; string vs_SelectedZip=""; double vd_Weight=0; int vi_RandomPoint=-1; int vi_ChoosenAsOriginPoint=-1; int vi_RandomChoosenPoint=-1; int vi_RandomZipSelected=-1; TextReader vs_TextReader; List<CLSCOBO_DeliveryPoint> vl_DeliveryPoints=null; CLSCOBO_DeliveryPoint vo_TemporaryPoint; CLSCOBO_DeliveryPoint vo_DeliveryPoint; CLSCOBO_OriginPoint vo_OriginPoint; CLSCOBO_ConsolidationProblem vo_ConsolidationProblem; try { vs_FileName=System.AppDomain.CurrentDomain.BaseDirectory+cs_DEMO_DEFAULT_FILE; ps_FileName=cs_DEMO_DEFAULT_FILE; vs_TextReader=new StreamReader(vs_FileName); vl_DeliveryPoints=new List<CLSCOBO_DeliveryPoint>(); while((vs_Line=vs_TextReader.ReadLine())!=null) { vs_SelectedZip=""; vs_State=vs_Line.Substring(0, vs_Line.IndexOf(",")); vs_Line=vs_Line.Remove(0, vs_Line.IndexOf(",")+1); vs_FirstZip=vs_Line.Substring(0, vs_Line.IndexOf(",")); vs_Line=vs_Line.Remove(0, vs_Line.IndexOf(",")+1); vs_SecondZip=vs_Line.Substring(0, vs_Line.IndexOf(",")); vs_Line=vs_Line.Remove(0, vs_Line.IndexOf(",")+1); vd_Weight=double.Parse(vs_Line.Remove(0, vs_Line.IndexOf(",")+1)); vi_RandomZipSelected=GenerateRandomNumber(1, 2); vs_SelectedZip=(vi_RandomZipSelected==1)?(string.IsNullOrEmpty(vs_FirstZip)?vs_SecondZip:vs_FirstZip):(string.IsNullOrEmpty(vs_SecondZip)?vs_FirstZip:vs_SecondZip); vs_SelectedZip=vs_State+" "+vs_SelectedZip; vo_TemporaryPoint=new CLSCOBO_DeliveryPoint(vs_SelectedZip); vo_TemporaryPoint.Weight=vd_Weight; vl_DeliveryPoints.Add(vo_TemporaryPoint); } vs_TextReader.Close(); vi_RandomPoint=GenerateRandomNumber(2, vl_DeliveryPoints.Count-1); vi_ChoosenAsOriginPoint=GenerateRandomNumber(0, vi_RandomPoint); vo_ConsolidationProblem=new CLSCOBO_ConsolidationProblem(); vo_OriginPoint=new CLSCOBO_OriginPoint(vl_DeliveryPoints[vi_ChoosenAsOriginPoint].ZipCode); vo_ConsolidationProblem.OriginPoint=vo_OriginPoint; vl_DeliveryPoints.RemoveAt(vi_ChoosenAsOriginPoint); vi_RandomPoint--; for(int x=1;x<=vi_RandomPoint;x++) { vi_RandomChoosenPoint=GenerateRandomNumber(0, vl_DeliveryPoints.Count-1); vo_DeliveryPoint=vl_DeliveryPoints[vi_RandomChoosenPoint]; vo_ConsolidationProblem.AddDeliveryPoint(vo_DeliveryPoint); vl_DeliveryPoints.RemoveAt(vi_RandomChoosenPoint); } } catch { vo_ConsolidationProblem=null; } return vo_ConsolidationProblem; }