Ejemplo n.º 1
0
        public List <int> GetRanksREGIME()
        {
            REGIMEDecisionProvider    provider = new REGIMEDecisionProvider();
            DecisionConfigurationBase config   = new DecisionConfigurationBase
            {
                CriteriaRanks = _criterias.GetNormalizedWeight()
            };

            provider.Init(config);

            AlternativesBase alternatives = GetAlternativesBases(MethodsEnum.REGIME);

            List <int> result = provider.Solve(alternatives).Ranks;

            return(result);
        }
Ejemplo n.º 2
0
        public void TestREGIMEDecision()
        {
            REGIMEDecisionProvider    provider      = new REGIMEDecisionProvider();
            DecisionConfigurationBase configuration = new DecisionConfigurationBase
            {
                CriteriaRanks = new List <double> {
                    0.1, 0.175, 0.25, 0.35, 0.125
                }
            };

            provider.Init(configuration);

            var alternatives = new AlternativesBase
            {
                Criterias = new List <ICriteria>
                {
                    new CriteriaBase {
                        CriteriaDirection = CriteriaDirectionType.Minimization
                    },                                                                       //cost
                    new QualitativeCriteriaBase {
                        CriteriaDirection = CriteriaDirectionType.Maximization
                    },                                                                                   //strength
                    new QualitativeCriteriaBase {
                        CriteriaDirection = CriteriaDirectionType.Maximization
                    },                                                                                    //national reputation
                    new CriteriaBase {
                        CriteriaDirection = CriteriaDirectionType.Maximization
                    },                                                                        // capacity
                    new QualitativeCriteriaBase {
                        CriteriaDirection = CriteriaDirectionType.Minimization
                    },                                                                                   // work hardness
                },
                Alternatives = new List <AlternativeBase>
                {
                    new AlternativeBase
                    {
                        Values = new List <IAlternativeValue>
                        {
                            new AlternativeValueBase(3),
                            new QualitativeAlternativeValue(QualitativeCriteriaEnum.Medium, new QualitativeCriteriaBase()),
                            new QualitativeAlternativeValue(QualitativeCriteriaEnum.VeryGood, new QualitativeCriteriaBase()),
                            new AlternativeValueBase(24000),
                            new QualitativeAlternativeValue(QualitativeCriteriaEnum.FairlyWeak, new QualitativeCriteriaBase())
                        }
                    },
                    new AlternativeBase
                    {
                        Values = new List <IAlternativeValue>
                        {
                            new AlternativeValueBase(1.2),
                            new QualitativeAlternativeValue(QualitativeCriteriaEnum.Good, new QualitativeCriteriaBase()),
                            new QualitativeAlternativeValue(QualitativeCriteriaEnum.Medium, new QualitativeCriteriaBase()),
                            new AlternativeValueBase(25000),
                            new QualitativeAlternativeValue(QualitativeCriteriaEnum.Medium, new QualitativeCriteriaBase())
                        }
                    },
                    new AlternativeBase
                    {
                        Values = new List <IAlternativeValue>
                        {
                            new AlternativeValueBase(1.5),
                            new QualitativeAlternativeValue(QualitativeCriteriaEnum.VeryGood, new QualitativeCriteriaBase()),
                            new QualitativeAlternativeValue(QualitativeCriteriaEnum.Poor, new QualitativeCriteriaBase()),
                            new AlternativeValueBase(32000),
                            new QualitativeAlternativeValue(QualitativeCriteriaEnum.Excellent, new QualitativeCriteriaBase())
                        }
                    }
                }
            };
            var result = provider.Solve(alternatives);

            Assert.IsTrue(result.Ranks.Count == 3);
            Assert.IsTrue(result.Ranks[0] == 3);
            Assert.IsTrue(result.Ranks[1] == 2);
            Assert.IsTrue(result.Ranks[2] == 1);
        }
Ejemplo n.º 3
0
        public List <DataGridViewRow> GetSolutionsAsDataGrid()
        {
            REGIMEDecisionProvider    resultProvider = new REGIMEDecisionProvider();
            DecisionConfigurationBase resultBase     = new DecisionConfigurationBase
            {
                CriteriaRanks = GetResultRanks()
            };
            AlternativesBase resultAlternatives = PrepareResultAlternativesBase();

            List <DataGridViewRow> result = new List <DataGridViewRow>();

            if (_methods[MethodsEnum.SMART] == true)
            {
                DataGridViewRow         NewRow    = new DataGridViewRow();
                DataGridViewTextBoxCell TitleCell = new DataGridViewTextBoxCell();
                TitleCell.Value = "SMART";
                NewRow.Cells.Add(TitleCell);

                List <int> localRanks = GetRanksSMART();

                for (int i = 0; i < localRanks.Count; ++i)
                {
                    resultAlternatives.Alternatives[i].Values.Add(new AlternativeValueBase(localRanks[i]));
                }

                foreach (int value in localRanks)
                {
                    DataGridViewTextBoxCell newCell = new DataGridViewTextBoxCell();
                    newCell.Value = value.ToString();
                    NewRow.Cells.Add(newCell);
                }
                result.Add(NewRow);
            }
            if (_methods[MethodsEnum.REGIME] == true)
            {
                DataGridViewRow         NewRow    = new DataGridViewRow();
                DataGridViewTextBoxCell TitleCell = new DataGridViewTextBoxCell();
                TitleCell.Value = "REGIME";
                NewRow.Cells.Add(TitleCell);

                List <int> localRanks = GetRanksREGIME();

                for (int i = 0; i < localRanks.Count; ++i)
                {
                    resultAlternatives.Alternatives[i].Values.Add(new AlternativeValueBase(localRanks[i]));
                }

                foreach (int value in localRanks)
                {
                    DataGridViewTextBoxCell newCell = new DataGridViewTextBoxCell();
                    newCell.Value = value.ToString();
                    NewRow.Cells.Add(newCell);
                }
                result.Add(NewRow);
            }
            if (_methods[MethodsEnum.PROMETHEE] == true)
            {
                DataGridViewRow         NewRow    = new DataGridViewRow();
                DataGridViewTextBoxCell TitleCell = new DataGridViewTextBoxCell();
                TitleCell.Value = "PROMETHEE";
                NewRow.Cells.Add(TitleCell);

                List <int> localRanks = GetRanksPROMETHEE();

                for (int i = 0; i < localRanks.Count; ++i)
                {
                    resultAlternatives.Alternatives[i].Values.Add(new AlternativeValueBase(localRanks[i]));
                }

                foreach (int value in localRanks)
                {
                    DataGridViewTextBoxCell newCell = new DataGridViewTextBoxCell();
                    newCell.Value = value.ToString();
                    NewRow.Cells.Add(newCell);
                }
                result.Add(NewRow);
            }
            if (_methods[MethodsEnum.WASPAS] == true)
            {
                DataGridViewRow         NewRow    = new DataGridViewRow();
                DataGridViewTextBoxCell TitleCell = new DataGridViewTextBoxCell();
                TitleCell.Value = "WASPAS";
                NewRow.Cells.Add(TitleCell);

                List <int> localRanks = GetRanksWASPAS();

                for (int i = 0; i < localRanks.Count; ++i)
                {
                    resultAlternatives.Alternatives[i].Values.Add(new AlternativeValueBase(localRanks[i]));
                }

                foreach (int value in localRanks)
                {
                    DataGridViewTextBoxCell newCell = new DataGridViewTextBoxCell();
                    newCell.Value = value.ToString();
                    NewRow.Cells.Add(newCell);
                }
                result.Add(NewRow);
            }
            if (_methods[MethodsEnum.TAXONOMY] == true)
            {
                DataGridViewRow         NewRow    = new DataGridViewRow();
                DataGridViewTextBoxCell TitleCell = new DataGridViewTextBoxCell();
                TitleCell.Value = "TAXONOMY";
                NewRow.Cells.Add(TitleCell);

                List <int> localRanks = GetRanksTAXONOMY();

                for (int i = 0; i < localRanks.Count; ++i)
                {
                    resultAlternatives.Alternatives[i].Values.Add(new AlternativeValueBase(localRanks[i]));
                }

                foreach (int value in localRanks)
                {
                    DataGridViewTextBoxCell newCell = new DataGridViewTextBoxCell();
                    newCell.Value = value.ToString();
                    NewRow.Cells.Add(newCell);
                }
                result.Add(NewRow);
            }
            if (_methods[MethodsEnum.ELECTRE] == true)
            {
                DataGridViewRow         NewRow    = new DataGridViewRow();
                DataGridViewTextBoxCell TitleCell = new DataGridViewTextBoxCell();
                TitleCell.Value = "ELECTRE";
                NewRow.Cells.Add(TitleCell);

                List <int> localRanks;
                try
                {
                    localRanks = GetRanksELECTRE();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    localRanks = new List <int>();
                    for (int i = 0; i < _alternatives.Alternatives.Count; ++i)
                    {
                        localRanks.Add(1);
                    }
                }

                for (int i = 0; i < localRanks.Count; ++i)
                {
                    resultAlternatives.Alternatives[i].Values.Add(new AlternativeValueBase(localRanks[i]));
                }

                foreach (int value in localRanks)
                {
                    DataGridViewTextBoxCell newCell = new DataGridViewTextBoxCell();
                    newCell.Value = value.ToString();
                    NewRow.Cells.Add(newCell);
                }
                result.Add(NewRow);
            }

            resultProvider.Init(resultBase);
            List <int> ranks = resultProvider.Solve(resultAlternatives).Ranks;

            DataGridViewRow         NewRowResult    = new DataGridViewRow();
            DataGridViewTextBoxCell TitleCellResult = new DataGridViewTextBoxCell();

            TitleCellResult.Value = "RESULT";
            NewRowResult.Cells.Add(TitleCellResult);
            foreach (int value in ranks)
            {
                DataGridViewTextBoxCell newCell = new DataGridViewTextBoxCell();
                newCell.Value = value.ToString();
                NewRowResult.Cells.Add(newCell);
            }
            result.Add(NewRowResult);
            return(result);
        }