예제 #1
0
        private double selectMinValueFormAcivatedRule(Cloudy cloudy, int cloudyLevel, Pressure pressure, int pressureLevel)
        {
            double cloudyScore   = cloudy.selectCloudyLevelValue(cloudyLevel);
            double pressureScore = pressure.selectPressureLevelValue(pressureLevel);

            return(Math.Round(Math.Min(cloudyScore, pressureScore), 2));
        }
예제 #2
0
        private void fillFormLabelsWithVariableMinValue(int currentRow, Cloudy cloudy, int cloudyLevel, Pressure pressure, int pressureLevel)
        {
            Label  minLabel = this.Controls.Find("min_row" + currentRow + "_label", true).FirstOrDefault() as Label;
            double minValueFromActivatedRule = selectMinValueFormAcivatedRule(cloudy, cloudyLevel, pressure, pressureLevel);

            minLabel.Text = "" + minValueFromActivatedRule;
        }
예제 #3
0
        private void fillFormLabelsWithVariablesName(int currentRow, int cloudyLevel, int pressureLevel, int precipitationLevel)
        {
            Label cloudyLabel        = this.Controls.Find("cloudy_row" + currentRow + "_label", true).FirstOrDefault() as Label;
            Label pressureLabel      = this.Controls.Find("pressure_row" + currentRow + "_label", true).FirstOrDefault() as Label;
            Label precipitationLabel = this.Controls.Find("precipitation_row" + currentRow + "_label", true).FirstOrDefault() as Label;

            cloudyLabel.Text        = Cloudy.chooseCloudyName(cloudyLevel);
            pressureLabel.Text      = Pressure.choosePressureName(pressureLevel);
            precipitationLabel.Text = Precipitation.choosePrecipitationName(precipitationLevel);
        }
예제 #4
0
        private void calculatePrecipitation()
        {
            Cloudy       cloudy   = new Cloudy(cloudy_scrollbar.Value);
            Pressure     pressure = new Pressure(pressure_scrollbar.Value);
            DBConnection db       = new DBConnection("Database.mdf");
            ArrayList    rules    = db.getRules(cloudy, pressure);

            fillFormWithVariableNamesAndValues(rules, cloudy, pressure);
            Dictionary <int, double> maxOfPrecipitation = calculateMaximumOfPercipitation(rules, cloudy, pressure);

            fillFormWithPrecipitationResult(maxOfPrecipitation);
            calculateDefuzzyficationAndShowResults(maxOfPrecipitation);
        }
예제 #5
0
        private void fillFormWithVariableNamesAndValues(ArrayList rules, Cloudy cloudy, Pressure pressure)
        {
            int currentRow = 1;

            foreach (int[] rule in rules)
            {
                int cloudyLevel        = rule[1];
                int pressureLevel      = rule[2];
                int precipitationLevel = rule[3];
                fillFormLabelsWithVariablesName(currentRow, cloudyLevel, pressureLevel, precipitationLevel);
                fillFormLabelsWithVariableMinValue(currentRow, cloudy, cloudyLevel, pressure, pressureLevel);
                currentRow++;
            }
        }
예제 #6
0
 public ArrayList getRules(Cloudy cloudy, Pressure pressure)
 {
     if (executedRules == null)
     {
         using (SqlConnection conn = new SqlConnection())
         {
             ArrayList cloudyRules   = findActiveCloudyLevels(cloudy);
             ArrayList pressureRules = findActivePressureLevels(pressure);
             string    sql           = prepareSqlQuery(cloudyRules, pressureRules);
             DataTable dt            = findRulesInDB(conn, sql);
             executedRules = new ArrayList();
             fillExecutedRules(dt);
         }
     }
     return(executedRules);
 }
예제 #7
0
        public ArrayList findActiveCloudyLevels(Cloudy cloudy)
        {
            ArrayList cloudyRules = new ArrayList();

            if (cloudy.cloudless != 0)
            {
                cloudyRules.Add(1);
            }
            if (cloudy.small != 0)
            {
                cloudyRules.Add(2);
            }
            if (cloudy.cloudy != 0)
            {
                cloudyRules.Add(3);
            }
            if (cloudy.complete != 0)
            {
                cloudyRules.Add(4);
            }
            return(cloudyRules);
        }
예제 #8
0
        private Dictionary <int, double> calculateMaximumOfPercipitation(ArrayList rules, Cloudy cloudy, Pressure pressure)
        {
            int currentRow = 1;
            Dictionary <int, double> maxOfPrecipitation = new Dictionary <int, double>();

            foreach (int[] rule in rules)
            {
                int    cloudyLevel               = rule[1];
                int    pressureLevel             = rule[2];
                int    precipitationLevel        = rule[3];
                double minValueFromActivatedRule = selectMinValueFormAcivatedRule(cloudy, cloudyLevel, pressure, pressureLevel);
                addPrecipitationOrReplaceMaximumValueInDictionary(maxOfPrecipitation, precipitationLevel, minValueFromActivatedRule);
                currentRow++;
            }
            return(maxOfPrecipitation);
        }