Skip to content

Commit fdfa325

Browse files
authored
Merge pull request #245171 from Homebrew/or-tool_highs
or-tools: add Highs support
2 parents 5c889be + b01a132 commit fdfa325

File tree

1 file changed

+31
-8
lines changed

1 file changed

+31
-8
lines changed

Formula/o/or-tools.rb

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@ class OrTools < Formula
2424
end
2525

2626
bottle do
27-
sha256 cellar: :any, arm64_tahoe: "3d8be92dfa0ed3760900144bf706aed5b2c316d20592ce49b1050c4873b9a3b5"
28-
sha256 cellar: :any, arm64_sequoia: "2bb0f282f2893aceb0b48cf723e1bb88006ec8e9cb6a27434cb2dd47cc639269"
29-
sha256 cellar: :any, arm64_sonoma: "95184c01386c70196cae423bfcfefe730f93ccba4fedc5a176cd4ebae7efbcd2"
30-
sha256 cellar: :any, sonoma: "47fd30353cf1e9506236084691ccc5ed15d052a5c98bad75fd0ffe217a6dbd75"
31-
sha256 arm64_linux: "0b879971f40682344bc0a3df6f1804e36aa3c4bd73be5fb37cbe646ed8712cf8"
32-
sha256 x86_64_linux: "3e0a5958c01be2b053b66cf99004cf1c97cbede0f5f3c40bf7a3bf86c9f8b767"
27+
rebuild 1
28+
sha256 cellar: :any, arm64_tahoe: "68f1360be26513f2c7df331cc9d3a37b6f3a13ad4dc089235af2b566888b5ae5"
29+
sha256 cellar: :any, arm64_sequoia: "74eaae9e575db9fab340a6f2ba562534f23bf701bdcfd6721760455618901f8a"
30+
sha256 cellar: :any, arm64_sonoma: "45b0bbc7a29c9b970d178799a82456045e7803accf760eb0538c830970ea325b"
31+
sha256 cellar: :any, sonoma: "8f2cef449475cecd3eec0b52b607598367203a7e068046a36874b645bd14f5a5"
32+
sha256 arm64_linux: "7082187fb6d7d4d40eaa9989be3a9ef4ed5d075da4478752ba6299319ba623ea"
33+
sha256 x86_64_linux: "ee29a34374a2340acd72ff771bbe37a05908d015f945e84ebf47b26cce200d2d"
3334
end
3435

3536
depends_on "cmake" => [:build, :test]
@@ -40,6 +41,7 @@ class OrTools < Formula
4041
depends_on "clp"
4142
depends_on "coinutils"
4243
depends_on "eigen"
44+
depends_on "highs"
4345
depends_on "openblas"
4446
depends_on "osi"
4547
depends_on "protobuf"
@@ -52,9 +54,8 @@ class OrTools < Formula
5254
patch :DATA
5355

5456
def install
55-
# FIXME: Upstream enabled Highs support in their binary distribution, but our build fails with it.
5657
args = %w[
57-
-DUSE_HIGHS=OFF
58+
-DUSE_HIGHS=ON
5859
-DBUILD_DEPS=OFF
5960
-DBUILD_SAMPLES=OFF
6061
-DBUILD_EXAMPLES=OFF
@@ -112,6 +113,28 @@ def install
112113
*shell_output("pkg-config --cflags --libs #{absl_libs.join(" ")}").chomp.split,
113114
"-o", "simple_sat_program"
114115
system "./simple_sat_program"
116+
117+
# Highs backend
118+
(testpath/"highs_test.cc").write <<~EOS
119+
#include "ortools/linear_solver/linear_solver.h"
120+
using operations_research::MPSolver;
121+
int main() {
122+
if (!MPSolver::SupportsProblemType(MPSolver::HIGHS_LINEAR_PROGRAMMING)) return 1;
123+
MPSolver solver("t", MPSolver::HIGHS_LINEAR_PROGRAMMING);
124+
auto* x = solver.MakeNumVar(0.0, 1.0, "x");
125+
auto* obj = solver.MutableObjective();
126+
obj->SetCoefficient(x, 1.0);
127+
obj->SetMaximization();
128+
if (solver.Solve() != MPSolver::OPTIMAL) return 2;
129+
return x->solution_value() > 0.99 ? 0 : 3;
130+
}
131+
EOS
132+
system ENV.cxx, "-std=c++17", "highs_test.cc",
133+
"-I#{include}", "-L#{lib}", "-lortools",
134+
"-DOR_PROTO_DLL=", "-DPROTOBUF_USE_DLLS",
135+
*shell_output("pkg-config --cflags --libs #{absl_libs.join(" ")}").chomp.split,
136+
"-o", "highs_test"
137+
system "./highs_test"
115138
end
116139
end
117140

0 commit comments

Comments
 (0)