コード例 #1
0
 /// <summary>
 /// 
 /// </summary>
 public MainWindow()
 {
     InitializeComponent();
     this.DistributionBox.ItemsSource = distributionNames;
     distribution = new Distribution();
     selectedIndex = 0;
 }
コード例 #2
0
ファイル: GRandom.cs プロジェクト: akbiggs/Crash.net
        /**
         * Returns a random Vector3D from specified
         * random distribution.
         **/
        public Vector3D GetRandomVector3D(Distribution type, Vector3D alpha, Vector3D beta)
        {
            if (type == Distribution.Uniform)
            {
                return GetUniformVector3D(alpha, beta);
            }

            if (type == Distribution.Normal)
            {
                return GetNormalVector3D(alpha, beta);
            }

            if (type == Distribution.Exponential)
            {
                return GetExpVector3D(alpha);
            }


            if (type == Distribution.Fixed)
            {
                return alpha;
            }

            return new Vector3D(0, 0, 0);
        }
コード例 #3
0
 public MonteCarloModel(int rankCount, Rank[] ranks)
 {
     MyDistribution = new Distribution();
     MyDistribution.RankCount = rankCount;
     MyDistribution.Ranks = ranks;
     Run();
 }
コード例 #4
0
        public LanguageModel<T> Load(XElement xLanguageModel)
        {
            var metadata = xLanguageModel.Element(MetadataElement).Elements().ToDictionary(el => el.Name.ToString(), el => el.Value);
            var xLanguage = xLanguageModel.Element(LanguageElement);
            string iso639_2T = null;
            var xIso639_2T = xLanguage.Attribute(LanguageIso639_2T_Attribute);
            if (xIso639_2T != null)
                iso639_2T = xIso639_2T.Value;
            string iso639_3 = null;
            var xIso639_3 = xLanguage.Attribute(LanguageIso639_3_Attribute);
            if (xIso639_3 != null)
                iso639_3 = xIso639_3.Value;
            string englishName = null;
            var xEnglishName = xLanguage.Attribute(LanguageEnglishNameAttribute);
            if (xEnglishName != null)
                englishName = xEnglishName.Value;
            string localName = null;
            var xLocalName = xLanguage.Attribute(LanguageLocalNameAttribute);
            if (xLocalName != null)
                localName = xLocalName.Value;
            var language = new LanguageInfo(iso639_2T, iso639_3, englishName, localName);

            var features = new Distribution<T>(new Bag<T>());
            var xNgramsElement = xLanguageModel.Element(NGramsElement);
            foreach (var xElement in xNgramsElement.Elements(NGramElement))
            {
                features.AddEvent(_deserializeFeature(xElement.Attribute(TextAttribute).Value), long.Parse(xElement.Attribute(CountAttribute).Value));
            }
            features.AddNoise(long.Parse(xNgramsElement.Attribute(TotalNoiseCountAtribute).Value), long.Parse(xNgramsElement.Attribute(DistinctNoiseCountAtribute).Value));
            return new LanguageModel<T>(features, language, metadata);
        }
コード例 #5
0
ファイル: AssertionLTL-MEC.cs プロジェクト: nhannhan159/PAT
        public Distribution DistrbutionReCalculate(HashSet<string> scc, MDPState node, Distribution distr)
        {
            double nonSelfLoopProb = 0.0;
            for (int i = 0; i < distr.States.Count; i++)
            {
                KeyValuePair<double, MDPState> pair = distr.States[i];
                if (scc.Contains(pair.Value.ID))
                {
                    //selfLoopProb += pair.Key;
                    //hasSelfLoop = true;
                    //the self loop is removed in this distribution
                    distr.States.Remove(pair);
                    //i-- is used to keep the loop correct after removing one element
                    i--;
                }
                else
                {
                    nonSelfLoopProb += pair.Key;
                }

            }
            foreach (KeyValuePair<double, MDPState> pair in distr.States)
            {
                //KeyValuePair<double, MDPState> newPair = new KeyValuePair<double, MDPState>(pair.Key / nonSelfLoopProb, pair.Value);
                distr.AddProbStatePair(pair.Key / nonSelfLoopProb, pair.Value);
                distr.States.Remove(pair);
            }
            return distr;
        }
コード例 #6
0
ファイル: SimpleSimulation.cs プロジェクト: aidint/SimExpert
        public override Statistics run()
        {
            Environment env = new Environment();

            //dist
            List<double> valueList = new List<double>() { 1, 2, 3, 4, 5 };
            List<double> distribution = new List<double>() { 0.5, 0.6, 0.7, 0.8, 1.0 };
            Discrete d = new Discrete(valueList, distribution);
            //dist1
            Uniform n = new Uniform(1, 3);
            Distribution dist = new Distribution(d);
            Distribution dist1 = new Distribution(n);

            Create c = new Create(env, 0, 20, dist);

            Dispose di = new Dispose(env, 1);

            Queue q = new Queue(env, 3);
            q.Capacity = 1;
            Resource r = new Resource(env, 2, 1, dist1, q);

            c.Next_AID.Add("First", 2);
            r.Next_AID.Add("First", 1);

            env.System_Time = new DateTime(1970, 1, 1, 0, 0, 0);
            env.Start_Time = new DateTime(1970, 1, 1, 0, 0, 0);
            env.Setup_Simulation();
            return env.Simulate();
        }
コード例 #7
0
ファイル: Distribute.cs プロジェクト: wey521520/NewMGC
    public static void AutoDistribute(RectTransform[] rts, SpaceStyle style, Distribution dis)
    {
        float space = 0f;
        switch (style) {
        case SpaceStyle.None:
            space = 0f;
            break;
        case SpaceStyle.Half:
            space = 0.5f;
            break;
        case SpaceStyle.One:
            space = 1f;
            break;
        case SpaceStyle.Two:
            space = 2f;
            break;
        }

        float l = 1f / (rts.Length + space * rts.Length - space);
        switch (dis) {
        case Distribution.Horizontal:
            for (int i = 0; i < rts.Length; i++) {
                rts [i].anchorMin = new Vector2 (i * l * (1 + space), 0f);
                rts [i].anchorMax = new Vector2 (i * l * (1 + space) + l, 1f);
            }
            break;
        case Distribution.Vertical:
            for (int i = 0; i < rts.Length; i++) {
                rts [i].anchorMin = new Vector2 (0f, i * l * (1 + space));
                rts [i].anchorMax = new Vector2 (1f, i * l * (1 + space) + l);
            }
            break;
        }
    }
コード例 #8
0
 public MonteCarloModel(double mean, double std_dev)
 {
     _mean = mean;
     _std_dev = std_dev;
     MyDistribution = new Distribution(new SimulationData(), 0);
     Run();
 }
コード例 #9
0
ファイル: MainWindow.xaml.cs プロジェクト: easla/FuzzyRain
        public Distribution[] ParseFile(string fileName)
        {
            XmlDocument xDoc = new XmlDocument();
            xDoc.Load(fileName);

            // TODO: Es un array de 12 Distributions, 1 x mes, las cuales tienen los valores de lluvias de ese mes para la cantidad de años muestreados.
            // no se si sera una buena estructura pero fue la primera que se me ocurrió para probar el parseo. De ultima habria que cambiarla
            Distribution[] monthsPrecipitations = new Distribution[13];

            for (int i = 1; i <= 12; i++)
            {
                monthsPrecipitations[i] = new Distribution();
            }

            try
            {
                int month;
                double precipitation;
                SimulationType simulationType = GetSimulationType();

                foreach (XmlNode item in xDoc.SelectNodes("/rainfall/yearfall/fall"))
                {
                    month = int.Parse(item.SelectSingleNode("month").Attributes["value"].InnerText);
                    precipitation = double.Parse(item.SelectSingleNode("precipitation").Attributes["value"].InnerText);

                    if (month == 1)
                        monthsPrecipitations[1].AddValueInOrderOfAppearance(precipitation, simulationType);
                    else if (month == 2)
                        monthsPrecipitations[2].AddValueInOrderOfAppearance(precipitation, simulationType);
                    else if (month == 3)
                        monthsPrecipitations[3].AddValueInOrderOfAppearance(precipitation, simulationType);
                    else if (month == 4)
                        monthsPrecipitations[4].AddValueInOrderOfAppearance(precipitation, simulationType);
                    else if (month == 5)
                        monthsPrecipitations[5].AddValueInOrderOfAppearance(precipitation, simulationType);
                    else if (month == 6)
                        monthsPrecipitations[6].AddValueInOrderOfAppearance(precipitation, simulationType);
                    else if (month == 7)
                        monthsPrecipitations[7].AddValueInOrderOfAppearance(precipitation, simulationType);
                    else if (month == 8)
                        monthsPrecipitations[8].AddValueInOrderOfAppearance(precipitation, simulationType);
                    else if (month == 9)
                        monthsPrecipitations[9].AddValueInOrderOfAppearance(precipitation, simulationType);
                    else if (month == 10)
                        monthsPrecipitations[10].AddValueInOrderOfAppearance(precipitation, simulationType);
                    else if (month == 11)
                        monthsPrecipitations[11].AddValueInOrderOfAppearance(precipitation, simulationType);
                    else if (month == 12)
                        monthsPrecipitations[12].AddValueInOrderOfAppearance(precipitation, simulationType);
                }

            }
            catch (Exception ex)
            {
                monthsPrecipitations = null;
            }

            return monthsPrecipitations;
        }
コード例 #10
0
 /// <summary>
 /// Initialize The Static Members in Class Rabbits
 /// </summary>
 /// <param name="MultiInterval">Time (in Days) between each 2 Multiplication Seasons</param>
 /// <param name="Median">Expected Age of Rabbits based on Vegetation Level</param>
 /// <param name="BRate">The number of Rabbits born per couple based on vegetation level
 /// <param name="trRate"> Ratio Of Rabbits which travel to neighbouring Cells</param>
 /// <param name="trDist">the Distance a Rabbit Can travel</param>
 /// And the Number of rabbits in the current context</param>
 public static void init(int MultiInterval, Distribution<float, int> Median, Distribution<int, float, int> BRate, float trRate, int trDist)
 {
     MultiplicationInterval = MultiInterval;
     MedianAge = Median;
     BirthRate = BRate;
     RateOfTravel = trRate;
     TravellingDistance = trDist;
 }
コード例 #11
0
 public MonteCarloModel(int rankCount, Rank[] ranks, double mean, double std_dev)
 {
     _mean = mean;
     _std_dev = std_dev;
     MyDistribution = new Distribution(new SimulationData(), 0);
     MyDistribution.Ranks = ranks;
     Run();
 }
コード例 #12
0
 public LugusRandomGeneratorDistribution(Distribution type,float min, float max, float delta, int seed)
 {
     SetDistributionMethod(type);
     SetSeed(seed);
     _delta = delta;
     _firstOverlap = true;
     _dr = new DataRange(min,max);
 }
コード例 #13
0
ファイル: Distribute.cs プロジェクト: wey521520/NewMGC
 public static void AutoDistribute(GameObject[] objs, SpaceStyle style, Distribution dis)
 {
     RectTransform[] trans = new RectTransform[objs.Length];
     for (int i = 0; i < objs.Length; i++) {
         trans [i] = objs [i].GetComponent <RectTransform> ();
     }
     AutoDistribute (trans, style, dis);
 }
 public static void Initialize(int tstep)
 {
     TStep = tstep;
     deadcohorts = new Landis.Extension.Succession.Biomass.Species.AuxParm<Distribution>(PlugIn.ModelCore.Species);
     foreach (ISpecies species in PlugIn.ModelCore.Species)
     {
         deadcohorts[species] = new Distribution(TStep);
     }
 }
コード例 #15
0
        public void SetInitialData(Distribution distribution)
        {
            double avg = distribution.Average;
            double desv = distribution.Std_Desv;

            lwValues.ItemsSource = distribution.ValuesInOrderOfAppearance;
            txtAvg.Text = avg.ToString("#0.00");
            txtDesv.Text = desv.ToString("#0.00");
        }
コード例 #16
0
        public static double RunSimulation(Task task, Distribution randomNumberGeneratorParameter)
        {
            FisherTippettDistribution randomNumberGenerator = randomNumberGeneratorParameter as FisherTippettDistribution;
            Debug.Assert(randomNumberGenerator != null, "randomNumberGenerator must be not null");

            randomNumberGenerator.Mu = task.Length;
            randomNumberGenerator.Alpha = task.Uncertainty;
            double simulationResult = randomNumberGenerator.NextDouble();
            return simulationResult;
        }
コード例 #17
0
	    public void Insert(string Name,int? Capacity)
	    {
		    Distribution item = new Distribution();
		    
            item.Name = Name;
            
            item.Capacity = Capacity;
            
	    
		    item.Save(UserName);
	    }
コード例 #18
0
 public void DistibutionTest()
 {
     Distribution<float, int> one_dim = new Distribution<float, int>();
     Distribution<int, float, int> tow_Dim = new Distribution<int, float, int>();
     Random r = new Random();
     one_dim[1f] = 4;
     tow_Dim[1] = new Distribution<float, int>();
     tow_Dim[1][2f] = 3;
     AreEqual(one_dim[0f], 4);
     AreEqual(tow_Dim[1][1f], 3);
 }
コード例 #19
0
 private static IDistribution<string> CreateModel(IFeatureExtractor<string, Tuple<string, int>> featureExtractor, string document)
 {
     var features = featureExtractor.GetFeatures(document);
     var bag = new Bag<string>();
     foreach (var feature in features)
     {
         bag.Add(feature.Item1, feature.Item2);
     }
     var distribution = new Distribution<string>(bag);
     return distribution;
 }
コード例 #20
0
ファイル: MonthTab.xaml.cs プロジェクト: easla/FuzzyRain
        public void SetDataMonths(Distribution[] distributions)
        {
            for (int month = 10; month <= 12; month++)
            {
                double avg = distributions[month].Average;
                double desv = distributions[month].Std_Desv;

                ((ListView)tabMonths.FindName("values_" + month)).ItemsSource = distributions[month].ValuesInOrderOfAppearance;
                ((TextBlock)tabMonths.FindName("avg_" + month)).Text = avg.ToString("#0.00");
                ((TextBlock)tabMonths.FindName("desv_" + month)).Text = desv.ToString("#0.00");
            }
        }
コード例 #21
0
        public MonteCarloWithRanks(double convergenceError, Distribution distBase)
        {
            int seed = unchecked( (int)DateTime.Now.Ticks );
            random = new Random(seed);

            MyDistribution = new Distribution(distBase.SimulationData, int.Parse(distBase.Month));
            MyDistribution.Ranks = distBase.Ranks;
            ConvergenceError = convergenceError;
            distributionBase = distBase;

            Run();
        }
コード例 #22
0
ファイル: InventorySample.cs プロジェクト: aidint/SimExpert
        public double run()
        {
            Environment env = new Environment();

            //dist for Create
            Constant Const = new Constant(1);
            Distribution CreateDist = new Distribution(Const);
            //distributions for Inventory
            List<double> States = new List<double>() { 1, 2, 3 }; //1 for good, 2 for fair, 3 for poor
            List<double> States_Prob = new List<double>() { 0.35, 0.80, 1.00 };
            Discrete StatesDisc = new Discrete(States, States_Prob);

            List<double> State1 = new List<double>() { 40, 50, 60, 70, 80, 90, 100 };
            List<double> State1_Prob = new List<double>() { 0.03, 0.08, 0.23, 0.43, 0.78, 0.93, 1.00 };
            Discrete State1Disc = new Discrete(State1, State1_Prob);

            List<double> State2 = new List<double>() { 40, 50, 60, 70, 80, 90, 100 };
            List<double> State2_Prob = new List<double>() { 0.10, 0.28, 0.68, 0.88, 0.96, 1.00, 1.00 };
            Discrete State2Disc = new Discrete(State2, State2_Prob);

            List<double> State3 = new List<double>() { 40, 50, 60, 70, 80, 90, 100 };
            List<double> State3_Prob = new List<double>() { 0.44, 0.66, 0.82, 0.94, 1.00, 1.00, 1.00 };
            Discrete State3Disc = new Discrete(State3, State3_Prob);

            Dictionary<double, Discrete> Demand = new Dictionary<double, Discrete>();
            Demand.Add(1, State1Disc);
            Demand.Add(2, State2Disc);
            Demand.Add(3, State3Disc);

            List<Int64> Amount = new List<Int64>();
            for (int i = 0; i < 20; i++) Amount.Add(70);

            Create create = new Create(env, 0, 20, CreateDist, Amount);

            Dispose dispose = new Dispose(env, 2);

            Inventory inv = new Inventory(env, 1, new TimeSpan(1), 70, StatesDisc, Demand, 0.33, 0.50, true, 0.05);

            create.Next_AID.Add("First", 1);
            inv.Next_AID.Add("First", 2);

            env.System_Time = new DateTime(1970, 1, 1, 0, 0, 0);
            env.Start_Time = new DateTime(1970, 1, 1, 0, 0, 0);

            env.Setup_Simulation();
            env.Simulate();

            double sumOfProfit = 0;
            for (int i = 1; i <= 20; i++)
                sumOfProfit += (double)inv.Statistics.OtherStatistics[i][5].StatisticValue;
            return sumOfProfit;
        }
コード例 #23
0
        public Distribution[] ParseFile(string fileName)
        {
            var rankCount = int.Parse(txtRankCount.Text);
            var rankAmplitude = int.Parse(txtRankAmplitude.Text);

            XmlDocument xDoc = new XmlDocument();
            xDoc.Load(fileName);

            Distribution[] monthsPrecipitations = new Distribution[13];

            for (int i = 1; i <= 12; i++)
            {
                monthsPrecipitations[i] = new Distribution(GetSimulationData(), i);
                monthsPrecipitations[i].CreateRanks(rankCount, rankAmplitude);
            }

            try
            {
                int month;
                double precipitation;
                int year;
                SimulationType simulationType = GetSimulationType();

                foreach (XmlNode item in xDoc.SelectNodes("/rainfall/yearfall"))
                {
                    year = int.Parse(item.Attributes["year"].Value);

                    //foreach (XmlNode item2 in xDoc.SelectNodes("/rainfall/yearfall/fall"))
                    foreach (XmlNode item2 in item.SelectNodes("fall"))
                    {
                        month = int.Parse(item2.SelectSingleNode("month").Attributes["value"].InnerText);
                        precipitation = double.Parse(item2.SelectSingleNode("precipitation").Attributes["value"].InnerText, CultureInfo.InvariantCulture);

                        monthsPrecipitations[month].PutValueInRank(year, precipitation);
                    }
                }

            }
            catch (Exception)
            {
                monthsPrecipitations = null;
            }

            return monthsPrecipitations;
        }
コード例 #24
0
ファイル: Chain.cs プロジェクト: aidint/SimExpert
        public void run()
        {
            Environment env = new Environment();

            //
            List<double> valueList = new List<double>() { 1, 2, 3, 4, 5 };
            List<double> distribution = new List<double>() { 0.5, 0.6, 0.7, 0.8, 1.0 };
            Discrete discrete = new Discrete(valueList, distribution, 0);
            //
            Uniform uniform = new Uniform(1, 3, 0);
            Distribution CreateDist = new Distribution(discrete);
            Distribution ResDist = new Distribution(uniform);

            Create c = new Create(env, 0, 4, CreateDist);

            Dispose dispose = new Dispose(env, 10);

            Queue q = new Queue(env, 5);
            q.Capacity = 10;
            Resource r = new Resource(env, 1, 1, ResDist, q);

            Queue q2 = new Queue(env, 6);
            q2.Capacity = 10;
            Resource r2 = new Resource(env, 2, 1, ResDist, q2);

            Queue q3 = new Queue(env, 7);
            q3.Capacity = 10;
            Resource r3 = new Resource(env, 3, 1, ResDist, q3);

            Queue q4 = new Queue(env, 8);
            q4.Capacity = 10;
            Resource r4 = new Resource(env, 4, 1, ResDist, q4);

            c.Next_AID.Add("First", 1);
            r.Next_AID.Add("First", 2);
            r2.Next_AID.Add("First", 3);
            r3.Next_AID.Add("First", 4);
            r4.Next_AID.Add("First", 2);

            env.System_Time = new DateTime(1970, 1, 1, 0, 0, 0);
            env.Start_Time = new DateTime(1970, 1, 1, 0, 0, 0);
            env.Setup_Simulation(TimeSpan.FromSeconds(300));
            env.Simulate();
        }
コード例 #25
0
ファイル: MosaicPanel.cs プロジェクト: ridomin/waslibs
        protected override Size MeasureOverride(Size availableSize)
        {
            if (base.Children.Count > 0)
            {
                var engine = new Distribution(base.Children.Count, this.SeedWidth);
                _rects = engine.Distribute(availableSize.Width).ToArray();

                for (int n = 0; n < base.Children.Count; n++)
                {
                    var control = base.Children[n];
                    control.Measure(new Size(_rects[n].Width, _rects[n].Height));
                }

                double w = _rects.Max(r => r.X + r.Width);
                double h = _rects.Max(r => r.Y + r.Height);
                return new Size(w, h);
            }
            return new Size(availableSize.Width, 0);
        }
コード例 #26
0
ファイル: AbleBaker.cs プロジェクト: aidint/SimExpert
        public override Statistics run()
        {
            Environment env = new Environment();

            //dist for Create
            Uniform CreateDist = new Uniform(1, 5);

            //dist for Able
            Uniform AbleDist = new Uniform(4, 6);

            //dist for Baker
            Uniform BakerDist = new Uniform(2, 5);

            Distribution DistCreate = new Distribution(CreateDist);
            Distribution DistAble = new Distribution(AbleDist);
            Distribution DistBaker = new Distribution(BakerDist);

            Create create = new Create(env, 0, 100, DistCreate);

            Dispose dispose = new Dispose(env, 10);

            Queue SharedQueue = new Queue(env, 3);

            Resource Able = new Resource(env, 1, 1, DistAble, SharedQueue);

            Resource Baker = new Resource(env, 2, 1, DistBaker, SharedQueue);

            Decide decide = new Decide(env, 5);
            //Condition
            EQCond cond = new EQCond(0, Able, Actor.StateType.Idle);
            decide.AddCondition(cond, Able.AID);
            decide.AddElse(Baker.AID);

            create.Next_AID.Add("First", 5);
            Able.Next_AID.Add("First", 10);
            Baker.Next_AID.Add("First", 10);

            env.System_Time = new DateTime(1970, 1, 1, 0, 0, 0);
            env.Start_Time = new DateTime(1970, 1, 1, 0, 0, 0);

            env.Setup_Simulation();
            return env.Simulate();
        }
コード例 #27
0
ファイル: SimpleProbShare.cs プロジェクト: aidint/SimExpert
        public void run()
        {
            Environment env = new Environment();

            //dist
            List<double> valueList = new List<double>() { 1, 2, 3, 4, 5 };
            List<double> distribution = new List<double>() { 0.5, 0.6, 0.7, 0.8, 1.0 };
            Discrete d = new Discrete(valueList, distribution, 0);
            //dist1
            Uniform n = new Uniform(1, 3, 0);
            Distribution dist = new Distribution(d);
            Distribution dist1 = new Distribution(n);

            Create c = new Create(env, 0, 10000, dist,null,new List<double>(){0.3,0.8,1.0});

            Dispose di = new Dispose(env, 1);

            Queue q = new Queue(env, 3);
            q.Capacity = 1;
            Resource r = new Resource(env, 2, 1, dist1, q);

            Queue q2 = new Queue(env,5);
            q2.Capacity = 1;
            Resource r2 = new Resource(env, 6, 1, dist1, q2);

            Queue q3 = new Queue(env, 10);
            q3.Capacity = 1;
            Resource r3 = new Resource(env, 7, 1, dist1, q3);

            c.Next_AID.Add("First", 2);
            c.Next_AID.Add("Second", 6);
            c.Next_AID.Add("Third", 7);

            r.Next_AID.Add("First", 1);
            r2.Next_AID.Add("First", 1);
            r3.Next_AID.Add("First", 1);

            env.System_Time = new DateTime(1970, 1, 1, 0, 0, 0);
            env.Start_Time = new DateTime(1970, 1, 1, 0, 0, 0);
            env.Setup_Simulation();
            env.Simulate();
        }
コード例 #28
0
 /**
  * Explicit contructor initializes emitter with 
  * specified parameters.
  **/
 public XNAEmitter(
     Vector3D positionMean, Vector3D positionVar, Distribution pDist,
     Vector3D velocityMean, Vector3D velocityVar, Distribution vDist,
     Vector3D accelerationMean, Vector3D accelerationVar, Distribution aDist,
     double angleMean, double angleVar, Distribution angDist,
     double angVelocityMean, double angVelocityVar, Distribution angVelDist,
     Vector3D colorMean, Vector3D colorVar, Distribution colDist,
     double alphaMean, double alphaVar, Distribution transDist,
     double alphaDeltaMean, double alphaDeltaVar, Distribution transDeltaDist,
     double sizeMean, double sizeVar, Distribution sizeDist,
     double sizeDeltaMean, double sizeDeltaVar, Distribution sizeGrowthDist,
     double ttlMean, double ttlVar, Distribution ttlDist,
     Vector3D location,
     Vector3D dimension,
     int maxNumPart,
     int emitRate,
     int emitDelay,
     int emitLife,
     bool permParts)
     : base(positionMean, positionVar, pDist,
     velocityMean, velocityVar, vDist,
     accelerationMean, accelerationVar, aDist,
     angleMean, angleVar, angDist,
     angVelocityMean, angVelocityVar, angVelDist,
     colorMean, colorVar, colDist,
     alphaMean, alphaVar, transDist,
     alphaDeltaMean, alphaDeltaVar, transDeltaDist,
     sizeMean, sizeVar, sizeDist,
     sizeDeltaMean, sizeDeltaVar, sizeGrowthDist,
     ttlMean, ttlVar,ttlDist,
     location,
     dimension,
      maxNumPart,
      emitRate,
      emitDelay,
      emitLife,
      permParts)
 {
      
 }
コード例 #29
0
        public void Distribution()
        {
            var distribution = new Distribution(0, 10, 20);
            distribution.Ranges.Should().BeEquivalentTo(0, 10, 20);
            distribution.Values.Should().BeEquivalentTo(0, 0, 0);
            distribution.ToString().Should().BeEquivalentTo("0=0;10=0;20=0");

            distribution.Add(0);
            distribution.Values.Should().BeEquivalentTo(1, 0, 0);
            distribution.ToString().Should().BeEquivalentTo("0=1;10=0;20=0");

            distribution.Add(9);
            distribution.Values.Should().BeEquivalentTo(2, 0, 0);
            distribution.ToString().Should().BeEquivalentTo("0=2;10=0;20=0");

            distribution.Add(12);
            distribution.Values.Should().BeEquivalentTo(2, 1, 0);
            distribution.ToString().Should().BeEquivalentTo("0=2;10=1;20=0");

            distribution.Add(3);
            distribution.Values.Should().BeEquivalentTo(3, 1, 0);
            distribution.ToString().Should().BeEquivalentTo("0=3;10=1;20=0");

            distribution.Add(10);
            distribution.Values.Should().BeEquivalentTo(3, 2, 0);
            distribution.ToString().Should().BeEquivalentTo("0=3;10=2;20=0");

            distribution.Add(99);
            distribution.Values.Should().BeEquivalentTo(3, 2, 1);
            distribution.ToString().Should().BeEquivalentTo("0=3;10=2;20=1");

            distribution = new Distribution(7, 13);
            distribution.Ranges.Should().BeEquivalentTo(7, 13);
            distribution.Values.Should().BeEquivalentTo(0, 0);
            distribution.ToString().Should().BeEquivalentTo("7=0;13=0");

            distribution.Add(5);
            distribution.Values.Should().BeEquivalentTo(1, 0);
            distribution.ToString().Should().BeEquivalentTo("7=1;13=0");
        }
コード例 #30
0
ファイル: SimpleSharedQueue.cs プロジェクト: aidint/SimExpert
        public void run()
        {
            Environment env = new Environment();

            //dist
            Uniform d = new Uniform(1, 1, 0);

            //dist1
            Uniform n = new Uniform(5, 5, 0);
            Distribution dist = new Distribution(d);
            Distribution dist1 = new Distribution(n);

            Create c = new Create(env, 0, 10, dist);

            Dispose di = new Dispose(env, 10);

            Queue q = new Queue(env, 3);
            q.Capacity = 10;
            Resource r = new Resource(env, 1, 1, dist1, q);

            Queue q2 = new Queue(env, 4);
            q2.Capacity = 5;
            Resource r2 = new Resource(env, 2, 1, dist1, q);

            Decide de = new Decide(env, 5);
            //Condition
            EQCond cond = new EQCond(0, r, Actor.StateType.Busy);
            de.AddCondition(cond, r2.AID);
            de.AddElse(r.AID);

            c.Next_AID.Add("First", 5);
            r.Next_AID.Add("First", 10);
            r2.Next_AID.Add("First", 10);

            env.System_Time = new DateTime(1970, 1, 1, 0, 0, 0);
            env.Start_Time = new DateTime(1970, 1, 1, 0, 0, 0);
            env.Setup_Simulation();
            env.Simulate();
            ///////
        }
コード例 #31
0
ファイル: Distribution.cs プロジェクト: losttech/TorchSharp
 /// <summary>
 /// Returns a new distribution instance (or populates an existing instance provided by a derived class) with batch dimensions expanded to
 /// `batch_shape`. This method calls `~torch.Tensor.expand()` on the distribution's parameters. As such, this does not allocate new
 /// memory for the expanded distribution instance.
 /// </summary>
 /// <param name="batch_shape">Tthe desired expanded size.</param>
 /// <param name="instance">new instance provided by subclasses that need to override `.expand`.</param>
 /// <returns></returns>
 public abstract Distribution expand(long[] batch_shape, Distribution instance = null);
コード例 #32
0
        public static int Main(string[] args)
        {
            var configuration = new Configuration(XDocument.Load(args[0]));

            var xmlOutSettings = new XmlWriterSettings
            {
                Encoding    = Encoding.UTF8,
                Indent      = true,
                IndentChars = "  "
            };

            using (var xmlOut = XmlWriter.Create(args[1], xmlOutSettings))
            {
                xmlOut.WriteComment("This XML format is not an API");
                xmlOut.WriteStartElement("AnalysisOutput");

                xmlOut.WriteStartElement("Files");
                var n = 0;
                foreach (var file in configuration.Files)
                {
                    xmlOut.Flush();
                    Console.WriteLine(n + "/" + configuration.Files.Count() + " files analyzed, starting to analyze: " + file);
                    n++;

                    try
                    {
                        var solution = CompilationHelper.GetSolutionFromFiles(file);

                        var compilation       = solution.Projects.First().GetCompilationAsync().Result;
                        var syntaxTree        = compilation.SyntaxTrees.First();
                        var diagnosticsRunner = new DiagnosticsRunner(configuration.Analyzers());

                        var metrics = new Metrics(syntaxTree);

                        xmlOut.WriteStartElement("File");
                        xmlOut.WriteElementString("Path", file);

                        xmlOut.WriteStartElement("Metrics");

                        xmlOut.WriteElementString("Lines", metrics.Lines().ToString(CultureInfo.InvariantCulture));
                        xmlOut.WriteElementString("Classes", metrics.Classes().ToString(CultureInfo.InvariantCulture));
                        xmlOut.WriteElementString("Accessors", metrics.Accessors().ToString(CultureInfo.InvariantCulture));
                        xmlOut.WriteElementString("Statements", metrics.Statements().ToString(CultureInfo.InvariantCulture));
                        xmlOut.WriteElementString("Functions", metrics.Functions().ToString(CultureInfo.InvariantCulture));
                        xmlOut.WriteElementString("PublicApi", metrics.PublicApi().ToString(CultureInfo.InvariantCulture));
                        xmlOut.WriteElementString("PublicUndocumentedApi", metrics.PublicUndocumentedApi().ToString(CultureInfo.InvariantCulture));

                        var complexity = metrics.Complexity();
                        xmlOut.WriteElementString("Complexity", complexity.ToString(CultureInfo.InvariantCulture));

                        // TODO This is a bit ridiculous, but is how SonarQube works
                        var fileComplexityDistribution = new Distribution(0, 5, 10, 20, 30, 60, 90);
                        fileComplexityDistribution.Add(complexity);
                        xmlOut.WriteElementString("FileComplexityDistribution", fileComplexityDistribution.ToString());

                        xmlOut.WriteElementString("FunctionComplexityDistribution", metrics.FunctionComplexityDistribution().ToString());

                        var comments = metrics.Comments(configuration.IgnoreHeaderComments);
                        xmlOut.WriteStartElement("Comments");
                        xmlOut.WriteStartElement("NoSonar");
                        foreach (var line in comments.NoSonar)
                        {
                            xmlOut.WriteElementString("Line", line.ToString(CultureInfo.InvariantCulture));
                        }
                        xmlOut.WriteEndElement();
                        xmlOut.WriteStartElement("NonBlank");
                        foreach (var line in comments.NonBlank)
                        {
                            xmlOut.WriteElementString("Line", line.ToString(CultureInfo.InvariantCulture));
                        }
                        xmlOut.WriteEndElement();
                        xmlOut.WriteEndElement();

                        xmlOut.WriteStartElement("LinesOfCode");
                        foreach (var line in metrics.LinesOfCode())
                        {
                            xmlOut.WriteElementString("Line", line.ToString(CultureInfo.InvariantCulture));
                        }
                        xmlOut.WriteEndElement();

                        xmlOut.WriteEndElement();

                        xmlOut.WriteStartElement("Issues");

                        foreach (var diagnostic in diagnosticsRunner.GetDiagnostics(compilation))
                        {
                            xmlOut.WriteStartElement("Issue");
                            xmlOut.WriteElementString("Id", diagnostic.Id);
                            if (diagnostic.Location != Location.None)
                            {
                                xmlOut.WriteElementString("Line", (diagnostic.GetLineNumberToReport()).ToString(CultureInfo.InvariantCulture));
                            }
                            xmlOut.WriteElementString("Message", diagnostic.GetMessage());
                            xmlOut.WriteEndElement();
                        }

                        xmlOut.WriteEndElement();

                        xmlOut.WriteEndElement();
                    }
                    catch (Exception e)
                    {
                        Console.Error.WriteLine("Failed to analyze the file: " + file);
                        Console.Error.WriteLine(e);
                        return(1);
                    }
                }

                xmlOut.WriteEndElement();

                xmlOut.WriteEndElement();
                xmlOut.WriteEndDocument();

                xmlOut.Flush();
                return(0);
            }
        }
コード例 #33
0
 public RawDictionaryBenchmark(string type, int threadCount, int workLoadPerThread, Distribution distribution,
                               double theta, int recordCount = 1000000, int capacity = 10000, int innerCapacity = 100)
 {
     this.threadCount       = threadCount;
     this.workLoadPerThread = workLoadPerThread;
     this.distribution      = distribution;
     this.theta             = theta;
     this.recordCount       = recordCount;
     this.dictionary        = DictionaryFactory.newInstance(type);
     this.dictionary.Init(capacity, innerCapacity, recordCount);
     this.capacity      = capacity;
     this.innerCapacity = innerCapacity;
     this.type          = type;
 }
コード例 #34
0
        /// <summary>Computations that depend on the observed value of vVector__230 and vdouble__690</summary>
        private void Changed_vVector__230_vdouble__690()
        {
            if (this.Changed_vVector__230_vdouble__690_iterationsDone == 1)
            {
                return;
            }
            this.vVector__230_marginal = new PointMass <Vector[]>(this.VVector__230);
            this.vdouble__690_marginal = new DistributionStructArray <Gaussian, double>(5622, delegate(int index230) {
                return(Gaussian.Uniform());
            });
            this.vdouble__690_marginal = Distribution.SetPoint <DistributionStructArray <Gaussian, double>, double[]>(this.vdouble__690_marginal, this.Vdouble__690);
            // The constant 'vVectorGaussian230'
            VectorGaussian vVectorGaussian230 = VectorGaussian.FromNatural(DenseVector.FromArray(new double[3] {
                0.0, 0.0, 0.0
            }), new PositiveDefiniteMatrix(new double[3, 3] {
                { 1.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }, { 0.0, 0.0, 1.0 }
            }));

            this.vVector691_marginal_F = ArrayHelper.MakeUniform <VectorGaussian>(vVectorGaussian230);
            // Message from use of 'vdouble__691'
            DistributionStructArray <Gaussian, double> vdouble__691_use_B = default(DistributionStructArray <Gaussian, double>);

            // Create array for 'vdouble__691_use' Backwards messages.
            vdouble__691_use_B = new DistributionStructArray <Gaussian, double>(5622);
            for (int index230 = 0; index230 < 5622; index230++)
            {
                vdouble__691_use_B[index230] = Gaussian.Uniform();
                // Message to 'vdouble__691_use' from GaussianFromMeanAndVariance factor
                vdouble__691_use_B[index230] = GaussianFromMeanAndVarianceOp.MeanAverageConditional(this.Vdouble__690[index230], 0.1);
            }
            DistributionRefArray <VectorGaussian, Vector> vVector691_rep_B = default(DistributionRefArray <VectorGaussian, Vector>);

            // Create array for 'vVector691_rep' Backwards messages.
            vVector691_rep_B = new DistributionRefArray <VectorGaussian, Vector>(5622);
            for (int index230 = 0; index230 < 5622; index230++)
            {
                vVector691_rep_B[index230] = ArrayHelper.MakeUniform <VectorGaussian>(vVectorGaussian230);
                // Message to 'vVector691_rep' from InnerProduct factor
                vVector691_rep_B[index230] = InnerProductOp.AAverageConditional(vdouble__691_use_B[index230], this.VVector__230[index230], vVector691_rep_B[index230]);
            }
            // Buffer for ReplicateOp_Divide.Marginal<VectorGaussian>
            VectorGaussian vVector691_rep_B_toDef = default(VectorGaussian);

            // Message to 'vVector691_rep' from Replicate factor
            vVector691_rep_B_toDef = ReplicateOp_Divide.ToDefInit <VectorGaussian>(vVectorGaussian230);
            // Message to 'vVector691_rep' from Replicate factor
            vVector691_rep_B_toDef = ReplicateOp_Divide.ToDef <VectorGaussian>(vVector691_rep_B, vVector691_rep_B_toDef);
            // Message to 'vVector691_marginal' from Variable factor
            this.vVector691_marginal_F = VariableOp.MarginalAverageConditional <VectorGaussian>(vVector691_rep_B_toDef, vVectorGaussian230, this.vVector691_marginal_F);
            DistributionStructArray <Gaussian, double> vdouble__691_F = default(DistributionStructArray <Gaussian, double>);

            // Create array for 'vdouble__691' Forwards messages.
            vdouble__691_F = new DistributionStructArray <Gaussian, double>(5622);
            for (int index230 = 0; index230 < 5622; index230++)
            {
                vdouble__691_F[index230] = Gaussian.Uniform();
            }
            DistributionRefArray <VectorGaussian, Vector> vVector691_rep_F = default(DistributionRefArray <VectorGaussian, Vector>);

            // Create array for 'vVector691_rep' Forwards messages.
            vVector691_rep_F = new DistributionRefArray <VectorGaussian, Vector>(5622);
            for (int index230 = 0; index230 < 5622; index230++)
            {
                vVector691_rep_F[index230] = ArrayHelper.MakeUniform <VectorGaussian>(vVectorGaussian230);
            }
            // Buffer for ReplicateOp_Divide.UsesAverageConditional<VectorGaussian>
            VectorGaussian vVector691_rep_F_marginal = default(VectorGaussian);

            // Message to 'vVector691_rep' from Replicate factor
            vVector691_rep_F_marginal = ReplicateOp_Divide.MarginalInit <VectorGaussian>(vVectorGaussian230);
            // Message to 'vVector691_rep' from Replicate factor
            vVector691_rep_F_marginal = ReplicateOp_Divide.Marginal <VectorGaussian>(vVector691_rep_B_toDef, vVectorGaussian230, vVector691_rep_F_marginal);
            // Buffer for InnerProductOp.InnerProductAverageConditional
            // Create array for replicates of 'vVector691_rep_F_index230__AMean'
            Vector[] vVector691_rep_F_index230__AMean = new Vector[5622];
            for (int index230 = 0; index230 < 5622; index230++)
            {
                // Message to 'vdouble__691' from InnerProduct factor
                vVector691_rep_F_index230__AMean[index230] = InnerProductOp.AMeanInit(vVector691_rep_F[index230]);
            }
            // Buffer for InnerProductOp.AMean
            // Create array for replicates of 'vVector691_rep_F_index230__AVariance'
            PositiveDefiniteMatrix[] vVector691_rep_F_index230__AVariance = new PositiveDefiniteMatrix[5622];
            for (int index230 = 0; index230 < 5622; index230++)
            {
                // Message to 'vdouble__691' from InnerProduct factor
                vVector691_rep_F_index230__AVariance[index230] = InnerProductOp.AVarianceInit(vVector691_rep_F[index230]);
                // Message to 'vVector691_rep' from Replicate factor
                vVector691_rep_F[index230] = ReplicateOp_Divide.UsesAverageConditional <VectorGaussian>(vVector691_rep_B[index230], vVector691_rep_F_marginal, index230, vVector691_rep_F[index230]);
            }
            // Create array for 'vdouble__691_marginal' Forwards messages.
            this.vdouble__691_marginal_F = new DistributionStructArray <Gaussian, double>(5622);
            for (int index230 = 0; index230 < 5622; index230++)
            {
                this.vdouble__691_marginal_F[index230] = Gaussian.Uniform();
                // Message to 'vdouble__691' from InnerProduct factor
                vVector691_rep_F_index230__AVariance[index230] = InnerProductOp.AVariance(vVector691_rep_F[index230], vVector691_rep_F_index230__AVariance[index230]);
                // Message to 'vdouble__691' from InnerProduct factor
                vVector691_rep_F_index230__AMean[index230] = InnerProductOp.AMean(vVector691_rep_F[index230], vVector691_rep_F_index230__AVariance[index230], vVector691_rep_F_index230__AMean[index230]);
                // Message to 'vdouble__691' from InnerProduct factor
                vdouble__691_F[index230] = InnerProductOp.InnerProductAverageConditional(vVector691_rep_F_index230__AMean[index230], vVector691_rep_F_index230__AVariance[index230], this.VVector__230[index230]);
                // Message to 'vdouble__691_marginal' from DerivedVariable factor
                this.vdouble__691_marginal_F[index230] = DerivedVariableOp.MarginalAverageConditional <Gaussian>(vdouble__691_use_B[index230], vdouble__691_F[index230], this.vdouble__691_marginal_F[index230]);
            }
            this.Changed_vVector__230_vdouble__690_iterationsDone = 1;
        }
コード例 #35
0
        /// <summary>Computations that depend on the observed value of numberOfIterationsDecreased and WetGrass</summary>
        /// <param name="numberOfIterations">The number of times to iterate each loop</param>
        public void Changed_numberOfIterationsDecreased_WetGrass(int numberOfIterations)
        {
            if (this.Changed_numberOfIterationsDecreased_WetGrass_iterationsDone == numberOfIterations)
            {
                return;
            }
            // The constant 'vBernoulli59'
            Bernoulli vBernoulli59 = Bernoulli.FromLogOdds(4.5951198501345889);

            this.WetGrass_marginal = ArrayHelper.MakeUniform <Bernoulli>(vBernoulli59);
            this.WetGrass_marginal = Distribution.SetPoint <Bernoulli, bool>(this.WetGrass_marginal, this.wetGrass);
            Bernoulli Rain_F = ArrayHelper.MakeUniform <Bernoulli>(this.vBernoulli57);
            // The constant 'vBernoulli54'
            Bernoulli vBernoulli54 = Bernoulli.FromLogOdds(0);

            this.Cloudy_marginal_F = ArrayHelper.MakeUniform <Bernoulli>(vBernoulli54);
            DistributionStructArray <Bernoulli, bool> Rain_cond_Cloudy_F = default(DistributionStructArray <Bernoulli, bool>);

            // Create array for 'Rain_cond_Cloudy' Forwards messages.
            Rain_cond_Cloudy_F = new DistributionStructArray <Bernoulli, bool>(2);
            for (int _gateind = 0; _gateind < 2; _gateind++)
            {
                Rain_cond_Cloudy_F[_gateind] = ArrayHelper.MakeUniform <Bernoulli>(this.vBernoulli57);
            }
            // Message to 'Rain_cond_Cloudy' from Copy factor
            Rain_cond_Cloudy_F[0] = Factor.Copy <Bernoulli>(this.vBernoulli57);
            // The constant 'vBernoulli58'
            Bernoulli vBernoulli58 = Bernoulli.FromLogOdds(0.28185115214098749);

            // Message to 'Rain_cond_Cloudy' from Copy factor
            Rain_cond_Cloudy_F[1] = Factor.Copy <Bernoulli>(vBernoulli58);
            DistributionStructArray <Bernoulli, bool> Cloudy_selector_cases_F = default(DistributionStructArray <Bernoulli, bool>);

            // Create array for 'Cloudy_selector_cases' Forwards messages.
            Cloudy_selector_cases_F = new DistributionStructArray <Bernoulli, bool>(2);
            for (int _iv0 = 0; _iv0 < 2; _iv0++)
            {
                Cloudy_selector_cases_F[_iv0] = ArrayHelper.MakeUniform <Bernoulli>(new Bernoulli());
            }
            // Message to 'Cloudy_selector_cases' from Cases factor
            Cloudy_selector_cases_F = CasesOp.CasesAverageConditional <DistributionStructArray <Bernoulli, bool> >(vBernoulli54, Cloudy_selector_cases_F);
            // The constant 'vBernoulli55'
            Bernoulli vBernoulli55 = Bernoulli.FromLogOdds(-2.1972245773362191);
            DistributionStructArray <Bernoulli, bool> Sprinkler_cond_Cloudy_F = default(DistributionStructArray <Bernoulli, bool>);

            // Create array for 'Sprinkler_cond_Cloudy' Forwards messages.
            Sprinkler_cond_Cloudy_F = new DistributionStructArray <Bernoulli, bool>(2);
            for (int _gateind = 0; _gateind < 2; _gateind++)
            {
                Sprinkler_cond_Cloudy_F[_gateind] = ArrayHelper.MakeUniform <Bernoulli>(vBernoulli55);
            }
            // Message to 'Sprinkler_cond_Cloudy' from Copy factor
            Sprinkler_cond_Cloudy_F[0] = Factor.Copy <Bernoulli>(vBernoulli55);
            // Message to 'Sprinkler_cond_Cloudy' from Copy factor
            Sprinkler_cond_Cloudy_F[1] = Factor.Copy <Bernoulli>(vBernoulli54);
            Bernoulli Rain_cond_Sprinkler_0_selector_cases_0_B = ArrayHelper.MakeUniform <Bernoulli>(new Bernoulli());

            // Message to 'Rain_cond_Sprinkler_0_selector_cases_0' from Random factor
            Rain_cond_Sprinkler_0_selector_cases_0_B = Bernoulli.FromLogOdds(UnaryOp <bool> .LogEvidenceRatio <Bernoulli>(this.wetGrass, vBernoulli59));
            DistributionStructArray <Bernoulli, bool> Rain_cond_Sprinkler_0_selector_cases_B = default(DistributionStructArray <Bernoulli, bool>);

            // Create array for 'Rain_cond_Sprinkler_0_selector_cases' Backwards messages.
            Rain_cond_Sprinkler_0_selector_cases_B = new DistributionStructArray <Bernoulli, bool>(2);
            for (int _ind0 = 0; _ind0 < 2; _ind0++)
            {
                Rain_cond_Sprinkler_0_selector_cases_B[_ind0] = ArrayHelper.MakeUniform <Bernoulli>(new Bernoulli());
            }
            // Message to 'Rain_cond_Sprinkler_0_selector_cases' from Copy factor
            Rain_cond_Sprinkler_0_selector_cases_B[0] = Factor.Copy <Bernoulli>(Rain_cond_Sprinkler_0_selector_cases_0_B);
            // The constant 'vBernoulli60'
            Bernoulli vBernoulli60 = Bernoulli.FromLogOdds(2.1972245773362196);
            Bernoulli Rain_cond_Sprinkler_0_selector_cases_1_B = ArrayHelper.MakeUniform <Bernoulli>(new Bernoulli());

            // Message to 'Rain_cond_Sprinkler_0_selector_cases_1' from Random factor
            Rain_cond_Sprinkler_0_selector_cases_1_B = Bernoulli.FromLogOdds(UnaryOp <bool> .LogEvidenceRatio <Bernoulli>(this.wetGrass, vBernoulli60));
            // Message to 'Rain_cond_Sprinkler_0_selector_cases' from Copy factor
            Rain_cond_Sprinkler_0_selector_cases_B[1] = Factor.Copy <Bernoulli>(Rain_cond_Sprinkler_0_selector_cases_1_B);
            Bernoulli[] Sprinkler_selector_cases_0_uses_B = default(Bernoulli[]);
            // Create array for 'Sprinkler_selector_cases_0_uses' Backwards messages.
            Sprinkler_selector_cases_0_uses_B = new Bernoulli[5];
            for (int _ind = 0; _ind < 5; _ind++)
            {
                Sprinkler_selector_cases_0_uses_B[_ind] = ArrayHelper.MakeUniform <Bernoulli>(new Bernoulli());
            }
            Bernoulli Sprinkler_selector_cases_0_B = ArrayHelper.MakeUniform <Bernoulli>(new Bernoulli());
            DistributionStructArray <Bernoulli, bool> Sprinkler_selector_cases_B = default(DistributionStructArray <Bernoulli, bool>);

            // Create array for 'Sprinkler_selector_cases' Backwards messages.
            Sprinkler_selector_cases_B = new DistributionStructArray <Bernoulli, bool>(2);
            for (int _ind0 = 0; _ind0 < 2; _ind0++)
            {
                Sprinkler_selector_cases_B[_ind0] = ArrayHelper.MakeUniform <Bernoulli>(new Bernoulli());
            }
            Bernoulli Rain_cond_Sprinkler_1_selector_cases_0_B = ArrayHelper.MakeUniform <Bernoulli>(new Bernoulli());

            // Message to 'Rain_cond_Sprinkler_1_selector_cases_0' from Random factor
            Rain_cond_Sprinkler_1_selector_cases_0_B = Bernoulli.FromLogOdds(UnaryOp <bool> .LogEvidenceRatio <Bernoulli>(this.wetGrass, vBernoulli60));
            DistributionStructArray <Bernoulli, bool> Rain_cond_Sprinkler_1_selector_cases_B = default(DistributionStructArray <Bernoulli, bool>);

            // Create array for 'Rain_cond_Sprinkler_1_selector_cases' Backwards messages.
            Rain_cond_Sprinkler_1_selector_cases_B = new DistributionStructArray <Bernoulli, bool>(2);
            for (int _ind0 = 0; _ind0 < 2; _ind0++)
            {
                Rain_cond_Sprinkler_1_selector_cases_B[_ind0] = ArrayHelper.MakeUniform <Bernoulli>(new Bernoulli());
            }
            // Message to 'Rain_cond_Sprinkler_1_selector_cases' from Copy factor
            Rain_cond_Sprinkler_1_selector_cases_B[0] = Factor.Copy <Bernoulli>(Rain_cond_Sprinkler_1_selector_cases_0_B);
            // The constant 'vBernoulli62'
            Bernoulli vBernoulli62 = Bernoulli.FromLogOdds(-2.4423470353692043);
            Bernoulli Rain_cond_Sprinkler_1_selector_cases_1_B = ArrayHelper.MakeUniform <Bernoulli>(new Bernoulli());

            // Message to 'Rain_cond_Sprinkler_1_selector_cases_1' from Random factor
            Rain_cond_Sprinkler_1_selector_cases_1_B = Bernoulli.FromLogOdds(UnaryOp <bool> .LogEvidenceRatio <Bernoulli>(this.wetGrass, vBernoulli62));
            // Message to 'Rain_cond_Sprinkler_1_selector_cases' from Copy factor
            Rain_cond_Sprinkler_1_selector_cases_B[1] = Factor.Copy <Bernoulli>(Rain_cond_Sprinkler_1_selector_cases_1_B);
            Bernoulli[] Sprinkler_selector_cases_1_uses_B = default(Bernoulli[]);
            // Create array for 'Sprinkler_selector_cases_1_uses' Backwards messages.
            Sprinkler_selector_cases_1_uses_B = new Bernoulli[5];
            for (int _ind = 0; _ind < 5; _ind++)
            {
                Sprinkler_selector_cases_1_uses_B[_ind] = ArrayHelper.MakeUniform <Bernoulli>(new Bernoulli());
            }
            Bernoulli Sprinkler_selector_cases_1_B = ArrayHelper.MakeUniform <Bernoulli>(new Bernoulli());

            Bernoulli[] Sprinkler_selector_uses_B = default(Bernoulli[]);
            // Create array for 'Sprinkler_selector_uses' Backwards messages.
            Sprinkler_selector_uses_B = new Bernoulli[2];
            for (int _ind = 0; _ind < 2; _ind++)
            {
                Sprinkler_selector_uses_B[_ind] = ArrayHelper.MakeUniform <Bernoulli>(vBernoulli55);
            }
            Bernoulli Sprinkler_selector_B = ArrayHelper.MakeUniform <Bernoulli>(vBernoulli55);
            // Buffer for Replicate2BufferOp.UsesAverageConditional<DistributionStructArray<Bernoulli,bool>>
            DistributionStructArray <Bernoulli, bool> Cloudy_selector_cases_uses_B_marginal = default(DistributionStructArray <Bernoulli, bool>);

            // Message to 'Cloudy_selector_cases_uses' from Replicate factor
            Cloudy_selector_cases_uses_B_marginal = Replicate2BufferOp.MarginalInit <DistributionStructArray <Bernoulli, bool> >(Cloudy_selector_cases_F);
            DistributionStructArray <Bernoulli, bool>[] Cloudy_selector_cases_uses_F = default(DistributionStructArray <Bernoulli, bool>[]);
            // Create array for 'Cloudy_selector_cases_uses' Forwards messages.
            Cloudy_selector_cases_uses_F = new DistributionStructArray <Bernoulli, bool> [4];
            for (int _ind = 0; _ind < 4; _ind++)
            {
                // Create array for 'Cloudy_selector_cases_uses' Forwards messages.
                Cloudy_selector_cases_uses_F[_ind] = new DistributionStructArray <Bernoulli, bool>(2);
                for (int _iv0 = 0; _iv0 < 2; _iv0++)
                {
                    Cloudy_selector_cases_uses_F[_ind][_iv0] = ArrayHelper.MakeUniform <Bernoulli>(new Bernoulli());
                }
            }
            Bernoulli Sprinkler_F = ArrayHelper.MakeUniform <Bernoulli>(vBernoulli55);
            // Buffer for Replicate2BufferOp.UsesAverageConditional<Bernoulli>
            Bernoulli Sprinkler_selector_uses_B_marginal = default(Bernoulli);

            // Message to 'Sprinkler_selector_uses' from Replicate factor
            Sprinkler_selector_uses_B_marginal = Replicate2BufferOp.MarginalInit <Bernoulli>(Sprinkler_F);
            Bernoulli[] Sprinkler_selector_uses_F = default(Bernoulli[]);
            // Create array for 'Sprinkler_selector_uses' Forwards messages.
            Sprinkler_selector_uses_F = new Bernoulli[2];
            for (int _ind = 0; _ind < 2; _ind++)
            {
                Sprinkler_selector_uses_F[_ind] = ArrayHelper.MakeUniform <Bernoulli>(vBernoulli55);
            }
            Bernoulli Rain_cond_Sprinkler_0_selector_B = ArrayHelper.MakeUniform <Bernoulli>(this.vBernoulli57);

            // Message to 'Rain_cond_Sprinkler_0_selector' from Cases factor
            Rain_cond_Sprinkler_0_selector_B = CasesOp.BAverageConditional(Rain_cond_Sprinkler_0_selector_cases_B);
            DistributionStructArray <Bernoulli, bool> Rain_cond_Sprinkler_B = default(DistributionStructArray <Bernoulli, bool>);

            // Create array for 'Rain_cond_Sprinkler' Backwards messages.
            Rain_cond_Sprinkler_B = new DistributionStructArray <Bernoulli, bool>(2);
            for (int _gateind = 0; _gateind < 2; _gateind++)
            {
                Rain_cond_Sprinkler_B[_gateind] = ArrayHelper.MakeUniform <Bernoulli>(this.vBernoulli57);
            }
            // Message to 'Rain_cond_Sprinkler' from Copy factor
            Rain_cond_Sprinkler_B[0] = Factor.Copy <Bernoulli>(Rain_cond_Sprinkler_0_selector_B);
            Bernoulli Rain_cond_Sprinkler_1_selector_B = ArrayHelper.MakeUniform <Bernoulli>(this.vBernoulli57);

            // Message to 'Rain_cond_Sprinkler_1_selector' from Cases factor
            Rain_cond_Sprinkler_1_selector_B = CasesOp.BAverageConditional(Rain_cond_Sprinkler_1_selector_cases_B);
            // Message to 'Rain_cond_Sprinkler' from Copy factor
            Rain_cond_Sprinkler_B[1] = Factor.Copy <Bernoulli>(Rain_cond_Sprinkler_1_selector_B);
            for (int iteration = this.Changed_numberOfIterationsDecreased_WetGrass_iterationsDone; iteration < numberOfIterations; iteration++)
            {
                // Message to 'Cloudy_selector_cases_uses' from Replicate factor
                Cloudy_selector_cases_uses_B_marginal = Replicate2BufferOp.Marginal <DistributionStructArray <Bernoulli, bool> >(this.Cloudy_selector_cases_uses_B, Cloudy_selector_cases_F, Cloudy_selector_cases_uses_B_marginal);
                // Message to 'Cloudy_selector_cases_uses' from Replicate factor
                Cloudy_selector_cases_uses_F[1] = Replicate2BufferOp.UsesAverageConditional <DistributionStructArray <Bernoulli, bool> >(this.Cloudy_selector_cases_uses_B, Cloudy_selector_cases_F, Cloudy_selector_cases_uses_B_marginal, 1, Cloudy_selector_cases_uses_F[1]);
                // Message to 'Rain' from Exit factor
                Rain_F = GateExitOp <bool> .ExitAverageConditional <Bernoulli>(this.Rain_use_B, Cloudy_selector_cases_uses_F[1], Rain_cond_Cloudy_F, Rain_F);

                // Message to 'Sprinkler_selector_cases_1_uses' from Cases factor
                Sprinkler_selector_cases_1_uses_B[4] = Bernoulli.FromLogOdds(CasesOp.LogEvidenceRatio(Rain_cond_Sprinkler_1_selector_cases_B, Rain_F));
                // Message to 'Sprinkler_selector_cases_1' from Replicate factor
                Sprinkler_selector_cases_1_B = ReplicateOp.DefAverageConditional <Bernoulli>(Sprinkler_selector_cases_1_uses_B, Sprinkler_selector_cases_1_B);
                // Message to 'Sprinkler_selector_cases' from Copy factor
                Sprinkler_selector_cases_B[1] = Factor.Copy <Bernoulli>(Sprinkler_selector_cases_1_B);
                // Message to 'Sprinkler_selector_cases_0_uses' from Cases factor
                Sprinkler_selector_cases_0_uses_B[4] = Bernoulli.FromLogOdds(CasesOp.LogEvidenceRatio(Rain_cond_Sprinkler_0_selector_cases_B, Rain_F));
                // Message to 'Sprinkler_selector_cases_0' from Replicate factor
                Sprinkler_selector_cases_0_B = ReplicateOp.DefAverageConditional <Bernoulli>(Sprinkler_selector_cases_0_uses_B, Sprinkler_selector_cases_0_B);
                // Message to 'Sprinkler_selector_cases' from Copy factor
                Sprinkler_selector_cases_B[0] = Factor.Copy <Bernoulli>(Sprinkler_selector_cases_0_B);
                // Message to 'Sprinkler_selector_uses' from Cases factor
                Sprinkler_selector_uses_B[0] = CasesOp.BAverageConditional(Sprinkler_selector_cases_B);
                // Message to 'Sprinkler_selector' from Replicate factor
                Sprinkler_selector_B = ReplicateOp.DefAverageConditional <Bernoulli>(Sprinkler_selector_uses_B, Sprinkler_selector_B);
                // Message to 'Cloudy_selector_cases_uses' from Exit factor
                this.Cloudy_selector_cases_uses_B[3] = GateExitOp <bool> .CasesAverageConditional <Bernoulli, DistributionStructArray <Bernoulli, bool> >(Sprinkler_selector_B, Sprinkler_cond_Cloudy_F, this.Cloudy_selector_cases_uses_B[3]);

                // Message to 'Cloudy_selector_cases_uses' from Replicate factor
                Cloudy_selector_cases_uses_B_marginal = Replicate2BufferOp.Marginal <DistributionStructArray <Bernoulli, bool> >(this.Cloudy_selector_cases_uses_B, Cloudy_selector_cases_F, Cloudy_selector_cases_uses_B_marginal);
                // Message to 'Cloudy_selector_cases_uses' from Replicate factor
                Cloudy_selector_cases_uses_F[3] = Replicate2BufferOp.UsesAverageConditional <DistributionStructArray <Bernoulli, bool> >(this.Cloudy_selector_cases_uses_B, Cloudy_selector_cases_F, Cloudy_selector_cases_uses_B_marginal, 3, Cloudy_selector_cases_uses_F[3]);
                // Message to 'Sprinkler' from Exit factor
                Sprinkler_F = GateExitOp <bool> .ExitAverageConditional <Bernoulli>(Sprinkler_selector_B, Cloudy_selector_cases_uses_F[3], Sprinkler_cond_Cloudy_F, Sprinkler_F);

                // Message to 'Sprinkler_selector_uses' from Replicate factor
                Sprinkler_selector_uses_B_marginal = Replicate2BufferOp.Marginal <Bernoulli>(Sprinkler_selector_uses_B, Sprinkler_F, Sprinkler_selector_uses_B_marginal);
                // Message to 'Sprinkler_selector_uses' from Replicate factor
                Sprinkler_selector_uses_F[1] = Replicate2BufferOp.UsesAverageConditional <Bernoulli>(Sprinkler_selector_uses_B, Sprinkler_F, Sprinkler_selector_uses_B_marginal, 1, Sprinkler_selector_uses_F[1]);
                // Message to 'Rain_use' from EnterPartial factor
                this.Rain_use_B = GateEnterPartialOp <bool> .ValueAverageConditional <Bernoulli>(Rain_cond_Sprinkler_B, Sprinkler_selector_uses_F[1], Rain_F, new int[2] {
                    0, 1
                }, this.Rain_use_B);

                // Message to 'Cloudy_selector_cases_uses' from Exit factor
                this.Cloudy_selector_cases_uses_B[1] = GateExitOp <bool> .CasesAverageConditional <Bernoulli, DistributionStructArray <Bernoulli, bool> >(this.Rain_use_B, Rain_cond_Cloudy_F, this.Cloudy_selector_cases_uses_B[1]);

                this.OnProgressChanged(new ProgressChangedEventArgs(iteration));
            }
            DistributionStructArray <Bernoulli, bool> Cloudy_selector_cases_B = default(DistributionStructArray <Bernoulli, bool>);

            // Create array for 'Cloudy_selector_cases' Backwards messages.
            Cloudy_selector_cases_B = new DistributionStructArray <Bernoulli, bool>(2);
            for (int _iv0 = 0; _iv0 < 2; _iv0++)
            {
                Cloudy_selector_cases_B[_iv0] = ArrayHelper.MakeUniform <Bernoulli>(new Bernoulli());
            }
            // Message to 'Cloudy_selector_cases' from Replicate factor
            Cloudy_selector_cases_B = ReplicateOp.DefAverageConditional <DistributionStructArray <Bernoulli, bool> >(this.Cloudy_selector_cases_uses_B, Cloudy_selector_cases_B);
            Bernoulli Cloudy_selector_B = ArrayHelper.MakeUniform <Bernoulli>(vBernoulli54);

            // Message to 'Cloudy_selector' from Cases factor
            Cloudy_selector_B = CasesOp.BAverageConditional(Cloudy_selector_cases_B);
            // Message to 'Cloudy_marginal' from Variable factor
            this.Cloudy_marginal_F = VariableOp.MarginalAverageConditional <Bernoulli>(Cloudy_selector_B, vBernoulli54, this.Cloudy_marginal_F);
            this.Rain_marginal_F   = ArrayHelper.MakeUniform <Bernoulli>(this.vBernoulli57);
            // Message to 'Rain_marginal' from DerivedVariable factor
            this.Rain_marginal_F      = DerivedVariableOp.MarginalAverageConditional <Bernoulli>(this.Rain_use_B, Rain_F, this.Rain_marginal_F);
            this.Sprinkler_marginal_F = ArrayHelper.MakeUniform <Bernoulli>(vBernoulli55);
            // Message to 'Sprinkler_marginal' from DerivedVariable factor
            this.Sprinkler_marginal_F = DerivedVariableOp.MarginalAverageConditional <Bernoulli>(Sprinkler_selector_B, Sprinkler_F, this.Sprinkler_marginal_F);
            this.Changed_numberOfIterationsDecreased_WetGrass_iterationsDone = numberOfIterations;
        }
コード例 #36
0
 public void TestNullBucketBoundaries()
 {
     Assert.Throws <ArgumentNullException>(() => Distribution.Create(null));;
 }
コード例 #37
0
ファイル: Containers.cs プロジェクト: marcos914/RawTools
 public NewMetaData(double dutyCycle, double fillTime, double scanTime, double ms2ScansPerCycle, Distribution intensityDistribution)
 {
     DutyCycle             = dutyCycle;
     FillTime              = fillTime;
     MS2ScansPerCycle      = ms2ScansPerCycle;
     IntensityDistribution = intensityDistribution;
 }
コード例 #38
0
        public string FTP_King(string streetno, string streettype, string streetname, string unitnumber, string ownernm, string parcelNumber, string searchType, string orderNumber, string directParcel)
        {
            GlobalClass.global_orderNo             = orderNumber;
            HttpContext.Current.Session["orderNo"] = orderNumber;
            GlobalClass.global_parcelNo            = parcelNumber;
            var option = new ChromeOptions();

            option.AddArgument("No-Sandbox");
            //var driverService = PhantomJSDriverService.CreateDefaultService();
            //driverService.HideCommandPromptWindow = true;
            //driver = new ChromeDriver();
            //driver = new PhantomJSDriver();
            using (driver = new ChromeDriver(option))
            {
                if (directParcel.ToUpper() == "NORTH")
                {
                    directParcel = "N";
                }
                if (directParcel.ToUpper() == "NORTH EAST")
                {
                    directParcel = "NE";
                }
                if (directParcel.ToUpper() == "SOUTH EAST")
                {
                    directParcel = "SE";
                }
                string Address = "";
                if (directParcel != "")
                {
                    Address = streetno + " " + directParcel + " " + streetname + " " + streettype;
                }
                else
                {
                    Address = streetno + " " + streetname + " " + streettype;
                }
                try
                {
                    StartTime = DateTime.Now.ToString("HH:mm:ss");

                    if (searchType == "titleflex")
                    {
                        string straddress = "";
                        if (directParcel != "")
                        {
                            straddress = streetno + " " + directParcel + " " + streetname + " " + streettype + " " + unitnumber;
                        }
                        else
                        {
                            straddress = streetno + " " + streetname + " " + streettype + " " + unitnumber;
                        }


                        gc.TitleFlexSearch(orderNumber, "", ownernm, straddress, "WA", "King");
                        if (HttpContext.Current.Session["TitleFlex_Search"] != null)
                        {
                            string result = HttpContext.Current.Session["TitleFlex_Search"].ToString();
                        }

                        if ((HttpContext.Current.Session["TitleFlex_Search"] != null && HttpContext.Current.Session["TitleFlex_Search"].ToString() == "Yes"))
                        {
                            driver.Quit();
                            return("MultiParcel");
                        }
                        else if (HttpContext.Current.Session["titleparcel"].ToString() == "")
                        {
                            HttpContext.Current.Session["Nodata_WAKing"] = "Yes";
                            driver.Quit();
                            return("No Data Found");
                        }
                        parcelNumber = HttpContext.Current.Session["titleparcel"].ToString();
                        searchType   = "parcel";
                    }
                    if (searchType == "address")
                    {
                        Start(orderNumber);
                        gc.CreatePdf_WOP(orderNumber, "AddressSearch before", driver, "WA", "King");
                        Thread.Sleep(8000);
                        driver.FindElement(By.Id("cphContent_txtAddress")).SendKeys(Address);
                        gc.CreatePdf_WOP(orderNumber, "AddressSearch", driver, "WA", "King");
                        driver.FindElement(By.Id("cphContent_btn_SearchAddress")).SendKeys(Keys.Enter);
                        Thread.Sleep(2000);
                        try
                        { try
                          {                                         //  cphContent_GridViewParcelList
                              multy = driver.FindElement(By.Id("kingcounty_gov_cphContent_GridViewParcelList"));
                          }
                          catch { }
                          try
                          {
                              multy = driver.FindElement(By.Id("cphContent_GridViewParcelList"));
                          }
                          catch { }
                          IList <IWebElement> muladdress = multy.FindElements(By.TagName("tr"));
                          IList <IWebElement> mulid;
                          foreach (IWebElement addressrow in muladdress)
                          {
                              mulid = addressrow.FindElements(By.TagName("td"));
                              if (mulid.Count != 0)
                              {
                                  if (Mcount <= 25)
                                  {
                                      Parcel_no       = mulid[0].Text;
                                      Addresss        = mulid[1].Text;
                                      Taxpayer_Name   = mulid[2].Text;
                                      Building_Number = mulid[3].Text;
                                      Unit_Number     = mulid[4].Text;
                                      string MultyInst = "" + "~" + Addresss + "~" + Taxpayer_Name + "~" + Building_Number + "~" + Unit_Number;
                                      gc.insert_date(orderNumber, Parcel_no, 552, MultyInst, 1, DateTime.Now);
                                  }
                                  Mcount++;
                              }
                          }
                          if (Mcount > 25)
                          {
                              HttpContext.Current.Session["multiParcel_King_Multicount"] = "Maximum";
                          }
                          else
                          {
                              HttpContext.Current.Session["multiparcel_King"] = "Yes";
                          }
                          driver.Quit();
                          return("MultiParcel"); }
                        catch { }

                        try
                        {
                            //No Data Found
                            string nodata = driver.FindElement(By.Id("cphContent_lblAddressMsg")).Text;
                            if (nodata.Contains("Can not find"))
                            {
                                HttpContext.Current.Session["Nodata_WAKing"] = "Yes";
                                driver.Quit();
                                return("No Data Found");
                            }
                        }
                        catch { }
                    }
                    if (searchType == "parcel")
                    {
                        Start(orderNumber);
                        gc.CreatePdf(orderNumber, Parcel_no, "Aggre Click", driver, "WA", "King");
                        Thread.Sleep(2000); //cphContent_txtParcelNbr
                        driver.FindElement(By.Id("cphContent_txtParcelNbr")).SendKeys(parcelNumber);
                        gc.CreatePdf(orderNumber, parcelNumber, "Parcelsearch", driver, "WA", "King");
                        // cphContent_btn_Search
                        driver.FindElement(By.Id("cphContent_btn_Search")).SendKeys(Keys.Enter);
                        Thread.Sleep(2000);
                        try
                        {
                            IWebElement         multy      = driver.FindElement(By.Id("kingcounty_gov_cphContent_GridViewComplex"));
                            IList <IWebElement> muladdress = multy.FindElements(By.TagName("tr"));
                            IList <IWebElement> mulid;
                            foreach (IWebElement addressrow in muladdress)
                            {
                                mulid = addressrow.FindElements(By.TagName("td"));
                                if (mulid.Count != 0)
                                {
                                    if (mulid[0].Text.Trim() == parcelNumber.Trim())
                                    {
                                        IWebElement parcelclick = mulid[0];
                                        parcelclick.Click();
                                        Thread.Sleep(2000);
                                        break;
                                    }
                                }
                            }
                        }
                        catch { }

                        try
                        {
                            //No Data Found
                            string nodata = driver.FindElement(By.Id("cphContent_LblMsg")).Text;
                            if (nodata.Contains("Can not find"))
                            {
                                HttpContext.Current.Session["Nodata_WAKing"] = "Yes";
                                driver.Quit();
                                return("No Data Found");
                            }
                        }
                        catch { }
                    }
                    if (searchType == "Property Name")
                    {
                        Start(orderNumber);
                        gc.CreatePdf(orderNumber, Parcel_no, "Aggre Click", driver, "WA", "King");
                        driver.FindElement(By.Id("kingcounty_gov_cphContent_txtPropName")).SendKeys(streettype);
                        gc.CreatePdf(orderNumber, parcelNumber, "Owner Name search", driver, "WA", "King");
                        driver.FindElement(By.Id("kingcounty_gov_cphContent_btn_SearchPropName")).SendKeys(Keys.Enter);
                        try
                        {
                            IWebElement         ownarnameTable = driver.FindElement(By.Id("kingcounty_gov_cphContent_GridViewPropName"));
                            IList <IWebElement> ownarnameRow   = ownarnameTable.FindElements(By.TagName("tr"));
                            IList <IWebElement> Ownarid;
                            foreach (IWebElement ownar in ownarnameRow)
                            {
                                Ownarid = ownar.FindElements(By.TagName("td"));
                                if (Ownarid.Count != 0)
                                {
                                    if (WCount <= 25)
                                    {
                                        Parcel_no       = Ownarid[0].Text;
                                        Property_Name   = Ownarid[1].Text;
                                        Addresss        = Ownarid[2].Text;
                                        Taxpayer_Name   = Ownarid[3].Text;
                                        Building_Number = Ownarid[4].Text;
                                        Unit_Number     = Ownarid[5].Text;
                                        string Mownername = Property_Name + "~" + Addresss + "~" + Taxpayer_Name + "~" + Building_Number + "~" + Unit_Number;
                                        gc.insert_date(orderNumber, Parcel_no, 552, Mownername, 1, DateTime.Now);
                                    }
                                    WCount++;
                                }
                            }
                            if (WCount > 25)
                            {
                                HttpContext.Current.Session["multiParcel_King_Multicount"] = "Maximum";
                            }
                            else
                            {
                                HttpContext.Current.Session["multiparcel_King"] = "Yes";
                            }
                            driver.Quit();
                            return("MultiParcel");
                        }

                        catch { }

                        try
                        {
                            //No Data Found
                            string nodata = driver.FindElement(By.Id("cphContent_lblPropNameMsg")).Text;
                            if (nodata.Contains("Can not find"))
                            {
                                HttpContext.Current.Session["Nodata_WAKing"] = "Yes";
                                driver.Quit();
                                return("No Data Found");
                            }
                        }
                        catch { }
                    }

                    //Property Details
                    gc.CreatePdf(orderNumber, Parcel_no, "Propety Result", driver, "WA", "King");
                    string fulltext = driver.FindElement(By.Id("cphContent_DetailsViewDashboardHeader")).Text;
                    Parcel_no     = gc.Between(fulltext, "Parcel Number", "Name");
                    ownername     = gc.Between(fulltext, "Name", "Site Address");
                    situs_address = gc.Between(fulltext, "Site Address", "Legal");
                    Legal         = GlobalClass.After(fulltext, "Legal");
                    try
                    {
                        string buildingfulltext = driver.FindElement(By.Id("cphContent_DetailsViewPropTypeR")).Text;
                        year_built = gc.Between(buildingfulltext, "Year Built", "Total Square Footage");
                    }
                    catch { }
                    try
                    {
                        string buildingfulltext = driver.FindElement(By.Id("kingcounty_gov_cphContent_DetailsViewPropTypeK")).Text;
                        year_built = gc.Between(buildingfulltext, "Year Built", "Construction Class");
                    }
                    catch { }
                    string propdetails = ownername + "~" + situs_address + "~" + Legal + "~" + year_built;
                    gc.insert_date(orderNumber, Parcel_no, 537, propdetails, 1, DateTime.Now);


                    //Assessment Details

                    int Count = 0;
                    try
                    {
                        IWebElement         taxrolltable = driver.FindElement(By.XPath("//*[@id='cphContent_GridViewDBTaxRoll']/tbody"));
                        IList <IWebElement> taxrow       = taxrolltable.FindElements(By.TagName("tr"));
                        IList <IWebElement> taxrollTd;
                        foreach (IWebElement Taxrow in taxrow)
                        {
                            taxrollTd = Taxrow.FindElements(By.TagName("td"));
                            if (taxrollTd.Count != 0)
                            {
                                if (Count < 3)
                                {
                                    string taxroll = taxrollTd[0].Text + "~" + taxrollTd[1].Text + "~" + taxrollTd[2].Text + "~" + taxrollTd[3].Text + "~" + taxrollTd[4].Text + "~" + taxrollTd[5].Text + "~" + taxrollTd[6].Text + "~" + taxrollTd[7].Text;
                                    gc.insert_date(orderNumber, Parcel_no, 538, taxroll, 1, DateTime.Now);
                                }
                                Count++;
                            }
                        }
                    }
                    catch { }
                    AssessmentTime = DateTime.Now.ToString("HH:mm:ss");
                    //Tax Details
                    driver.Navigate().GoToUrl("http://info.kingcounty.gov/finance/treasury/propertytax/");
                    Thread.Sleep(2000);
                    string parcelwoh = Parcel_no.Replace("-", "");
                    //*[@id="searchParcel"] searchParcel
                    driver.FindElement(By.Id("searchParcel")).SendKeys(parcelwoh.Trim());
                    Thread.Sleep(2000);
                    gc.CreatePdf(orderNumber, Parcel_no, "Tax Search", driver, "WA", "King");

                    //*[@id="ec-tenant-app"]/div/div[2]/div[2]/div[1]/div/form/div/span/button
                    //IWebElement Taxview = driver.FindElement(By.XPath("//*[@id='search - real - property - submi']/span"));
                    try
                    {                               //*[@id="ec-tenant-app"]/div/div[2]/div[2]/div[1]/div/form/div/span
                        driver.FindElement(By.XPath("//*[@id='ec-tenant-app']/div/div[2]/div[2]/div[1]/div/form/div/span/button")).Click();
                        Thread.Sleep(2000);
                    }
                    catch { }
                    try
                    {
                        IWebElement         Taxview = driver.FindElement(By.XPath("//*[@id='ec-tenant-app']/div/div[2]/div[2]/div[1]/div/form/div/span/button"));
                        IJavaScriptExecutor js1     = driver as IJavaScriptExecutor;
                        js1.ExecuteScript("arguments[0].click();", Taxview);
                    }
                    catch { }
                    try
                    {
                        driver.FindElement(By.XPath("//*[@id='ec-tenant-app']/div/div[2]/div[2]/div[1]/div/form/div/span/button")).SendKeys(Keys.Enter);
                        Thread.Sleep(2000);
                    }
                    catch { }
                    //IJavaScriptExecutor js1 = driver as IJavaScriptExecutor;
                    //js1.ExecuteScript("arguments[0].click();", Taxview);
                    //Taxview.SendKeys(Keys.Enter);
                    Thread.Sleep(2000);
                    gc.CreatePdf(orderNumber, Parcel_no, "Tax Result", driver, "WA", "King");
                    IWebElement acctorcher = driver.FindElement(By.XPath("//*[@id='parcelPanels']/div"));
                    string      torcher1   = acctorcher.Text.Replace("\r\n", "");
                    trocher = gc.Between(torcher1, "Tax account number:", "Parcel number:").Trim();
                    // trocher = GlobalClass.After(torcher1, "Tax account number: ");
                    string taxaccno1 = driver.FindElement(By.XPath("//*[@id='parcelAccount" + trocher + "']/h4/a/span/span")).Text;
                    taxaccno = GlobalClass.After(taxaccno1, "Tax account number:").Trim();
                    string taxpayname = driver.FindElement(By.XPath("//*[@id='parcelAccount" + trocher + "']/h4/a/p/strong[1]")).Text;
                    taxpaynam = GlobalClass.After(taxpayname, "Tax payer name:").Trim();
                    payststus = driver.FindElement(By.XPath("//*[@id='payment-details-panel" + trocher + "']/div/div/div/div[1]")).Text;
                    driver.FindElement(By.XPath("//*[@id='details-parcelAccount" + trocher + "']/div[3]/h4/a")).SendKeys(Keys.Enter);


                    driver.FindElement(By.XPath("//*[@id='details-parcelAccount" + trocher + "']/div[5]/h4/a")).SendKeys(Keys.Enter);
                    gc.CreatePdf(orderNumber, Parcel_no, "Recepit", driver, "WA", "King");
                    try
                    {
                        IWebElement         taxpaytabel = driver.FindElement(By.XPath("//*[@id='receipts-panel" + trocher + "']/div/div/table/tbody"));
                        IList <IWebElement> taxpayrow   = taxpaytabel.FindElements(By.TagName("tr"));
                        IList <IWebElement> taxpayID;
                        foreach (IWebElement trow in taxpayrow)
                        {
                            taxpayID = trow.FindElements(By.TagName("td"));
                            if (taxpayID.Count != 0 && !trow.Text.Contains("Date"))
                            {
                                string payhis = taxpayID[0].Text + "~" + taxpayID[1].Text + "~" + taxpayID[2].Text;
                                gc.insert_date(orderNumber, Parcel_no, 543, payhis, 1, DateTime.Now);
                            }
                        }
                    }
                    catch { }
                    driver.FindElement(By.XPath("//*[@id='details-parcelAccount" + trocher + "']/div[7]/h4/a")).SendKeys(Keys.Enter);
                    gc.CreatePdf(orderNumber, Parcel_no, "Tax Distribution", driver, "WA", "King");
                    try
                    {
                        IWebElement         Distributiontable = driver.FindElement(By.XPath("//*[@id='distribution-panel" + trocher + "']/div/div/div/table/tbody"));
                        IList <IWebElement> distributionrow   = Distributiontable.FindElements(By.TagName("tr"));
                        IList <IWebElement> distributionID;
                        foreach (IWebElement Distribution in distributionrow)
                        {
                            distributionID = Distribution.FindElements(By.TagName("td"));
                            if (distributionID.Count != 0 && !Distribution.Text.Contains("Distribution information"))
                            {
                                curtax2 = distributionID[0].Text + "~" + distributionID[1].Text + "~" + distributionID[2].Text;
                                gc.insert_date(orderNumber, Parcel_no, 568, curtax2, 1, DateTime.Now);
                            }
                        }
                    }
                    catch { }
                    int a = 0;
                    try
                    {
                        IWebElement         taxyeardetail = driver.FindElement(By.XPath("//*[@id='tax-year-details-panel" + trocher + "']/div/div/fieldset/div/div/table"));
                        IList <IWebElement> taxyear       = taxyeardetail.FindElements(By.TagName("tr"));
                        IList <IWebElement> taxyeartd;
                        IList <IWebElement> taxyeartd1;
                        foreach (IWebElement year in taxyear)
                        {
                            taxyeartd  = year.FindElements(By.TagName("th"));
                            taxyeartd1 = year.FindElements(By.TagName("td"));
                            if (taxyeartd.Count != 0 && !year.Text.Contains("Taxable"))
                            {
                                if (taxyeartd[0].Text.Contains("Tax Information"))
                                {
                                    taxyer = taxyeartd[1].Text + "~" + taxyeartd[2].Text + "~" + taxyeartd[3].Text;
                                    DBconnection dbconn = new DBconnection();
                                    string       header = "Tax Information" + "~" + taxyer;
                                    dbconn.ExecuteQuery("update data_field_master set Data_Fields_Text='" + header + "' where Id = '" + 539 + "'");
                                }
                            }
                            else
                            {
                                if (taxyeartd1.Count != 0 && !year.Text.Contains("Charges"))
                                {
                                    value = taxyeartd1[0].Text + "~" + taxyeartd1[1].Text + "~" + taxyeartd1[2].Text + "~" + taxyeartd1[3].Text;
                                    gc.insert_date(orderNumber, Parcel_no, 539, value, 1, DateTime.Now);
                                }
                            }
                        }
                    }

                    catch
                    {
                        try
                        {
                            IWebElement         taxyeardetail = driver.FindElement(By.XPath("//*[@id='tax-year-details-panel" + trocher + "']/div/div/fieldset/div/div/table"));
                            IList <IWebElement> taxyear       = taxyeardetail.FindElements(By.TagName("tr"));
                            IList <IWebElement> taxyeartd;
                            IList <IWebElement> taxyeartd1;
                            foreach (IWebElement year in taxyear)
                            {
                                taxyeartd  = year.FindElements(By.TagName("th"));
                                taxyeartd1 = year.FindElements(By.TagName("td"));
                                if (taxyeartd.Count != 0 && !year.Text.Contains("Taxable"))
                                {
                                    if (taxyeartd[0].Text.Contains("Tax Information"))
                                    {
                                        taxyer = taxyeartd[1].Text + "~" + taxyeartd[2].Text;
                                        DBconnection dbconn = new DBconnection();
                                        string       header = "Tax Information" + "~" + taxyer;
                                        dbconn.ExecuteQuery("update data_field_master set Data_Fields_Text='" + header + "' where Id = '" + 539 + "'");
                                    }
                                }
                                else
                                {
                                    if (taxyeartd1.Count != 0 && !year.Text.Contains("Charges"))
                                    {
                                        value = taxyeartd1[0].Text + "~" + taxyeartd1[1].Text + "~" + taxyeartd1[2].Text;
                                        gc.insert_date(orderNumber, Parcel_no, 539, value, 1, DateTime.Now);
                                    }
                                }
                            }
                        }
                        catch
                        { }
                    }

                    //taxing authority
                    try
                    {
                        driver.Navigate().GoToUrl("http://blue.kingcounty.gov/about/contact/");
                        driver.FindElement(By.XPath("//*[@id='footer-nav']/div/div/div[3]/ul/li[1]/a")).SendKeys(Keys.Enter);
                        Thread.Sleep(2000);
                        taxauthority = driver.FindElement(By.XPath("//*[@id='kcMasterPagePlaceHolder_pnlForm']/div/div/div/p[3]/strong")).Text;
                        taxauthority = taxauthority.Replace("\r\n", " ");
                    }
                    catch { }


                    string curtax1 = taxaccno + "~" + payststus + "~" + taxauthority;
                    gc.insert_date(orderNumber, Parcel_no, 575, curtax1, 1, DateTime.Now);

                    TaxTime = DateTime.Now.ToString("HH:mm:ss");

                    LastEndTime = DateTime.Now.ToString("HH:mm:ss");
                    gc.insert_TakenTime(orderNumber, "WA", "King", StartTime, AssessmentTime, TaxTime, CitytaxTime, LastEndTime);

                    driver.Quit();

                    gc.mergpdf(orderNumber, "WA", "King");
                    return("Data Inserted Successfully");
                }

                catch (Exception ex)
                {
                    driver.Quit();
                    throw ex;
                }
            }
        }
コード例 #39
0
 /// <summary>Get the query-specific marginal distribution of a variable, converted to type T</summary>
 /// <typeparam name="T">The distribution type.</typeparam>
 /// <param name="variableName">Name of the variable in the generated code</param>
 /// <param name="query">QueryType name. For example, GibbsSampling answers 'Marginal', 'Samples', and 'Conditionals' queries</param>
 /// <remarks>Execute, Update, or Reset must be called first to set the value of the marginal.</remarks>
 public T Marginal <T>(string variableName, string query)
 {
     return(Distribution.ChangeType <T>(this.Marginal(variableName, query)));
 }
コード例 #40
0
ファイル: SnyderStart.cs プロジェクト: Patiun/LadyBug
    private void BuildModel()
    {
        List <string> Sigma       = new List <string>();
        List <string> Delta       = new List <string>();
        List <State>  states      = new List <State>();
        List <State>  rewards     = new List <State>();
        List <State>  punishments = new List <State>();

        Sigma.AddRange(new string[] { "1N", "1S", "1W", "1E", "2N", "2S", "2W", "2E", "F" });
        Delta.AddRange(new string[] { "LEFT", "RIGHT", "FORWARD" });

        State s0 = new State(0); //Default
        State s1 = new State(1); //1N
        State s2 = new State(2); //2N
        State s3 = new State(3); //1E
        State s4 = new State(4); //2E
        State s5 = new State(5); //1S
        State s6 = new State(6); //2S
        State s7 = new State(7); //1W
        State s8 = new State(8); //2W
        State s9 = new State(9); //F

        states.AddRange(new State[] { s1, s2, s3, s4, s5, s6, s7, s8, s9 });
        rewards.AddRange(new State[] { s9 });
        punishments.AddRange(new State[] { });

        model = new Model(states, rewards, punishments, Sigma, Delta, s0);

        Transition transition0_1 = new Transition(0, 1, "1N");
        Transition transition0_2 = new Transition(0, 2, "2N");
        Transition transition0_3 = new Transition(0, 3, "1E");
        Transition transition0_4 = new Transition(0, 4, "2E");
        Transition transition0_5 = new Transition(0, 5, "1S");
        Transition transition0_6 = new Transition(0, 6, "2S");
        Transition transition0_7 = new Transition(0, 7, "1W");
        Transition transition0_8 = new Transition(0, 8, "2W");
        Transition transition0_9 = new Transition(0, 9, "F");

        transition0_1.SetConfidence(100);
        transition0_2.SetConfidence(100);
        transition0_3.SetConfidence(100);
        transition0_4.SetConfidence(100);
        transition0_5.SetConfidence(100);
        transition0_6.SetConfidence(100);
        transition0_7.SetConfidence(100);
        transition0_8.SetConfidence(100);
        transition0_9.SetConfidence(100);
        s0.AddTransitionOnSymbol(transition0_1, transition0_1.GetSymbol());
        s0.AddTransitionOnSymbol(transition0_2, transition0_2.GetSymbol());
        s0.AddTransitionOnSymbol(transition0_3, transition0_3.GetSymbol());
        s0.AddTransitionOnSymbol(transition0_4, transition0_4.GetSymbol());
        s0.AddTransitionOnSymbol(transition0_5, transition0_5.GetSymbol());
        s0.AddTransitionOnSymbol(transition0_6, transition0_6.GetSymbol());
        s0.AddTransitionOnSymbol(transition0_7, transition0_7.GetSymbol());
        s0.AddTransitionOnSymbol(transition0_8, transition0_8.GetSymbol());
        s0.AddTransitionOnSymbol(transition0_9, transition0_9.GetSymbol());

        Distribution canForward = (new Distribution(Delta));

        canForward.SetDistribution(new List <Symbol>()
        {
            new Symbol("LEFT", 0.333f), new Symbol("RIGHT", 0.333f), new Symbol("FORWARD", 0.333f), new Symbol("", 0f)
        });
        Distribution cannotForward = (new Distribution(Delta));

        cannotForward.SetDistribution(new List <Symbol>()
        {
            new Symbol("LEFT", 0.5f), new Symbol("RIGHT", 0.5f), new Symbol("FORWARD", 0.0f), new Symbol("", 0f)
        });

        transition0_1.SetDistribution(cannotForward);
        transition0_2.SetDistribution(cannotForward);
        transition0_3.SetDistribution(canForward);
        transition0_4.SetDistribution(canForward);
        transition0_5.SetDistribution(cannotForward);
        transition0_6.SetDistribution(cannotForward);
        transition0_7.SetDistribution(cannotForward);
        transition0_8.SetDistribution(canForward);
    }
コード例 #41
0
        public void QualityBandDistributionTest()
        {
            // Expected unknown
            List <Type> unknownTypes = new List <Type>();

            unknownTypes.Add(typeof(CUnmarked <DExperimental, double>));
            unknownTypes.Add(typeof(CUnmarked <double, DExperimental>));
            unknownTypes.Add(typeof(CUnmarked <CPreview <DExperimental, double>, double>));
            unknownTypes.Add(typeof(CUnmarked <double, CPreview <DExperimental, double> >));
            unknownTypes.Add(typeof(CUnmarked <CMature <DExperimental, double>, CPreview <DExperimental, double> >));
            unknownTypes.Add(typeof(CExperimental <DUnmarked, double>));
            unknownTypes.Add(typeof(CExperimental <double, DUnmarked>));
            unknownTypes.Add(typeof(CExperimental <CPreview <DUnmarked, double>, double>));
            unknownTypes.Add(typeof(CExperimental <double, CUnmarked <DMature, double> >));
            unknownTypes.Add(typeof(CExperimental <CMature <DMature, double>, CPreview <DUnmarked, double> >));
            unknownTypes.Add(typeof(CExperimental <CUnmarked <DMature, double>, CPreview <DUnmarked, double> >));
            int uexp = unknownTypes.Count;

            for (int i = 0; i < uexp; i++)
            {
                unknownTypes.Add(unknownTypes[i].MakeArrayType(i + 1));
            }
            foreach (Type ut in unknownTypes)
            {
                Assert.True(Distribution.HasDistributionType(ut));
                Assert.Equal(QualityBand.Unknown, Distribution.GetQualityBand(ut));
            }

            // Expected experimental
            List <Type> experimentalTypes = new List <Type>();

            experimentalTypes.Add(typeof(CStable <DExperimental, double>));
            experimentalTypes.Add(typeof(CStable <double, DExperimental>));
            experimentalTypes.Add(typeof(CStable <CPreview <DExperimental, double>, double>));
            experimentalTypes.Add(typeof(CStable <double, CPreview <DExperimental, double> >));
            experimentalTypes.Add(typeof(CStable <CMature <DExperimental, double>, CPreview <DExperimental, double> >));
            experimentalTypes.Add(typeof(CExperimental <DStable, double>));
            experimentalTypes.Add(typeof(CExperimental <double, DStable>));
            experimentalTypes.Add(typeof(CExperimental <CPreview <DMature, double>, double>));
            experimentalTypes.Add(typeof(CExperimental <double, CPreview <DMature, double> >));
            experimentalTypes.Add(typeof(CExperimental <CMature <DMature, double>, CPreview <DStable, double> >));
            int nexp = experimentalTypes.Count;

            for (int i = 0; i < nexp; i++)
            {
                experimentalTypes.Add(experimentalTypes[i].MakeArrayType(i + 1));
            }
            foreach (Type et in experimentalTypes)
            {
                Assert.True(Distribution.HasDistributionType(et));
                Assert.Equal(QualityBand.Experimental, Distribution.GetQualityBand(et));
            }
            // Expected stable
            List <Type> stableTypes = new List <Type>();

            stableTypes.Add(typeof(CStable <DStable, double>));
            stableTypes.Add(typeof(CStable <double, DMature>));
            stableTypes.Add(typeof(CStable <CMature <DStable, double>, double>));
            stableTypes.Add(typeof(CStable <double, CStable <DMature, double> >));
            stableTypes.Add(typeof(CStable <CMature <DStable, double>, CStable <DStable, double> >));
            stableTypes.Add(typeof(CMature <DStable, double>));
            stableTypes.Add(typeof(CMature <double, DStable>));
            stableTypes.Add(typeof(CMature <CStable <DMature, double>, double>));
            stableTypes.Add(typeof(CMature <double, CStable <DMature, double> >));
            stableTypes.Add(typeof(CMature <CMature <DMature, double>, CStable <DStable, double> >));
            int nstb = stableTypes.Count;

            for (int i = 0; i < nstb; i++)
            {
                stableTypes.Add(stableTypes[i].MakeArrayType(i + 1));
            }
            foreach (Type st in stableTypes)
            {
                Assert.True(Distribution.HasDistributionType(st));
                Assert.Equal(QualityBand.Stable, Distribution.GetQualityBand(st));
            }
            // Expected Mature
            List <Type> matureTypes = new List <Type>();

            matureTypes.Add(typeof(CMature <DMature, double>));
            matureTypes.Add(typeof(CMature <double, DMature>));
            matureTypes.Add(typeof(CMature <CMature <DMature, double>, double>));
            matureTypes.Add(typeof(CMature <double, CMature <DMature, double> >));
            matureTypes.Add(typeof(CMature <CMature <DMature, double>, CMature <DMature, double> >));
            int nmat = matureTypes.Count;

            for (int i = 0; i < nmat; i++)
            {
                matureTypes.Add(matureTypes[i].MakeArrayType(i + 1));
            }
            foreach (Type mt in matureTypes)
            {
                Assert.True(Distribution.HasDistributionType(mt));
                Assert.Equal(QualityBand.Mature, Distribution.GetQualityBand(mt));
            }
        }
コード例 #42
0
        public virtual void FinishTraining()
        {
            Timing.Tick("Counting characters...");
            ClassicCounter <ChineseCharacterBasedLexicon.Symbol> charCounter = new ClassicCounter <ChineseCharacterBasedLexicon.Symbol>();

            // first find all chars that occur only once
            foreach (IList <TaggedWord> labels in trainingSentences)
            {
                foreach (TaggedWord label in labels)
                {
                    string word = label.Word();
                    if (word.Equals(LexiconConstants.Boundary))
                    {
                        continue;
                    }
                    for (int j = 0; j < length; j++)
                    {
                        ChineseCharacterBasedLexicon.Symbol sym = ChineseCharacterBasedLexicon.Symbol.CannonicalSymbol(word[j]);
                        charCounter.IncrementCount(sym);
                    }
                    charCounter.IncrementCount(ChineseCharacterBasedLexicon.Symbol.EndWord);
                }
            }
            ICollection <ChineseCharacterBasedLexicon.Symbol> singletons = Counters.KeysBelow(charCounter, 1.5);

            knownChars = Generics.NewHashSet(charCounter.KeySet());
            Timing.Tick("Counting nGrams...");
            GeneralizedCounter[] POSspecificCharNGrams = new GeneralizedCounter[ContextLength + 1];
            for (int i = 0; i <= ContextLength; i++)
            {
                POSspecificCharNGrams[i] = new GeneralizedCounter(i + 2);
            }
            ClassicCounter <string> POSCounter = new ClassicCounter <string>();
            IList <ISerializable>   context    = new List <ISerializable>(ContextLength + 1);

            foreach (IList <TaggedWord> words in trainingSentences)
            {
                foreach (TaggedWord taggedWord in words)
                {
                    string word = taggedWord.Word();
                    string tag  = taggedWord.Tag();
                    tagIndex.Add(tag);
                    if (word.Equals(LexiconConstants.Boundary))
                    {
                        continue;
                    }
                    POSCounter.IncrementCount(tag);
                    for (int i_1 = 0; i_1 <= size; i_1++)
                    {
                        ChineseCharacterBasedLexicon.Symbol sym;
                        ChineseCharacterBasedLexicon.Symbol unknownCharClass = null;
                        context.Clear();
                        context.Add(tag);
                        if (i_1 < size)
                        {
                            char thisCh = word[i_1];
                            sym = ChineseCharacterBasedLexicon.Symbol.CannonicalSymbol(thisCh);
                            if (singletons.Contains(sym))
                            {
                                unknownCharClass = UnknownCharClass(sym);
                                charCounter.IncrementCount(unknownCharClass);
                            }
                        }
                        else
                        {
                            sym = ChineseCharacterBasedLexicon.Symbol.EndWord;
                        }
                        POSspecificCharNGrams[0].IncrementCount(context, sym);
                        // POS-specific 1-gram
                        if (unknownCharClass != null)
                        {
                            POSspecificCharNGrams[0].IncrementCount(context, unknownCharClass);
                        }
                        // for unknown ch model
                        // context is constructed incrementally:
                        // tag prevChar prevPrevChar
                        // this could be made faster using .sublist like in score
                        for (int j = 1; j <= ContextLength; j++)
                        {
                            // poly grams
                            if (i_1 - j < 0)
                            {
                                context.Add(ChineseCharacterBasedLexicon.Symbol.BeginWord);
                                POSspecificCharNGrams[j].IncrementCount(context, sym);
                                if (unknownCharClass != null)
                                {
                                    POSspecificCharNGrams[j].IncrementCount(context, unknownCharClass);
                                }
                                // for unknown ch model
                                break;
                            }
                            else
                            {
                                ChineseCharacterBasedLexicon.Symbol prev = ChineseCharacterBasedLexicon.Symbol.CannonicalSymbol(word[i_1 - j]);
                                if (singletons.Contains(prev))
                                {
                                    context.Add(UnknownCharClass(prev));
                                }
                                else
                                {
                                    context.Add(prev);
                                }
                                POSspecificCharNGrams[j].IncrementCount(context, sym);
                                if (unknownCharClass != null)
                                {
                                    POSspecificCharNGrams[j].IncrementCount(context, unknownCharClass);
                                }
                            }
                        }
                    }
                }
            }
            // for unknown ch model
            POSDistribution = Distribution.GetDistribution(POSCounter);
            Timing.Tick("Creating character prior distribution...");
            charDistributions = Generics.NewHashMap();
            //    charDistributions = Generics.newHashMap();  // 1.5
            //    charCounter.incrementCount(Symbol.UNKNOWN, singletons.size());
            int numberOfKeys = charCounter.Size() + singletons.Count;
            Distribution <ChineseCharacterBasedLexicon.Symbol> prior = Distribution.GoodTuringSmoothedCounter(charCounter, numberOfKeys);

            charDistributions[Java.Util.Collections.EmptyList] = prior;
            for (int i_2 = 0; i_2 <= ContextLength; i_2++)
            {
                ICollection <KeyValuePair <IList <ISerializable>, ClassicCounter <ChineseCharacterBasedLexicon.Symbol> > > counterEntries = POSspecificCharNGrams[i_2].LowestLevelCounterEntrySet();
                Timing.Tick("Creating " + counterEntries.Count + " character " + (i_2 + 1) + "-gram distributions...");
                foreach (KeyValuePair <IList <ISerializable>, ClassicCounter <ChineseCharacterBasedLexicon.Symbol> > entry in counterEntries)
                {
                    context = entry.Key;
                    ClassicCounter <ChineseCharacterBasedLexicon.Symbol> c         = entry.Value;
                    Distribution <ChineseCharacterBasedLexicon.Symbol>   thisPrior = charDistributions[context.SubList(0, context.Count - 1)];
                    double priorWeight = thisPrior.GetNumberOfKeys() / 200.0;
                    Distribution <ChineseCharacterBasedLexicon.Symbol> newDist = Distribution.DynamicCounterWithDirichletPrior(c, thisPrior, priorWeight);
                    charDistributions[context] = newDist;
                }
            }
        }
コード例 #43
0
ファイル: Containers.cs プロジェクト: marcos914/RawTools
 public ScanMetaDataDIA(double dutyCycle, double fillTime, double scanTime, Distribution intensityDistribution)
 {
     DutyCycle             = dutyCycle;
     FillTime              = fillTime;
     IntensityDistribution = intensityDistribution;
 }