add export model api with decision builder.

This commit is contained in:
lperron@google.com
2012-08-27 16:01:37 +00:00
parent 63744c6d83
commit bdddd9d2d4
2 changed files with 15 additions and 0 deletions

View File

@@ -1065,6 +1065,11 @@ class Solver {
// the objective and limits to the protobuf.
void ExportModel(const std::vector<SearchMonitor*>& monitors,
CPModelProto* const proto) const;
// Exports the model to protobuf. Search monitors are useful to pass
// the objective and limits to the protobuf.
void ExportModel(const std::vector<SearchMonitor*>& monitors,
CPModelProto* const proto,
DecisionBuilder* const db) const;
// Loads the model into the solver, and returns true upon success.
bool LoadModel(const CPModelProto& proto);
// Loads the model into the solver, appends search monitors to monitors,

View File

@@ -2606,6 +2606,16 @@ bool CPModelLoader::ScanOneArgument(int type_index,
// ----- Solver API -----
void Solver::ExportModel(const std::vector<SearchMonitor*>& monitors,
CPModelProto* const model_proto,
DecisionBuilder* const db) const {
CHECK_NOTNULL(model_proto);
FirstPassVisitor first_pass;
Accept(&first_pass, monitors, db);
SecondPassVisitor second_pass(first_pass, model_proto);
Accept(&second_pass, monitors, db);
}
void Solver::ExportModel(const std::vector<SearchMonitor*>& monitors,
CPModelProto* const model_proto) const {
CHECK_NOTNULL(model_proto);