Ejemplo n.º 1
0
        protected void buildFruitsSet()
        {
            product            = new DiscreteDimension("Product", "Product being offered");
            fruits             = new DiscreteSet(product, "Fruits");
            product.DefaultSet = fruits;

            apple        = new Fruit(product, "Apple");
            pear         = new Fruit(product, "Pear");
            tomato       = new Fruit(product, "Tomato");
            blueberry    = new Fruit(product, "Blueberry");
            blackberry   = new Fruit(product, "Blackberry");
            blackCurrant = new Fruit(product, "Black-currant");
            strawberry   = new Fruit(product, "Strawberry");
            lemon        = new Fruit(product, "Lemon");
            melon        = new Fruit(product, "Melon");
            broccoli     = new Fruit(product, "Broccoli");

            fruits.AddMember(apple, (double)trackBar1.Value / 100);
            fruits.AddMember(pear, (double)trackBar2.Value / 100);
            fruits.AddMember(lemon, (double)trackBar3.Value / 100);
            fruits.AddMember(melon, (double)trackBar4.Value / 100);
            fruits.AddMember(tomato, (double)trackBar5.Value / 100);
            fruits.AddMember(blackCurrant, (double)trackBar6.Value / 100);
            fruits.AddMember(blackberry, (double)trackBar7.Value / 100);
            fruits.AddMember(strawberry, (double)trackBar8.Value / 100);
            fruits.AddMember(blueberry, (double)trackBar9.Value / 100);
            fruits.AddMember(broccoli, (double)trackBar10.Value / 100);

            RelationImage imgFruits = new RelationImage(fruits);
            Bitmap        bmpFruits = new Bitmap(pictureBoxFruits.Width, pictureBoxFruits.Height);

            imgFruits.DrawImage(Graphics.FromImage(bmpFruits));
            pictureBoxFruits.Image = bmpFruits;
        }
Ejemplo n.º 2
0
        protected void buildTemperatureSets()
        {
            temperature = new ContinuousDimension("t", "Temperature detected by sensor", "°C", -30, +40);

            lowTemperature     = new RightQuadraticSet(temperature, "Low temperature", 10, 15, 20);
            highTemperature    = new LeftQuadraticSet(temperature, "High temperature", 20, 25, 30);
            correctTemperature = new BellSet(temperature, "Correct temperature", 20, 5, 10);

            #region Show it graphically
            RelationImage imgLowTemp     = new RelationImage(lowTemperature);
            RelationImage imgHighTemp    = new RelationImage(highTemperature);
            RelationImage imgCorrectTemp = new RelationImage(correctTemperature);

            Bitmap bmpLowTemp     = new Bitmap(pictureBoxLowTemp.Width, pictureBoxLowTemp.Height);
            Bitmap bmpHighTemp    = new Bitmap(pictureBoxHighTemp.Width, pictureBoxHighTemp.Height);
            Bitmap bmpCorrectTemp = new Bitmap(pictureBoxCorrectTemp.Width, pictureBoxCorrectTemp.Height);

            imgLowTemp.DrawImage(Graphics.FromImage(bmpLowTemp));
            imgHighTemp.DrawImage(Graphics.FromImage(bmpHighTemp));
            imgCorrectTemp.DrawImage(Graphics.FromImage(bmpCorrectTemp));

            pictureBoxLowTemp.Image     = bmpLowTemp;
            pictureBoxHighTemp.Image    = bmpHighTemp;
            pictureBoxCorrectTemp.Image = bmpCorrectTemp;
            #endregion
        }
Ejemplo n.º 3
0
        protected void buildActionSets()
        {
            action = new ContinuousDimension("Action", "-10 Cool ... 0 Do nothing ... +10 heat", "", -10, +10);

            heat      = new SingletonSet(action, "Heat", 10);
            cool      = new SingletonSet(action, "Cool", -10);
            doNothing = new SingletonSet(action, "Do nothing", 0);

            #region Show it graphically
            RelationImage imgHeat      = new RelationImage(heat);
            RelationImage imgCool      = new RelationImage(cool);
            RelationImage imgDoNothing = new RelationImage(doNothing);

            Bitmap bmpHeat      = new Bitmap(pictureBoxHeat.Width, pictureBoxHeat.Height);
            Bitmap bmpCool      = new Bitmap(pictureBoxCool.Width, pictureBoxCool.Height);
            Bitmap bmpDoNothing = new Bitmap(pictureBoxDoNothing.Width, pictureBoxDoNothing.Height);

            imgHeat.DrawImage(Graphics.FromImage(bmpHeat));
            imgCool.DrawImage(Graphics.FromImage(bmpCool));
            imgDoNothing.DrawImage(Graphics.FromImage(bmpDoNothing));

            pictureBoxHeat.Image      = bmpHeat;
            pictureBoxCool.Image      = bmpCool;
            pictureBoxDoNothing.Image = bmpDoNothing;
            #endregion
        }
Ejemplo n.º 4
0
        protected void buildDeltaTemperatureSets()
        {
            deltaTemperature = new ContinuousDimension("∆t", "Change of temperature detected by temperature sensor in time period", "°C/min", -5, +5);

            fallingTemperature  = new RightQuadraticSet(deltaTemperature, "Falling temperature", -3, -1, 0);
            risingTemperature   = new LeftQuadraticSet(deltaTemperature, "Rising temperature", 0, 1, 3);
            constantTemperature = new BellSet(deltaTemperature, "Constant temperature", 0, 1, 3);

            #region Show it graphically
            RelationImage imgFallingTemp  = new RelationImage(fallingTemperature);
            RelationImage imgRisingTemp   = new RelationImage(risingTemperature);
            RelationImage imgConstantTemp = new RelationImage(constantTemperature);

            Bitmap bmpFallingTemp  = new Bitmap(pictureBoxFallingTemp.Width, pictureBoxFallingTemp.Height);
            Bitmap bmpRisingTemp   = new Bitmap(pictureBoxRisingTemp.Width, pictureBoxRisingTemp.Height);
            Bitmap bmpConstantTemp = new Bitmap(pictureBoxConstantTemp.Width, pictureBoxConstantTemp.Height);

            imgFallingTemp.DrawImage(Graphics.FromImage(bmpFallingTemp));
            imgRisingTemp.DrawImage(Graphics.FromImage(bmpRisingTemp));
            imgConstantTemp.DrawImage(Graphics.FromImage(bmpConstantTemp));

            pictureBoxFallingTemp.Image  = bmpFallingTemp;
            pictureBoxRisingTemp.Image   = bmpRisingTemp;
            pictureBoxConstantTemp.Image = bmpConstantTemp;
            #endregion
        }
Ejemplo n.º 5
0
        protected void buildCheapSet()
        {
            price = new ContinuousDimension("Price", "Price we are about to pay for an offer", "$", 0, 1000);

            if (trackBarCheapSupport.Value < trackBarCheapKernel.Value)
            {
                trackBarCheapSupport.Value = trackBarCheapKernel.Value;
            }

            cheap = new RightLinearSet(price, "Cheap", trackBarCheapKernel.Value, trackBarCheapSupport.Value);

            RelationImage imgCheap = new RelationImage(cheap);
            Bitmap        bmpCheap = new Bitmap(pictureBoxCheap.Width, pictureBoxCheap.Height);

            imgCheap.DrawImage(Graphics.FromImage(bmpCheap));
            pictureBoxCheap.Image = bmpCheap;
        }
Ejemplo n.º 6
0
        private async Task <string> Reasoning(string rainInput, string temperatureInput, string fogInput /*, string darknessInput*/)
        {
            Debug.WriteLine(rainInput);
            Debug.WriteLine(fogInput);
            Debug.WriteLine(temperatureInput);
            //Debug.WriteLine(darknessInput);
            return(await Task.Run(() =>
            {
                decimal rain;
                decimal fog;
                decimal temperature;
                decimal darkness;

                if (!Decimal.TryParse(rainInput, out rain))
                {
                    return String.Empty;
                }
                if (!Decimal.TryParse(fogInput, out fog))
                {
                    return String.Empty;
                }
                if (!Decimal.TryParse(temperatureInput, out temperature))
                {
                    return String.Empty;
                }
                // if (!Decimal.TryParse(darknessInput, out darkness))
                //    return String.Empty;
                var condParameter = new FuzzyParameter
                {
                    PositiveSet = GoodCondControl.FuzzySet,
                    NegativeSet = BadCondControl.FuzzySet,
                    Dimension = CondDimension,
                };
                _fr = new FuzzyReasoning(RainControl.Parameter, TemperatureControl.Parameter, FogControl.Parameter,
                                         /*DarknessControl.Parameter,*/ condParameter);

                var r = _fr.Work(rain, temperature, fog /*, darkness*/, (DefuzzificationFactory.DefuzzificationMethod)(Method + 1)); //,temperature,hour);
                var chart = (PictureBox)Wfh.Child;
                var imgBuyIt = new RelationImage(r.Relation, r.Inputs, r.OutputDimension);
                var bmpBuyIt = new Bitmap(chart.Width, chart.Height);
                imgBuyIt.DrawImage(Graphics.FromImage(bmpBuyIt));
                chart.Image = bmpBuyIt;
                return r.CrispValue.ToString();
            }));
        }
Ejemplo n.º 7
0
        private void UpdateChart()
        {
            try
            {
                _dimension = new ContinuousDimension(FuzzyName, Description, Unit, (decimal)Min, (decimal)Max);

                _fuzzySet = new QuadraticSet(_dimension, FuzzyName, LeftTop, RightTop, LeftBot, RightBot, LeftMid, RightMid);
                //_fuzzySet = new RightQuadraticSet(_dimension, FuzzyName, Top, Mid,Bot);
                var           chart    = (PictureBox)Wfh.Child;
                RelationImage imgBuyIt = new RelationImage(_fuzzySet);
                Bitmap        bmpBuyIt = new Bitmap(chart.Width, chart.Height);
                imgBuyIt.DrawImage(Graphics.FromImage(bmpBuyIt));
                chart.Image = bmpBuyIt;
            }
            catch
            {
            }
        }
Ejemplo n.º 8
0
        public void UpdateChart()
        {
            if (!ShallUpdateChart)
            {
                return;
            }
            if (_min >= _max)
            {
                return;
            }
            //_dimension = new ContinuousDimension(FuzzyName, Description, Unit, (decimal)_min, (decimal)_max);
            if (IsLinear)
            {
                if (IsLeft)
                {
                    _fuzzySet = new LeftLinearSet(Dimension, FuzzyName, (decimal)_bot, (decimal)_top);
                }
                else
                {
                    _fuzzySet = new RightLinearSet(Dimension, FuzzyName, (decimal)_top, (decimal)_bot);
                }
            }
            else
            {
                if (IsLeft)
                {
                    _fuzzySet = new LeftQuadraticSet(Dimension, FuzzyName, (decimal)_bot, (decimal)_mid, (decimal)_top);
                }
                else
                {
                    _fuzzySet = new RightQuadraticSet(Dimension, FuzzyName, (decimal)_top, (decimal)_mid, (decimal)_bot);
                }
            }
            //_fuzzySet = new RightQuadraticSet(_dimension, FuzzyName, Top, Mid,Bot);
            var chart    = (PictureBox)Wfh.Child;
            var imgBuyIt = new RelationImage(_fuzzySet);
            var bmpBuyIt = new Bitmap(chart.Width, chart.Height);

            imgBuyIt.DrawImage(Graphics.FromImage(bmpBuyIt));
            chart.Image = bmpBuyIt;
        }