# C++ Reference: class SharedResponseManager

Note: This documentation is automatically generated.

Manages the global best response kept by the solver. This class is responsible for logging the progress of the solutions and bounds as they are found.All functions are thread-safe except if specified otherwise.

Method | |
---|---|

`AddFinalResponsePostprocessor` | Return type: Arguments: These "postprocessing" steps will only be applied after the others to the solution returned by GetResponse(). |

`AddResponsePostprocessor` | Return type: Arguments: These "postprocessing" steps will be applied in REVERSE order of registration to all solution passed to the callbacks. |

`AddSolutionCallback` | Return type: Arguments: Adds a callback that will be called on each new solution (for statisfiablity problem) or each improving new solution (for an optimization problem). Returns its id so it can be unregistered if needed. Note that adding a callback is not free since the solution will be postsolved before this is called. Note that currently the class is waiting for the callback to finish before accepting any new updates. That could be changed if needed. |

`AddSolutionPostprocessor` | Return type: Arguments: These will be called in REVERSE order on any feasible solution returned to the user. |

`AddUnsatCore` | Return type: Arguments: Adds to the shared response a subset of assumptions that are enough to make the problem infeasible. |

`BestSolutionInnerObjectiveValue` | Return type: Returns the current best solution inner objective value or kInt64Max if there is no solution. |

`DisplayImprovementStatistics` | Return type: Display improvement stats. |

`GapIntegral` | Return type: Returns the integral of the log of the absolute gap over deterministic time. This is mainly used to compare how fast the gap closes on a particular instance. Or to evaluate how efficient our LNS code is improving solution. Note: The integral will start counting on the first UpdateGapIntegral() call, since before the difference is assumed to be zero. Important: To report a proper deterministic integral, we only update it on UpdateGapIntegral() which should be called in the main subsolver synchronization loop. Note(user): In the litterature, people use the relative gap to the optimal solution (or the best known one), but this is ill defined in many case (like if the optimal cost is zero), so I prefer this version. |

`GetInnerObjectiveLowerBound` | Return type: The "inner" objective is the CpModelProto objective without scaling/offset. Note that these bound correspond to valid bound for the problem of finding a strictly better objective than the current one. Thus the lower bound is always a valid bound for the global problem, but the upper bound is NOT. |

`GetInnerObjectiveUpperBound` | Return type: |

`GetResponse` | Return type: Arguments: Returns the current solver response. That is the best known response at the time of the call with the best feasible solution and objective bounds. Note that the solver statistics correspond to the last time a better solution was found or SetStatsFromModel() was called. If full response is true, we will do more postprocessing by calling all the AddFinalSolutionPostprocessor() postprocesors. Note that the response given to the AddSolutionCallback() will not call them. |

`InitializeObjective` | Return type: Arguments: Loads the initial objective bounds and keep a reference to the objective to properly display the scaled bounds. This is optional if the model has no objective. This function is not thread safe. |

`LoadDebugSolution` | Return type: Arguments: This should be called after the model is loaded. It will read the file
specified by --cp_model_load_debug_solution and properly fill the
model->Get |

`LoggingIsEnabled` | Return type: |

`LogMessage` | Return type: Arguments: |

`LogPeriodicMessage` | Return type: Arguments: |

`MutableResponse` | Return type: This is here for the few codepath that needs to modify the returned response directly. Note that this do not work in parallel. TODO(user): This can probably be removed. |

`MutableSolutionsRepository` | Return type: |

`NewSolution` | Return type: Arguments: Reads the new solution from the response and update our state. For an optimization problem, we only do something if the solution is strictly improving. TODO(user): Only the following fields from response are accessed here, we might want a tighter API: - solution_info - solution |

`NotifyThatImprovingProblemIsInfeasible` | Return type: Arguments: Changes the solution to reflect the fact that the "improving" problem is infeasible. This means that if we have a solution, we have proven optimality, otherwise the global problem is infeasible. Note that this shouldn't be called before the solution is actually reported. We check for this case in NewSolution(). |

`ProblemIsSolved` | Return type: Returns true if we found the optimal solution or the problem was proven infeasible. Note that if the gap limit is reached, we will also report OPTIMAL and consider the problem solved. |

`set_dump_prefix` | Return type: Arguments: Debug only. Set dump prefix for solutions written to file. |

`SetGapLimitsFromParameters` | Return type: Arguments: Reports OPTIMAL and stop the search if any gap limit are specified and crossed. By default, we only stop when we have the true optimal, which is well defined since we are solving our pure integer problem exactly. |

`SetStatsFromModel` | Return type: Arguments: Sets the statistics in the response to the one of the solver inside the given in-memory model. This does nothing if the model is nullptr. TODO(user): Also support merging statistics together. |

`SetUpdateGapIntegralOnEachChange` | Return type: Arguments: Sets this to true to have the "real" but non-deterministic primal integral. If this is true, then there is no need to manually call UpdateGapIntegral() but it is not an issue to do so. |

`SharedResponseManager` | Return type: Arguments: |

`SolutionsRepository` | Return type: Returns the underlying solution repository where we keep a set of best solutions. |

`Synchronize` | Return type: These functions return the same as the non-synchronized() version but only the values at the last time Synchronize() was called. |

`SynchronizedInnerObjectiveLowerBound` | Return type: |

`SynchronizedInnerObjectiveUpperBound` | Return type: |

`UnregisterCallback` | Return type: Arguments: |

`UpdateGapIntegral` | Return type: |

`UpdateInnerObjectiveBounds` | Return type: Arguments: Updates the inner objective bounds. |