switch flags setters and getters to the absl format

This commit is contained in:
Laurent Perron
2020-10-21 00:21:54 +02:00
parent 1bf7ccf721
commit a4258f2bdf
527 changed files with 48384 additions and 45461 deletions

View File

@@ -20,17 +20,17 @@
namespace operations_research {
void BuildLinearProgrammingMaxExample(MPSolver::OptimizationProblemType type) {
const double kObjCoef[] = {10.0, 6.0, 4.0};
const std::string kVarName[] = {"x1", "x2", "x3"};
const double kObjCoef[] = { 10.0, 6.0, 4.0 };
const std::string kVarName[] = { "x1", "x2", "x3" };
const int numVars = 3;
const int kNumConstraints = 3;
const std::string kConstraintName[] = {"c1", "c2", "c3"};
const double kConstraintCoef1[] = {1.0, 1.0, 1.0};
const double kConstraintCoef2[] = {10.0, 4.0, 5.0};
const double kConstraintCoef3[] = {2.0, 2.0, 6.0};
const double* kConstraintCoef[] = {kConstraintCoef1, kConstraintCoef2,
kConstraintCoef3};
const double kConstraintUb[] = {100.0, 600.0, 300.0};
const std::string kConstraintName[] = { "c1", "c2", "c3" };
const double kConstraintCoef1[] = { 1.0, 1.0, 1.0 };
const double kConstraintCoef2[] = { 10.0, 4.0, 5.0 };
const double kConstraintCoef3[] = { 2.0, 2.0, 6.0 };
const double *kConstraintCoef[] = { kConstraintCoef1, kConstraintCoef2,
kConstraintCoef3 };
const double kConstraintUb[] = { 100.0, 600.0, 300.0 };
const double infinity = MPSolver::infinity();
MPModelProto model_proto;
@@ -38,20 +38,20 @@ void BuildLinearProgrammingMaxExample(MPSolver::OptimizationProblemType type) {
// Create variables and objective function
for (int j = 0; j < numVars; ++j) {
MPVariableProto* x = model_proto.add_variable();
x->set_name(kVarName[j]); // Could be skipped (optional).
MPVariableProto *x = model_proto.add_variable();
x->set_name(kVarName[j]); // Could be skipped (optional).
x->set_lower_bound(0.0);
x->set_upper_bound(infinity); // Could be skipped (default value).
x->set_is_integer(false); // Could be skipped (default value).
x->set_upper_bound(infinity); // Could be skipped (default value).
x->set_is_integer(false); // Could be skipped (default value).
x->set_objective_coefficient(kObjCoef[j]);
}
model_proto.set_maximize(true);
// Create constraints
for (int i = 0; i < kNumConstraints; ++i) {
MPConstraintProto* constraint_proto = model_proto.add_constraint();
constraint_proto->set_name(kConstraintName[i]); // Could be skipped.
constraint_proto->set_lower_bound(-infinity); // Could be skipped.
MPConstraintProto *constraint_proto = model_proto.add_constraint();
constraint_proto->set_name(kConstraintName[i]); // Could be skipped.
constraint_proto->set_lower_bound(-infinity); // Could be skipped.
constraint_proto->set_upper_bound(kConstraintUb[i]);
for (int j = 0; j < numVars; ++j) {
// These two lines may be skipped when the coefficient is zero.
@@ -66,12 +66,12 @@ void BuildLinearProgrammingMaxExample(MPSolver::OptimizationProblemType type) {
if (type == MPSolver::GLOP_LINEAR_PROGRAMMING) {
model_request.set_solver_type(MPModelRequest::GLOP_LINEAR_PROGRAMMING);
}
#endif // USE_GLOP
#endif // USE_GLOP
#if defined(USE_CLP)
if (type == MPSolver::CLP_LINEAR_PROGRAMMING) {
model_request.set_solver_type(MPModelRequest::CLP_LINEAR_PROGRAMMING);
}
#endif // USE_CLP
#endif // USE_CLP
MPSolutionResponse solution_response;
MPSolver::SolveWithProto(model_request, &solution_response);
@@ -90,15 +90,15 @@ void RunAllExamples() {
#if defined(USE_GLOP)
LOG(INFO) << "----- Running Max Example with GLOP -----";
BuildLinearProgrammingMaxExample(MPSolver::GLOP_LINEAR_PROGRAMMING);
#endif // USE_GLOP
#endif // USE_GLOP
#if defined(USE_CLP)
LOG(INFO) << "----- Running Max Example with Coin LP -----";
BuildLinearProgrammingMaxExample(MPSolver::CLP_LINEAR_PROGRAMMING);
#endif // USE_CLP
#endif // USE_CLP
}
} // namespace operations_research
} // namespace operations_research
int main(int argc, char** argv) {
int main(int argc, char **argv) {
gflags::ParseCommandLineFlags(&argc, &argv, true);
operations_research::RunAllExamples();
return EXIT_SUCCESS;