public void CanHandleZeroLengthEndSegments() { const string featureClassName = "TLM_STEHENDES_GEWAESSER"; var locator = TestDataUtils.GetTestDataLocator(); string path = locator.GetPath("QaBorderSense.gdb"); IFeatureWorkspace workspace = WorkspaceUtils.OpenFileGdbFeatureWorkspace(path); IFeatureClass featureClass = workspace.OpenFeatureClass(featureClassName); // expect counter-clockwise: 0 errors var runnerCounterClockwise = new QaContainerTestRunner(1000, new QaBorderSense( featureClass, false)); Assert.AreEqual(0, runnerCounterClockwise.Execute()); // expect clockwise: 1 error var runnerClockwise = new QaContainerTestRunner(1000, new QaBorderSense(featureClass, true)); Assert.AreEqual(1, runnerClockwise.Execute()); }
public static void CreateAnAdditionalAggregateCalculation_Number() { CreateCalculationPage createcalculationpage = new CreateCalculationPage(); ManagePoliciesPage managepoliciespage = new ManagePoliciesPage(); string newname = "TestAggCalculationName"; string descriptiontext = "This is a Description for: "; var randomSpecCalcName = newname + TestDataUtils.RandomString(6); ScenarioContext.Current["AddAggCalcName"] = randomSpecCalcName; managepoliciespage.CreateCalculation.Click(); Thread.Sleep(2000); createcalculationpage.CalculationName.SendKeys(randomSpecCalcName); createcalculationpage.CalculationDescription.SendKeys(descriptiontext + randomSpecCalcName); Actions.CreateCalculationSpecificationpageSelectPolicyOrSubpolicyDropDown(); var calctype = createcalculationpage.CalculationTypeDropDown; var selectElement = new SelectElement(calctype); selectElement.SelectByValue("Number"); createcalculationpage.SaveCalculation.Click(); Thread.Sleep(2000); var aggCalcNumName = ScenarioContext.Current["AddAggCalcName"]; string aggCalcCreated = aggCalcNumName.ToString(); Console.WriteLine(aggCalcCreated + " has been created successfully"); Thread.Sleep(5000); }
private void InitializeWeightsAndDistributionsMixture() { _distributionWeights = new double[_NumberOfStates][]; for (var i = 0; i < _NumberOfStates; i++) { _distributionWeights[i] = new double[_NumberOfDistributionsInState]; _distributionWeights[i][0] = 0.5; _distributionWeights[i][1] = 0.5; } var util = new TestDataUtils(); var series = util.GetSvcData(util.FTSEFilePath, new DateTime(2010, 12, 18), new DateTime(2011, 12, 18)); var distributions = CreateEmissions(series, _NumberOfStates * _NumberOfComponents * _NumberOfDistributionsInState); _distributions = new Mixture <IMultivariateDistribution> [_NumberOfStates][]; var index = 0; for (int i = 0; i < _NumberOfStates; i++) { _distributions[i] = new Mixture <IMultivariateDistribution> [_NumberOfDistributionsInState]; for (int k = 0; k < _NumberOfDistributionsInState; k++) { _distributions[i][k] = new Mixture <IMultivariateDistribution>(_NumberOfComponents, series[0].Length); for (int j = 0; j < _NumberOfComponents; j++) { ((Mixture <IMultivariateDistribution>)_distributions[i][k]).Components[j] = distributions[index]; index++; } } } }
private void InitializeWeightsAndDistributionsMultivariate() { _distributionWeights = new double[_NumberOfStates][]; for (var i = 0; i < _NumberOfStates; i++) { _distributionWeights[i] = new double[_NumberOfDistributionsInState]; _distributionWeights[i][0] = 0.5; _distributionWeights[i][1] = 0.5; } var util = new TestDataUtils(); var series = util.GetSvcData(util.FTSEFilePath, new DateTime(2010, 12, 18), new DateTime(2011, 12, 18)); var distributions = CreateEmissions(series, _NumberOfStates * _NumberOfDistributionsInState); _distributions = new IMultivariateDistribution[_NumberOfStates][]; var index = 0; for (int i = 0; i < _NumberOfStates; i++) { _distributions[i] = new IMultivariateDistribution[_NumberOfDistributionsInState]; for (int k = 0; k < _NumberOfDistributionsInState; k++) { _distributions[i][k] = distributions[index]; index++; } } }
public void Gen2847_NonZawarePolylineWithInteriorLoops() { var locator = TestDataUtils.GetTestDataLocator(); string path = locator.GetPath("DKM25_HOEHENKURVE_OID_2178.xml"); var nonZAwarePolyline = (IPolyline)GeometryUtils.FromXmlFile(path); var fc = new FeatureClassMock(1, "Contours", esriGeometryType.esriGeometryPolyline, esriFeatureType.esriFTSimple, nonZAwarePolyline.SpatialReference, hasZ: false, hasM: false); IFeature f = fc.CreateFeature(nonZAwarePolyline); const double toleranceFactor = 1.0; var test = new QaSimpleGeometry(fc, false, toleranceFactor); var runner = new QaTestRunner(test) { KeepGeometry = true }; runner.Execute(f); Assert.AreEqual(1, runner.Errors.Count); Assert.AreEqual(3, ((IPointCollection)runner.ErrorGeometries[0]).PointCount); }
public void HiddenMarkovModelMultivariateGaussianDistribution_ModelState_ModelCreated() { var pi = new double[NumberOfStates] { 0.5, 0.5 }; var tpm = new double[NumberOfStates][] { new [] { 0.5, 0.5 }, new [] { 0.5, 0.5 } }; var util = new TestDataUtils(); var series = util.GetSvcData(util.FTSEFilePath, new DateTime(2010, 12, 18), new DateTime(2011, 12, 18)); var emissions = CreateEmissions(series, NumberOfStates); var model = HiddenMarkovModelFactory.GetModel(new ModelCreationParameters <IMultivariateDistribution>() { Pi = pi, TransitionProbabilityMatrix = tpm, Emissions = emissions }); //new HiddenMarkovModelMultivariateGaussianDistribution(pi, tpm, emissions); Assert.AreEqual(ModelType.Ergodic, model.Type); Assert.AreEqual(NumberOfStates, model.N); Assert.IsFalse(model.Normalized); for (int n = 0; n < NumberOfStates; n++) { Assert.AreEqual(0.5, model.Pi[n]); Assert.IsNotNull(model.Emission[n]); Assert.IsInstanceOfType(model.Emission[n], typeof(NormalDistribution)); for (int i = 0; i < NumberOfStates; i++) { Assert.AreEqual(0.5, model.TransitionProbabilityMatrix[n][i]); } } }
public void Predict_HMMMultivariateAndFTSESeriesLength20_Predicted20Days() { var util = new TestDataUtils(); var series = util.GetSvcData(util.FTSEFilePath, new DateTime(2010, 12, 18), new DateTime(2011, 12, 18)); var test = util.GetSvcData(util.FTSEFilePath, new DateTime(2011, 12, 18), new DateTime(2012, 01, 18)); var model = (HiddenMarkovModelMultivariateGaussianDistribution)HiddenMarkovModelFactory.GetModel(new ModelCreationParameters <IMultivariateDistribution>() { NumberOfStates = _NumberOfStates }); model.Normalized = true; model.Train(series, _NumberOfIterations, _LikelihoodTolerance); var pred = new ViterbiBasedPredictor(); var request = new PredictionRequest { TrainingSet = series, NumberOfDays = 20, TestSet = test }; pred.NumberOfIterations = _NumberOfIterations; pred.LikelihoodTolerance = _LikelihoodTolerance; var predictions = pred.Predict(model, request); Assert.AreEqual(20, predictions.Predicted.Length); }
public static void CreateANewProviderDataset() { ManageSpecificationPage managespecficationpage = new ManageSpecificationPage(); CreateSpecificationPage createspecificationpage = new CreateSpecificationPage(); ManagePoliciesPage managepoliciespage = new ManagePoliciesPage(); ChooseDatasetRelationshipPage choosedatasetrelationshippage = new ChooseDatasetRelationshipPage(); string newname = "TestDatasetName"; string descriptiontext = "This is a Datset Description for: "; managepoliciespage.datasetsTab.Click(); managepoliciespage.Createdatatyperelationship.Should().NotBeNull(); managepoliciespage.Createdatatyperelationship.Click(); Thread.Sleep(2000); Actions.SelectDatasetDataSchemaDropDown(); var randomDatasetName = newname + TestDataUtils.RandomString(6); ScenarioContext.Current["DatasetSchemaName"] = randomDatasetName; choosedatasetrelationshippage.datasetSchemaRelationshipName.SendKeys(randomDatasetName); choosedatasetrelationshippage.datasetSchemaRelationshipDescription.SendKeys(descriptiontext + randomDatasetName); choosedatasetrelationshippage.createDatasetSetAsDataProvider.Click(); choosedatasetrelationshippage.datasetSchemaRelationshipSaveButton.Click(); Thread.Sleep(2000); managepoliciespage.datasetsTab.Should().NotBeNull(); Console.WriteLine(randomDatasetName + " has been created successfully"); }
public void Alpha_ErgodicAndNotNormalized_AlphaCalculated() { const int numberOfStates = 2; var util = new TestDataUtils(); var observations = util.GetSvcData(util.FTSEFilePath, new DateTime(2011, 11, 18), new DateTime(2011, 12, 18)); var model = HiddenMarkovModelStateFactory.GetState(new ModelCreationParameters <NormalDistribution>() { NumberOfStates = numberOfStates, Emissions = CreateEmissions(observations, numberOfStates) }); //new HiddenMarkovModelState<NormalDistribution>(numberOfStates, CreateEmissions(observations, numberOfStates)) { LogNormalized = true }; model.Normalized = false; var alphaEstimator = new AlphaEstimator <NormalDistribution>(); var alpha = alphaEstimator.Estimate(new BasicEstimationParameters <NormalDistribution> { Model = model, Observations = Helper.Convert(observations), Normalized = model.Normalized }); Assert.IsNotNull(alpha); for (int i = 0; i < observations.Length; i++) { for (int j = 0; j < numberOfStates; j++) { Assert.IsTrue(alpha[i][j] > 0 && alpha[i][j] < 1, string.Format("Failed Alpha [{0}][{1}] : {2}", i, j, alpha[i][j])); } } }
public void TestTopgisTMultiPatches() { IWorkspace workspace = TestDataUtils.OpenTopgisTlm(); IFeatureClass gebaeude = ((IFeatureWorkspace)workspace).OpenFeatureClass( "TOPGIS_TLM.TLM_GEBAEUDE"); var test = new QaMpVertexNotNearFace( gebaeude, new[] { gebaeude }, 1, 0.2); test.VerifyWithinFeature = true; test.PointCoincidence = 0.1; test.EdgeCoincidence = 0.1; test.IgnoreNonCoplanarFaces = true; test.MinimumSlopeDegrees = 15; var runner = new QaContainerTestRunner(10000, test); runner.LogErrors = false; IFeatureWorkspace ws = TestWorkspaceUtils.CreateTestFgdbWorkspace("QaMpVertexNotNearFaceTest"); var logger = new SimpleErrorWorkspace(ws); runner.TestContainer.QaError += logger.TestContainer_QaError; runner.Execute(); Console.WriteLine(runner.Errors.Count); }
public void Gamma_RightLeftNotNormalized_EachEntryMatrixIsSummedToOne() { var delta = 3; var numberOfStatesRightLeft = 4; var util = new TestDataUtils(); var observations = util.GetSvcData(util.FTSEFilePath, new DateTime(2011, 11, 18), new DateTime(2011, 12, 18)); var model = HiddenMarkovModelStateFactory.GetState(new ModelCreationParameters <NormalDistribution>() { NumberOfStates = numberOfStatesRightLeft, Delta = delta, Emissions = CreateEmissions(observations, numberOfStatesRightLeft) }); //new HiddenMarkovModelState<NormalDistribution>(numberOfStatesRightLeft, delta, CreateEmissions(observations, numberOfStatesRightLeft)) { LogNormalized = false }; model.Normalized = false; var baseParameters = new BasicEstimationParameters <NormalDistribution> { Model = model, Observations = Helper.Convert(observations), Normalized = model.Normalized }; var alphaEstimator = new AlphaEstimator <NormalDistribution>(); var alpha = alphaEstimator.Estimate(baseParameters); var betaEstimator = new BetaEstimator <NormalDistribution>(); var beta = betaEstimator.Estimate(baseParameters); var @params = new AdvancedEstimationParameters <NormalDistribution> { Alpha = alpha, Beta = beta, Observations = Helper.Convert(observations), Model = model, Normalized = model.Normalized }; var estimator = new GammaEstimator <NormalDistribution>(); for (int i = 0; i < observations.Length; i++) { Assert.AreEqual(1.0d, Math.Round(estimator.Estimate(@params)[i].Sum(), 5), string.Format("Failed Gamma Component [{1}] : {0}", estimator.Estimate(@params)[i], i)); } }
public void Initialize() { var util = new TestDataUtils(); // Create 2 Distributions // Stock + Ema7, Stock + Ema28 => Data : Stock + Index _observations = util.GetSvcData(util.MSFTFilePath, new DateTime(2011, 10, 7), new DateTime(2012, 3, 1));//SecurityDailyDataManager.GetRange("MSFT", new DateTime(2011, 10, 7), new DateTime(2012, 3, 1)); _observed = util.GetSvcData(util.MSFTFilePath, new DateTime(2012, 3, 2), new DateTime(2012, 3, 29)); var trainData1 = util.GetSvcData(util.MSFTFilePath, new DateTime(2010, 1, 1), new DateTime(2011, 1, 1)); var trainData2 = util.GetSvcData(util.MSFTFilePath, new DateTime(2009, 1, 1), new DateTime(2010, 1, 1)); var d0 = new NormalDistribution(4); var likelihood0 = 0.0d; _distributions[0] = (NormalDistribution)d0.Evaluate(trainData1, out likelihood0); var d1 = new NormalDistribution(4); var likelihood1 = 0.0d; _distributions[1] = (NormalDistribution)d1.Evaluate(trainData2, out likelihood1); for (var k = 0; k < K; k++) { _coefficients[k] = 1d / K; } }
public ApplySchemaChangeTestData() { tables = new TableConf[2]; //first table has no column list tables[0] = new TableConf(); tables[0].SchemaName = "dbo"; tables[0].Name = "test1"; //second one has column list tables[1] = new TableConf(); tables[1].SchemaName = "dbo"; tables[1].Name = "test2"; tables[1].ColumnList = new string[] { "column1", "column2" }; sourceDataUtils = new TestDataUtils(TServer.RELAY); destDataUtils = new TestDataUtils(TServer.SLAVE); testData = new DataSet(); sourceDataUtils.testData = new DataSet(); destDataUtils.testData = new DataSet(); //this method, conveniently, sets up the datatable schema we need sourceDataUtils.CreateSchemaChangeTable("CT_testdb", 1); Config.Tables = tables.ToList(); Config.RelayDB = "CT_testdb"; var logger = new Logger(null, null, null, ""); slave = new Slave(sourceDataUtils, destDataUtils, logger); }
public void Ksi_ErgodicNotNormalized_EachEntryMatrixIsSummedToOne() { var util = new TestDataUtils(); var observations = util.GetSvcData(util.FTSEFilePath, new DateTime(2011, 11, 18), new DateTime(2011, 12, 18)); var model = HiddenMarkovModelStateFactory.GetState(new ModelCreationParameters <NormalDistribution>() { NumberOfStates = NumberOfStates, Emissions = CreateEmissions(observations, NumberOfStates) }); //new HiddenMarkovModelState<NormalDistribution>(NumberOfStates, CreateEmissions(observations, NumberOfStates)) { LogNormalized = true }; model.Normalized = false; var baseParameters = new BasicEstimationParameters <NormalDistribution> { Model = model, Observations = Helper.Convert(observations), Normalized = model.Normalized }; var alphaEstimator = new AlphaEstimator <NormalDistribution>(); var alpha = alphaEstimator.Estimate(baseParameters); var betaEstimator = new BetaEstimator <NormalDistribution>(); var beta = betaEstimator.Estimate(baseParameters); var @params = new AdvancedEstimationParameters <NormalDistribution> { Alpha = alpha, Beta = beta, Observations = Helper.Convert(observations), Model = model, Normalized = model.Normalized }; var estimator = new KsiEstimator <NormalDistribution>(); for (int t = 0; t < observations.Length - 1; t++) { Assert.AreEqual(1.0d, Math.Round(estimator.Estimate(@params)[t].Sum(), 5), string.Format("Failed Ksi [{1}] :{0}", new Matrix(estimator.Estimate(@params)[t]), t)); } }
/// <summary> /// xunit will automatically create an instance of DDLEventTestData and pass it to this method before running tests /// </summary> public void SetFixture(ApplySchemaChangeTestData data) { this.tables = data.tables; this.sourceDataUtils = data.sourceDataUtils; this.destDataUtils = data.destDataUtils; this.slave = data.slave; }
public void Search_OneNodeAndKis3AndNis10_3Nodes() { var util = new TestDataUtils(); var crf = new ChangeRatioFinder(); var search = new BeamLikeSearch(); var series = util.GetSvcData(util.FTSEFilePath, new DateTime(2010, 12, 18), new DateTime(2011, 12, 18)); var ratios = crf.GetMaximumChangeRatios(series); var population = new double[1][] { series[series.Length] }; var k = 3; var n = 10; var numberOfIterations = 10; var model = (HiddenMarkovModelMixtureDistribution)HiddenMarkovModelFactory.GetModel(new ModelCreationParameters <Mixture <IMultivariateDistribution> >() { NumberOfComponents = _NumberOfComponents, NumberOfStates = _NumberOfStates }); model.Normalized = true; model.Train(series, _NumberOfIterations, _LikelihoodTolerance); var result = search.Search(population, k, n, numberOfIterations, ratios, model); Assert.IsNull(result); }
public static void CreateANewSpecificationSubPolicy() { ManagePoliciesPage managepoliciespage = new ManagePoliciesPage(); CreateSubPolicyPage createsubpolicypage = new CreateSubPolicyPage(); string newname = "Test Sub Policy Name "; string descriptiontext = "This is a Description for: "; var randomSpecSubPolicyName = newname + TestDataUtils.RandomString(6); ScenarioContext.Current["SpecSubPolicyName"] = randomSpecSubPolicyName; managepoliciespage.CreateSubPolicy.Click(); Thread.Sleep(2000); createsubpolicypage.SubPolicyName.SendKeys(randomSpecSubPolicyName); Actions.SelectPolicyForSubPolicyCreationDropdownOption(); createsubpolicypage.SubPolicyDescription.Click(); Thread.Sleep(2000); createsubpolicypage.SubPolicyDescription.SendKeys(descriptiontext + randomSpecSubPolicyName); createsubpolicypage.SaveSubPolicy.Click(); Thread.Sleep(2000); var specPolicyName = ScenarioContext.Current["SpecSubPolicyName"]; string specSubPolicyCreated = specPolicyName.ToString(); Console.WriteLine(specSubPolicyCreated + " has been created successfully"); Thread.Sleep(1000); }
private static IList <QaError> GetErrors([NotNull] string tableName, int maximumLength) { var locator = TestDataUtils.GetTestDataLocator(); string path = locator.GetPath("QaSchemaTests.mdb"); IFeatureWorkspace workspace = WorkspaceUtils.OpenPgdbFeatureWorkspace(path); const int minimumValueCount = 1; const int minimumNonEqualNameValueCount = 1; const bool allowEmptyName = false; ITable table = workspace.OpenTable(tableName); var test = new QaSchemaFieldDomainCodedValues(table, maximumLength, UniqueStringsConstraint.UniqueAnyCase, minimumValueCount, minimumNonEqualNameValueCount, allowEmptyName); var runner = new QaTestRunner(test); runner.Execute(); return(runner.Errors); }
public void GammaComponents_ErgodicNotNormalized_EachEntryMatrixIsSummedToOne() { var util = new TestDataUtils(); var observations = util.GetSvcData(util.FTSEFilePath, new DateTime(2011, 11, 18), new DateTime(2011, 12, 18)); var model = HiddenMarkovModelStateFactory.GetState(new ModelCreationParameters <Mixture <IMultivariateDistribution> >() { NumberOfStates = NumberOfStates, Emissions = CreateEmissions(observations, NumberOfStates, NumberOfComponents) }); //new HiddenMarkovModelState<Mixture<IMultivariateDistribution>>(NumberOfStates, CreateEmissions(observations, NumberOfStates, NumberOfComponents)) { LogNormalized = false }; model.Normalized = false; var baseParameters = new BasicEstimationParameters <Mixture <IMultivariateDistribution> > { Model = model, Observations = Helper.Convert(observations), Normalized = model.Normalized }; var alphaEstimator = new AlphaEstimator <Mixture <IMultivariateDistribution> >(); var alpha = alphaEstimator.Estimate(baseParameters); var betaEstimator = new BetaEstimator <Mixture <IMultivariateDistribution> >(); var beta = betaEstimator.Estimate(baseParameters); var estimator = new MixtureGammaEstimator <Mixture <IMultivariateDistribution> >(); var @params = new MixtureAdvancedEstimationParameters <Mixture <IMultivariateDistribution> > { Alpha = alpha, Beta = beta, L = model.Emission[0].Components.Length, Model = model, Normalized = model.Normalized, Observations = Helper.Convert(observations) }; var gammaComponents = estimator.Estimate(@params); for (int t = 0; t < observations.Length; t++) { Assert.AreEqual(1.0d, Math.Round(gammaComponents[t].Sum(), 5), string.Format("Failed Gamma Components {0} at time {1}", new Matrix(gammaComponents[t]), t)); } }
public void Beta_ErgodicLogNormalized_BetaCalculated() { const int numberOfStates = 2; var util = new TestDataUtils(); var observations = util.GetSvcData(util.FTSEFilePath, new DateTime(2011, 11, 18), new DateTime(2011, 12, 18)); var model = HiddenMarkovModelStateFactory.GetState(new ModelCreationParameters <NormalDistribution>() { NumberOfStates = numberOfStates, Emissions = CreateEmissions(observations, numberOfStates) }); //new HiddenMarkovModelState<NormalDistribution>(numberOfStates, CreateEmissions(observations, numberOfStates)) { LogNormalized = true }; model.Normalized = true; var estimator = new BetaEstimator <NormalDistribution>(); var beta = estimator.Estimate(new BasicEstimationParameters <NormalDistribution>() { Model = model, Observations = Helper.Convert(observations), Normalized = model.Normalized }); Assert.IsNotNull(beta); for (int i = 0; i < observations.Length - 1; i++) { for (int j = 0; j < numberOfStates; j++) { Assert.IsTrue(beta[i][j] < 0, string.Format("Failed Beta [{0}][{1}] : {2}", i, j, beta[i][j])); } } // Last observation has probability == 1 Assert.IsTrue(beta[observations.Length - 1][0] == 0); Assert.IsTrue(beta[observations.Length - 1][1] == 0); }
public void MixtureGammaEstimator_Parameters_MixtureGammaComponentsAndGammaInitialized() { var util = new TestDataUtils(); var observations = util.GetSvcData(util.FTSEFilePath, new DateTime(2011, 11, 18), new DateTime(2011, 12, 18)); var model = HiddenMarkovModelStateFactory.GetState(new ModelCreationParameters <Mixture <IMultivariateDistribution> >() { NumberOfStates = NumberOfStates, Emissions = CreateEmissions(observations, NumberOfStates, NumberOfComponents) }); //new HiddenMarkovModelState<Mixture<IMultivariateDistribution>>(NumberOfStates, CreateEmissions(observations, NumberOfStates, NumberOfComponents)) { LogNormalized = true }; model.Normalized = true; var baseParameters = new BasicEstimationParameters <Mixture <IMultivariateDistribution> > { Model = model, Observations = Helper.Convert(observations), Normalized = model.Normalized }; var alphaEstimator = new AlphaEstimator <Mixture <IMultivariateDistribution> >(); var alpha = alphaEstimator.Estimate(baseParameters); var betaEstimator = new BetaEstimator <Mixture <IMultivariateDistribution> >(); var beta = betaEstimator.Estimate(baseParameters); var gamma = new MixtureGammaEstimator <Mixture <IMultivariateDistribution> >(); var @params = new MixtureAdvancedEstimationParameters <Mixture <IMultivariateDistribution> > { Alpha = alpha, Beta = beta, L = model.Emission[0].Components.Length, Model = model, Normalized = model.Normalized, Observations = Helper.Convert(observations) }; Assert.IsNotNull(gamma.Estimate(@params as AdvancedEstimationParameters <Mixture <IMultivariateDistribution> >)); Assert.IsNotNull(gamma.Estimate(@params)); }
public void WhenIHaveEnteredATestNameForMyQATest() { var randomQATestName = qatestname + TestDataUtils.RandomString(6); ScenarioContext.Current["QATestName"] = randomQATestName; createqatestpage.createQATestName.Click(); createqatestpage.createQATestName.SendKeys(randomQATestName); }
public void GivenIHaveCompletedTheRequiredQATestScenarioFields() { Actions.SelectSpecificationCreateQATestPage(); createqatestpage.createQATestName.Click(); createqatestpage.createQATestName.SendKeys(qatestname + TestDataUtils.RandomString(6)); createqatestpage.createQATestDescription.Click(); createqatestpage.createQATestDescription.SendKeys(qatestdescription); Thread.Sleep(2000); }
private static string GetTestJson(string fileName) { var path = TestDataUtils.GetLocalFilePath(fileName); using (var reader = File.OpenText(path)) { return(reader.ReadToEnd()); } }
public void TestInitialized() { var util = new TestDataUtils(); var observations = util.GetSvcData(util.FTSEFilePath, new DateTime(2011, 11, 18), new DateTime(2011, 12, 18)); var model = HiddenMarkovModelStateFactory.GetState(new ModelCreationParameters <NormalDistribution>() { NumberOfStates = NumberOfStates, Emissions = CreateEmissions(observations, NumberOfStates) }); //new HiddenMarkovModelState<NormalDistribution>(NumberOfStates, CreateEmissions(observations, NumberOfStates)) { LogNormalized = true }; model.Normalized = true; }
public void Sigma_ErgodicAndObservationAndLogNormalized_SigmaCalculated() { var util = new TestDataUtils(); var observations = util.GetSvcData(util.FTSEFilePath, new DateTime(2011, 11, 18), new DateTime(2011, 12, 18)); var sequence = Helper.Convert(observations); var model = HiddenMarkovModelStateFactory.GetState(new ModelCreationParameters <NormalDistribution>() { NumberOfStates = NumberOfStates, Emissions = CreateEmissions(observations, NumberOfStates) }); //new HiddenMarkovModelState<NormalDistribution>(NumberOfStates, CreateEmissions(observations, NumberOfStates)) { LogNormalized = true }; model.Normalized = true; var baseParameters = new BasicEstimationParameters <NormalDistribution> { Model = model, Observations = sequence, Normalized = model.Normalized }; var alphaEstimator = new AlphaEstimator <NormalDistribution>(); var alpha = alphaEstimator.Estimate(baseParameters); var betaEstimator = new BetaEstimator <NormalDistribution>(); var beta = betaEstimator.Estimate(baseParameters); var @params = new AdvancedEstimationParameters <NormalDistribution> { Alpha = alpha, Beta = beta, Observations = sequence, Model = model }; var gammaEstimator = new GammaEstimator <NormalDistribution>(); var muEstimator = new MuMultivariateEstimator <NormalDistribution>(); var estimator = new SigmaMultivariateEstimator <NormalDistribution>(); var muParams = new MuEstimationParameters <NormalDistribution> { Gamma = gammaEstimator.Estimate(@params), Model = model, Normalized = model.Normalized, Observations = Helper.Convert(observations) }; Assert.IsNotNull(estimator); var sigma = estimator.Estimate(new SigmaEstimationParameters <NormalDistribution, double[][]>(muParams) { Mean = muEstimator.Estimate(muParams) }); for (int n = 0; n < NumberOfStates; n++) { for (int i = 0; i < sequence[0].Dimention; i++) { for (int j = 0; j < sequence[0].Dimention; j++) { Assert.IsTrue(sigma[n][i, j] > 0, string.Format("Failed Sigma {0}", sigma[n][i, j])); } } } }
public void Sigma_RightLeftAndParametersAnnNotNormalized_SigmaCalculated() { var delta = 3; var util = new TestDataUtils(); var observations = util.GetSvcData(util.FTSEFilePath, new DateTime(2011, 11, 18), new DateTime(2011, 12, 18)); var model = HiddenMarkovModelStateFactory.GetState(new ModelCreationParameters <Mixture <IMultivariateDistribution> >() { NumberOfStates = NumberOfStatesRightLeft, Delta = delta, Emissions = CreateEmissions(observations, NumberOfStatesRightLeft, NumberOfComponents) }); //new HiddenMarkovModelState<Mixture<IMultivariateDistribution>>(NumberOfStatesRightLeft, delta, CreateEmissions(observations, NumberOfStatesRightLeft, NumberOfComponents)) { LogNormalized = false }; model.Normalized = false; var baseParameters = new BasicEstimationParameters <Mixture <IMultivariateDistribution> > { Model = model, Observations = Helper.Convert(observations), Normalized = model.Normalized }; var alphaEstimator = new AlphaEstimator <Mixture <IMultivariateDistribution> >(); var alpha = alphaEstimator.Estimate(baseParameters); var betaEstimator = new BetaEstimator <Mixture <IMultivariateDistribution> >(); var beta = betaEstimator.Estimate(baseParameters); var parameters = new ParameterEstimations <Mixture <IMultivariateDistribution> >(model, Helper.Convert(observations), alpha, beta); var sigma = new MixtureSigmaEstimator <Mixture <IMultivariateDistribution> >(); var mixtureGammaEstimator = new MixtureGammaEstimator <Mixture <IMultivariateDistribution> >(); var mixtureMuEstimator = new MixtureMuEstimator <Mixture <IMultivariateDistribution> >(); var @params = new MixtureSigmaEstimationParameters <Mixture <IMultivariateDistribution> > { Model = model, Normalized = model.Normalized, Alpha = alpha, Beta = beta, Observations = Helper.Convert(observations), L = model.Emission[0].Components.Length }; var gamma = mixtureGammaEstimator.Estimate(@params as AdvancedEstimationParameters <Mixture <IMultivariateDistribution> >); var gammaComponens = mixtureGammaEstimator.Estimate(@params); @params.Gamma = gamma; @params.GammaComponents = gammaComponens; @params.Mu = mixtureMuEstimator.Estimate(@params); for (int i = 0; i < NumberOfStatesRightLeft; i++) { for (int l = 0; l < NumberOfComponents; l++) { for (int rows = 0; rows < parameters.Observation[0].Dimention; rows++) { for (int cols = 0; cols < parameters.Observation[0].Dimention; cols++) { Assert.IsTrue(sigma.Estimate(@params)[i, l][rows, cols] > 0, string.Format("Failed Sigma {0}", sigma.Estimate(@params)[i, l][rows, cols])); } } } } }
public void VerifyTOP4472_20140117_2() { IWorkspace ws = TestDataUtils.OpenPgdb(@"QA_Fehler\QA_Fehler2.mdb"); IFeatureClass fc = ((IFeatureWorkspace)ws).OpenFeatureClass("TLM_GEBAEUDE"); var test = new QaMpFootprintHoles(fc, InnerRingHandling.None); var runner = new QaTestRunner(test); runner.Execute(); Assert.AreEqual(0, runner.Errors.Count); }
public void Estimate_KsiGammaParameters_TransitionProbabilityMatrixCalculatedAndReturned() { const int numberOfStates = 2; var util = new TestDataUtils(); var observations = util.GetSvcData(util.FTSEFilePath, new DateTime(2010, 12, 18), new DateTime(2011, 12, 18)); var model = HiddenMarkovModelStateFactory.GetState(new ModelCreationParameters <NormalDistribution>() { NumberOfStates = numberOfStates, Emissions = CreateEmissions(observations, numberOfStates) }); model.Normalized = true; var observationsList = new List <IObservation>(); for (var i = 0; i < observations.Length; i++) { observationsList.Add(new Observation(observations[i], i.ToString())); } var baseEstimator = new BasicEstimationParameters <NormalDistribution> { Model = model, Observations = Helper.Convert(observations), Normalized = model.Normalized }; var alphaEstimator = new AlphaEstimator <NormalDistribution>(); var alpha = alphaEstimator.Estimate(baseEstimator); var betaEstimator = new BetaEstimator <NormalDistribution>(); var beta = betaEstimator.Estimate(baseEstimator); var @params = new AdvancedEstimationParameters <NormalDistribution> { Alpha = alpha, Beta = beta, Observations = observationsList, Model = model, Normalized = model.Normalized }; var gammaEstimator = new GammaEstimator <NormalDistribution>(); var ksiEstimator = new KsiEstimator <NormalDistribution>(); var gamma = gammaEstimator.Estimate(@params); var ksi = ksiEstimator.Estimate(@params); var estimator = new TransitionProbabilityEstimator <NormalDistribution>(); var parameters = new KsiGammaTransitionProbabilityMatrixParameters <NormalDistribution> { Model = model, Ksi = ksi, Gamma = gamma, T = observations.Length, Normalized = model.Normalized }; var estimatedTransitionProbabilityMatrix = estimator.Estimate(parameters); Assert.AreEqual(1d, Math.Round(estimatedTransitionProbabilityMatrix[0][0] + estimatedTransitionProbabilityMatrix[0][1], 5)); Assert.AreEqual(1d, Math.Round(estimatedTransitionProbabilityMatrix[1][0] + estimatedTransitionProbabilityMatrix[1][1], 5)); }
public void Denormalized_NormalizedEstimator_SigmaDenormalized() { var util = new TestDataUtils(); var observations = util.GetSvcData(util.FTSEFilePath, new DateTime(2011, 11, 18), new DateTime(2011, 12, 18)); var model = HiddenMarkovModelStateFactory.GetState(new ModelCreationParameters <Mixture <IMultivariateDistribution> >() { NumberOfStates = NumberOfStates, Emissions = CreateEmissions(observations, NumberOfStates, NumberOfComponents) }); //new HiddenMarkovModelState<Mixture<IMultivariateDistribution>>(NumberOfStates, CreateEmissions(observations, NumberOfStates, NumberOfComponents)) { LogNormalized = true }; model.Normalized = true; var baseParameters = new BasicEstimationParameters <Mixture <IMultivariateDistribution> > { Model = model, Observations = Helper.Convert(observations), Normalized = model.Normalized }; var alphaEstimator = new AlphaEstimator <Mixture <IMultivariateDistribution> >(); var alpha = alphaEstimator.Estimate(baseParameters); var betaEstimator = new BetaEstimator <Mixture <IMultivariateDistribution> >(); var beta = betaEstimator.Estimate(baseParameters); var parameters = new ParameterEstimations <Mixture <IMultivariateDistribution> >(model, Helper.Convert(observations), alpha, beta); var coefficients = new MixtureCoefficientsEstimator <Mixture <IMultivariateDistribution> >(); var mixtureGammaEstimator = new MixtureGammaEstimator <Mixture <IMultivariateDistribution> >(); var @params = new MixtureCoefficientEstimationParameters <Mixture <IMultivariateDistribution> > { Model = model, Normalized = model.Normalized, Alpha = alpha, Beta = beta, Observations = Helper.Convert(observations), L = model.Emission[0].Components.Length }; var gamma = mixtureGammaEstimator.Estimate(@params as AdvancedEstimationParameters <Mixture <IMultivariateDistribution> >); var gammaComponens = mixtureGammaEstimator.Estimate(@params); @params.Gamma = gamma; @params.GammaComponents = gammaComponens; for (int i = 0; i < NumberOfStates; i++) { for (int l = 0; l < NumberOfComponents; l++) { Assert.IsTrue(coefficients.Estimate(@params)[i][l] < 0, string.Format("Failed Coefficients {0}", coefficients.Estimate(@params)[i][l])); } } coefficients.Denormalize(); for (int i = 0; i < NumberOfStates; i++) { for (int l = 0; l < NumberOfComponents; l++) { Assert.IsTrue(coefficients.Estimate(@params)[i][l] > 0 && coefficients.Estimate(@params)[i][l] < 1, string.Format("Failed Coefficients {0}", coefficients.Estimate(@params)[i][l])); } } }