Пример #1
0
 private IEnumerable <SparseTwinIndex <float> > GPUDoublyConstrained(IZone[] zones, IEnumerator <SparseArray <float> > ep, IEnumerator <SparseArray <float> > ea, IEnumerator <IDemographicCategory> ec)
 {
     using (MultiRunGPUGravityModel gm =
                new MultiRunGPUGravityModel(zones.Length, (p => this.Progress = p), this.Epsilon, this.MaxIterations))
     {
         float[] friction = null;
         while (ep.MoveNext() && ea.MoveNext() && ec.MoveNext())
         {
             var production = ep.Current;
             var attraction = ea.Current;
             var cat        = ec.Current;
             var ret        = production.CreateSquareTwinArray <float>();
             friction = this.ComputeFriction(zones, cat, production.GetFlatData(), attraction.GetFlatData(), friction);
             yield return(gm.ProcessFlow(friction, production, attraction));
         }
     }
 }
Пример #2
0
        public IEnumerable <SparseTwinIndex <float> > Distribute(IEnumerable <SparseArray <float> > productions, IEnumerable <SparseArray <float> > attractions, IEnumerable <IDemographicCategory> cat)
        {
            var productionEnum = productions.GetEnumerator();
            var attractionEnum = attractions.GetEnumerator();
            var catEnum        = cat.GetEnumerator();
            var numberOfZones  = this.Root.ZoneSystem.ZoneArray.GetFlatData().Length;

            using (MultiRunGPUGravityModel multiDist = new MultiRunGPUGravityModel(numberOfZones, ((p) => this.Progress = p), this.Epsilon, this.MaxIterations))
            {
                var     zoneArray = this.Root.ZoneSystem.ZoneArray;
                float[] friction  = null;
                while (productionEnum.MoveNext() && attractionEnum.MoveNext() && catEnum.MoveNext())
                {
                    yield return(multiDist.ProcessFlow((friction = this.ComputeFriction(zoneArray.GetFlatData(), catEnum.Current, friction)), productionEnum.Current, attractionEnum.Current));
                }
                friction = null;
            }
        }