Ejemplo n.º 1
0
    def LoadSolutionFromProto(self, *args) -> "absl::Status":
        r"""
        Load a solution encoded in a protocol buffer onto this solver for easy
          access via the MPSolver interface.

        IMPORTANT: This may only be used in conjunction with ExportModel(),
          following this example:

           .. code-block:: c++

                 MPSolver my_solver;
                 ... add variables and constraints ...
                 MPModelProto model_proto;
                 my_solver.ExportModelToProto(model_proto);
                 MPSolutionResponse solver_response;
                 MPSolver::SolveWithProto(model_proto, solver_response);
                 if (solver_response.result_status() == MPSolutionResponse::OPTIMAL) {
                   CHECK_OK(my_solver.LoadSolutionFromProto(solver_response));
                   ... inspect the solution using the usual API: solution_value(), etc...
                 }

        The response must be in OPTIMAL or FEASIBLE status.

        Returns a non-OK status if a problem arised (typically, if it wasn't used
            like it should be):
        - loading a solution whose variables don't correspond to the solver's
          current variables
        - loading a solution with a status other than OPTIMAL / FEASIBLE.

        Note: the objective value isn't checked. You can use VerifySolution() for
              that.
        """
        return _pywraplp.Solver_LoadSolutionFromProto(self, *args)
Ejemplo n.º 2
0
 def LoadSolutionFromProto(self, *args) -> "util::Status":
     return _pywraplp.Solver_LoadSolutionFromProto(self, *args)