or-tools 0.1.5 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +3 -7
- data/ext/or-tools/extconf.rb +19 -6
- data/ext/or-tools/vendor.rb +95 -0
- data/lib/or_tools/version.rb +1 -1
- metadata +3 -3
- data/lib/or_tools/ext.bundle +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4377b9acdd93be666c700e05fb56cf01e59f088cf149f345ab888ef018c82d04
|
4
|
+
data.tar.gz: f32d95eb857cf479db372f4c0c27b18590bb9137aa72a9b6e478789830b7ea68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab952c566d3f84c57cce0b843c27ad6e3fa9c06f4e85b273af2c82564403cd6bb88e8f8ae1d39c21f5732e4d3415729b8d4bd87418a34f0d02c588d816ab9d49
|
7
|
+
data.tar.gz: 95a03e432680341c029e21ae2148385c1628a7df127ea8707991a47d087f37cd5ebb4288518f16b1cfd7c84c03a254c0cf8c26c5c8d574b949c3ed3901ca9cfe
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -6,18 +6,14 @@
|
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
9
|
-
Download the [OR-Tools C++ library](https://developers.google.com/optimization/install/cpp). Then run:
|
10
|
-
|
11
|
-
```sh
|
12
|
-
bundle config build.or-tools --with-or-tools-dir=/path/to/or-tools
|
13
|
-
```
|
14
|
-
|
15
9
|
Add this line to your application’s Gemfile:
|
16
10
|
|
17
11
|
```ruby
|
18
12
|
gem 'or-tools'
|
19
13
|
```
|
20
14
|
|
15
|
+
Installation can take a few minutes as OR-Tools downloads and builds.
|
16
|
+
|
21
17
|
## Getting Started
|
22
18
|
|
23
19
|
Linear Optimization
|
@@ -1951,7 +1947,7 @@ To get started with development:
|
|
1951
1947
|
git clone https://github.com/ankane/or-tools.git
|
1952
1948
|
cd or-tools
|
1953
1949
|
bundle install
|
1954
|
-
bundle exec rake compile
|
1950
|
+
bundle exec rake compile
|
1955
1951
|
bundle exec rake test
|
1956
1952
|
```
|
1957
1953
|
|
data/ext/or-tools/extconf.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require "mkmf-rice"
|
2
2
|
|
3
|
-
|
3
|
+
raise "Missing stdc++" unless have_library("stdc++")
|
4
4
|
|
5
5
|
$CXXFLAGS << " -std=c++11 -DUSE_CBC"
|
6
6
|
|
@@ -8,15 +8,28 @@ $CXXFLAGS << " -std=c++11 -DUSE_CBC"
|
|
8
8
|
$CXXFLAGS << " -Wno-sign-compare -Wno-shorten-64-to-32 -Wno-ignored-qualifiers"
|
9
9
|
|
10
10
|
inc, lib = dir_config("or-tools")
|
11
|
-
|
12
|
-
inc ||= "/usr/local/include"
|
13
|
-
lib ||= "/usr/local/lib"
|
11
|
+
if inc || lib
|
12
|
+
inc ||= "/usr/local/include"
|
13
|
+
lib ||= "/usr/local/lib"
|
14
|
+
rpath = lib
|
15
|
+
else
|
16
|
+
# download
|
17
|
+
require_relative "vendor"
|
18
|
+
|
19
|
+
inc = "#{$vendor_path}/include"
|
20
|
+
lib = "#{$vendor_path}/lib"
|
21
|
+
|
22
|
+
# make rpath relative
|
23
|
+
# use double dollar sign and single quotes to escape properly
|
24
|
+
rpath_prefix = RbConfig::CONFIG["host_os"] =~ /darwin/ ? "@loader_path" : "$$ORIGIN"
|
25
|
+
rpath = "'#{rpath_prefix}/../../tmp/or-tools/lib'"
|
26
|
+
end
|
14
27
|
|
15
28
|
$INCFLAGS << " -I#{inc}"
|
16
29
|
|
17
|
-
$LDFLAGS << " -Wl,-rpath,#{
|
30
|
+
$LDFLAGS << " -Wl,-rpath,#{rpath}"
|
18
31
|
$LDFLAGS << " -L#{lib}"
|
19
|
-
|
32
|
+
raise "OR-Tools not found" unless have_library("ortools")
|
20
33
|
|
21
34
|
Dir["#{lib}/libabsl_*.a"].each do |lib|
|
22
35
|
$LDFLAGS << " #{lib}"
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require "digest"
|
2
|
+
require "fileutils"
|
3
|
+
require "net/http"
|
4
|
+
require "tmpdir"
|
5
|
+
|
6
|
+
version = "7.6.7691"
|
7
|
+
|
8
|
+
if RbConfig::CONFIG["host_os"] =~ /darwin/i
|
9
|
+
filename = "or-tools_MacOsX-10.15.4_v#{version}.tar.gz"
|
10
|
+
checksum = "39e26ba27b4d3a1c194c1478e864cd016d62cf516cd9227a9f23e6143e131572"
|
11
|
+
else
|
12
|
+
os = %x[lsb_release -is].chomp rescue nil
|
13
|
+
os_version = %x[lsb_release -rs].chomp rescue nil
|
14
|
+
if os == "Ubuntu" && os_version == "18.04"
|
15
|
+
filename = "or-tools_ubuntu-18.04_v#{version}.tar.gz"
|
16
|
+
checksum = "79ef61dfc63b98133ed637f02e837f714a95987424332e511a3a87edd5ce17dc"
|
17
|
+
elsif os == "Ubuntu" && os_version == "16.04"
|
18
|
+
filename = "or-tools_ubuntu-16.04_v#{version}.tar.gz"
|
19
|
+
checksum = "a25fc94c0f0d16abf1f6da2a054040c21ef3cbf618a831a15afe21bf14f2d1fb"
|
20
|
+
elsif os == "Debian" && os_version == "10"
|
21
|
+
filename = "or-tools_debian-10_v#{version}.tar.gz "
|
22
|
+
checksum = "158c44038aebc42b42b98e8f3733ba83bf230e8a0379803cc48aafbb2f7bdf5a"
|
23
|
+
elsif os == "CentOS" && os_version == "8"
|
24
|
+
filename = "or-tools_centos-8_v#{version}.tar.gz"
|
25
|
+
checksum = "a2b800d4e498561e5b1fe95ee1e64c867be496038883f4f7b199499bf71a0eed"
|
26
|
+
else
|
27
|
+
# there is a binary download for Windows
|
28
|
+
# however, it's compiled with Visual Studio rather than MinGW (which RubyInstaller uses)
|
29
|
+
raise <<~MSG
|
30
|
+
Binary installation not available for this platform.
|
31
|
+
|
32
|
+
Build the OR-Tools C++ library from source, then run:
|
33
|
+
bundle config build.or-tools --with-or-tools-dir=/path/to/or-tools
|
34
|
+
|
35
|
+
MSG
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
short_version = version.split(".").first(2).join(".")
|
40
|
+
url = "https://github.com/google/or-tools/releases/download/v#{short_version}/#{filename}"
|
41
|
+
|
42
|
+
$stdout.sync = true
|
43
|
+
|
44
|
+
def download_file(url, download_path)
|
45
|
+
uri = URI(url)
|
46
|
+
location = nil
|
47
|
+
|
48
|
+
Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
49
|
+
request = Net::HTTP::Get.new(uri)
|
50
|
+
http.request(request) do |response|
|
51
|
+
case response
|
52
|
+
when Net::HTTPRedirection
|
53
|
+
location = response["location"]
|
54
|
+
when Net::HTTPSuccess
|
55
|
+
i = 0
|
56
|
+
File.open(download_path, "wb") do |f|
|
57
|
+
response.read_body do |chunk|
|
58
|
+
f.write(chunk)
|
59
|
+
|
60
|
+
# print progress
|
61
|
+
putc "." if i % 50 == 0
|
62
|
+
i += 1
|
63
|
+
end
|
64
|
+
end
|
65
|
+
puts # newline
|
66
|
+
else
|
67
|
+
raise "Bad response"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
# outside of Net::HTTP block to close previous connection
|
73
|
+
download_file(location, download_path) if location
|
74
|
+
end
|
75
|
+
|
76
|
+
# download
|
77
|
+
download_path = "#{Dir.tmpdir}/#{filename}"
|
78
|
+
unless File.exist?(download_path)
|
79
|
+
puts "Downloading #{url}..."
|
80
|
+
download_file(url, download_path)
|
81
|
+
end
|
82
|
+
|
83
|
+
# check integrity - do this regardless of if just downloaded
|
84
|
+
download_checksum = Digest::SHA256.file(download_path).hexdigest
|
85
|
+
raise "Bad checksum: #{download_checksum}" if download_checksum != checksum
|
86
|
+
|
87
|
+
# extract - can't use Gem::Package#extract_tar_gz from RubyGems
|
88
|
+
# since it limits filenames to 100 characters (doesn't support UStar format)
|
89
|
+
path = File.expand_path("../../tmp/or-tools", __dir__)
|
90
|
+
FileUtils.mkdir_p(path)
|
91
|
+
tar_args = Gem.win_platform? ? ["--force-local"] : []
|
92
|
+
system "tar", "zxf", download_path, "-C", path, "--strip-components=1", *tar_args
|
93
|
+
|
94
|
+
# export
|
95
|
+
$vendor_path = path
|
data/lib/or_tools/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: or-tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-05-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rice
|
@@ -93,6 +93,7 @@ files:
|
|
93
93
|
- README.md
|
94
94
|
- ext/or-tools/ext.cpp
|
95
95
|
- ext/or-tools/extconf.rb
|
96
|
+
- ext/or-tools/vendor.rb
|
96
97
|
- lib/or-tools.rb
|
97
98
|
- lib/or_tools/bool_var.rb
|
98
99
|
- lib/or_tools/comparison.rb
|
@@ -100,7 +101,6 @@ files:
|
|
100
101
|
- lib/or_tools/cp_model.rb
|
101
102
|
- lib/or_tools/cp_solver.rb
|
102
103
|
- lib/or_tools/cp_solver_solution_callback.rb
|
103
|
-
- lib/or_tools/ext.bundle
|
104
104
|
- lib/or_tools/int_var.rb
|
105
105
|
- lib/or_tools/knapsack_solver.rb
|
106
106
|
- lib/or_tools/linear_expr.rb
|
data/lib/or_tools/ext.bundle
DELETED
Binary file
|