Or-tools: class "operations_research::MPSolver" has no member "GLOP_LINEAR_PROGRAMMING"

Created on 23 Apr 2019  Â·  9Comments  Â·  Source: google/or-tools

Hi, I hope this is the right place to write this down.
I am trying to execute the following example code but I keep getting the "class "operations_research::MPSolver" has no member "GLOP_LINEAR_PROGRAMMING"" error. Could you help me through this?

#include "ortools/linear_solver/linear_solver.h"
#include "ortools/linear_solver/linear_solver.pb.h"

namespace operations_research {
  void RunTest(
    MPSolver::OptimizationProblemType optimization_problem_type) {
    MPSolver solver("Glop", optimization_problem_type);
    // Create the variables x and y.
    MPVariable* const x = solver.MakeNumVar(0.0, 1, "x");
    MPVariable* const y = solver.MakeNumVar(0.0, 2, "y");
    // Create the objective function, x + y.
    MPObjective* const objective = solver.MutableObjective();
    objective->SetCoefficient(x, 1);
    objective->SetCoefficient(y, 1);
    objective->SetMaximization();
    // Call the solver and display the results.
    solver.Solve();
    printf("\nSolution:");
    printf("\nx = %.1f", x->solution_value());
    printf("\ny = %.1f", y->solution_value());
  }

  void RunExample() {
    RunTest(MPSolver::GLOP_LINEAR_PROGRAMMING);
  }
}

int main(int argc, char** argv) {
  operations_research::RunExample();
  return 0;
}
Help Needed C++

Most helpful comment

you need to define -DUSE_GLOP
Laurent Perron | Operations Research | [email protected] | (33) 1 42 68 53
00

Le mar. 23 avr. 2019 à 23:15, Kaan Yilmaz notifications@github.com a
écrit :

Hi, I hope this is the right place to write this down.
I am trying to execute the following example code but I keep getting the
"class "operations_research::MPSolver" has no member
"GLOP_LINEAR_PROGRAMMING"" error. Could you help me through this?

include "ortools/linear_solver/linear_solver.h"

include "ortools/linear_solver/linear_solver.pb.h"

namespace operations_research {
void RunTest(
MPSolver::OptimizationProblemType optimization_problem_type) {
MPSolver solver("Glop", optimization_problem_type);
// Create the variables x and y.
MPVariable* const x = solver.MakeNumVar(0.0, 1, "x");
MPVariable* const y = solver.MakeNumVar(0.0, 2, "y");
// Create the objective function, x + y.
MPObjective* const objective = solver.MutableObjective();
objective->SetCoefficient(x, 1);
objective->SetCoefficient(y, 1);
objective->SetMaximization();
// Call the solver and display the results.
solver.Solve();
printf("\nSolution:");
printf("\nx = %.1f", x->solution_value());
printf("\ny = %.1f", y->solution_value());
}

void RunExample() {
RunTest(MPSolver::GLOP_LINEAR_PROGRAMMING);
}
}

int main(int argc, char** argv) {
operations_research::RunExample();
return 0;
}

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/google/or-tools/issues/1214, or mute the thread
https://github.com/notifications/unsubscribe-auth/ACUPL3OAPBHAPLGDVP4JIS3PR536VANCNFSM4HH6PA7Q
.

All 9 comments

you need to define -DUSE_GLOP
Laurent Perron | Operations Research | [email protected] | (33) 1 42 68 53
00

Le mar. 23 avr. 2019 à 23:15, Kaan Yilmaz notifications@github.com a
écrit :

Hi, I hope this is the right place to write this down.
I am trying to execute the following example code but I keep getting the
"class "operations_research::MPSolver" has no member
"GLOP_LINEAR_PROGRAMMING"" error. Could you help me through this?

include "ortools/linear_solver/linear_solver.h"

include "ortools/linear_solver/linear_solver.pb.h"

namespace operations_research {
void RunTest(
MPSolver::OptimizationProblemType optimization_problem_type) {
MPSolver solver("Glop", optimization_problem_type);
// Create the variables x and y.
MPVariable* const x = solver.MakeNumVar(0.0, 1, "x");
MPVariable* const y = solver.MakeNumVar(0.0, 2, "y");
// Create the objective function, x + y.
MPObjective* const objective = solver.MutableObjective();
objective->SetCoefficient(x, 1);
objective->SetCoefficient(y, 1);
objective->SetMaximization();
// Call the solver and display the results.
solver.Solve();
printf("\nSolution:");
printf("\nx = %.1f", x->solution_value());
printf("\ny = %.1f", y->solution_value());
}

void RunExample() {
RunTest(MPSolver::GLOP_LINEAR_PROGRAMMING);
}
}

int main(int argc, char** argv) {
operations_research::RunExample();
return 0;
}

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/google/or-tools/issues/1214, or mute the thread
https://github.com/notifications/unsubscribe-auth/ACUPL3OAPBHAPLGDVP4JIS3PR536VANCNFSM4HH6PA7Q
.

For the record:
https://github.com/google/or-tools/blob/39f44709bba203f5ff3bc18fab8098739f189a6d/ortools/linear_solver/linear_solver.h#L181-L218

note: some solvers are optional (ed SCIP, CPLEX, GLPK, GUROBI) and need a build from source + local install of theses solvers to be able to use them.

I am new to or-tools and I must use c++ (which I am new to as well). I am using Visual Studio 2017.

I added: #define DUSE_GLOP

It did nothing for me.

I get "operations_research::MPSolver" has no member "GLOP_LINEAR_PROGRAMMING""

Can you help?

define USE_GLOP

*De : *cjolinla notifications@github.com
*Date : *ven. 10 mai 2019 à 21:46
*À : *google/or-tools
*Cc : *Laurent Perron, Comment

I am new to or-tools and I must use c++ (which I am new to as well). I am

using Visual Studio 2017.

I added: #define DUSE_GLOP

It did nothing for me.

I get "operations_research::MPSolver" has no member
"GLOP_LINEAR_PROGRAMMING""

Can you help?

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/google/or-tools/issues/1214#issuecomment-491409009,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACUPL3KU43BLB2BCAVC4QDLPUXGIRANCNFSM4HH6PA7Q
.

@cjolinla you must #define USE_GLOP or on the command line for mvsc /DUSE_GLOP and for gcc/clang -DUSE_GLOP

I tried #define USE_GLOP

It did not solve the problem

In addition to the previous error message, I get:
Error C2065 'GLOP_LINEAR_PROGRAMMING': undeclared identifier

is the #define USE_GLOP before the include of linear_solver.h ?
Laurent Perron | Operations Research | [email protected] | (33) 1 42 68 53
00

*De : *cjolinla notifications@github.com
*Date : *ven. 10 mai 2019 à 22:19
*À : *google/or-tools
*Cc : *Laurent Perron, Comment

In addition to the previous error message, I get:

Error C2065 'GLOP_LINEAR_PROGRAMMING': undeclared identifier

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/google/or-tools/issues/1214#issuecomment-491417838,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACUPL3KEBOFMLIQAV4UA653PUXKDPANCNFSM4HH6PA7Q
.

It wasn't, now the error message is gone. Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

partumamet picture partumamet  Â·  4Comments

unfuse picture unfuse  Â·  5Comments

mlk621 picture mlk621  Â·  3Comments

frodrigo picture frodrigo  Â·  5Comments

Phibedy picture Phibedy  Â·  3Comments