protected void buildBuyItSet() { action = new ContinuousDimension("Action", "-10 surely don't buy ... +10 surely buy", "", -10, +10); if (trackBarBuyItKernel.Value < -8) { trackBarBuyItKernel.Value = -8; } if (trackBarBuyItCrossover.Value < -9) { trackBarBuyItCrossover.Value = -9; } if (trackBarBuyItCrossover.Value > trackBarBuyItKernel.Value - 1) { trackBarBuyItCrossover.Value = trackBarBuyItKernel.Value - 1; } if (trackBarBuyItSupport.Value > trackBarBuyItCrossover.Value - 1) { trackBarBuyItSupport.Value = trackBarBuyItCrossover.Value - 1; } buyIt = new LeftQuadraticSet(action, "Buy it!", trackBarBuyItSupport.Value, trackBarBuyItCrossover.Value, trackBarBuyItKernel.Value); RelationImage imgBuyIt = new RelationImage(buyIt); Bitmap bmpBuyIt = new Bitmap(pictureBoxBuyIt.Width, pictureBoxBuyIt.Height); imgBuyIt.DrawImage(Graphics.FromImage(bmpBuyIt)); pictureBoxBuyIt.Image = bmpBuyIt; }
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; }
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 }
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 }
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 }
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; }
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(); })); }
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 { } }
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; }