public void TestVacationSpotSelection() { double[][] criteria = new double[][] { new double[] {1,5,0.33333333,1}, new double[] {0,1,0.2,0.5}, new double[] {0,0,1,3}, new double[] {0,0,0,1} }; double[][] activitiesChoices = new double[][] { new double[] {1,4,3}, new double[] {0,1,2}, new double[] {0,0,1} }; double[][] nightlifeChoices = new double[][] { new double[] {1,0.5,0.3333333}, new double[] {0,1,0.5}, new double[] {0,0,1} }; double[][] siteseeingChoices = new double[][] { new double[] {1,0.142857,0.2}, new double[] {0,1,2}, new double[] {0,0,1} }; double[][] costChoices = new double[][] { new double[] {1,3,5}, new double[] {0,1,2}, new double[] {0,0,1} }; //4 criteria, 3 choices AHPModel model = new AHPModel(4,3); model.AddCriteria(criteria); model.AddCriterionRatedChoices(0,activitiesChoices); model.AddCriterionRatedChoices(1,nightlifeChoices); model.AddCriterionRatedChoices(2,siteseeingChoices); model.AddCriterionRatedChoices(3,costChoices); model.CalculateModel(); GeneralMatrix calcCriteria = model.CalculatedCriteria; GeneralMatrix results = model.ModelResult; GeneralMatrix choices = model.CalculatedChoices; //choices: SF 42%, Orlando31%, NY 27% Assert.AreEqual(31,System.Math.Round(choices.GetElement(0,0)*100,0)); Assert.AreEqual(42,System.Math.Round(choices.GetElement(1,0)*100,0)); Assert.AreEqual(27,System.Math.Round(choices.GetElement(2,0)*100,0)); }
public void TestFeatureSelection() { double[][] criteria = new double[][] { new double[] {1,0.33333333,0.166666667}, new double[] {0,1,0.2}, new double[] {0,0,1} }; double[][] costChoices = new double[][] { new double[] {1.00000, 0.50000, 0.11111, 0.25000, 0.20000, 3.00000, 2.00000, 0.33333, 7.00000, 2.00000, 5.00000, 1.00000, 3.00000, 4.00000, 0.25000, 0.33333, 0.20000, 1.00000, 0.14286}, new double[] {0.00000, 1.00000, 0.11111, 0.20000, 0.14286, 4.00000, 3.00000, 0.20000, 4.00000, 3.00000, 5.00000, 1.00000, 3.00000, 3.00000, 0.20000, 0.25000, 0.20000, 3.00000, 0.14286}, new double[] {0.00000, 0.00000, 1.00000, 9.00000, 5.00000, 9.00000, 9.00001, 5.00000, 9.00000, 9.00000, 9.00000, 8.00000, 9.00000, 6.00000, 4.00000, 6.00000, 5.00000, 7.00000, 1.00000}, new double[] {0.00000, 0.00000, 0.00000, 1.00000, 0.16667, 6.00000, 5.00000, 0.33333, 4.00000, 3.00000, 5.00000, 3.00000, 4.00000, 0.50000, 0.25000, 0.50000, 0.25000, 2.00000, 0.14286}, new double[] {0.00000, 0.00000, 0.00000, 0.00000, 1.00000, 9.00000, 8.00000, 5.00000, 9.00000, 6.00000, 8.00000, 6.00000, 9.00000, 7.00000, 3.00000, 6.00000, 5.00000, 7.00001, 2.00000}, new double[] {0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 1.00000, 0.33333, 0.14286, 1.00000, 0.25000, 0.33333, 0.20000, 1.00000, 0.20000, 0.12500, 0.20000, 0.14286, 0.25000, 0.11111}, new double[] {0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 1.00000, 0.16667, 2.00000, 0.33333, 2.00000, 0.25000, 3.00000, 0.20000, 0.14286, 0.20000, 0.14286, 0.25000, 0.12500}, new double[] {0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 1.00000, 8.00000, 5.00000, 6.00000, 4.00000, 8.00000, 3.00000, 0.33333, 4.00000, 1.00000, 4.00000, 0.16667}, new double[] {0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 1.00000, 0.20000, 0.33333, 0.16667, 1.00000, 0.16667, 0.12500, 0.20000, 0.12500, 0.25000, 0.11111}, new double[] {0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 1.00000, 4.00000, 0.50000, 6.00000, 0.25000, 0.14286, 0.25000, 0.16667, 0.33333, 0.12500}, new double[] {0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 1.00000, 0.20000, 4.00000, 0.20000, 0.14286, 0.20000, 0.14286, 0.33333, 0.12500}, new double[] {0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 1.00000, 5.00000, 1.00000, 0.33333, 1.00000, 0.33333, 3.00000, 0.14286}, new double[] {0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 1.00000, 0.16667, 0.12500, 0.16667, 0.12500, 0.20000, 0.11111}, new double[] {0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 1.00000, 0.33333, 1.00000, 0.33333, 3.00000, 0.16667}, new double[] {0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 1.00000, 5.00000, 4.00000, 5.99999, 0.33333}, new double[] {0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 1.00000, 0.33333, 3.00000, 0.16667}, new double[] {0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 1.00000, 3.00000, 0.20000}, new double[] {0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 1.00000, 0.16670}, new double[] {0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 1.00000} }; double[][] efficiencyChoices = new double[][] { new double[] {1.00000, 0.11110, 0.33333, 0.20000, 0.16667, 0.20000, 0.14286, 1.00000, 0.11111, 0.50000, 0.20000, 0.16667, 0.11111, 0.25000, 0.50000, 0.25000, 5.00000, 1.00000, 0.14286}, new double[] {0.00000, 1.00000, 8.00000, 6.00000, 5.00000, 4.00000, 0.25000, 9.00000, 0.33333, 7.00000, 7.00000, 5.00000, 0.20000, 4.00000, 8.00000, 4.00000, 9.00000, 7.00000, 0.33333}, new double[] {0.00000, 0.00000, 1.00000, 0.20000, 0.14286, 0.12500, 0.11111, 1.00000, 0.11111, 0.33333, 0.25000, 0.16667, 0.11111, 0.20000, 1.00000, 0.25000, 3.00000, 0.33333, 0.11111}, new double[] {0.00000, 0.00000, 0.00000, 1.00000, 0.25000, 0.50000, 0.20000, 9.00001, 0.25000, 4.00000, 6.00000, 4.00000, 0.14286, 0.33333, 6.00000, 2.00000, 8.00000, 4.00000, 0.16670}, new double[] {0.00000, 0.00000, 0.00000, 0.00000, 1.00000, 0.33333, 0.20000, 9.00001, 0.12500, 3.00000, 3.00000, 1.00000, 0.14286, 0.25000, 5.00000, 4.00000, 9.00000, 5.99999, 0.20000}, new double[] {0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 1.00000, 0.25000, 7.00001, 0.20000, 5.00000, 6.00000, 4.00000, 0.20000, 4.00000, 7.00000, 5.00000, 9.00000, 7.00001, 0.50000}, new double[] {0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 1.00000, 9.00000, 0.50000, 7.00000, 7.00000, 5.00000, 0.33333, 4.00000, 9.00000, 7.00000, 9.00000, 7.00000, 2.00000}, new double[] {0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 1.00000, 0.11111, 0.14286, 0.33333, 0.14286, 0.11111, 0.16667, 0.33333, 0.20000, 2.00000, 0.50000, 0.11111}, new double[] {0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 1.00000, 9.00000, 9.00000, 6.00000, 0.50000, 7.00000, 9.00000, 7.00000, 9.00000, 8.00000, 3.00000}, new double[] {0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 1.00000, 2.00000, 0.33333, 0.12500, 0.25000, 2.00000, 0.33333, 5.00000, 3.00000, 0.12500}, new double[] {0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 1.00000, 0.20000, 0.12500, 0.20000, 1.00000, 0.25000, 3.00000, 1.00000, 0.11111}, new double[] {0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 1.00000, 0.14286, 0.50000, 6.00000, 4.00000, 8.00000, 5.99999, 0.25000}, new double[] {0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 1.00000, 7.00000, 9.00000, 7.00001, 9.00000, 9.00001, 3.00000}, new double[] {0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 1.00000, 8.00000, 5.99999, 9.00000, 5.00000, 0.16667}, new double[] {0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 1.00000, 0.33333, 5.00000, 1.00000, 0.12500}, new double[] {0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 1.00000, 5.00000, 4.00000, 0.11111}, new double[] {0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 1.00000, 0.25000, 0.11111}, new double[] {0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 1.00000, 0.11110}, new double[] {0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 1.00000} }; double[][] revenueChoices = new double[][] { new double[] {1.00000, 7.00000, 0.50000, 4.00000, 2.00000, 4.00000, 7.00001, 2.00000, 8.00000, 6.00000, 2.00000, 0.50000, 0.25000, 7.00000, 6.00000, 0.16667, 0.50000, 0.25000, 9.00000}, new double[] {0.00000, 1.00000, 0.16667, 2.00000, 0.33333, 0.20000, 0.25000, 0.16667, 2.00000, 0.33333, 0.12500, 0.14286, 0.14286, 6.00000, 0.25000, 0.16667, 0.33333, 0.11110, 2.00000}, new double[] {0.00000, 0.00000, 1.00000, 0.33333, 0.33333, 0.50000, 3.00000, 0.25000, 5.00000, 4.00000, 0.50000, 0.33333, 0.16667, 5.00000, 0.33333, 0.20000, 0.33333, 0.12500, 9.00000}, new double[] {0.00000, 0.00000, 0.00000, 1.00000, 0.20000, 0.50000, 4.00000, 3.00000, 8.00000, 6.00000, 4.00000, 3.00000, 0.14286, 6.00000, 3.00000, 0.20000, 4.00000, 0.33333, 9.00000}, new double[] {0.00000, 0.00000, 0.00000, 0.00000, 1.00000, 3.00000, 2.00000, 4.00000, 8.00000, 6.00000, 3.00000, 2.00000, 0.12500, 8.00000, 2.00000, 0.25000, 6.00000, 0.33333, 9.00000}, new double[] {0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 1.00000, 3.00000, 2.00000, 7.00000, 4.00000, 3.00000, 2.00000, 0.12500, 4.00000, 1.00000, 0.20000, 3.00000, 0.16667, 9.00000}, new double[] {0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 1.00000, 3.00000, 5.00000, 0.50000, 0.33333, 0.25000, 0.11111, 2.00000, 1.00000, 0.14286, 0.33333, 0.14286, 3.00000}, new double[] {0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 1.00000, 4.00000, 5.00000, 2.00000, 0.50000, 0.14286, 5.00000, 2.00000, 0.14286, 1.00000, 0.16667, 5.00000}, new double[] {0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 1.00000, 0.50000, 0.33333, 0.25000, 0.11111, 2.00000, 0.33333, 0.14286, 0.33333, 0.16667, 3.00000}, new double[] {0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 1.00000, 0.20000, 0.16667, 0.11111, 4.00000, 0.33333, 0.12500, 0.16667, 0.14286, 6.00000}, new double[] {0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 1.00000, 0.33333, 0.11111, 4.00000, 0.50000, 0.14286, 2.00000, 0.16667, 7.00000}, new double[] {0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 1.00000, 0.11111, 5.00000, 4.00000, 0.14286, 2.00000, 0.16667, 6.00000}, new double[] {0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 1.00000, 9.00000, 9.00000, 7.00001, 9.00000, 4.00000, 9.00000}, new double[] {0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 1.00000, 0.25000, 0.14286, 0.33333, 0.16667, 3.00000}, new double[] {0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 1.00000, 0.20000, 3.00000, 0.20000, 6.00000}, new double[] {0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 1.00000, 7.00000, 2.00000, 9.00000}, new double[] {0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 1.00000, 0.25000, 9.00001}, new double[] {0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 1.00000, 9.00000}, new double[] {0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 1.00000} }; //3 criteria, 19 features = choices AHPModel model = new AHPModel(3,19); model.AddCriteria(criteria); model.AddCriterionRatedChoices(0,costChoices); model.AddCriterionRatedChoices(1,efficiencyChoices); model.AddCriterionRatedChoices(2,revenueChoices); model.CalculateModel(); GeneralMatrix choices = model.CalculatedChoices; Assert.AreEqual(19,System.Math.Round(choices.GetElement(12,0)*100,0)); }