Beispiel #1
0
        //ViewController (askKPI) //TODO use Dialog Service instead
        //DataService (CreateNewTreeEntry)
        //DAL (LogTreeEstimate) //should be dataservice instead
        //SampleGroup (MinKPI/MaxKPI)
        public static TallyAction TallyThreeP(CountTree count, ISampleSelector sampler, SampleGroup sg, ITreeDataService dataService, IDialogService dialogService)
        {
            TallyAction action = new TallyAction(count)
            {
                TreeCount = 1,
            };

            var sgCode = sg.Code;
            var stCode = sg.Stratum.Code;
            var spCode = count.TreeDefaultValue.Species;
            int kpi    = 0;
            int?value  = dialogService.AskKPI((int)sg.MinKPI, (int)sg.MaxKPI, stCode, sgCode, spCode);

            if (value == null)
            {
                return(null);
            }
            else
            {
                kpi = value.Value;
            }

            if (kpi == -1)  //user entered sure to measure
            {
                var tree = dataService.CreateNewTreeEntry(count);
                tree.STM          = "Y";
                action.TreeRecord = tree;
            }
            else
            {
                action.TreeEstimate = dataService.LogTreeEstimate(count, kpi);
                action.KPI          = kpi;

                var result = ((IThreePSelector)sampler).Sample(kpi);
                if (result != SampleResult.C)
                {
                    var tree = dataService.CreateNewTreeEntry(count);
                    tree.KPI            = kpi;
                    tree.CountOrMeasure = result.ToString();
                    action.TreeRecord   = tree;
                }
            }

            return(action);
        }
Beispiel #2
0
        //DataService (CreateNewTreeEntry)
        //
        public static TallyAction TallyStandard(CountTree count, ISampleSelector sampleSelecter, ITreeDataService dataService, IDialogService dialogService)
        {
            TallyAction action = new TallyAction(count)
            {
                TreeCount = 1,
            };

            var result = ((IFrequencyBasedSelecter)sampleSelecter).Sample();

            //If we receive nothing from the sampler, we don't have a sample
            if (result != SampleResult.C)//&& (item.IsSelected || item.IsInsuranceItem))
            {
                var tree = dataService.CreateNewTreeEntry(count);
                tree.CountOrMeasure = result.ToString();
                action.TreeRecord   = tree;
            }

            return(action);
        }
Beispiel #3
0
        // Extract data with the given generic criteria
        public void Extract( 
            ISampleSelector sampleSelector,
            IFeatureSelector featureSelector )
        {
            // TODO: Change to Q or Y data
            // Get the table of financial data
            Table<QLSample> qlSamples = dc.GetTable<QLSample>( );

            // copy the data to the list of training cases
            data = new ClassificationData( );
            foreach (QLSample sample in qlSamples)
            {
                // Apply the sample selection criteria
                if (sampleSelector.Select( sample ))
                {
                    // Apply the feature selection criteria
                    data.Samples.Add( featureSelector.Select( sample ) );
                }
            }
        }
Beispiel #4
0
        // Extract data with the given generic criteria
        public void Extract(
            ISampleSelector sampleSelector,
            IFeatureSelector featureSelector)
        {
            // TODO: Change to Q or Y data
            // Get the table of financial data
            Table <QLSample> qlSamples = dc.GetTable <QLSample>( );

            // copy the data to the list of training cases
            data = new ClassificationData( );
            foreach (QLSample sample in qlSamples)
            {
                // Apply the sample selection criteria
                if (sampleSelector.Select(sample))
                {
                    // Apply the feature selection criteria
                    data.Samples.Add(featureSelector.Select(sample));
                }
            }
        }
        public SamplerState(ISampleSelector sampler)
        {
            if (sampler is null)
            {
                throw new System.ArgumentNullException(nameof(sampler));
            }

            SampleSelectorType = sampler.GetType().Name;
            StratumCode        = sampler.StratumCode;
            SampleGroupCode    = sampler.SampleGroupCode;
            Counter            = sampler.Count;
            InsuranceCounter   = sampler.InsuranceCounter;
            InsuranceIndex     = sampler.InsuranceIndex;

            switch (sampler)
            {
            case SystematicSelecter s:
            {
                SystematicIndex = s.HitIndex;
                break;
            }

            case BlockSelecter b:
            {
                BlockState = b.BlockState;
                break;
            }

            case ThreePSelecter s:
            {
                break;
            }

            case S3PSelector s:
            {
                BlockState = s.BlockState;
                break;
            }
            }
        }
        public SamplerState(ISampleSelector sampler)
        {
            SampleSelectorType = sampler.GetType().Name;
            StratumCode        = sampler.StratumCode;
            SampleGroupCode    = sampler.SampleGroupCode;
            Counter            = sampler.Count;
            InsuranceCounter   = sampler.InsuranceCounter;
            InsuranceIndex     = sampler.InsuranceIndex;

            var samplerName = sampler.GetType().Name;

            switch (samplerName)
            {
            case "SystematicSelecter":
            {
                SystematicIndex = ((SystematicSelecter)sampler).HitIndex;
                break;
            }

            case "BlockSelecter":
            {
                BlockState = ((BlockSelecter)sampler).BlockState;
                break;
            }

            case "ThreePSelecter":
            {
                break;
            }

            case "S3PSelector":
            {
                BlockState = ((S3PSelector)sampler).BlockState;
                break;
            }
            }
        }
Beispiel #7
0
        public void SaveSampler(ISampleSelector sampler)
        {
            var state = new SamplerState(sampler);

            Dataservice.UpsertSamplerState(state);
        }