Class: NoSE::Search::IndexPresenceConstraints

Inherits:
Constraint show all
Defined in:
lib/nose/search/constraints.rb

Overview

Constraints which force indexes to be present to be used

Class Method Summary collapse

Methods inherited from Constraint

apply_query

Class Method Details

.apply(problem) ⇒ Object

Add constraint for indices being present



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/nose/search/constraints.rb', line 24

def self.apply(problem)
  problem.indexes.each do |index|
    problem.queries.each_with_index do |query, q|
      name = "q#{q}_#{index.key}_avail" if ENV['NOSE_LOG'] == 'debug'
      constr = MIPPeR::Constraint.new problem.query_vars[index][query] +
                                      problem.index_vars[index] * -1,
                                      :<=, 0, name
      problem.model << constr
    end
  end
end