라이브러리: Fuzzy - fuzzy 모델 개발을 위한 라이브러리

 

Fuzzy - fuzzy 모델 개발을 위한 라이브러리:

fuzzy 모델 개발을 위한 라이브러리인 FuzzyNet library C#으로 작성되었습니다. MQL5로 변환하는 동안 Mamdani-type 시스템을 위한 8개의 멤버십 기능과 4개의 defuzzification 방법이 라이브러리에 추가되었습니다.

Fuzzy - fuzzy 모델 개발을 위한 라이브러리

작성자: MetaQuotes

 

1. 이제 MT5에서 사용할 수 있다는 것이 좋습니다. 수학은 여전히 수학이고 MT4에서 작동한다는 것을 이해해도 되나요?

2. Matlab에서 Fuzzi를 처음 사용해봤지만 솔직히 말해서 오래 전의 일이고 수익이 보장되는 외환 거래에 적용하는 방법을 이해하지 못했습니다. 그 결과 파동, 통계 등의 방향으로 나아갔습니다.

3. 퍼지 로직을 실제로 적용하는 방법에 대한 문헌을 제안해 주시겠습니까? 트레이딩이 아니더라도요.

4. 이 주제에 관심이 있는데 사이트에 이 주제에 대한 기사가 필요합니까?

 
Alexey Volchanskiy:

1. 이제 MT5에서 사용할 수 있게 되어 기쁩니다. 아프리카에서 수학은 수학이고 MT4에서 작동한다는 것을 올바르게 이해했나요?

2. Matlab에서 Fuzzi를 처음 사용해봤지만 솔직히 말해서 오래 전 일이고 수익이 보장되는 외환 거래에 적용하는 방법을 이해하지 못했습니다. 그 결과 파동, 통계 등의 방향으로 나아갔습니다.

3. 퍼지 로직을 실제로 적용하는 방법에 대한 문헌을 제안해 주시겠습니까? 트레이딩이 아니더라도요.

4. 이 주제에 관심이 있는데 사이트에 이 주제에 대한 기사가 필요합니까?

안녕하세요.

1. MT4에 대한 적응을 할 것입니다 (조금 후에).

3. 4. 퍼지넷 사용에 대한 기사를 곧 공개할 예정입니다. 그 후 서비스 데스크에 편지를 보내 주제에 대해 더 구체적으로 논의하십시오.

 

이 주제는 주목할 가치가 있습니다. 응용 프로그램에서 주제에 대한 이해가 필요합니다. 그리고 이러한 관점에서 팁 예제는 심각하지 않습니다. 맘다니와 스게노 시스템의 차이점은 적어도 지나가면서 설명해야 합니다. 그리고 퍼지 논리의 기본 개념은 그러한 개념에 대해 처음 듣는 사람들에게 유용 할 것입니다.

아카이브 어딘가에 러시아어로 된 퍼지 논리에 관한 책이 있습니다 ( 퍼지 논리 시스템 프로그램에 대한 설명). 따라서 아카이브의 뇌졸중으로 찾을 수 없습니다. 나중에 나는 그것을 게시 할 것입니다.

행운을 빈다

 
주제에 대한 기본 지식이 있는 몇 가지 자료입니다.
파일:
FuzLog.zip  1062 kb
 

안녕하세요,

나는 퍼지, SVM, 신경과 같은 시스템을 좋아하기 때문에 주위를 둘러 보면서 그 라이브러리를 발견했습니다. 포함 된 스크립트는 이해하기에 충분하지만 컴파일시 오류가 거의 없으므로 sugeno가 포함 된 스크립트 cruise_control_sample_sugeno.mq5에서 :

//+------------------------------------------------------------------+
//|fuzzynet.mqh |
//| 저작권 2015, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
//| 메타쿼츠 언어 5(MQL5)에서 퍼지넷 라이브러리 구현하기 ||
//||
//| 퍼지넷 라이브러리의 기능은 다음과 같습니다.
//| - 맘다니 퍼지 모델 만들기|
//| - Sugeno 퍼지 모델 만들기|
//| - 일반 멤버십 기능|
//| - 삼각형 멤버십 함수|
//| - 사다리꼴 멤버십 함수|
//| - 상수 멤버십 함수|
//| - 무게 중심(COG)의 디퓨즈화 방법 |
//| - 영역 이등분선(BOA)의 디퓨즈화 방법 |
//| - 평균 최대값(MeOM)의 퍼지 제거 방법 |
//||
//| MQL5용 퍼지넷의 기능적 차이점을 발견하면
//| 및 오리지널 퍼지넷 프로젝트의 개발자에게 문의하세요.
//| 포럼의 MQL5( www.mql5.com)에서 확인하세요.|
//||
//| 의 계산 알고리즘에서 발견된 버그를 신고할 수 있습니다.
//| 퍼지넷 프로젝트 코디네이터에게 알림을 통해 퍼지넷 라이브러리 알림 ||
//+------------------------------------------------------------------+
//| 소스 라이선스|
//||
//| 이 프로그램은 무료 소프트웨어입니다. 재배포 및/또는 |
//| GNU 일반 공중 사용 허가서의 조건에 따라 다음과 같이 수정합니다.
자유 소프트웨어 재단(www.fsf.org) 에서 발행한 //| 또는 |
//| 라이선스 버전 2 또는 (사용자의 선택에 따라) 이후 버전. |
//||
//| 이 프로그램이 유용하게 사용되기를 바라는 마음으로 배포합니다.
의 묵시적 보증도 없이 //|하지만 어떠한 보증도 없습니다.
//| 상품성 또는 특정 목적에 대한 적합성. 참조
//| 자세한 내용은 GNU 일반 공개 라이선스를 참조하세요.
//||
//| GNU 일반 공중 사용 허가서 사본은 |에서 확인할 수 있습니다.
//| http://www.fsf.org/licensing/licenses                            |
//+------------------------------------------------------------------+
#property copyright "Copyright 2015, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property script_show_inputs
//+------------------------------------------------------------------+
//| 라이브러리 연결하기|
//+------------------------------------------------------------------+
#include <Math\FuzzyNet\SugenoFuzzySystem.mqh>
//--- 입력 매개변수
input double   Speed_Error;
input double   Speed_ErrorDot;
//+------------------------------------------------------------------+
//| 스크립트 프로그램 시작 함수|
//+------------------------------------------------------------------+
void OnStart()
  {
//--- 슈게노 퍼지 시스템
   CSugenoFuzzySystem *fsCruiseControl=new CSugenoFuzzySystem();
//--- 시스템에 대한 첫 번째 입력 변수를 만듭니다.
   CFuzzyVariable *fvSpeedError=new CFuzzyVariable("SpeedError",-20.0,20.0);
   fvSpeedError.Terms().Add(new CFuzzyTerm("slower",new CTriangularMembershipFunction(-35.0,-20.0,-5.0)));
   fvSpeedError.Terms().Add(new CFuzzyTerm("zero", new CTriangularMembershipFunction(-15.0, -0.0, 15.0)));
   fvSpeedError.Terms().Add(new CFuzzyTerm("faster", new CTriangularMembershipFunction(5.0, 20.0, 35.0)));
   fsCruiseControl.Input().Add(fvSpeedError);
//--- 시스템에 대한 두 번째 입력 변수를 만듭니다.
   CFuzzyVariable *fvSpeedErrorDot=new CFuzzyVariable("SpeedErrorDot",-5.0,5.0);
   fvSpeedErrorDot.Terms().Add(new CFuzzyTerm("slower", new CTriangularMembershipFunction(-9.0, -5.0, -1.0)));
   fvSpeedErrorDot.Terms().Add(new CFuzzyTerm("zero", new CTriangularMembershipFunction(-4.0, -0.0, 4.0)));
   fvSpeedErrorDot.Terms().Add(new CFuzzyTerm("faster", new CTriangularMembershipFunction(1.0, 5.0, 9.0)));
   fsCruiseControl.Input().Add(fvSpeedErrorDot);
//--- 출력 생성
   CSugenoVariable *svAccelerate=new CSugenoVariable("Accelerate");
   double coeff1[3]={0.0,0.0,0.0};
   svAccelerate.Functions().Add(fsCruiseControl.CreateSugenoFunction("zero",coeff1));
   double coeff2[3]={0.0,0.0,1.0};
   svAccelerate.Functions().Add(fsCruiseControl.CreateSugenoFunction("faster",coeff2));
   double coeff3[3]={0.0,0.0,-1.0};
   svAccelerate.Functions().Add(fsCruiseControl.CreateSugenoFunction("slower",coeff3));
   double coeff4[3]={-0.04,-0.1,0.0};
   svAccelerate.Functions().Add(fsCruiseControl.CreateSugenoFunction("func",coeff4));
   fsCruiseControl.Output().Add(svAccelerate);
//--- 크레이트 스게노 퍼지 규칙
   CSugenoFuzzyRule *rule1 = fsCruiseControl.ParseRule("if (SpeedError is slower) and (SpeedErrorDot is slower) then (Accelerate is faster)");
   CSugenoFuzzyRule *rule2 = fsCruiseControl.ParseRule("if (SpeedError is slower) and (SpeedErrorDot is zero) then (Accelerate is faster)");
   CSugenoFuzzyRule *rule3 = fsCruiseControl.ParseRule("if (SpeedError is slower) and (SpeedErrorDot is faster) then (Accelerate is zero)");
   CSugenoFuzzyRule *rule4 = fsCruiseControl.ParseRule("if (SpeedError is zero) and (SpeedErrorDot is slower) then (Accelerate is faster)");
   CSugenoFuzzyRule *rule5 = fsCruiseControl.ParseRule("if (SpeedError is zero) and (SpeedErrorDot is zero) then (Accelerate is func)");
   CSugenoFuzzyRule *rule6 = fsCruiseControl.ParseRule("if (SpeedError is zero) and (SpeedErrorDot is faster) then (Accelerate is slower)");
   CSugenoFuzzyRule *rule7 = fsCruiseControl.ParseRule("if (SpeedError is faster) and (SpeedErrorDot is slower) then (Accelerate is faster)");
   CSugenoFuzzyRule *rule8 = fsCruiseControl.ParseRule("if (SpeedError is faster) and (SpeedErrorDot is zero) then (Accelerate is slower)");
   CSugenoFuzzyRule *rule9 = fsCruiseControl.ParseRule("if (SpeedError is faster) and (SpeedErrorDot is faster) then (Accelerate is slower)");
//--- 시스템에 Sugeno 퍼지 규칙 추가
   fsCruiseControl.Rules().Add(rule1);
   fsCruiseControl.Rules().Add(rule2);
   fsCruiseControl.Rules().Add(rule3);
   fsCruiseControl.Rules().Add(rule4);
   fsCruiseControl.Rules().Add(rule5);
   fsCruiseControl.Rules().Add(rule6);
   fsCruiseControl.Rules().Add(rule7);
   fsCruiseControl.Rules().Add(rule8);
   fsCruiseControl.Rules().Add(rule9);
//--- 입력값 설정 및 결과 가져오기
   CList *in=new CList;
   CDictionary_Obj_Double *p_od_Error=new CDictionary_Obj_Double;
   CDictionary_Obj_Double *p_od_ErrorDot=new CDictionary_Obj_Double;
   p_od_Error.SetAll(fvSpeedError,Speed_Error);
   p_od_ErrorDot.SetAll(fvSpeedErrorDot,Speed_ErrorDot);
   in.Add(p_od_Error);
   in.Add(p_od_ErrorDot);
//--- 결과 가져오기
   CList *result;
   CDictionary_Obj_Double *p_od_Accelerate;
   result=fsCruiseControl.Calculate(in);
   p_od_Accelerate=result.GetNodeAtIndex(0);
   Alert("Accelerate, %: ",p_od_Accelerate.Value()*100);
   delete in;
   delete result;
   delete fsCruiseControl;
  }
//+------------------------------------------------------------------+

그리고 맘다니가있는 스크립트 :

//+------------------------------------------------------------------+
//|fuzzynet.mqh |
//| 저작권 2015, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
//| 메타쿼츠 언어 5(MQL5)에서 퍼지넷 라이브러리 구현하기 ||
//||
//| 퍼지넷 라이브러리의 기능은 다음과 같습니다.
//| - 맘다니 퍼지 모델 만들기|
//| - Sugeno 퍼지 모델 만들기|
//| - 일반 멤버십 기능|
//| - 삼각형 멤버십 함수|
//| - 사다리꼴 멤버십 함수|
//| - 상수 멤버십 함수|
//| - 무게 중심(COG)의 디퓨즈화 방법 |
//| - 영역 이등분선(BOA)의 디퓨즈화 방법 |
//| - 평균 최대값(MeOM)의 퍼지 제거 방법 |
//||
//| MQL5용 퍼지넷의 기능적 차이점을 발견하면
//| 및 오리지널 퍼지넷 프로젝트의 개발자에게 문의하세요.
//| 포럼의 MQL5( www.mql5.com)에서 확인하세요.|
//||
//| 의 계산 알고리즘에서 발견된 버그를 신고할 수 있습니다.
//| 퍼지넷 프로젝트 코디네이터에게 알림을 통해 퍼지넷 라이브러리 알림 ||
//+------------------------------------------------------------------+
//| 소스 라이선스|
//||
//| 이 프로그램은 무료 소프트웨어입니다. 재배포 및/또는 |
//| GNU 일반 공중 사용 허가서의 조건에 따라 다음과 같이 수정합니다.
자유 소프트웨어 재단(www.fsf.org) 에서 발행한 //| 또는 |
//| 라이선스 버전 2 또는 (사용자의 선택에 따라) 이후 버전. |
//||
//| 이 프로그램이 유용하게 사용되기를 바라는 마음으로 배포합니다.
의 묵시적 보증도 없이 //|하지만 어떠한 보증도 없습니다.
//| 상품성 또는 특정 목적에 대한 적합성. 참조
//| 자세한 내용은 GNU 일반 공개 라이선스를 참조하세요.
//||
//| GNU 일반 공중 사용 허가서 사본은 |에서 확인할 수 있습니다.
//| http://www.fsf.org/licensing/licenses&nbsp;                           |
//+------------------------------------------------------------------+
#property copyright "Copyright 2015, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property script_show_inputs
//+------------------------------------------------------------------+
//| 라이브러리 연결하기|
//+------------------------------------------------------------------+
#include <Math\FuzzyNet\MamdaniFuzzySystem.mqh>
//--- 입력 매개변수
input double   Service;
input double   Food;
//+------------------------------------------------------------------+
//| 스크립트 프로그램 시작 함수|
//+------------------------------------------------------------------+
void OnStart()
  {
//--- 맘다니 퍼지 시스템
   CMamdaniFuzzySystem *fsTips=new CMamdaniFuzzySystem();
//--- 시스템에 대한 첫 번째 입력 변수를 만듭니다.
   CFuzzyVariable *fvService=new CFuzzyVariable("service",0.0,10.0);
   fvService.Terms().Add(new CFuzzyTerm("poor", new CTriangularMembershipFunction(-5.0, 0.0, 5.0)));
   fvService.Terms().Add(new CFuzzyTerm("good", new CTriangularMembershipFunction(0.0, 5.0, 10.0)));
   fvService.Terms().Add(new CFuzzyTerm("excellent", new CTriangularMembershipFunction(5.0, 10.0, 15.0)));
   fsTips.Input().Add(fvService);
//--- 시스템에 대한 두 번째 입력 변수를 만듭니다.
   CFuzzyVariable *fvFood=new CFuzzyVariable("food",0.0,10.0);
   fvFood.Terms().Add(new CFuzzyTerm("rancid", new CTrapezoidMembershipFunction(0.0, 0.0, 1.0, 3.0)));
   fvFood.Terms().Add(new CFuzzyTerm("delicious", new CTrapezoidMembershipFunction(7.0, 9.0, 10.0, 10.0)));
   fsTips.Input().Add(fvFood);
//--- 출력 생성
   CFuzzyVariable *fvTips=new CFuzzyVariable("tips",0.0,30.0);
   fvTips.Terms().Add(new CFuzzyTerm("cheap", new CTriangularMembershipFunction(0.0, 5.0, 10.0)));
   fvTips.Terms().Add(new CFuzzyTerm("average", new CTriangularMembershipFunction(10.0, 15.0, 20.0)));
   fvTips.Terms().Add(new CFuzzyTerm("generous", new CTriangularMembershipFunction(20.0, 25.0, 30.0)));
   fsTips.Output().Add(fvTips);
//--- 3개의 맘다니 퍼지 규칙 만들기
   CMamdaniFuzzyRule *rule1 = fsTips.ParseRule("if (service is poor )  or (food is rancid) then tips is cheap");
   CMamdaniFuzzyRule *rule2 = fsTips.ParseRule("if ((service is good)) then tips is average");
   CMamdaniFuzzyRule *rule3 = fsTips.ParseRule("if (service is excellent) or (food is delicious) then (tips is generous)");
//--- 시스템에 3개의 맘다니 퍼지 규칙을 추가합니다.
   fsTips.Rules().Add(rule1);
   fsTips.Rules().Add(rule2);
   fsTips.Rules().Add(rule3);
//--- 입력 값 설정
   CList *in=new CList;
   CDictionary_Obj_Double *p_od_Service=new CDictionary_Obj_Double;
   CDictionary_Obj_Double *p_od_Food=new CDictionary_Obj_Double;
   p_od_Service.SetAll(fvService, Service);
   p_od_Food.SetAll(fvFood, Food);
   in.Add(p_od_Service);
   in.Add(p_od_Food);
//--- 결과 가져오기
   CList *result;
   CDictionary_Obj_Double *p_od_Tips;
   result=fsTips.Calculate(in);
   p_od_Tips=result.GetNodeAtIndex(0);
   Alert("Tips, %: ",p_od_Tips.Value());
   delete in;
   delete result;
   delete fsTips;
  }
//+------------------------------------------------------------------+

공유해 주셔서 감사합니다!

 
입력 변수가 02개 이상인 만다니 모델을 만들 수 있나요? 세 번째 입력 변수를 입력할 때 오류가 발생합니다.
 

리브를 지지하는 분들께, 또는 누구든 plz를 도와주세요.... :) 계산 속도를 높이고 싶습니다. 퍼지 논리 클래스의 객체를 생성하고 결과를 계산하고 삭제하는 예제 첨부 스크립트에서. 객체를 한 번만 생성 할 수 있고 Calculate ()에서 새 값만 전달하고 이미 구성된 퍼지 논리를 사용하여 결과를 가져 오도록하고 싶습니다.

다음은 올바르게 작동하는 원본 예제입니다:

//+------------------------------------------------------------------+
//|팁 샘플.mq5 |
//| 저작권 2017, MetaQuotes Software Corp.
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#include <Math\Fuzzy\MamdaniFuzzySystem.mqh>
//--- 입력 매개변수
input double   Service;
input double   Food;

//+------------------------------------------------------------------+
//| 전문가 초기화 기능|
//+------------------------------------------------------------------+
int OnInit()
  {
//---
  
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| 전문가 초기화 기능|
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| 전문가 틱 기능|
//+------------------------------------------------------------------+
void OnTick()
  {
//---
  //--- 맘다니 퍼지 시스템 
   CMamdaniFuzzySystem *fsTips=new CMamdaniFuzzySystem();
//--- 시스템에 대한 첫 번째 입력 변수를 만듭니다.
   CFuzzyVariable *fvService=new CFuzzyVariable("service",0.0,10.0);
   fvService.Terms().Add(new CFuzzyTerm("poor", new CTriangularMembershipFunction(-5.0, 0.0, 5.0)));
   fvService.Terms().Add(new CFuzzyTerm("good", new CTriangularMembershipFunction(0.0, 5.0, 10.0)));
   fvService.Terms().Add(new CFuzzyTerm("excellent", new CTriangularMembershipFunction(5.0, 10.0, 15.0)));
   fsTips.Input().Add(fvService);
//--- 시스템에 대한 두 번째 입력 변수를 만듭니다.
   CFuzzyVariable *fvFood=new CFuzzyVariable("food",0.0,10.0);
   fvFood.Terms().Add(new CFuzzyTerm("rancid", new CTrapezoidMembershipFunction(0.0, 0.0, 1.0, 3.0)));
   fvFood.Terms().Add(new CFuzzyTerm("delicious", new CTrapezoidMembershipFunction(7.0, 9.0, 10.0, 10.0)));
   fsTips.Input().Add(fvFood);
//--- 출력 생성
   CFuzzyVariable *fvTips=new CFuzzyVariable("tips",0.0,30.0);
   fvTips.Terms().Add(new CFuzzyTerm("cheap", new CTriangularMembershipFunction(0.0, 5.0, 10.0)));
   fvTips.Terms().Add(new CFuzzyTerm("average", new CTriangularMembershipFunction(10.0, 15.0, 20.0)));
   fvTips.Terms().Add(new CFuzzyTerm("generous", new CTriangularMembershipFunction(20.0, 25.0, 30.0)));
   fsTips.Output().Add(fvTips);
//--- 3개의 맘다니 퍼지 규칙 만들기
   CMamdaniFuzzyRule *rule1 = fsTips.ParseRule("if (service is poor )  or (food is rancid) then tips is cheap");
   CMamdaniFuzzyRule *rule2 = fsTips.ParseRule("if ((service is good)) then tips is average");
   CMamdaniFuzzyRule *rule3 = fsTips.ParseRule("if (service is excellent) or (food is delicious) then (tips is generous)");
//--- 시스템에 3개의 맘다니 퍼지 규칙을 추가합니다.
   fsTips.Rules().Add(rule1);
   fsTips.Rules().Add(rule2);
   fsTips.Rules().Add(rule3);
//--- 입력 값 설정
   CList *in=new CList;
   CDictionary_Obj_Double *p_od_Service=new CDictionary_Obj_Double;
   CDictionary_Obj_Double *p_od_Food=new CDictionary_Obj_Double;
   p_od_Service.SetAll(fvService, Service);
   p_od_Food.SetAll(fvFood, Food);
   in.Add(p_od_Service);
   in.Add(p_od_Food);
//--- 결과 가져오기
   CList *result;
   CDictionary_Obj_Double *p_od_Tips;
   result=fsTips.Calculate(in);
   p_od_Tips=result.GetNodeAtIndex(0);
   Print("Tips, %: ",p_od_Tips.Value());
   delete in;
   delete result;
   delete fsTips;
  }
//+------------------------------------------------------------------+

다음은 오류가 발생하는 제 예제입니다:

2017.09.07 14:28:56.949 Core 1  2017.07.03 00:00:00   Input values count is incorrect.
2017.09.07 14:28:56.949 Core 1  2017.07.03 00:00:00   invalid pointer access in 'MamdaniFuzzySystem.mqh' (172,42)

코드 자체입니다:

//+------------------------------------------------------------------+
//|TipsSample.mq5 |
//| 저작권 2017, MetaQuotes Software Corp.
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"

#include <Math\Fuzzy\MamdaniFuzzySystem.mqh>

input double   Service;
input double   Food;
//+------------------------------------------------------------------+
//| 전문가 초기화 기능|
//+------------------------------------------------------------------+
CMamdaniFuzzySystem *fsTips=new CMamdaniFuzzySystem();
CFuzzyVariable *fvService=new CFuzzyVariable("service",0.0,10.0);
CFuzzyVariable *fvFood=new CFuzzyVariable("food",0.0,10.0);
CFuzzyVariable *fvTips=new CFuzzyVariable("tips",0.0,30.0);
CMamdaniFuzzyRule *rule1, *rule2, *rule3;

CList *in=new CList;
CDictionary_Obj_Double *p_od_Service=new CDictionary_Obj_Double;
CDictionary_Obj_Double *p_od_Food=new CDictionary_Obj_Double;

CList *result;
CDictionary_Obj_Double *p_od_Tips;
   
int OnInit()
  {
//---
   
   fvService.Terms().Add(new CFuzzyTerm("poor", new CTriangularMembershipFunction(-5.0, 0.0, 5.0)));
   fvService.Terms().Add(new CFuzzyTerm("good", new CTriangularMembershipFunction(0.0, 5.0, 10.0)));
   fvService.Terms().Add(new CFuzzyTerm("excellent", new CTriangularMembershipFunction(5.0, 10.0, 15.0)));
   fsTips.Input().Add(fvService);
//--- 시스템에 대한 두 번째 입력 변수를 만듭니다.
   
   fvFood.Terms().Add(new CFuzzyTerm("rancid", new CTrapezoidMembershipFunction(0.0, 0.0, 1.0, 3.0)));
   fvFood.Terms().Add(new CFuzzyTerm("delicious", new CTrapezoidMembershipFunction(7.0, 9.0, 10.0, 10.0)));
   fsTips.Input().Add(fvFood);
//--- 출력 생성
  
   fvTips.Terms().Add(new CFuzzyTerm("cheap", new CTriangularMembershipFunction(0.0, 5.0, 10.0)));
   fvTips.Terms().Add(new CFuzzyTerm("average", new CTriangularMembershipFunction(10.0, 15.0, 20.0)));
   fvTips.Terms().Add(new CFuzzyTerm("generous", new CTriangularMembershipFunction(20.0, 25.0, 30.0)));
   fsTips.Output().Add(fvTips);
//--- 3개의 맘다니 퍼지 규칙 만들기
   rule1 = fsTips.ParseRule("if (service is poor )  or (food is rancid) then tips is cheap");
   rule2 = fsTips.ParseRule("if ((service is good)) then tips is average");
   rule3 = fsTips.ParseRule("if (service is excellent) or (food is delicious) then (tips is generous)");
   
   fsTips.Rules().Add(rule1);
   fsTips.Rules().Add(rule2);
   fsTips.Rules().Add(rule3);
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| 전문가 초기화 기능|
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| 전문가 틱 기능|
//+------------------------------------------------------------------+
void OnTick()
  { 
   int ir; 
   for(ir=1; ir<10; ir++)
   { 
   p_od_Service.SetAll(fvService, ir);
   p_od_Food.SetAll(fvFood, ir);
   Print(CheckPointer(in));
   in.Clear();
   in.Add(p_od_Service);
   in.Add(p_od_Food);
//--- 결과 가져오기
   
   result=fsTips.Calculate(in);
   Print("Error");
   p_od_Tips=result.GetNodeAtIndex(0);
   Print("Tips, %: ",p_od_Tips.Value());
   }
  }
//+------------------------------------------------------------------+

일반적으로 라이브러리는 객체를 생성한 다음 각각의 새 막대에서 결과를 가져올 수 있도록 설계되어 있습니까? 매번 로직을 다시 만드는 것은 느리고 경제적이지 않기 때문입니다.

 

라이브러리 버전이 수정되어 이제 퍼지 논리 객체를 한 번만 생성한 다음 Calculate() 만 호출할 수 있습니다.

예제를 확인하세요:

//+------------------------------------------------------------------+
//|TipsSample.mq5 |
//| 저작권 2017, MetaQuotes Software Corp.
//|https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"

#include <Math\Fuzzy\MamdaniFuzzySystem.mqh>

input double   Service;
input double   Food;
//+------------------------------------------------------------------+
//| 전문가 초기화 기능|
//+------------------------------------------------------------------+
CMamdaniFuzzySystem *FSTips=new CMamdaniFuzzySystem();
CFuzzyVariable *FVService=new CFuzzyVariable("service",0.0,10.0);
CFuzzyVariable *FVFood=new CFuzzyVariable("food",0.0,10.0);
CFuzzyVariable *FVTips=new CFuzzyVariable("tips",0.0,30.0);
CMamdaniFuzzyRule *Rule1,*Rule2,*Rule3;

CList *In=new CList;
CDictionary_Obj_Double *Dic_Service=new CDictionary_Obj_Double;
CDictionary_Obj_Double *Dic_Food=new CDictionary_Obj_Double;
CDictionary_Obj_Double *Dic_Tips;
//+------------------------------------------------------------------+
//||
//+------------------------------------------------------------------+
int OnInit()
  {
   In.FreeMode(false);
//--- 시스템에 대한 첫 번째 입력 변수를 만듭니다.

   FVService.Terms().Add(new CFuzzyTerm("poor", new CTriangularMembershipFunction(-5.0, 0.0, 5.0)));
   FVService.Terms().Add(new CFuzzyTerm("good", new CTriangularMembershipFunction(0.0, 5.0, 10.0)));
   FVService.Terms().Add(new CFuzzyTerm("excellent", new CTriangularMembershipFunction(5.0, 10.0, 15.0)));
   FSTips.Input().Add(FVService);
//--- 시스템에 대한 두 번째 입력 변수를 만듭니다.

   FVFood.Terms().Add(new CFuzzyTerm("rancid", new CTrapezoidMembershipFunction(0.0, 0.0, 1.0, 3.0)));
   FVFood.Terms().Add(new CFuzzyTerm("delicious", new CTrapezoidMembershipFunction(7.0, 9.0, 10.0, 10.0)));
   FSTips.Input().Add(FVFood);
//--- 출력 생성

   FVTips.Terms().Add(new CFuzzyTerm("cheap", new CTriangularMembershipFunction(0.0, 5.0, 10.0)));
   FVTips.Terms().Add(new CFuzzyTerm("average", new CTriangularMembershipFunction(10.0, 15.0, 20.0)));
   FVTips.Terms().Add(new CFuzzyTerm("generous", new CTriangularMembershipFunction(20.0, 25.0, 30.0)));
   FSTips.Output().Add(FVTips);
//--- 3개의 맘다니 퍼지 규칙 만들기
   Rule1 = FSTips.ParseRule("if (service is poor )  or (food is rancid) then tips is cheap");
   Rule2 = FSTips.ParseRule("if ((service is good)) then tips is average");
   Rule3 = FSTips.ParseRule("if (service is excellent) or (food is delicious) then (tips is generous)");

   FSTips.Rules().Add(Rule1);
   FSTips.Rules().Add(Rule2);
   FSTips.Rules().Add(Rule3);
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| 전문가 초기화 기능|
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//--- 퍼지 시스템 삭제
   In.FreeMode(true);  
   delete In;  
   delete FSTips;  
  }
//+------------------------------------------------------------------+
//| 전문가 틱 기능|
//+------------------------------------------------------------------+
void OnTick()
  {
   for(int ir=1; ir<10; ir++)
     {
      Dic_Service.SetAll(FVService,ir);
      Dic_Food.SetAll(FVFood,ir);
      In.Clear();
      In.Add(Dic_Service);
      In.Add(Dic_Food);
      //--- 결과 가져오기
      CList *result=FSTips.Calculate(In);
      Dic_Tips=result.GetNodeAtIndex(0);
      Print("Tips, %: ",Dic_Tips.Value());
      delete result;
     }
  }
//+------------------------------------------------------------------+
파일:
Fuzzy.zip  33 kb
 

h

2342 빌드를 위해 메타 트레이더를 업데이트했을 때

퍼지 논리 라이브러리가있는 모든 샘플

반환 오류 "포인터의 잘못된 캐스팅"MQL5 \ 포함 \ 수학 \에서 \ 수학 \. 퍼지 \ 규칙 파서 712 줄

버그 수정에 도움을주세요

많은 감사