or-tools 0.3.1 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +24 -0
- data/NOTICE.txt +2 -1
- data/README.md +35 -1
- data/ext/or-tools/assignment.cpp +39 -0
- data/ext/or-tools/bin_packing.cpp +55 -0
- data/ext/or-tools/constraint.cpp +423 -0
- data/ext/or-tools/ext.cpp +21 -975
- data/ext/or-tools/extconf.rb +1 -1
- data/ext/or-tools/linear.cpp +212 -0
- data/ext/or-tools/network_flows.cpp +105 -0
- data/ext/or-tools/routing.cpp +368 -0
- data/ext/or-tools/vendor.rb +10 -10
- data/lib/or-tools.rb +6 -0
- data/lib/or_tools/cp_model.rb +4 -0
- data/lib/or_tools/cp_solver.rb +7 -3
- data/lib/or_tools/cp_solver_solution_callback.rb +1 -1
- data/lib/or_tools/objective_solution_printer.rb +18 -0
- data/lib/or_tools/routing_index_manager.rb +11 -0
- data/lib/or_tools/sat_int_var.rb +4 -0
- data/lib/or_tools/sat_linear_expr.rb +2 -2
- data/lib/or_tools/var_array_and_objective_solution_printer.rb +20 -0
- data/lib/or_tools/var_array_solution_printer.rb +19 -0
- data/lib/or_tools/version.rb +1 -1
- metadata +20 -10
data/ext/or-tools/vendor.rb
CHANGED
@@ -3,26 +3,26 @@ require "fileutils"
|
|
3
3
|
require "net/http"
|
4
4
|
require "tmpdir"
|
5
5
|
|
6
|
-
version = "
|
6
|
+
version = "8.1.8487"
|
7
7
|
|
8
8
|
if RbConfig::CONFIG["host_os"] =~ /darwin/i
|
9
|
-
filename = "or-tools_MacOsX-10.15.
|
10
|
-
checksum = "
|
9
|
+
filename = "or-tools_MacOsX-10.15.7_v#{version}.tar.gz"
|
10
|
+
checksum = "cdf5d5c4dd10ddfa39eb951e6b8122b2a48c7d1dbd87bb5f792a7596aea8b8bb"
|
11
11
|
else
|
12
12
|
os = %x[lsb_release -is].chomp rescue nil
|
13
13
|
os_version = %x[lsb_release -rs].chomp rescue nil
|
14
|
-
if os == "Ubuntu" && os_version == "
|
14
|
+
if os == "Ubuntu" && os_version == "20.04"
|
15
|
+
filename = "or-tools_ubuntu-20.04_v#{version}.tar.gz"
|
16
|
+
checksum = "2de596d649d9a0f0dfec8007d6e1018d8fdddced7aa340b4e68d02e61df89a2e"
|
17
|
+
elsif os == "Ubuntu" && os_version == "18.04"
|
15
18
|
filename = "or-tools_ubuntu-18.04_v#{version}.tar.gz"
|
16
|
-
checksum = "
|
17
|
-
elsif os == "Ubuntu" && os_version == "16.04"
|
18
|
-
filename = "or-tools_ubuntu-16.04_v#{version}.tar.gz"
|
19
|
-
checksum = "cc696d342b97aa6cf7c62b6ae2cae95dfc665f2483d147c4117fdba434b13a53"
|
19
|
+
checksum = "201cf1d17379240311208f4c641bb5263ae19d8c4c1a6091d2778948fd375f48"
|
20
20
|
elsif os == "Debian" && os_version == "10"
|
21
21
|
filename = "or-tools_debian-10_v#{version}.tar.gz "
|
22
|
-
checksum = "
|
22
|
+
checksum = "18028ef7287cd83eed3dafeae1243a9adb445675f45984e8d3c60ab9e2aa75bd"
|
23
23
|
elsif os == "CentOS" && os_version == "8"
|
24
24
|
filename = "or-tools_centos-8_v#{version}.tar.gz"
|
25
|
-
checksum = "
|
25
|
+
checksum = "e26229320f9b78315f0122b55d16093c79e2dc6c95d591f4788f323f27cfd3bf"
|
26
26
|
else
|
27
27
|
# there is a binary download for Windows
|
28
28
|
# however, it's compiled with Visual Studio rather than MinGW (which RubyInstaller uses)
|
data/lib/or-tools.rb
CHANGED
@@ -11,12 +11,18 @@ require "or_tools/cp_solver_solution_callback"
|
|
11
11
|
require "or_tools/int_var"
|
12
12
|
require "or_tools/knapsack_solver"
|
13
13
|
require "or_tools/linear_expr"
|
14
|
+
require "or_tools/routing_index_manager"
|
14
15
|
require "or_tools/routing_model"
|
15
16
|
require "or_tools/sat_linear_expr"
|
16
17
|
require "or_tools/sat_int_var"
|
17
18
|
require "or_tools/solver"
|
18
19
|
require "or_tools/version"
|
19
20
|
|
21
|
+
# solution printers
|
22
|
+
require "or_tools/objective_solution_printer"
|
23
|
+
require "or_tools/var_array_solution_printer"
|
24
|
+
require "or_tools/var_array_and_objective_solution_printer"
|
25
|
+
|
20
26
|
# higher level interfaces
|
21
27
|
require "or_tools/basic_scheduler"
|
22
28
|
require "or_tools/seating"
|
data/lib/or_tools/cp_model.rb
CHANGED
data/lib/or_tools/cp_solver.rb
CHANGED
@@ -7,7 +7,7 @@ module ORTools
|
|
7
7
|
def_delegators :@response, :objective_value, :num_conflicts, :num_branches, :wall_time
|
8
8
|
|
9
9
|
def solve(model)
|
10
|
-
@response = _solve(model)
|
10
|
+
@response = _solve(model, parameters)
|
11
11
|
@response.status
|
12
12
|
end
|
13
13
|
|
@@ -20,13 +20,17 @@ module ORTools
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def solve_with_solution_callback(model, observer)
|
23
|
-
@response = _solve_with_observer(model, observer, false)
|
23
|
+
@response = _solve_with_observer(model, parameters, observer, false)
|
24
24
|
@response.status
|
25
25
|
end
|
26
26
|
|
27
27
|
def search_for_all_solutions(model, observer)
|
28
|
-
@response = _solve_with_observer(model, observer, true)
|
28
|
+
@response = _solve_with_observer(model, parameters, observer, true)
|
29
29
|
@response.status
|
30
30
|
end
|
31
|
+
|
32
|
+
def parameters
|
33
|
+
@parameters ||= SatParameters.new
|
34
|
+
end
|
31
35
|
end
|
32
36
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module ORTools
|
2
|
+
class ObjectiveSolutionPrinter < CpSolverSolutionCallback
|
3
|
+
attr_reader :solution_count
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
super
|
7
|
+
@solution_count = 0
|
8
|
+
@start_time = Time.now
|
9
|
+
end
|
10
|
+
|
11
|
+
def on_solution_callback
|
12
|
+
current_time = Time.now
|
13
|
+
obj = objective_value
|
14
|
+
puts "Solution %i, time = %0.2f s, objective = %i" % [@solution_count, current_time - @start_time, obj]
|
15
|
+
@solution_count += 1
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/or_tools/sat_int_var.rb
CHANGED
@@ -43,10 +43,10 @@ module ORTools
|
|
43
43
|
case other
|
44
44
|
when SatLinearExpr
|
45
45
|
other.vars
|
46
|
-
when BoolVar, SatIntVar
|
46
|
+
when BoolVar, SatIntVar, Integer
|
47
47
|
[[other, 1]]
|
48
48
|
else
|
49
|
-
raise ArgumentError, "Unsupported type"
|
49
|
+
raise ArgumentError, "Unsupported type: #{other.class.name}"
|
50
50
|
end
|
51
51
|
|
52
52
|
self.class.new(vars + other_vars.map { |a, b| [a, sign * b] })
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module ORTools
|
2
|
+
class VarArrayAndObjectiveSolutionPrinter < CpSolverSolutionCallback
|
3
|
+
attr_reader :solution_count
|
4
|
+
|
5
|
+
def initialize(variables)
|
6
|
+
super()
|
7
|
+
@variables = variables
|
8
|
+
@solution_count = 0
|
9
|
+
@start_time = Time.now
|
10
|
+
end
|
11
|
+
|
12
|
+
def on_solution_callback
|
13
|
+
current_time = Time.now
|
14
|
+
obj = objective_value
|
15
|
+
puts "Solution %i, time = %0.2f s, objective = %i" % [@solution_count, current_time - @start_time, obj]
|
16
|
+
puts @variables.map { |v| " %s = %i" % [v.name, value(v)] }.join(" ")
|
17
|
+
@solution_count += 1
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module ORTools
|
2
|
+
class VarArraySolutionPrinter < CpSolverSolutionCallback
|
3
|
+
attr_reader :solution_count
|
4
|
+
|
5
|
+
def initialize(variables)
|
6
|
+
super()
|
7
|
+
@variables = variables
|
8
|
+
@solution_count = 0
|
9
|
+
@start_time = Time.now
|
10
|
+
end
|
11
|
+
|
12
|
+
def on_solution_callback
|
13
|
+
current_time = Time.now
|
14
|
+
puts "Solution %i, time = %0.2f s" % [@solution_count, current_time - @start_time]
|
15
|
+
puts @variables.map { |v| " %s = %i" % [v.name, value(v)] }.join(" ")
|
16
|
+
@solution_count += 1
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
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.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rice
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '3'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,7 +80,7 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '5'
|
83
|
-
description:
|
83
|
+
description:
|
84
84
|
email: andrew@chartkick.com
|
85
85
|
executables: []
|
86
86
|
extensions:
|
@@ -91,8 +91,14 @@ files:
|
|
91
91
|
- LICENSE.txt
|
92
92
|
- NOTICE.txt
|
93
93
|
- README.md
|
94
|
+
- ext/or-tools/assignment.cpp
|
95
|
+
- ext/or-tools/bin_packing.cpp
|
96
|
+
- ext/or-tools/constraint.cpp
|
94
97
|
- ext/or-tools/ext.cpp
|
95
98
|
- ext/or-tools/extconf.rb
|
99
|
+
- ext/or-tools/linear.cpp
|
100
|
+
- ext/or-tools/network_flows.cpp
|
101
|
+
- ext/or-tools/routing.cpp
|
96
102
|
- ext/or-tools/vendor.rb
|
97
103
|
- lib/or-tools.rb
|
98
104
|
- lib/or_tools/basic_scheduler.rb
|
@@ -105,6 +111,8 @@ files:
|
|
105
111
|
- lib/or_tools/int_var.rb
|
106
112
|
- lib/or_tools/knapsack_solver.rb
|
107
113
|
- lib/or_tools/linear_expr.rb
|
114
|
+
- lib/or_tools/objective_solution_printer.rb
|
115
|
+
- lib/or_tools/routing_index_manager.rb
|
108
116
|
- lib/or_tools/routing_model.rb
|
109
117
|
- lib/or_tools/sat_int_var.rb
|
110
118
|
- lib/or_tools/sat_linear_expr.rb
|
@@ -112,12 +120,14 @@ files:
|
|
112
120
|
- lib/or_tools/solver.rb
|
113
121
|
- lib/or_tools/sudoku.rb
|
114
122
|
- lib/or_tools/tsp.rb
|
123
|
+
- lib/or_tools/var_array_and_objective_solution_printer.rb
|
124
|
+
- lib/or_tools/var_array_solution_printer.rb
|
115
125
|
- lib/or_tools/version.rb
|
116
126
|
homepage: https://github.com/ankane/or-tools
|
117
127
|
licenses:
|
118
128
|
- MIT
|
119
129
|
metadata: {}
|
120
|
-
post_install_message:
|
130
|
+
post_install_message:
|
121
131
|
rdoc_options: []
|
122
132
|
require_paths:
|
123
133
|
- lib
|
@@ -125,15 +135,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
125
135
|
requirements:
|
126
136
|
- - ">="
|
127
137
|
- !ruby/object:Gem::Version
|
128
|
-
version: '2.
|
138
|
+
version: '2.6'
|
129
139
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
140
|
requirements:
|
131
141
|
- - ">="
|
132
142
|
- !ruby/object:Gem::Version
|
133
143
|
version: '0'
|
134
144
|
requirements: []
|
135
|
-
rubygems_version: 3.
|
136
|
-
signing_key:
|
145
|
+
rubygems_version: 3.2.3
|
146
|
+
signing_key:
|
137
147
|
specification_version: 4
|
138
148
|
summary: Operations research tools for Ruby
|
139
149
|
test_files: []
|