⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 migrationfc.h

📁 人工智能中模糊逻辑算法 FuzzyLib 2.0 is a comprehensive C++ Fuzzy Logic library for constructing fuzzy logic sy
💻 H
字号:
//---------------------------------------------------------------------------
#ifndef MigrationFCH
#define MigrationFCH
//---------------------------------------------------------------------------

#include "TFuzzySet.h"
#include "TFuzzyRule.h"
#include "TFuzzyController.h"
#include "TFuzzySystem.h"

//#include "Fragment.h"
//---------------------------------------------------------------------------


#define MAX_DEMANDING_NODES		256
#define MAX_CANDIDATE_NODES		 16
//
// multi-satge controller
//
//      RemoteDemand-----|
//                       |-----RemoteAttraction-----|
//      LocalDemand------|                          |
//                                                  |
//                                                  |-----Migration-----
//      LocalLoad--------|                          |
//                       |------LocalRepulsion------|
//      RemoteLoad-------|
//
//
class TMigrationFC
{
  public:
	TFuzzyController* 	C1; // Demand-Based Remote Attraction Force
	TFuzzyController* 	C2; // Load-Based   Local  Repulsion  Force
	TFuzzyController* 	C3; // Attraction- and Repulsion-Based Migration Force

  private:
	// inputs
    // average info from fragment's statistics in last T (+ forcast)
    double local_demand;
    double remote_demands[MAX_DEMANDING_NODES];
    double local_load;
    double remote_loads[MAX_CANDIDATE_NODES];

  public:
	// outputs
    int    demanding_nodes_ids[MAX_DEMANDING_NODES];
    double remote_attractions[MAX_DEMANDING_NODES];
    TFuzzySet* remote_attractionsets[MAX_DEMANDING_NODES];
    int    candidate_nodes_ids[MAX_CANDIDATE_NODES];
    double local_repulsions[MAX_CANDIDATE_NODES];
    TFuzzySet* local_repulsionsets[MAX_CANDIDATE_NODES];
    double migrations[MAX_CANDIDATE_NODES];
    TFuzzySet* migrationsets[MAX_CANDIDATE_NODES];
    int    migration_node_id;

  public:
	TMigrationFC(/*TFragment* fragment*/);
	~TMigrationFC();


    // fill demanding_nodes_ids[MAX_DEMANDING_NODES]
    void IdentifyDemandingNodes();  // using Fragment->DemandHistoryTable[i]


    // fill local_demand
    void GetLocalDemand();  // using Fragment->DemandHistoryTable[i]

    // for each demanding node in demanding_nodes_ids[MAX_DEMANDING_NODES]
    // fill remote_loads[index]
    void GetRemoteDemand(int index);  // using Fragment->DemandHistoryTable[i]

    // for each demanding node, run C1 to get its attraction force and
	// fill remote_attractions[MAX_DEMANDING_NODES] with the results
    int RunC1(int index, double input1, double input2,
    int AggregationMethod, int CorrelationMethod, int AlphaCutType, int CompositionMethod, int DefuzzificationMethod);


	// fill (partially) candidate_nodes_ids[MAX_CANDIDATE_NODES] with ids of
    // first nodes with attraction force > MEDIUM, the rest fill with INVALID_ID
	void ChooseCandidates();



    // fill local_load
    void GetLocalLoad();          //using Fragment->Node->NodeMonitor->Others[i]

    // for each chosen candidate node
    // fill remote_loads[index]
    void GetRemoteLoad(int index);//using Fragment->Node->NodeMonitor->Others[i]


    // for each chosen candidate node
    // run C2 to get the local_repulsion force relative to its load
	// fill local_repulsions[MAX_CANDIDATE_NODES] with the results
    int RunC2(int index, double input1, double input2,
    int AggregationMethod, int CorrelationMethod, int AlphaCutType, int CompositionMethod, int DefuzzificationMethod);

    // for each chosen candidate node, run C3 to get the migration force
	// fill migrations[MAX_CANDIDATE_NODES] with the results
    int RunC3(int index, double input1, double input2,
    int AggregationMethod, int CorrelationMethod, int AlphaCutType, int CompositionMethod, int DefuzzificationMethod);


	// fill migration_node_id with the id of the node with the highest
    // migrations[MAX_CANDIDATE_NODES] to migrate to.
    // or fill migration_node_id with INVALID_ID for no migration
	void SelectCandidate();

    // returns the migration_node_id, if any
	int Run();

    // re-create rules from current values in the RulesEditor form
    void UpdateRules(TFuzzyController* C);

};

//---------------------------------------------------------------------------
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -