forked from google/or-tools
-
Notifications
You must be signed in to change notification settings - Fork 9
/
issue173.cc
36 lines (30 loc) · 938 Bytes
/
issue173.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "ortools/base/commandlineflags.h"
#include "ortools/base/logging.h"
#include "ortools/linear_solver/linear_solver.h"
namespace operations_research {
void SolveLP() {
// Create the linear solver with the GLOP backend.
std::unique_ptr<MPSolver> solver(MPSolver::CreateSolver("CBC"));
if (!solver) {
return;
}
const double kInfinity = solver->infinity();
MPVariable* const x = solver->MakeNumVar(-kInfinity, kInfinity, "x");
MPObjective* const objective = solver->MutableObjective();
objective->SetMaximization();
objective->SetCoefficient(x, 1);
MPConstraint* const constraint = solver->MakeRowConstraint(0, 5);
constraint->SetCoefficient(x, 1);
solver->Solve();
}
void BreakLoop() {
for (int i = 0; i < 500; i++) {
SolveLP();
}
}
} // namespace operations_research
int main(int argc, char** argv) {
absl::ParseCommandLine(argc, argv);
operations_research::BreakLoop();
return 0;
}