Stay organized with collections
Save and categorize content based on your preferences.
C++ Reference: class SubSolver
Note: This documentation is automatically generated.
The API used for distributing work. Each subsolver can generate tasks and
synchronize itself with the rest of the world.
Note that currently only the main thread interact with subsolvers. Only the
tasks generated by GenerateTask() are executed in parallel in a threadpool.
Returns a task to run. The task_id is just an ever increasing counter that
correspond to the number of total calls to GenerateTask().
TODO(user): We could use a more complex selection logic and pass in the
deterministic time limit this subtask should run for. Unclear at this
stage.
Returns the score as updated by the completed tasks before the last
Synchronize() call. Everything else being equal, we prefer to run a
SubSolver with the highest score.
TODO(user): This is unused for now.
Synchronizes with the external world from this SubSolver point of view.
Also incorporate the results of the latest completed tasks if any.
Note(user): The intended implementation for determinism is that tasks
update asynchronously (and so non-deterministically) global "shared"
classes, but this global state is incorporated by the Subsolver only when
Synchronize() is called.
Returns true iff GenerateTask() can be called.
Note(user): In the current design, a SubSolver is never deleted until the
end of the Solve() that created it. But is is okay to always return false
here and release the memory used by the Subsolver internal if there is no
need to call this Subsolver ever again. The overhead of iterating over it
in the main solver loop should be minimal.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-08-06 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eSubSolver\u003c/code\u003e class in C++ distributes work by generating tasks that are executed in parallel within a threadpool.\u003c/p\u003e\n"],["\u003cp\u003eSubsolvers primarily interact with the main thread and utilize the \u003ccode\u003eGenerateTask()\u003c/code\u003e method to produce tasks for parallel execution.\u003c/p\u003e\n"],["\u003cp\u003eSynchronization with the external environment and incorporating task results are achieved through the \u003ccode\u003eSynchronize()\u003c/code\u003e method.\u003c/p\u003e\n"],["\u003cp\u003eEach subsolver can provide a score and deterministic time which might be used for task selection and prioritization.\u003c/p\u003e\n"]]],["SubSolvers, used for distributing work, generate tasks via `GenerateTask()`, which are executed in parallel. `Synchronize()` integrates results from completed tasks. Key information includes the `deterministic_time` spent and the `score` of tasks. `TaskIsAvailable()` determines if more tasks can be generated. `name()` and `StatisticsString()` provide identification and search statistics respectively. Only the main thread interacts with subsolvers.\n"],null,["C++ Reference: class SubSolver\n\n\nNote: This documentation is automatically generated.\nThe API used for distributing work. Each subsolver can generate tasks and synchronize itself with the rest of the world. \n\nNote that currently only the main thread interact with subsolvers. Only the tasks generated by GenerateTask() are executed in parallel in a threadpool.\n\n| Method ||\n|--------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [`deterministic_time`](https://github.com/google/or-tools/blob/v9.4/ortools/sat/subsolver.h#L83) | Return type: `double ` Returns the total deterministic time spend by the completed tasks before the last Synchronize() call. |\n| [`GenerateTask`](https://github.com/google/or-tools/blob/v9.4/ortools/sat/subsolver.h#L63) | Return type: `virtual std::function\u003cvoid()\u003e ` Arguments: `int64_t task_id` Returns a task to run. The task_id is just an ever increasing counter that correspond to the number of total calls to GenerateTask(). TODO(user): We could use a more complex selection logic and pass in the deterministic time limit this subtask should run for. Unclear at this stage. |\n| [`name`](https://github.com/google/or-tools/blob/v9.4/ortools/sat/subsolver.h#L86) | Return type: `std::string ` Returns the name of this SubSolver. Used in logs. |\n| [`score`](https://github.com/google/or-tools/blob/v9.4/ortools/sat/subsolver.h#L79) | Return type: `double ` Returns the score as updated by the completed tasks before the last Synchronize() call. Everything else being equal, we prefer to run a SubSolver with the highest score. TODO(user): This is unused for now. |\n| [`StatisticsString`](https://github.com/google/or-tools/blob/v9.4/ortools/sat/subsolver.h#L89) | Return type: `virtual std::string ` Returns search statistics. |\n| [`SubSolver`](https://github.com/google/or-tools/blob/v9.4/ortools/sat/subsolver.h#L45) | Return type: `explicit ` Arguments: `const std::string& name` \u003cbr /\u003e |\n| [`~SubSolver`](https://github.com/google/or-tools/blob/v9.4/ortools/sat/subsolver.h#L46) | Return type: `virtual ` \u003cbr /\u003e |\n| [`Synchronize`](https://github.com/google/or-tools/blob/v9.4/ortools/sat/subsolver.h#L72) | Return type: `virtual void ` Synchronizes with the external world from this SubSolver point of view. Also incorporate the results of the latest completed tasks if any. Note(user): The intended implementation for determinism is that tasks update asynchronously (and so non-deterministically) global \"shared\" classes, but this global state is incorporated by the Subsolver only when Synchronize() is called. |\n| [`TaskIsAvailable`](https://github.com/google/or-tools/blob/v9.4/ortools/sat/subsolver.h#L55) | Return type: `virtual bool ` Returns true iff GenerateTask() can be called. Note(user): In the current design, a SubSolver is never deleted until the end of the Solve() that created it. But is is okay to always return false here and release the memory used by the Subsolver internal if there is no need to call this Subsolver ever again. The overhead of iterating over it in the main solver loop should be minimal. |"]]