Guest User

Untitled

a guest
Dec 6th, 2019
84
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. private void buttonMaximax_Click(object sender, EventArgs e)
  2. {
  3. int[] vector = new int[NoActions];
  4. int buff;
  5. for (int i = 0; i < NoActions; i++)
  6. {
  7. buff = payoffs[i, 0];
  8. for (int j = 0; j < NoStates; j++)
  9. {
  10. if (buff < payoffs[i, j])
  11. {
  12. buff = payoffs[i, j];
  13. }
  14. }
  15. vector[i] = buff;
  16. }
  17. buff = vector[0];
  18. int index = 0;
  19. for (int i = 0; i < NoActions; i++)
  20. {
  21. if (buff < vector[i])
  22. {
  23. buff = vector[i];
  24. index = i;
  25. }
  26. }
  27. textBoxResults.AppendText("[Maximax]Actiunea:A" + (index + 1) + " Profitul " + buff + System.Environment.NewLine);
  28. }
  29.  
  30. private void buttonMaximin_Click(object sender, EventArgs e)
  31. {
  32. int[] vector = new int[NoActions];
  33. int buff;
  34. for (int i = 0; i < NoActions; i++)
  35. {
  36. buff = payoffs[i, 0];
  37. for (int j = 0; j < NoStates; j++)
  38. {
  39. if (buff > payoffs[i, j])
  40. {
  41. buff = payoffs[i, j];
  42. }
  43. }
  44. vector[i] = buff;
  45. }
  46. buff = vector[0];
  47. int index = 0;
  48. for (int i = 0; i < NoActions; i++)
  49. {
  50. if (buff < vector[i])
  51. {
  52. buff = vector[i];
  53. index = i;
  54. }
  55. }
  56. textBoxResults.AppendText("[Maximin]Actiunea:A" + (index + 1) + " Profitul " + buff + System.Environment.NewLine);
  57. }
  58.  
  59. private void buttonHurwicz_Click(object sender, EventArgs e)
  60. {
  61. double a = Double.Parse(textBoxHurwiczAlpha.Text);
  62. int[] vectormax = new int[NoActions];
  63. int[] vectormin = new int[NoActions];
  64. double[] vectorH = new double[NoActions];
  65. int buffmin, buffmax;
  66. for (int i = 0; i < NoActions; i++)
  67. {
  68. buffmin = payoffs[i, 0];
  69. buffmax = payoffs[i, 0];
  70. for (int j = 0; j < NoStates; j++)
  71. {
  72. if (buffmin > payoffs[i, j])
  73. {
  74. buffmin = payoffs[i, j];
  75. }
  76. if (buffmax < payoffs[i, j])
  77. {
  78. buffmax = payoffs[i, j];
  79. }
  80. }
  81. vectormin[i] = buffmin;
  82. vectormax[i] = buffmax;
  83. }
  84. for (int i = 0; i < NoActions; i++)
  85. {
  86. vectorH[i] = a * vectormin[i] + (1 - a) * vectormax[i];
  87. }
  88. double buff = vectorH[0];
  89. for (int j = 0; j<NoActions; j++)
  90. {
  91. if (buff<vectorH[j])
  92. {
  93. buff = vectorH[j];
  94. }
  95. }
  96. textBoxResults.AppendText("[Hurwicz]Profitul " + buff + System.Environment.NewLine);
  97. }
  98.  
  99. private void buttonLaplace_Click(object sender, EventArgs e)
  100. {
  101. double[] vector = new double[NoActions];
  102. double buff = (double)1 / NoStates;
  103. double sum;
  104. for (int i = 0; i < NoActions; i++)
  105. {
  106. sum = 0;
  107. for (int j = 0; j < NoStates; j++)
  108. {
  109. sum = sum + (payoffs[i, j] * buff);
  110. }
  111. vector[i] = sum;
  112. }
  113. double buffx = vector[0];
  114. for (int j = 0; j<NoActions; j++)
  115. {
  116. if (buffx<vector[j])
  117. {
  118. buffx = vector[j];
  119. }
  120. }
  121. textBoxResults.AppendText("[LaPlace]Profitul " + buffx + System.Environment.NewLine);
  122. }
  123.  
  124. private void buttonRegret_Click(object sender, EventArgs e)
  125. {
  126. int[] vector = new int[NoStates];
  127. int[,] mat = new int[NoActions, NoStates];
  128. int buff;
  129. for (int i = 0; i < NoStates; i++)
  130. {
  131. buff = payoffs[0, i];
  132. for (int j = 0; j < NoActions; j++)
  133. {
  134. if (buff < payoffs[j, i])
  135. {
  136. buff = payoffs[j, i];
  137. }
  138. }
  139. vector[i] = buff;
  140. }
  141. for (int i = 0; i < NoStates; i++)
  142. {
  143. for (int j = 0; j < NoActions; j++)
  144. {
  145. mat[j, i] = vector[i] - payoffs[j, i];
  146. }
  147. }
  148. int[] vector2 = new int[NoActions];
  149. int buff2;
  150. for (int i = 0; i < NoActions; i++)
  151. {
  152. buff2 = mat[i, 0];
  153. for (int j = 0; j < NoStates; j++)
  154. {
  155. if (buff2 < mat[i, j])
  156. {
  157. buff2 = mat[i, j];
  158. }
  159. }
  160. vector2[i] = buff2;
  161. }
  162. int buff3 = vector[0];
  163. for (int i = 0; i < NoActions; i++)
  164. {
  165. if (buff3 > vector2[i])
  166. {
  167. buff3 = vector2[i];
  168. }
  169. }
  170. textBoxResults.AppendText("[Savage]MaxReget " + buff3 + System.Environment.NewLine);
  171. }
RAW Paste Data