Class: NoSE::Search::SpaceConstraint

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

Overview

The single constraint used to enforce a maximum storage cost

Class Method Summary collapse

Methods inherited from Constraint

apply_query

Class Method Details

.apply(problem) ⇒ Object

Add space constraint if needed



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/nose/search/constraints.rb', line 40

def self.apply(problem)
  return unless problem.data[:max_space].finite?

  fail 'Space constraint not supported when grouping by ID graph' \
    if problem.data[:by_id_graph]

  space = problem.total_size
  constr = MIPPeR::Constraint.new space, :<=,
                                  problem.data[:max_space] * 1.0,
                                  'max_space'
  problem.model << constr
end