当前位置: 首页>>代码示例>>C#>>正文


C# IZone.Last方法代码示例

本文整理汇总了C#中IZone.Last方法的典型用法代码示例。如果您正苦于以下问题:C# IZone.Last方法的具体用法?C# IZone.Last怎么用?C# IZone.Last使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IZone的用法示例。


在下文中一共展示了IZone.Last方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BuildLocationChoiceCacheHome


//.........这里部分代码省略.........
                        maxDist = p[3, 18];
                        index = 18;
                    }

                    if ( distkm >= 0 && distkm <= maxDist )
                    {
                        //empR = ( kz.RetailActivityLevel / 1000 ) + 0.001;
                        sh0 = 0.0;
                        sh1 = 0.0;
                        sh2 = 0.0;
                        if ( distkm >= 0 && distkm < 1 ) sh0 = 1;
                        else if ( distkm >= 1 && distkm < 2 ) sh1 = 1;

                        switch ( index )
                        {
                            case 16:
                                sumExp += Math.Exp( ( p[3, 0] * distkm ) + ( p[3, 1] * empR ) + ( p[3, 2] * sh0 ) + ( p[3, 3] * sh1 ) + ( p[3, 4] * sh2 ) );
                                break;

                            case 17:
                                sumExp += Math.Exp( p[3, 6] + ( p[3, 5] * distkm ) + ( p[3, 7] * empR ) + ( p[3, 8] * sh0 ) + ( p[4, 9] * sh1 ) + ( p[3, 10] * sh2 ) );
                                break;

                            case 18:
                                sumExp += Math.Exp( p[3, 12] + ( p[3, 11] * distkm ) + ( p[3, 13] * empR ) + ( p[3, 14] * sh0 ) + ( p[3, 15] * sh1 ) );
                                break;
                        }
                    }
                }

                //line.Append(sumExp);
                cdf = 0.0;
                for ( int k = 0; k < flatZones.Length; k++ )
                {
                    IZone kz = flatZones[k];

                    if ( kz.TotalEmployment > 0 )
                    {
                        empR = Math.Log( ( (double)kz.RetailEmployment / 1000.0 ) + 1.0 );
                        distkm = this.ZoneSystem.Distances[iz.ZoneNumber, kz.ZoneNumber] / 1000;

                        double maxDist;
                        int index;
                        if ( kz.PlanningDistrict == 1 )
                        {
                            maxDist = p[3, 16]; //config <MMaxDist1>
                            index = 16;
                        }
                        //if retail activity > 3
                        else if ( ActivityDistribution.GetDistribution( kz, 0 ) >= 3 )
                        {
                            maxDist = p[3, 17];
                            index = 17;
                        }
                        else
                        {
                            maxDist = p[3, 18];
                            index = 18;
                        }

                        if ( distkm >= 0 && distkm <= maxDist && kz.InternalDistance > 0 )
                        {
                            // empR = ( kz.RetailActivityLevel / 1000 ) + 0.001;
                            sh0 = 0.0;
                            sh1 = 0.0;
                            sh2 = 0.0;
                            if ( distkm >= 0 && distkm < 1 ) sh0 = 1;
                            else if ( distkm >= 1 && distkm < 2 ) sh1 = 1;

                            switch ( index )
                            {
                                case 16:

                                    cdf += Math.Exp( ( p[3, 0] * distkm ) + ( p[3, 1] * empR ) + ( p[3, 2] * sh0 ) + ( p[3, 3] * sh1 ) + ( p[3, 4] * sh2 ) ) / sumExp;
                                    break;

                                case 17:
                                    cdf += Math.Exp( p[3, 6] + ( p[3, 5] * distkm ) + ( p[3, 7] * empR ) + ( p[3, 8] * sh0 ) + ( p[4, 9] * sh1 ) + ( p[3, 10] * sh2 ) ) / sumExp;
                                    break;

                                case 18:
                                    cdf += Math.Exp( p[3, 12] + ( p[3, 11] * distkm ) + ( p[3, 13] * empR ) + ( p[3, 14] * sh0 ) + ( p[3, 15] * sh1 ) ) / sumExp;
                                    break;
                            }
                        }
                    }
                    line.Append( "," );
                    line.Append( cdf );
                }

                writer.WriteLine( line.ToString( 0, line.Length - 1 ) );
            }
            writer.Close();
            //IConfigurationDirectory directory =
            //    TashaConfiguration.GetDirectory("LocationChoiceModelParameters");
            SparseZoneCreator creator = new SparseZoneCreator( 3, ( 4 * flatZones.Last().ZoneNumber ) + 1 );
            creator.LoadCSV( temp, false );
            creator.Save( this.LocatonChoiceModelHomeCache );
            File.Delete( temp );
        }
开发者ID:Cocotus,项目名称:XTMF,代码行数:101,代码来源:LocationChoiceCacheMaker.cs

示例2: BuildLocationChoiceCache

        public void BuildLocationChoiceCache(float[,] p, IZone[] flatZones)
        {
            string temp = Path.GetTempFileName();
            //string temp = Directory.GetCurrentDirectory() + "\\" + "test.csv";
            Console.WriteLine( temp );
            StreamWriter writer = new StreamWriter( temp );
            //fire up the cache

            ZoneCache<IZone>.CacheSize = 8000;
            //each row comparing one zone to another zone
            //column 1 zone ID, column 2 zone(comparing zone),column 3 distance,
            //column 4 sumExp1,
            //column5 exponentExpression1: exp( (p1*distkm) + (p2*log(empP)) + (p3*log(empG)) + (p4*sh0) + (p5*sh1) + (p6*sh2) )
            //column 6 sumExp1,
            //column7 exponentExpression1: exp( (p1*distkm) + (p2*log(empP)) + (p3*log(empG)) + (p4*sh0) + (p5*sh1) + (p6*sh2) )
            //column 8 sumExp1,
            //column9 exponentExpression1: exp( (p1*distkm) + (p2*log(empP)) + (p3*log(empG)) + (p4*sh0) + (p5*sh1) + (p6*sh2) )
            //column 10 sumExp1,
            //column11 exponentExpression1: exp( (p1*distkm) + (p2*log(empP)) + (p3*log(empG)) + (p4*sh0) + (p5*sh1) + (p6*sh2) )
            //n = number of zones, so n*n number of rows
            StringBuilder line = null;
            int sum = 0;

            for ( int i = 0; i < flatZones.Length; i++ )
            {
                IZone iz = flatZones[i];
                if ( ( iz.Population == 0 &&
                   iz.X == 0 && iz.Y == 0 ) || iz.InternalDistance == 0 ) continue;
                else
                {
                    sum++;
                }

                line = new StringBuilder( 100000 );
                line.Append( i );

                BuildOfficeWorkCache( line, iz, p, flatZones );
                BuildManufacturingWorkCache( line, iz, p, flatZones );
                BuildRetailWorkCache( line, iz, p, flatZones );
                BuildProfessionalWorkCache( line, iz, p, flatZones );

                writer.WriteLine( line.ToString( 0, line.Length - 1 ) );
            }
            writer.Close();

            //IConfigurationDirectory directory =
            //    TashaConfiguration.GetDirectory("LocationChoiceModelParameters");
            SparseZoneCreator creator = new SparseZoneCreator( 3, ( 4 * flatZones.Last().ZoneNumber ) + 1 );
            creator.LoadCSV( temp, false );
            creator.Save( LocatonChoiceModelWorkCache );
            File.Delete( temp );
        }
开发者ID:Cocotus,项目名称:XTMF,代码行数:52,代码来源:LocationChoiceCacheMaker.cs


注:本文中的IZone.Last方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。