Example #1
0
 public void addSite(EligibleHomeSite inSite)
 {
     mLog.Debug("adding an eligible home site");
     mLog.Debug("X = " + inSite.X.ToString() + " Y= " + inSite.Y.ToString());
     mLog.Debug("Food = " + inSite.Food.ToString() + " Risk = " + inSite.Risk.ToString());
     this.mySites.Add(inSite);
     mLog.Debug("now there are " + this.mySites.Count.ToString() + " sites to choose from");
 }
Example #2
0
        // end of doTimeStep
        public PointClass GetEligibleStep(int stepNum)
        {
            IPoint           p   = new PointClass();
            EligibleHomeSite ehs = MyVisitedSites.getSite(stepNum) as EligibleHomeSite;

            p.X = ehs.X;
            p.Y = ehs.Y;
            return(p as PointClass);
        }
Example #3
0
        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);
            }
        }
Example #4
0
        public int CompareTo(object obj)
        {
            int result = 0;

            try
            {
                if (obj is EligibleHomeSite)
                {
                    EligibleHomeSite other = (EligibleHomeSite)obj;
                    switch (_sortOrder)
                    {
                    //because the default is asscending order we do it backwards to get descending order
                    case SortMethod.Food:
                        result = other.Food.CompareTo(mFood);
                        break;

                    case SortMethod.Risk:
                        result = other.Risk.CompareTo(mRisk);
                        break;

                    case SortMethod.Rank:
                        result = other.Rank.CompareTo(mRank);
                        break;

                    case SortMethod.Dist:
                        result = other.DistanceFromCurrLocation.CompareTo(mDistanceFromCurrLocation);
                        break;

                    default:
                        throw new System.Exception(_sortOrder.ToString() + " is bad Sort Method for EligibleHomeSite");
                    }
                }
                else
                {
                    throw new ArgumentException("Object is not an EligibleHomeSite");
                }
            }
            catch (System.Exception ex)
            {
#if (DEBUG)
                System.Windows.Forms.MessageBox.Show(ex.Message);
#endif
                eLog.Debug(ex);
            }
            return(result);
        }
Example #5
0
        private List <EligibleHomeSite> GetListOfPoints(IFeatureClass fc)
        {
            mLog.Debug("inside GetListOfPoints for " + fc.AliasName);
            List <EligibleHomeSite> outSites = new List <EligibleHomeSite>();
            IFeatureCursor          search   = fc.Search(null, false);
            IFeature feat = search.NextFeature();

            while (feat != null)
            {
                IPoint           p   = feat.ShapeCopy as IPoint;
                EligibleHomeSite ehs = new EligibleHomeSite(p);
                outSites.Add(ehs);
                feat = search.NextFeature();
            }

            System.Runtime.InteropServices.Marshal.ReleaseComObject(search);
            mLog.Debug("we have " + outSites.Count.ToString() + " number of points that are good");
            return(outSites);
        }
Example #6
0
        public EligibleHomeSite getSite(int index)
        {
            EligibleHomeSite ehs = null;

            try
            {
                if (this.mySites.Count > 0)
                {
                    ehs = this.mySites[index] as EligibleHomeSite;
                }
            }
            catch (System.Exception ex)
            {
#if (DEBUG)
                System.Windows.Forms.MessageBox.Show(ex.Message);
#endif
                eLog.Debug(ex);
            }
            return(ehs);
        }
Example #7
0
        public EligibleHomeSite getFirstSuitableSite()
        {
            EligibleHomeSite ehs = null;

            try
            {
                for (int i = 0; i < this.mySites.Count; i++)
                {
                    ehs = this.mySites[i] as EligibleHomeSite;
                    if (ehs.SuitableSite)
                    {
                        break;
                    }
                }
            }
            catch (System.Exception ex)
            {
#if (DEBUG)
                System.Windows.Forms.MessageBox.Show(ex.Message);
#endif
                eLog.Debug(ex);
            }
            return(ehs);
        }