#include "ortools/linear_solver/linear_solver.h" using namespace operations_research; int main() { // Criar o Resolvedor, que usa o GLOP MPSolver solver("simple_lp_program", MPSolver::GLOP_LINEAR_PROGRAMMING); // Criar as variáveis x e y, já dizendo o tipo, os limitantes, e um nome MPVariable* const x = solver.MakeNumVar(0.0, 1, "x"); MPVariable* const y = solver.MakeNumVar(0.0, 2, "y"); // Criar a restrição, 0 <= x + y <= 2. MPConstraint* const ct = solver.MakeRowConstraint(0.0, 2.0, "ct"); ct->SetCoefficient(x, 1); ct->SetCoefficient(y, 1); // Create the objective function, 3 * x + y. MPObjective* const objective = solver.MutableObjective(); objective->SetCoefficient(x, 3); objective->SetCoefficient(y, 1); objective->SetMaximization(); solver.Solve(); std::cout << "Solution:" << std::endl; std::cout << "Objective value = " << objective->Value() << std::endl; std::cout << "x = " << x->solution_value() << std::endl; std::cout << "y = " << y->solution_value() << std::endl; return EXIT_SUCCESS; }