diff --git a/ortools/java/com/google/ortools/sat/CpModel.java b/ortools/java/com/google/ortools/sat/CpModel.java index ce9a271d91..f7fd53df79 100644 --- a/ortools/java/com/google/ortools/sat/CpModel.java +++ b/ortools/java/com/google/ortools/sat/CpModel.java @@ -1003,6 +1003,11 @@ public final class CpModel { return SatHelper.validateModel(model()); } + /** Write the model as a ascii protocol buffer to 'file'.*/ + public Boolean ExportToFile(String file) { + return SatHelper.writeModelToFile(file); + } + // Helpers long[] toLongArray(int[] values) { diff --git a/ortools/sat/csharp/CpModel.cs b/ortools/sat/csharp/CpModel.cs index 803ee6d2fa..8232cb94ad 100644 --- a/ortools/sat/csharp/CpModel.cs +++ b/ortools/sat/csharp/CpModel.cs @@ -323,10 +323,10 @@ namespace Google.OrTools.Sat res.Demands.Add(Convert.ToInt64(d)); } - ct.Proto.Reservoir = res; res.MinLevel = min_level; res.MaxLevel = max_level; - + ct.Proto.Reservoir = res; + return ct; } @@ -350,10 +350,11 @@ namespace Google.OrTools.Sat { res.Actives.Add(var.Index); } + res.MinLevel = min_level; res.MaxLevel = max_level; - ct.Proto.Reservoir = res; + return ct; } @@ -690,7 +691,7 @@ namespace Google.OrTools.Sat } foreach (KeyValuePair it in dict) { - objective.Vars.Add(it.Key.Index); + objective.Vars.Add(it.Key.Index); objective.Coeffs.Add(minimize ? it.Value : -it.Value); } } @@ -702,7 +703,7 @@ namespace Google.OrTools.Sat return SatHelper.ModelStats(model_); } - public Boolean WriteModelToFile(String filename) { + public Boolean ExportToFile(String filename) { return SatHelper.WriteModelToFile(model_, filename); } diff --git a/ortools/sat/java/sat.i b/ortools/sat/java/sat.i index 94000190e1..3406df96d3 100644 --- a/ortools/sat/java/sat.i +++ b/ortools/sat/java/sat.i @@ -62,6 +62,7 @@ PROTO2_RETURN(operations_research::sat::CpSolverResponse, %rename (solverResponseStats) operations_research::sat::SatHelper::SolverResponseStats; %rename (validateModel) operations_research::sat::SatHelper::ValidateModel; %rename (variableDomain) operations_research::sat::SatHelper::VariableDomain; +%rename (writeModelToFile) operations_research::sat::SatHelper::WriteModelToFile; %typemap(javaimports) operations_research::sat::SatHelper %{ import com.google.ortools.util.Domain; diff --git a/ortools/sat/python/cp_model.py b/ortools/sat/python/cp_model.py index 12f05f7249..38afad05ad 100644 --- a/ortools/sat/python/cp_model.py +++ b/ortools/sat/python/cp_model.py @@ -1505,6 +1505,10 @@ class CpModel(object): """Returns a string indicating that the model is invalid.""" return pywrapsat.SatHelper.ValidateModel(self.__model) + def ExportToFile(self, file): + """Write the model as a ascii protocol buffer to 'file'.""" + return pywrapsat.SatHelper.WriteModelToFile(file) + def AssertIsBooleanVariable(self, x): if isinstance(x, IntVar): var = self.__model.variables[x.Index()] diff --git a/ortools/sat/python/sat.i b/ortools/sat/python/sat.i index b2940ba1da..5cdf0934d3 100644 --- a/ortools/sat/python/sat.i +++ b/ortools/sat/python/sat.i @@ -61,6 +61,7 @@ PY_PROTO_TYPEMAP(ortools.sat.sat_parameters_pb2, %unignore operations_research::sat::SatHelper::SolverResponseStats; %unignore operations_research::sat::SatHelper::ValidateModel; %unignore operations_research::sat::SatHelper::VariableDomain; +%unignore operations_research::sat::SatHelper::WriteModelToFile; %feature("director") operations_research::sat::SolutionCallback; %unignore operations_research::sat::SolutionCallback; @@ -98,4 +99,3 @@ PY_PROTO_TYPEMAP(ortools.sat.sat_parameters_pb2, %include "ortools/sat/swig_helper.h" %unignoreall -