109 std::function<
void(
const std::string&)> logging_callback) {
110 glop::GlopParameters params;
111 params.set_log_search_progress(request->enable_internal_solver_output());
120 if (logging_callback !=
nullptr) {
127 if (request->has_solver_specific_parameters()) {
129 if (!std::is_base_of<Message, glop::GlopParameters>::value) {
130 if (!params.MergeFromString(request->solver_specific_parameters())) {
131 return ModelInvalidParametersResponse(
133 "solver_specific_parameters is not a valid binary stream of the "
134 "GLOPParameters proto");
138 request->solver_specific_parameters(), ¶ms)) {
139 return ModelInvalidParametersResponse(
141 "solver_specific_parameters is not a valid textual representation "
142 "of the GlopParameters proto");
146 if (request->has_solver_time_limit_seconds()) {
147 params.set_max_time_in_seconds(request->solver_time_limit_seconds());
152 if (!error.empty()) {
153 return ModelInvalidParametersResponse(
154 logger, absl::StrCat(
"Invalid Glop parameters: ", error));
158 MPSolutionResponse response;
163 std::optional<LazyMutableCopy<MPModelProto>> optional_model =
165 if (!optional_model)
return response;
167 const MPModelProto& mp_model = **optional_model;
168 if (!mp_model.general_constraint().empty()) {
169 return ModelInvalidResponse(logger,
170 "GLOP does not support general constraints");
174 MPModelProtoToLinearProgram(mp_model, &linear_program);
175 std::move(request).dispose();
184 if (interrupt_solve !=
nullptr) {
185 if (interrupt_solve->load()) {
186 response.set_status(MPSOLVER_CANCELLED_BY_USER);
187 response.set_status_str(
188 "Solve not started, because the user set the atomic<bool> in "
189 "MPSolver::SolveWithProto() to true before solving could "
193 time_limit->RegisterExternalBooleanAsLimit(interrupt_solve);
200 const MPSolverResponseStatus result_status = ToMPSolverResultStatus(
status);
201 response.set_status(result_status);
204 if (result_status == MPSOLVER_OPTIMAL || result_status == MPSOLVER_FEASIBLE) {
208 for (
int var_id = 0; var_id < num_vars; ++var_id) {
211 response.add_variable_value(solution_value);
215 response.add_reduced_cost(reduced_cost);
219 if (result_status == MPSOLVER_UNKNOWN_STATUS && interrupt_solve !=
nullptr &&
220 interrupt_solve->load()) {
221 response.set_status(MPSOLVER_CANCELLED_BY_USER);
225 for (
int ct_id = 0; ct_id < num_constraints; ++ct_id) {
228 response.add_dual_value(dual_value);