public void TestMethod3() { double[,] newMatrix = { { 5, 1 }, { 4, 2 }, { 2, 3 }, }; Playoff playoff = new Playoff(newMatrix); Risk risk = Converter.fromPlayoffToRisk(playoff); double[] currentState = { 0.6, 0.2 }; Assert.AreEqual(false, risk.addStateOfNature(currentState)); }
public void TestMethod2() { double[,] newMatrix = { { 5, 1 }, { 4, 2 }, { 2, 3 }, }; Playoff playoff = new Playoff(newMatrix); Risk risk = Converter.fromPlayoffToRisk(playoff); double[] currentState = { 0.6, 0.4 }; risk.addStateOfNature(currentState); risk.findMaxExperimentPrice(); Assert.AreEqual(0.8, risk.MaxExperiment); }
public void TestMethod1() { double[,] newMatrix = { { 7, 5, 5, 1, 6 }, { 2, 3, 4, 2, 5 }, { 6, 3, 2, 4, 4 }, { 3, 5, 5, 7, 7 }, { 7, 2, 4, 3, 2 }, { 5, 4, 7, 5, 3 }, { 4, 3, 4, 3, 4 }, { 3, 4, 4, 5, 5 } }; Playoff playoff = new Playoff(newMatrix); Risk risk = Converter.fromPlayoffToRisk(playoff); double[] currentState = { 0.2, 0.1, 0.3, 0.3, 0.1 }; risk.addStateOfNature(currentState); risk.findMaxExperimentPrice(); Assert.AreEqual(1.4, risk.MaxExperiment); }
private void findMaxButton_Click(object sender, EventArgs e) { int m = winMatrixView.Columns.Count; int n = winMatrixView.Rows.Count - 2; enterMatrix = new double[n, m]; enterArray = new double[m]; //Reading values from winMatrixView and adding them to enterMatrix for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { try { enterMatrix[j, i] = double.Parse(winMatrixView[i, j].Value.ToString()); } catch (Exception error) { MessageBox.Show("Ошибка, неверный составлена матрица выигрышей", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } } Playoff playoff = new Playoff(enterMatrix); //Reading the state of nature values for (int i = 0; i < m; i++) { try { enterArray[i] = double.Parse(winMatrixView[i, n].Value.ToString()); } catch (Exception error) { MessageBox.Show("Ошибка, неверный составлены вероятности", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } riskMatrixView.Columns.Clear(); Risk risk = Converter.fromPlayoffToRisk(playoff); //Checking state of nature if (!risk.addStateOfNature(enterArray)) { MessageBox.Show("Ошибка, неверный составлены вероятности", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //Creating risk matrix n*m for riskMatrixView for (int i = 0; i < m; i++) { riskMatrixView.Columns.Add($"{i}", $"{i}"); } for (int i = 0; i < n; i++) { riskMatrixView.Rows.Add(); riskMatrixView.Rows[i].HeaderCell.Value = i.ToString(); } //Adding risk matrix values to riskMatrixView for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { riskMatrixView[j, i].Value = risk.Matrix[i, j]; riskMatrixView[j, i].ReadOnly = true; } } riskMatrixView.Columns.Add($"", $"Risk"); risk.findMaxExperimentPrice(); //Displaying max experiment price maxExp.Text = "Максимальная цена эксперимента: " + risk.MaxExperiment.ToString(); //Displaying risks values in riskMatirxView for (int i = 0; i < n; i++) { riskMatrixView[m, i].Value = risk.RiskValues[i]; riskMatrixView[m, i].ReadOnly = true; } riskMatrixView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; risk.printToTxt(); }