or-tools 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/CHANGELOG.md +6 -0
 - data/README.md +1 -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 +18 -1025
 - 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/lib/or-tools.rb +5 -0
 - data/lib/or_tools/cp_model.rb +4 -0
 - 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/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 +11 -2
 
    
        data/lib/or-tools.rb
    CHANGED
    
    | 
         @@ -18,6 +18,11 @@ require "or_tools/sat_int_var" 
     | 
|
| 
       18 
18 
     | 
    
         
             
            require "or_tools/solver"
         
     | 
| 
       19 
19 
     | 
    
         
             
            require "or_tools/version"
         
     | 
| 
       20 
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 
     | 
    
         
            +
             
     | 
| 
       21 
26 
     | 
    
         
             
            # higher level interfaces
         
     | 
| 
       22 
27 
     | 
    
         
             
            require "or_tools/basic_scheduler"
         
     | 
| 
       23 
28 
     | 
    
         
             
            require "or_tools/seating"
         
     | 
    
        data/lib/or_tools/cp_model.rb
    CHANGED
    
    
| 
         @@ -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. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.4.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: 2021- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2021-02-23 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: rice
         
     | 
| 
         @@ -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,7 @@ 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
         
     | 
| 
       108 
115 
     | 
    
         
             
            - lib/or_tools/routing_index_manager.rb
         
     | 
| 
       109 
116 
     | 
    
         
             
            - lib/or_tools/routing_model.rb
         
     | 
| 
       110 
117 
     | 
    
         
             
            - lib/or_tools/sat_int_var.rb
         
     | 
| 
         @@ -113,6 +120,8 @@ files: 
     | 
|
| 
       113 
120 
     | 
    
         
             
            - lib/or_tools/solver.rb
         
     | 
| 
       114 
121 
     | 
    
         
             
            - lib/or_tools/sudoku.rb
         
     | 
| 
       115 
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
         
     | 
| 
       116 
125 
     | 
    
         
             
            - lib/or_tools/version.rb
         
     | 
| 
       117 
126 
     | 
    
         
             
            homepage: https://github.com/ankane/or-tools
         
     | 
| 
       118 
127 
     | 
    
         
             
            licenses:
         
     |