/
spirzen
/
it-code-examples
Обзор
Документация
Войти
/
spirzen
/
it-code-examples
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
examples/python/mp-9-002/main.py
11 строк
417 B
Spirzen
Code migration pack
09 июн 2026, 01:41
09 июн 2026, 01:41
cebc284
Код
Авторство
О чём код?
from ortools.linear_solver import pywraplp solver = pywraplp.Solver.CreateSolver("GLOP") x1 = solver.NumVar(0, solver.infinity(), "x1") x2 = solver.NumVar(0, solver.infinity(), "x2") solver.Add(2 * x1 + x2 <= 8) solver.Add(x1 + 2 * x2 <= 8) solver.Maximize(3 * x1 + 2 * x2) status = solver.Solve() if status == pywraplp.Solver.OPTIMAL: print(x1.solution_value(), x2.solution_value(), solver.Objective().Value())