sync with internal code
This commit is contained in:
@@ -264,7 +264,7 @@ void WriteProtoToFileOrDie(const google::protobuf::Message& proto,
|
||||
}
|
||||
|
||||
util::Status GetTextProto(const absl::string_view& filename,
|
||||
google::protobuf::Message* proto, int flags) {
|
||||
google::protobuf::Message* proto, int flags) {
|
||||
if (flags == Defaults()) {
|
||||
if (ReadFileToProto(filename, proto)) return util::Status::OK;
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ util::Status Open(const absl::string_view& filename,
|
||||
File* OpenOrDie(const absl::string_view& filename,
|
||||
const absl::string_view& mode, int flags);
|
||||
util::Status GetTextProto(const absl::string_view& filename,
|
||||
google::protobuf::Message* proto, int flags);
|
||||
google::protobuf::Message* proto, int flags);
|
||||
util::Status SetTextProto(const absl::string_view& filename,
|
||||
const google::protobuf::Message& proto, int flags);
|
||||
util::Status SetBinaryProto(const absl::string_view& filename,
|
||||
|
||||
@@ -3462,8 +3462,8 @@ class ModelVisitor : public BaseObject {
|
||||
/// ----- Virtual methods for visitors -----
|
||||
|
||||
/// Begin/End visit element.
|
||||
virtual void BeginVisitModel(const std::string& solver_name);
|
||||
virtual void EndVisitModel(const std::string& solver_name);
|
||||
virtual void BeginVisitModel(const std::string& type_name);
|
||||
virtual void EndVisitModel(const std::string& type_name);
|
||||
virtual void BeginVisitConstraint(const std::string& type_name,
|
||||
const Constraint* const constraint);
|
||||
virtual void EndVisitConstraint(const std::string& type_name,
|
||||
|
||||
@@ -22,7 +22,7 @@ from ortools.constraint_solver import routing_enums_pb2
|
||||
|
||||
|
||||
# [START data_model]
|
||||
class DataModel: # pylint: disable=too-many-instance-attributes
|
||||
class DataModel(object): # pylint: disable=too-many-instance-attributes
|
||||
"""Stores the data for the problem."""
|
||||
|
||||
def __init__(self, args):
|
||||
@@ -253,7 +253,7 @@ class DataModel: # pylint: disable=too-many-instance-attributes
|
||||
###########
|
||||
# Printer #
|
||||
###########
|
||||
class GoogleColorPalette():
|
||||
class GoogleColorPalette(object):
|
||||
"""Google color codes palette."""
|
||||
|
||||
def __init__(self):
|
||||
@@ -288,7 +288,7 @@ class GoogleColorPalette():
|
||||
return dict(self._colors)[name]
|
||||
|
||||
|
||||
class SVG():
|
||||
class SVG(object):
|
||||
"""SVG draw primitives."""
|
||||
|
||||
@staticmethod
|
||||
@@ -375,7 +375,7 @@ class SVG():
|
||||
txt=text))
|
||||
|
||||
|
||||
class SVGPrinter(): # pylint: disable=too-many-instance-attributes
|
||||
class SVGPrinter(object): # pylint: disable=too-many-instance-attributes
|
||||
"""Generate Problem as svg file to stdout."""
|
||||
|
||||
# pylint: disable=too-many-arguments
|
||||
|
||||
@@ -457,9 +457,9 @@ class RoutingModel {
|
||||
/// model.
|
||||
/// Returns false if a dimension with the same name has already been created
|
||||
/// (and doesn't create the new dimension).
|
||||
bool AddMatrixDimension(std::vector<std::vector<int64>> values,
|
||||
int64 capacity, bool fix_start_cumul_to_zero,
|
||||
const std::string& name);
|
||||
bool AddMatrixDimension(
|
||||
std::vector<std::vector<int64> /*needed_for_swig*/> values,
|
||||
int64 capacity, bool fix_start_cumul_to_zero, const std::string& name);
|
||||
/// Creates a dimension with transits depending on the cumuls of another
|
||||
/// dimension. 'pure_transits' are the per-vehicle fixed transits as above.
|
||||
/// 'dependent_transits' is a vector containing for each vehicle an index to a
|
||||
@@ -476,6 +476,7 @@ class RoutingModel {
|
||||
pure_transits, dependent_transits, base_dimension, slack_max,
|
||||
std::move(vehicle_capacities), fix_start_cumul_to_zero, name);
|
||||
}
|
||||
|
||||
/// As above, but pure_transits are taken to be zero evaluators.
|
||||
bool AddDimensionDependentDimensionWithVehicleCapacity(
|
||||
const std::vector<int>& transits, const RoutingDimension* base_dimension,
|
||||
|
||||
@@ -66,33 +66,25 @@ public class SimpleMipProgram {
|
||||
|
||||
// [START solve]
|
||||
final MPSolver.ResultStatus resultStatus = solver.solve();
|
||||
// Check that the problem has an optimal solution.
|
||||
if (resultStatus != MPSolver.ResultStatus.OPTIMAL) {
|
||||
System.err.println("The problem does not have an optimal solution!");
|
||||
return;
|
||||
}
|
||||
// Verify that the solution satisfies all constraints (when using solvers
|
||||
// others than GLOP_LINEAR_PROGRAMMING, this is highly recommended!).
|
||||
if (!solver.verifySolution(/*tolerance=*/1e-7, /*log_errors=*/true)) {
|
||||
System.err.println("The solution returned by the solver violated the"
|
||||
+ " problem constraints by at least 1e-7");
|
||||
return;
|
||||
}
|
||||
// [END solve]
|
||||
|
||||
// [START print_solution]
|
||||
System.out.println("Solution:");
|
||||
System.out.println("Objective value = " + objective.value());
|
||||
System.out.println("x = " + x.solutionValue());
|
||||
System.out.println("y = " + y.solutionValue());
|
||||
// [END print_solution]
|
||||
if (resultStatus == MPSolver.ResultStatus.OPTIMAL) {
|
||||
System.out.println("Solution:");
|
||||
System.out.println("Objective value = " + objective.value());
|
||||
System.out.println("x = " + x.solutionValue());
|
||||
System.out.println("y = " + y.solutionValue());
|
||||
// [END print_solution]
|
||||
|
||||
// [START advanced]
|
||||
System.out.println("\nAdvanced usage:");
|
||||
System.out.println("Problem solved in " + solver.wallTime() + " milliseconds");
|
||||
System.out.println("Problem solved in " + solver.iterations() + " iterations");
|
||||
System.out.println("Problem solved in " + solver.nodes() + " branch-and-bound nodes");
|
||||
// [END advanced]
|
||||
// [START advanced]
|
||||
System.out.println("\nAdvanced usage:");
|
||||
System.out.println("Problem solved in " + solver.wallTime() + " milliseconds");
|
||||
System.out.println("Problem solved in " + solver.iterations() + " iterations");
|
||||
System.out.println("Problem solved in " + solver.nodes() + " branch-and-bound nodes");
|
||||
// [END advanced]
|
||||
} else {
|
||||
System.err.println("The problem does not have an optimal solution!");
|
||||
}
|
||||
}
|
||||
}
|
||||
// [END program]
|
||||
|
||||
@@ -226,16 +226,18 @@ class Domain {
|
||||
*/
|
||||
Domain ContinuousMultiplicationBy(int64 coeff) const;
|
||||
|
||||
/// Returns a super-set of MultiplicationBy() to avoid the explosion in the
|
||||
/// representation size. This behaves as if we replace the set D of
|
||||
/// non-adjacent integer intervals by the set of floating-point element in the
|
||||
/// same intervals.
|
||||
///
|
||||
/// For instance, [1, 100] * 2 will be transformed in [2, 200] and not in
|
||||
/// [2][4][6]...[200] like in MultiplicationBy(). Note that this would be
|
||||
/// similar to a InverseDivisionBy(), but not quite the same because if we
|
||||
/// look for {x ∈ Int64, ∃ e ∈ D, x / coeff = e}, then we will get [2, 201] in
|
||||
/// the case above.
|
||||
/**
|
||||
* Returns a superset of MultiplicationBy() to avoid the explosion in the
|
||||
* representation size. This behaves as if we replace the set D of
|
||||
* non-adjacent integer intervals by the set of floating-point elements in the
|
||||
* same intervals.
|
||||
*
|
||||
* For instance, [1, 100] * 2 will be transformed in [2, 200] and not in
|
||||
* [2][4][6]...[200] like in MultiplicationBy(). Note that this would be
|
||||
* similar to a InverseDivisionBy(), but not quite the same because if we
|
||||
* look for {x ∈ Int64, ∃ e ∈ D, x / coeff = e}, then we will get [2, 201] in
|
||||
* the case above.
|
||||
*/
|
||||
Domain ContinuousMultiplicationBy(const Domain& domain) const;
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user