diff --git a/ortools/constraint_solver/csharp/constraint_solver.i b/ortools/constraint_solver/csharp/constraint_solver.i index 4ab4587268..2254a7bf42 100644 --- a/ortools/constraint_solver/csharp/constraint_solver.i +++ b/ortools/constraint_solver/csharp/constraint_solver.i @@ -238,7 +238,7 @@ DEFINE_ARGS_TO_R_CALLBACK( #undef DEFINE_ARGS_TO_R_CALLBACK #undef DEFINE_VOID_TO_STRING_CALLBACK -// RENAMING +// Renaming namespace operations_research { // Decision diff --git a/ortools/dotnet/main.dotnet.dox b/ortools/dotnet/main.dotnet.dox index 5be39f90e1..e6022c0b73 100644 --- a/ortools/dotnet/main.dotnet.dox +++ b/ortools/dotnet/main.dotnet.dox @@ -15,7 +15,7 @@ This repository contains several component: @li @ref Google.OrTools.Graph "Google.OrTools.Graph" @li @ref Google.OrTools.LinearSolver "Google.OrTools.LinearSolver" -@li @ref Google.OrTools.LinearSolver "Google.OrTools.ModelBuilder" +@li @ref Google.OrTools.ModelBuilder "Google.OrTools.ModelBuilder" @li @ref Google.OrTools.Bop "Google.OrTools.Bop" @li @ref Google.OrTools.Glop "Google.OrTools.Glop" @li @ref Google.OrTools.Sat "Google.OrTools.SAT" diff --git a/ortools/linear_solver/csharp/ModelBuilder.cs b/ortools/linear_solver/csharp/ModelBuilder.cs index 612f146f95..95b24a5d8e 100644 --- a/ortools/linear_solver/csharp/ModelBuilder.cs +++ b/ortools/linear_solver/csharp/ModelBuilder.cs @@ -329,9 +329,9 @@ public class ModelBuilder private ModelBuilderHelper helper_; private Dictionary constantMap_; - // Used to process linear exppressions. + // Used to process linear expressions. private SortedDictionary tmp_var_value_map_; private Queue tmp_terms_; } -} // namespace Google.OrTools.ModelBuilder \ No newline at end of file +} // namespace Google.OrTools.ModelBuilder diff --git a/ortools/linear_solver/csharp/ModelSolver.cs b/ortools/linear_solver/csharp/ModelSolver.cs index 6645d765c8..8acaf97b0f 100644 --- a/ortools/linear_solver/csharp/ModelSolver.cs +++ b/ortools/linear_solver/csharp/ModelSolver.cs @@ -125,7 +125,8 @@ public class ModelSolver } /// - /// The best objective value found during search. This raises a ModelSolverException is no solution has been found, or if Solve() has not been called. + /// The best objective value found during search. This raises a ModelSolverException is no solution has been found, + /// or if Solve() has not been called. /// public double ObjectiveValue { @@ -140,7 +141,8 @@ public class ModelSolver } /// - /// The best objective bound found during search. This raises a ModelSolverException is no solution has been found, or if Solve() has not been called. + /// The best objective bound found during search. This raises a ModelSolverException is no solution has been found, + /// or if Solve() has not been called. /// public double BestObjectiveBound { @@ -155,19 +157,20 @@ public class ModelSolver } /// - /// The value of a variable in the current solution. This raises a ModelSolverException is no solution has been found, or if Solve() has not been called. + /// The value of a variable in the current solution. This raises a ModelSolverException is no solution has been + /// found, or if Solve() has not been called. /// public double Value(Variable var) { if (!helper_.HasSolution()) { - throw new ModelSolverException("ModelSolver.Value())", - "Solve() was not called or no solution was found"); + throw new ModelSolverException("ModelSolver.Value())", "Solve() was not called or no solution was found"); } return helper_.VariableValue(var.Index); } /// - /// The reduced cost of a variable in the current solution. This raises a ModelSolverException is no solution has been found, or if Solve() has not been called. + /// The reduced cost of a variable in the current solution. This raises a ModelSolverException is no solution has + /// been found, or if Solve() has not been called. /// public double ReducedCost(Variable var) { @@ -180,7 +183,8 @@ public class ModelSolver } /// - /// The dual value of a linear constraint in the current solution. This raises a ModelSolverException is no solution has been found, or if Solve() has not been called. + /// The dual value of a linear constraint in the current solution. This raises a ModelSolverException is no solution + /// has been found, or if Solve() has not been called. /// public double DualValue(LinearConstraint ct) { @@ -193,7 +197,8 @@ public class ModelSolver } /// - /// The activity of a constraint in the current solution. This raises a ModelSolverException is no solution has been found, or if Solve() has not been called. + /// The activity of a constraint in the current solution. This raises a ModelSolverException is no solution has been + /// found, or if Solve() has not been called. /// public double Activity(LinearConstraint ct) { diff --git a/ortools/linear_solver/proto_solver/gurobi_proto_solver.cc b/ortools/linear_solver/proto_solver/gurobi_proto_solver.cc index 066d68c9af..5673c45bac 100644 --- a/ortools/linear_solver/proto_solver/gurobi_proto_solver.cc +++ b/ortools/linear_solver/proto_solver/gurobi_proto_solver.cc @@ -15,12 +15,15 @@ #include #include +#include #include #include #include #include #include +#include "absl/base/attributes.h" +#include "absl/log/check.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/strings/str_cat.h" @@ -28,8 +31,11 @@ #include "absl/strings/str_join.h" #include "absl/strings/str_split.h" #include "absl/strings/string_view.h" +#include "absl/time/clock.h" +#include "absl/time/time.h" #include "absl/types/optional.h" #include "ortools/base/cleanup.h" +#include "ortools/base/logging.h" #include "ortools/base/status_macros.h" #include "ortools/base/timer.h" #include "ortools/gurobi/environment.h" diff --git a/ortools/linear_solver/samples/AssignmentMb.cs b/ortools/linear_solver/samples/AssignmentMb.cs index 8dbdb59685..52e2195f03 100644 --- a/ortools/linear_solver/samples/AssignmentMb.cs +++ b/ortools/linear_solver/samples/AssignmentMb.cs @@ -30,7 +30,7 @@ public class AssignmentMb int numTasks = costs.GetLength(1); // [END data_model] - // [START model] + // [START model] ModelBuilder model = new ModelBuilder(); // [END model] @@ -58,7 +58,7 @@ public class AssignmentMb { assignedWork.Add(x[i, j]); } - model.Add(assignedWork <= 1); + model.Add(assignedWork <= 1); } // Each task is assigned to exactly one worker. @@ -69,7 +69,7 @@ public class AssignmentMb { assignedWorker.Add(x[i, j]); } - model.Add(assignedWorker == 1); + model.Add(assignedWorker == 1); } // [END constraints] @@ -89,9 +89,10 @@ public class AssignmentMb // [START solver] // Create the solver with the SCIP backend and check it is supported. ModelSolver solver = new ModelSolver("SCIP"); - if (!solver.SolverIsSupported()) return; + if (!solver.SolverIsSupported()) + return; // [END solver] - + // Solve // [START solve] SolveStatus resultStatus = solver.Solve(model); diff --git a/ortools/linear_solver/samples/AssignmentMb.java b/ortools/linear_solver/samples/AssignmentMb.java index 0990d9c229..f2ce85a234 100644 --- a/ortools/linear_solver/samples/AssignmentMb.java +++ b/ortools/linear_solver/samples/AssignmentMb.java @@ -13,21 +13,23 @@ // [START program] package com.google.ortools.linearsolver.samples; + // [START import] import com.google.ortools.Loader; -import com.google.ortools.modelbuilder.LinearConstraint; import com.google.ortools.modelbuilder.LinearExpr; import com.google.ortools.modelbuilder.LinearExprBuilder; import com.google.ortools.modelbuilder.ModelBuilder; import com.google.ortools.modelbuilder.ModelSolver; import com.google.ortools.modelbuilder.SolveStatus; import com.google.ortools.modelbuilder.Variable; + // [END import] /** MIP example that solves an assignment problem. */ public class AssignmentMb { public static void main(String[] args) { Loader.loadNativeLibraries(); + // Data // [START data_model] double[][] costs = { @@ -92,7 +94,9 @@ public class AssignmentMb { // [START solver] // Create the solver with the SCIP backend and check it is supported. ModelSolver solver = new ModelSolver("scip"); - if (!solver.solverIsSupported()) return; + if (!solver.solverIsSupported()) { + return; + } // [END solver] // [START solve] diff --git a/ortools/linear_solver/samples/BUILD.bazel b/ortools/linear_solver/samples/BUILD.bazel index a89996f707..00853e0e8c 100644 --- a/ortools/linear_solver/samples/BUILD.bazel +++ b/ortools/linear_solver/samples/BUILD.bazel @@ -36,6 +36,10 @@ code_sample_cc(name = "stigler_diet") # Model Builder +code_sample_java(name = "AssignmentMb") + +code_sample_java(name = "BinPackingMb") + code_sample_java(name = "CloneModelMb") code_sample_java(name = "SimpleLpProgramMb") diff --git a/ortools/linear_solver/samples/BinPackingMb.cs b/ortools/linear_solver/samples/BinPackingMb.cs index 9719be46ba..cee853d690 100644 --- a/ortools/linear_solver/samples/BinPackingMb.cs +++ b/ortools/linear_solver/samples/BinPackingMb.cs @@ -86,9 +86,10 @@ public class BinPackingMb // [START solver] // Create the solver with the SCIP backend and check it is supported. ModelSolver solver = new ModelSolver("SCIP"); - if (!solver.SolverIsSupported()) return; + if (!solver.SolverIsSupported()) + return; // [END solver] - + // [START solve] SolveStatus resultStatus = solver.Solve(model); // [END solve] diff --git a/ortools/linear_solver/samples/BinPackingMb.java b/ortools/linear_solver/samples/BinPackingMb.java index b76369f860..0328224ef9 100644 --- a/ortools/linear_solver/samples/BinPackingMb.java +++ b/ortools/linear_solver/samples/BinPackingMb.java @@ -14,15 +14,16 @@ // MIP example that solves a bin packing problem. // [START program] package com.google.ortools.linearsolver.samples; + // [START import] import com.google.ortools.Loader; -import com.google.ortools.modelbuilder.LinearConstraint; import com.google.ortools.modelbuilder.LinearExpr; import com.google.ortools.modelbuilder.LinearExprBuilder; import com.google.ortools.modelbuilder.ModelBuilder; import com.google.ortools.modelbuilder.ModelSolver; import com.google.ortools.modelbuilder.SolveStatus; import com.google.ortools.modelbuilder.Variable; + // [END import] /** Bin packing problem. */ @@ -35,6 +36,7 @@ public class BinPackingMb { public final int numBins = weights.length; public final int binCapacity = 100; } + // [END data_model] public static void main(String[] args) throws Exception { @@ -71,7 +73,7 @@ public class BinPackingMb { model.addEquality(oneCopy, 1); } - // The bin capacity contraint for bin j is + // The bin capacity constraint for bin j is // sum_i w_i x_ij <= C*y_j // To define this constraint, first subtract the left side from the right to get // 0 <= C*y_j - sum_i w_i x_ij @@ -95,7 +97,9 @@ public class BinPackingMb { // [START solver] // Create the solver with the SCIP backend and check it is supported. ModelSolver solver = new ModelSolver("scip"); - if (!solver.solverIsSupported()) return; + if (!solver.solverIsSupported()) { + return; + } // [END solver] // [START solve] diff --git a/ortools/linear_solver/samples/CloneModelMb.cs b/ortools/linear_solver/samples/CloneModelMb.cs index 7e68d9a57d..f4c79a24ac 100644 --- a/ortools/linear_solver/samples/CloneModelMb.cs +++ b/ortools/linear_solver/samples/CloneModelMb.cs @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// Minimal example to call the SCIP solver. +// Minimal example to clone a model. // [START program] // [START import] using System; @@ -63,12 +63,13 @@ public class SimpleMipProgramMb Console.WriteLine("Number of constraints in the original model = " + model.ConstraintsCount()); Console.WriteLine("Number of constraints in the cloned model = " + modelCopy.ConstraintsCount()); - // [END clone] + // [END clone] // [START solver] - // Create the solver with the SCIP backend and checks it is supported. - ModelSolver solver = new ModelSolver("SCIP"); - if (!solver.SolverIsSupported()) return; + // Create the solver with the CP-SAT backend and checks it is supported. + ModelSolver solver = new ModelSolver("sat"); + if (!solver.SolverIsSupported()) + return; // [END solver] // [START solve] diff --git a/ortools/linear_solver/samples/CloneModelMb.java b/ortools/linear_solver/samples/CloneModelMb.java index c351cb1de8..8c34148f2d 100644 --- a/ortools/linear_solver/samples/CloneModelMb.java +++ b/ortools/linear_solver/samples/CloneModelMb.java @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// Minimal example to call the MIP solver. +// Minimal example to clone a model. // [START program] package com.google.ortools.linearsolver.samples; @@ -75,9 +75,11 @@ public final class CloneModelMb { // [END clone] // [START solver] - // Create the solver with the SCIP backend and check it is supported. - ModelSolver solver = new ModelSolver("scip"); - if (!solver.solverIsSupported()) return; + // Create the solver with the CP-SAT backend and check it is supported. + ModelSolver solver = new ModelSolver("sat"); + if (!solver.solverIsSupported()) { + return; + } // [END solver] // [START solve] diff --git a/ortools/linear_solver/samples/SimpleMipProgramMb.cs b/ortools/linear_solver/samples/SimpleMipProgramMb.cs index b0f87cb6b5..e3f8875d7b 100644 --- a/ortools/linear_solver/samples/SimpleMipProgramMb.cs +++ b/ortools/linear_solver/samples/SimpleMipProgramMb.cs @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// Minimal example to call the SCIP solver. +// Minimal example to solve a MIP problem. // [START program] // [START import] using System; diff --git a/ortools/linear_solver/samples/SimpleMipProgramMb.java b/ortools/linear_solver/samples/SimpleMipProgramMb.java index 66c2969d1a..4622ed497b 100644 --- a/ortools/linear_solver/samples/SimpleMipProgramMb.java +++ b/ortools/linear_solver/samples/SimpleMipProgramMb.java @@ -56,9 +56,15 @@ public final class SimpleMipProgramMb { model.maximize(LinearExpr.newBuilder().add(x).addTerm(y, 10.0)); // [END objective] - // [START solve] - // Solve with the SCIP MIP solver. + // [START solver] + // Create the solver with the SCIP backend and check it is supported. ModelSolver solver = new ModelSolver("scip"); + if (!solver.solverIsSupported()) { + return; + } + // [END solver] + + // [START solve] final SolveStatus status = solver.solve(model); // [END solve] diff --git a/ortools/util/csharp/vector.i b/ortools/util/csharp/vector.i index 92fc4e9ddb..337a6b7e69 100644 --- a/ortools/util/csharp/vector.i +++ b/ortools/util/csharp/vector.i @@ -251,4 +251,3 @@ // By default vector> is mapped to a jagged array i.e. .Net type[][] // If you want a regular matrix i.e. .Net type[,] use REGULAR_MATRIX_AS_CSHARP_ARRAY instead. %include "std_vector.i" -