Skip to main content
1 of 3

ValidateModel or tools in c++ and proto problems

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

    cp_model.Maximize(LinearExpr::Sum(obj_final));

    SatHelper::ValidateModel(cp_model);
    //solve
    Model model;
    //
    // Sets a time limit of 10 seconds.
    
    SatParameters parameters;
    parameters.set_max_time_in_seconds(10.0);
    model.Add(NewSatParameters(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&)’
     SatHelper::ValidateModel(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 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, becuase the examples uses FLAGS and LOG and its confusing.

Thanks!