I'm trying to validate my model, this is the relevant part of my code:


    Model model;
    // Sets a time limit of 10 seconds.

    SatParameters parameters;

    // Solve.

    const CpSolverResponse response = SolveCpModel(cp_model.Build(), &model);
    LOG(INFO) << CpSolverResponseStats(response);

    if (response.status() == CpSolverStatus::FEASIBLE) {
        for (int j = 0; j < nbTasks; ++j)
            LOG(INFO) << "  x = " << SolutionIntegerValue(response, starts[j]);

For some reason my model is invalid and I want to validate it to get detailed information about it. But I get this error:

 error: no matching function for call to ‘operations_research::sat::SatHelper::ValidateModel(operations_research::sat::Model&)’

and suggests:

note: candidate: static std::__cxx11::string operations_research::sat::SatHelper::ValidateModel(const operations_research::sat::CpModelProto&)

So, what is a CpModelProto? I read the documentation but it is hard to understand. I've seen most of the c++ examples of or-tools and I haven't found any CpModelProto in the solving part. And finally, what can I do to validate my model and check where the problem is?

Additionally, if someone can give me a nice explanation of how to print/solve and setting parameters, it will be nice, because the examples use FLAGS and LOG and they are confusing.



1 Answer 1


CpModelProto is a protobuf representation of your model in ortools.

You create it by using the CpModelBuilder class (your cp_model), and calling its Build() method, the SolveCpModel function that you are using actually also takes a CpModelProto as its first argument.

  • $\begingroup$ Thanks! it works, but its no printing anything. i used: std::cout << SatHelper::ValidateModel(cp_model.Build()) << std::endl; and just print coeffs: -1 on cmd. This is the info that the method drops? $\endgroup$ Jan 23, 2020 at 15:38
  • $\begingroup$ If you parse C++ command line arguments using the Google gflags code, you can try with -vmodule=cp_model_checker=2. It should display more information $\endgroup$ Jan 23, 2020 at 16:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.