def base_calc(table: SimplexTable): html = "Начальное состояние системы:" html += table.to_html() + "<br><br>" iteration = 1 while table.one_step(): html += "Шаг номер №" + str(iteration) html += table.to_html() + "<br><br>" iteration += 1 return html
def matrix_game_solution(table: SimplexTable): solution_1 = table.get_solution() solution_2 = DualSolutonCreator.dual_task_solution(table) solution_1.coefficients = solution_1.coefficients[:-len(solution_2. coefficients)] solution_1 /= solution_1.free_member solution_2 /= solution_2.free_member return solution_2.coefficients, solution_1.coefficients
def matrix_game_calc(matrix: List[List[float]]): html = "Начальное состояние системы:<br>" for row in matrix: html += str(row) + "<br>" system, min_value = MatrixGame.create_matrix_game(matrix) html += "Для решения будем использовать метод симлекс-метод в чистом виде<br>" table = SimplexTable(system) html += base_calc(table) p, q = MatrixGame.matrix_game_solution(table) html += "p = [" + '; '.join(["%8.5f" % (v) for v in p]) + " ]<br>" html += "q = [" + '; '.join(["%8.5f" % (v) for v in q]) + " ]<br>" html += "Цена игры = " html += "%8.5f" % (1 / table.__objective_function__.free_member + min_value) + "<br>" return html
def __init__(self, system: Optional[RestrictionSystem] = None): SimplexTable.__init__(self, system)
def simplex_method_calc(system: RestrictionSystem): return "Решение системы симплекс методом в чистом виде<br>" + base_calc( SimplexTable(system))