protected IPointList makePointList(EligibleHomeSites inEhs) { IPointList pl = null; mLog.Debug("inside make point list going to make " + inEhs.SiteCount.ToString() + " points"); try { pl = new IPointList(); IPoint p = null; for (int i = 0; i < inEhs.SiteCount - 1; i++) { p.X = inEhs.getSite(i).X; p.Y = inEhs.getSite(1).Y; pl.add(p); } mLog.Debug("actuall made " + pl.Count().ToString() + " points"); } catch (System.Exception ex) { #if (DEBUG) System.Windows.Forms.MessageBox.Show(ex.Message); #endif eLog.Debug(ex); } return(pl); }
private void setComboRank(double distWeight) { double d = 0; double adjustDistance = 0; double maxFood = 0.0; double maxRisk = 0.0; double foodValue = 0.0; double riskValue = 0.0; //set up to sort by food first EligibleHomeSite.SortOrder = EligibleHomeSite.SortMethod.Food; base.siteList.Sort(); maxFood = base.siteList[0].Food; //get the risk data now EligibleHomeSite.SortOrder = EligibleHomeSite.SortMethod.Risk; base.siteList.Sort(); maxRisk = base.siteList[0].Risk; mLog.Debug("inside setComboRank with a distance factor of " + distWeight.ToString()); mLog.Debug("max food was " + maxFood.ToString()); mLog.Debug("max Risk was " + maxRisk.ToString()); try { for (int i = 0; i < base.siteList.Count; i++) { EligibleHomeSite ehs = base.siteList[i]; adjustDistance = Math.Pow(ehs.DistanceFromCurrLocation, (1 / distWeight)); mLog.Debug(ehs.X.ToString() + " " + ehs.Y.ToString() + " site is eligible"); mLog.Debug("the distance from current location is " + ehs.DistanceFromCurrLocation.ToString()); mLog.Debug("so adjusted distace value is " + adjustDistance.ToString()); mLog.Debug("this sites food value is " + ehs.Food.ToString()); mLog.Debug("this sites risk value is " + ehs.Risk.ToString()); foodValue = ehs.Food / maxFood; mLog.Debug("food value is " + foodValue.ToString()); riskValue = (1 - ehs.Risk / maxRisk); mLog.Debug("risk value is " + riskValue.ToString()); ehs.Rank = (foodValue + riskValue) / adjustDistance; mLog.Debug("final rank is " + ehs.Rank.ToString()); d += ehs.Rank; } EligibleHomeSites siteManager = new EligibleHomeSites(); siteManager.MySites = base.siteList; siteManager.setRanges(d); } catch (System.Exception ex) { #if (DEBUG) System.Windows.Forms.MessageBox.Show(ex.Message); #endif eLog.Debug(ex); } }
private void logValues(EligibleHomeSites inEhs) { EligibleHomeSite eh; for (int i = 0; i < inEhs.SiteCount; i++) { eh = inEhs.getSite(i); mLog.Debug("site number " + i.ToString()); mLog.Debug("site is eligible = " + eh.SuitableSite.ToString()); mLog.Debug("X = " + eh.X.ToString() + " Y+ " + eh.Y.ToString()); mLog.Debug("rank is " + eh.Rank.ToString()); } }
protected IPoint getHomeRangeCenter(EligibleHomeSites inEhs) { double luckyNumber = rn.getUniformRandomNum(); IPoint p = null; int i = 0; try { mLog.Debug("inside getHomeRangeCenter "); mLog.Debug("the roll of the dice is " + luckyNumber.ToString()); logValues(inEhs); //should set up some sort of binary search but wtf over budget already. while (luckyNumber >= inEhs.getSite(i++).Rank) { mLog.Debug("current site rank is " + inEhs.getSite(i).Rank.ToString()); } //since the index is auto incremented we are one past after the comparison //so we need to go back 1 to get the correct point //if it was the first one in the list then we can not go back any further if (i > 0) { i--; } p = new PointClass(); p.X = inEhs.getSite(i).X; p.Y = inEhs.getSite(i).Y; mLog.Debug("site we chose has a rank of " + inEhs.getSite(i).Rank.ToString()); } catch (System.Exception ex) { #if (DEBUG) System.Windows.Forms.MessageBox.Show(ex.Message); #endif eLog.Debug(ex); } return(p); }