or-tools 0.1.0 → 0.1.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 +6 -0
- data/README.md +748 -2
- data/ext/or-tools/ext.cpp +465 -7
- data/ext/or-tools/extconf.rb +60 -1
- data/lib/or-tools.rb +8 -0
- data/lib/or_tools/comparison.rb +11 -0
- data/lib/or_tools/comparison_operators.rb +9 -0
- data/lib/or_tools/cp_model.rb +29 -0
- data/lib/or_tools/cp_solver.rb +4 -0
- data/lib/or_tools/ext.bundle +0 -0
- data/lib/or_tools/linear_expr.rb +19 -0
- data/lib/or_tools/routing_model.rb +17 -0
- data/lib/or_tools/sat_int_var.rb +9 -0
- data/lib/or_tools/sat_linear_expr.rb +35 -0
- data/lib/or_tools/solver.rb +7 -0
- data/lib/or_tools/version.rb +1 -1
- metadata +10 -2
@@ -0,0 +1,19 @@
|
|
1
|
+
module ORTools
|
2
|
+
class LinearExpr
|
3
|
+
def +(other)
|
4
|
+
if other.is_a?(LinearExpr)
|
5
|
+
_add_linear_expr(other)
|
6
|
+
else
|
7
|
+
_add_mp_variable(other)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def <=(other)
|
12
|
+
if other.is_a?(LinearExpr)
|
13
|
+
_lte_linear_expr(other)
|
14
|
+
else
|
15
|
+
_lte_double(other)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module ORTools
|
2
|
+
class RoutingModel
|
3
|
+
def solve(solution_limit: nil, time_limit: nil, lns_time_limit: nil,
|
4
|
+
first_solution_strategy: nil, local_search_metaheuristic: nil,
|
5
|
+
log_search: nil)
|
6
|
+
|
7
|
+
search_parameters = ORTools.default_routing_search_parameters
|
8
|
+
search_parameters.solution_limit = solution_limit if solution_limit
|
9
|
+
search_parameters.time_limit = time_limit if time_limit
|
10
|
+
search_parameters.lns_time_limit = lns_time_limit if lns_time_limit
|
11
|
+
search_parameters.first_solution_strategy = first_solution_strategy if first_solution_strategy
|
12
|
+
search_parameters.local_search_metaheuristic = local_search_metaheuristic if local_search_metaheuristic
|
13
|
+
search_parameters.log_search = log_search unless log_search.nil?
|
14
|
+
solve_with_parameters(search_parameters)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module ORTools
|
2
|
+
class SatLinearExpr
|
3
|
+
include ComparisonOperators
|
4
|
+
|
5
|
+
attr_reader :vars
|
6
|
+
|
7
|
+
def initialize(vars = [])
|
8
|
+
@vars = vars
|
9
|
+
end
|
10
|
+
|
11
|
+
def +(other)
|
12
|
+
add(other, 1)
|
13
|
+
end
|
14
|
+
|
15
|
+
def -(other)
|
16
|
+
add(other, -1)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def add(other, sign)
|
22
|
+
other_vars =
|
23
|
+
case other
|
24
|
+
when SatLinearExpr
|
25
|
+
other.vars
|
26
|
+
when BoolVar
|
27
|
+
[[other, 1]]
|
28
|
+
else
|
29
|
+
raise ArgumentError, "Unsupported type"
|
30
|
+
end
|
31
|
+
|
32
|
+
self.class.new(vars + other_vars.map { |a, b| [a, sign * b] })
|
33
|
+
end
|
34
|
+
end
|
35
|
+
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.1.
|
4
|
+
version: 0.1.1
|
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-02-
|
11
|
+
date: 2020-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rice
|
@@ -94,9 +94,17 @@ files:
|
|
94
94
|
- ext/or-tools/ext.cpp
|
95
95
|
- ext/or-tools/extconf.rb
|
96
96
|
- lib/or-tools.rb
|
97
|
+
- lib/or_tools/comparison.rb
|
98
|
+
- lib/or_tools/comparison_operators.rb
|
99
|
+
- lib/or_tools/cp_model.rb
|
97
100
|
- lib/or_tools/cp_solver.rb
|
98
101
|
- lib/or_tools/ext.bundle
|
99
102
|
- lib/or_tools/knapsack_solver.rb
|
103
|
+
- lib/or_tools/linear_expr.rb
|
104
|
+
- lib/or_tools/routing_model.rb
|
105
|
+
- lib/or_tools/sat_int_var.rb
|
106
|
+
- lib/or_tools/sat_linear_expr.rb
|
107
|
+
- lib/or_tools/solver.rb
|
100
108
|
- lib/or_tools/version.rb
|
101
109
|
homepage: https://github.com/ankane/or-tools
|
102
110
|
licenses:
|