コード例 #1
0
 public DecisionMatrixDisplayForm(DecisionMatrix decisionMatrix, Standardize standardize)
     : this()
 {
     _decisionMatrix = decisionMatrix;
     _standardize = standardize;
     Init();
 }
コード例 #2
0
 public DecisionMatrixForm(DecisionMatrix decisionMatrix)
 {
     InitializeComponent();
     //将决策矩阵中的数据转化为专家列表
     _decisionMatrix = decisionMatrix;
     _experts = decisionMatrix.ToExpertList();
     dataGrid.DataSource = _experts;
 }
コード例 #3
0
ファイル: Standardize.cs プロジェクト: uc12706501/ExpertCore
        public static DecisionMatrix ApprovedNormalize(DecisionMatrix toBeStandardize)
        {
            //归一化之后的矩阵
            DecisionMatrix standardized = new DecisionMatrix(toBeStandardize.Level, toBeStandardize.X);
            //将原始数据头填充到新数据中,所有操作都不改变原来的判断矩阵
            standardized.InsertFromMatrix(toBeStandardize);

            var factors = toBeStandardize.Level.Factors;
            int m = standardized.X;
            //标准化按照指标值,逐列进行的
            for (int j = 0; j < factors.Count; j++)
            {
                //每一列的最大值和最小值
                double columnMax = toBeStandardize.GetColumnMaxValue(j);
                double columnMin = toBeStandardize.GetColumnMinValue(j);

                //1. 如果是逆向指标,就执行
                if (factors[j].Direction == FactorDirection.Negative)
                {
                    for (int i = 0; i < toBeStandardize.X; i++)
                    {
                        standardized[i, j] = columnMax - toBeStandardize[i, j] + columnMin;
                    }
                }

                //2. 如果指标值包含负数,就执行
                bool containsNegative = false;
                for (int i = 0; i < standardized.X; i++)
                {
                    if (standardized[i, j] < 0)
                    {
                        containsNegative = true;
                        break;
                    }
                }
                //如果包含负数
                if (containsNegative)
                {
                    for (int i = 0; i < standardized.X; i++)
                    {
                        standardized[i, j] = standardized[i, j] - columnMin;
                    }
                }

                //3. 执行标准的归一化操作
                //考虑到如果m太大,会造成标准化之太小,所以统一都乘以m
                double columnSum = standardized.GetColumnSum(j);
                for (int i = 0; i < standardized.X; i++)
                {
                    standardized[i, j] = (standardized[i, j] / columnSum) * m;
                }
            }

            return standardized;
        }
コード例 #4
0
ファイル: MainWindow.cs プロジェクト: uc12706501/ExpertCore
        //构造函数
        public MainWindow()
        {
            InitializeComponent();
            //默认不使用改进的方式
            isApproved = false;
            judgeMatrixSwitchBtn.Text = "常规构造";

            //初始化层次结构模型
            InitModel();
            //初始化决策矩阵
            _decisionMatrix = new DecisionMatrix(_ahpModel.Levels[2], 0);
            //初始化判断矩阵
            InitJudgeMatrixPairs();
            //更新模型中的判断矩阵
            UpdateJudgeMatrix();
        }
コード例 #5
0
ファイル: Tester.cs プロジェクト: uc12706501/ExpertCore
        public static void AhpModelSample()
        {
            //创建第一层
            Level topLevel = new Level(null,
                new List<Factor> { new Factor("Z") },
                null,
                null);
            //实例化一个AhpModel,并设置第一层对象
            AhpModel ahpModel = new AhpModel(topLevel);

            //插入一个层次,直到用户表示不再增减
            while (true)
            {
                //默认插入第二层
                InsertLevel(ahpModel);

                //然后询问是否继续插入其他层次
                var ifAddLevel = DataHelper.ReadBool("是否插入一个层次");
                if (!ifAddLevel)
                    break;
            }

            //打印层次结构模型中的相关信息
            ahpModel.DisplayModelInfo();

            //选择用以生成决策矩阵的层次
            //读入的数要-1
            int selectLevel = DataHelper.ReadValus<int>(string.Format("请从第1层到第{0}层中选择一层来创建决策矩阵", ahpModel.Levels.Count))[0] - 1;
            //选择待评价的元素
            int elementCount = DataHelper.ReadValus<int>("请问一共有多少待评价元素?")[0];
            //建立空的决策矩阵
            DecisionMatrix decisionMatrix = new DecisionMatrix(ahpModel.Levels[selectLevel], elementCount, "决策矩阵");
            //读入决策矩阵数据
            decisionMatrix.InsertMatrix(DataHelper.ConsoleArrayInput);
            //打印决策矩阵
            decisionMatrix.DisplayMatrix(DataHelper.ConsoloOutput);
            //使用改进的标准化方法处理决策矩阵
            Console.WriteLine("使用改进的归一化法对决策矩阵进行标准化法");
            ManipulateDecisionMatrix(decisionMatrix, Standardizer.ApprovedNormalize);
            //使用常规归一化法处理决策矩阵
            Console.WriteLine("使用常规的归一化法对决策矩阵进行标准化");
            ManipulateDecisionMatrix(decisionMatrix, Standardizer.Normalize);
        }
コード例 #6
0
ファイル: Standardize.cs プロジェクト: uc12706501/ExpertCore
        public static DecisionMatrix Normalize(DecisionMatrix toBeStandardize)
        {
            //归一化之后的矩阵
            DecisionMatrix standardized = new DecisionMatrix(toBeStandardize.Level, toBeStandardize.X);
            //将原始数据头填充到新数据中,所有操作都不改变原来的判断矩阵
            standardized.InsertFromMatrix(toBeStandardize);

            var factors = toBeStandardize.Level.Factors;
            for (int j = 0; j < factors.Count; j++)
            {
                //执行标准的归一化操作
                //获取一列的和
                double columnSum = standardized.GetColumnSum(j);
                for (int i = 0; i < standardized.X; i++)
                {
                    standardized[i, j] = (standardized[i, j] / columnSum);
                }
            }
            return standardized;
        }
コード例 #7
0
        //将ExpertList的数据导入到决策矩阵中
        public static DecisionMatrix SetDecisionMatrix(this DecisionMatrix decisionMatrix, IList<ExpertModel> expertModels)
        {
            DecisionMatrix newDecisionMatrix = new DecisionMatrix(decisionMatrix.Level, expertModels.Count);

            for (int i = 0; i < expertModels.Count; i++)
            {
                newDecisionMatrix[i, 0] = expertModels[i].B1;
                newDecisionMatrix[i, 1] = expertModels[i].B2;
                newDecisionMatrix[i, 2] = expertModels[i].B3;
                newDecisionMatrix[i, 3] = expertModels[i].B4;
                newDecisionMatrix[i, 4] = expertModels[i].B5;
                newDecisionMatrix[i, 5] = expertModels[i].B6;
                newDecisionMatrix[i, 6] = expertModels[i].B7;
                newDecisionMatrix[i, 7] = expertModels[i].B8;
                newDecisionMatrix[i, 8] = expertModels[i].B9;
                newDecisionMatrix[i, 9] = expertModels[i].B10;
                newDecisionMatrix[i, 10] = expertModels[i].B11;
                newDecisionMatrix[i, 11] = expertModels[i].B12;
                newDecisionMatrix[i, 12] = expertModels[i].B13;
                newDecisionMatrix[i, 13] = expertModels[i].B14;
            }

            return newDecisionMatrix;
        }
コード例 #8
0
ファイル: MainWindow.cs プロジェクト: uc12706501/ExpertCore
 //响应决策矩阵的修改
 private void OnDcsMatrixUpdate(DecisionMatrix decisionMatrix)
 {
     _decisionMatrix = decisionMatrix;
 }
コード例 #9
0
ファイル: Tester.cs プロジェクト: uc12706501/ExpertCore
 //处理决策矩阵,打印出决策矩阵的标准化值,以及最终的决策向量
 public static void ManipulateDecisionMatrix(DecisionMatrix decisionMatrix, Standardize standardize)
 {
     //获得并打印标准化矩阵
     var standardized = decisionMatrix.GetStandardized(standardize);
     standardized.Name = "决策矩阵的标准化矩阵";
     standardized.DisplayMatrix(DataHelper.ConsoloOutput);
     //获得决策向量
     var decisionVect = decisionMatrix.GetDecisionVect(standardize);
     //打印决策结果
     decisionVect.DisplayMatrix(DataHelper.ConsoloOutput);
 }
コード例 #10
0
 //保存按钮
 //只能在这里修改决策矩阵!!
 private void saveBtn_Click(object sender, EventArgs e)
 {
     _decisionMatrix = _decisionMatrix.SetDecisionMatrix(_experts);
     DecisionMatrixSave(_decisionMatrix);
     Close();
 }