CTrapezoidMembershipFunction

X1、X2、X3、X4パラメータを持つ台形メンバーシップ関数を実装するためのクラス。  

説明

この関数は、区分線形近似を用いて形成されます。これは、ファジー集合コアを区間として割り当てることを可能にする三角関数の一般化です。このようなメンバーシップ関数によって、楽観的/悲観的な評価を簡便に解釈することが可能になります。

この関数は、変数の非対称メンバーシップ関数を、特定の間隔内で定義された最も重要な値で設定するために使用されます。

fuzzy_trapezoid_function

下記はチャートをプロットするためのサンプルコードです。

宣言

  class CTrapezoidMembershipFuncion : public IMembershipFunction

タイトル

  #include <Math\Fuzzy\membershipfunction.mqh>

継承階層

  CObject

      IMembershipFunction

          CTrapezoidMembershipFunction

クラスメソッド

クラスメソッド  

説明

X1

X軸上の1番目の点の値を取得および設定します。

X2

X軸上の2番目の点の値を取得および設定します。

X3

X軸上の3番目の点の値を取得および設定します。

X4

X軸上の4番目の点の値を取得および設定します。

GetValue

メンバーシップ関数の値を指定された引数で計算します。

クラスから継承されたメソッド CObject

Prev, Prev, Next, Next, Save, Load, Type, Compare

//+------------------------------------------------------------------+
//|                                  TrapezoidMembershipFunction.mq5 |
//|                        Copyright 2016, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#include <Math\Fuzzy\membershipfunction.mqh>
#include <Graphics\Graphic.mqh>
//--- メンバーシップ関数を作成します
CTrapezoidMembershipFunction func1(0,2,5,5);
CTrapezoidMembershipFunction func2(0,3,7,10);
CTrapezoidMembershipFunction func3(4,8,8,10);
//--- メンバーシップ関数用のラッパーを作成する
double TrapezoidMembershipFunction1(double x) { return(func1.GetValue(x)); }
double TrapezoidMembershipFunction2(double x) { return(func2.GetValue(x)); }
double TrapezoidMembershipFunction3(double x) { return(func3.GetValue(x)); }
//+------------------------------------------------------------------+
//| スクリプトプログラム開始関数                                              |
//+------------------------------------------------------------------+
void OnStart()
 {
//--- グラフィックを作成する
  CGraphic graphic;
  if(!graphic.Create(0,"TrapezoidMembershipFunction",0,30,30,780,380))
    {
     graphic.Attach(0,"TrapezoidMembershipFunction");
    }
  graphic.HistoryNameWidth(70);
  graphic.BackgroundMain("TrapezoidMembershipFunction");
  graphic.BackgroundMainSize(16);
//--- 曲線を作成する
  graphic.CurveAdd(TrapezoidMembershipFunction1,0.0,10.0,0.1,CURVE_LINES,"[0, 2, 5, 5]");
  graphic.CurveAdd(TrapezoidMembershipFunction2,0.0,10.0,0.1,CURVE_LINES,"[0, 5, 7, 10]");
  graphic.CurveAdd(TrapezoidMembershipFunction3,0.0,10.0,0.1,CURVE_LINES,"[4, 8, 8, 10]");
//--- X軸のプロパティを設定する
  graphic.XAxis().AutoScale(false);
  graphic.XAxis().Min(0.0);
  graphic.XAxis().Max(10.0);
  graphic.XAxis().DefaultStep(1.0);
//--- Y軸のプロパティを設定する
  graphic.YAxis().AutoScale(false);
  graphic.YAxis().Min(0.0);
  graphic.YAxis().Max(1.1);
  graphic.YAxis().DefaultStep(0.2);
//--- プロット
  graphic.CurvePlotAll();
  graphic.Update();
 }