Skip to content

Commit

Permalink
Merge branch 'v99bugfix' of github.com:google/or-tools into v99bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
lperron committed Oct 13, 2024
2 parents 711490c + b55d393 commit 98bd462
Show file tree
Hide file tree
Showing 19 changed files with 146 additions and 147 deletions.
1 change: 0 additions & 1 deletion .github/workflows/amd64_linux_bazel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ jobs:
strategy:
matrix:
python: [
{version: '3.9'},
{version: '3.10'},
{version: '3.11'},
{version: '3.12'},
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/amd64_macos_bazel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ jobs:
strategy:
matrix:
python: [
{version: '3.9'},
{version: '3.10'},
{version: '3.11'},
{version: '3.12'},
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/amd64_windows_bazel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ jobs:
matrix:
runner: [windows-2022]
python: [
{version: '3.9'},
{version: '3.10'},
{version: '3.11'},
{version: '3.12'},
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/arm64_macos_bazel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ jobs:
strategy:
matrix:
python: [
{version: '3.9'},
{version: '3.10'},
{version: '3.11'},
{version: '3.12'},
Expand Down
1 change: 1 addition & 0 deletions bazel/notebook_requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ jupyter-server==2.14.2
tornado==6.4.1
Pygments==2.15.0
jsonschema==4.19.0
jinja2==3.1.4
11 changes: 6 additions & 5 deletions bazel/notebook_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#
# This file is autogenerated by pip-compile with Python 3.12
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# bazel run //bazel:notebook_requirements.update
#
absl-py==2.0.0
absl-py==2.1.0
# via -r bazel/notebook_requirements.in
anyio==4.0.0
# via
Expand Down Expand Up @@ -85,8 +85,9 @@ isoduration==20.11.0
# via jsonschema
jedi==0.19.0
# via ipython
jinja2==3.1.3
jinja2==3.1.4
# via
# -r bazel/notebook_requirements.in
# jupyter-server
# jupyterlab
# jupyterlab-server
Expand Down Expand Up @@ -176,7 +177,7 @@ notebook-shim==0.2.3
# via
# jupyterlab
# notebook
numpy==2.1.0
numpy==2.1.1
# via
# -r bazel/notebook_requirements.in
# pandas
Expand Down Expand Up @@ -215,7 +216,7 @@ prometheus-client==0.17.1
# via jupyter-server
prompt-toolkit==3.0.39
# via ipython
protobuf==5.27.3
protobuf==5.27.5
# via
# -r bazel/notebook_requirements.in
# mypy-protobuf
Expand Down
2 changes: 1 addition & 1 deletion examples/java/LinearProgramming.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private static void runLinearProgrammingExample(String solverType, boolean print
System.out.println("Number of constraints = " + solver.numConstraints());

if (printModel) {
String model = solver.exportModelAsLpFormat();
String model = solver.exportModelAsLpFormat(/* obfuscate = */false);
System.out.println(model);
}

Expand Down
2 changes: 1 addition & 1 deletion ortools/linear_solver/java/linear_solver.i
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ PROTO2_RETURN(
/**
* Export the loaded model in LP format.
*/
std::string exportModelAsLpFormat(bool obfuscate) {
std::string exportModelAsLpFormat(bool obfuscate = false) {
operations_research::MPModelExportOptions options;
options.obfuscate = obfuscate;
operations_research::MPModelProto model;
Expand Down
4 changes: 2 additions & 2 deletions ortools/linear_solver/python/linear_solver.i
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,8 @@ PY_CONVERT(MPVariable);
%rename (LookupVariable) operations_research::MPSolver::LookupVariableOrNull;
%unignore operations_research::MPSolver::SetSolverSpecificParametersAsString;
%unignore operations_research::MPSolver::NextSolution;
%unignore operations_research::MPSolver::ExportModelAsLpFormat;
%unignore operations_research::MPSolver::ExportModelAsMpsFormat;
%unignore operations_research::MPSolver::ExportModelAsLpFormat(bool);
%unignore operations_research::MPSolver::ExportModelAsMpsFormat(bool, bool);
%unignore operations_research::MPSolver::WriteModelToMpsFile;
%unignore operations_research::MPSolver::Write;

Expand Down
2 changes: 1 addition & 1 deletion ortools/linear_solver/python/lp_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def testExportToMps(self):
sum_of_vars = sum([x1, x2, x3])
c2 = solver.Add(sum_of_vars <= 100.0, "OtherConstraintName")

mps_str = solver.ExportModelAsMpsFormat(fixed_format=False, obfuscated=False)
mps_str = solver.ExportModelAsMpsFormat(fixed_format=False, obfuscate=False)
self.assertIn("ExportMps", mps_str)


Expand Down
8 changes: 8 additions & 0 deletions ortools/lp_data/lp_data_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,14 @@ Fractional LpScalingHelper::UnscaleDualValue(RowIndex row,
return value / (RowUnscalingFactor(row) * objective_scaling_factor_);
}

Fractional LpScalingHelper::UnscaleLeftSolveValue(RowIndex row,
Fractional value) const {
// In the scaled domain, we are takeing a sum coeff * scaling * row,
// so to get the same effect in the unscaled domain, we want to multiply by
// (coeff * scaling).
return value / RowUnscalingFactor(row);
}

Fractional LpScalingHelper::UnscaleConstraintActivity(RowIndex row,
Fractional value) const {
// The activity move with the row_scale and the bound_scaling_factor.
Expand Down
1 change: 1 addition & 0 deletions ortools/lp_data/lp_data_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class LpScalingHelper {
Fractional UnscaleVariableValue(ColIndex col, Fractional value) const;
Fractional UnscaleReducedCost(ColIndex col, Fractional value) const;
Fractional UnscaleDualValue(RowIndex row, Fractional value) const;
Fractional UnscaleLeftSolveValue(RowIndex row, Fractional value) const;
Fractional UnscaleConstraintActivity(RowIndex row, Fractional value) const;

// Unscale a row vector v such that v.B = unit_row. When basis_col is the
Expand Down
2 changes: 2 additions & 0 deletions ortools/sat/cp_model_presolve.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1787,6 +1787,8 @@ bool CpModelPresolver::PresolveIntProd(ConstraintProto* ct) {
linear_for_true);
AddLinearExpressionToLinearConstraint(ct->int_prod().target(), -1,
linear_for_true);
context_->CanonicalizeLinearConstraint(constraint_for_false);
context_->CanonicalizeLinearConstraint(constraint_for_true);
context_->UpdateRuleStats("int_prod: boolean affine term");
context_->UpdateNewConstraintsVariableUsage();
return RemoveConstraint(ct);
Expand Down
3 changes: 3 additions & 0 deletions ortools/sat/cuts.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ struct CutTerm {
bool IsBoolean() const { return bound_diff == 1; }
bool IsSimple() const { return expr_coeffs[1] == 0; }
bool HasRelevantLpValue() const { return lp_value > 1e-2; }
bool IsFractional() const {
return std::abs(lp_value - std::round(lp_value)) > 1e-4;
}
double LpDistToMaxValue() const {
return static_cast<double>(bound_diff.value()) - lp_value;
}
Expand Down
Loading

0 comments on commit 98bd462

Please sign in to comment.