module Solve

Constants

Problem
VERSION

Attributes

engine[R]

Returns the currently configured engine. @see engine= @return [Symbol]

tracer[R]

@return [Solve::Formatter]

Public Class Methods

engine=(selected_engine) click to toggle source

Sets the solving backend engine. Solve supports 2 engines:

  • `:ruby` - Molinillo, a pure ruby solver

  • `:gecode` - dep-selector, a wrapper around the Gecode CSP solver library

Note that dep-selector is an optional dependency and may therefore not be available.

@param [Symbol] selected_engine @return [Symbol] selected_engine @raise [Solve::Errors::EngineNotAvailable] when the selected engine's deps aren't installed. @raise [Solve::Errors::InvalidEngine] when `selected_engine` is invalid.

# File lib/solve.rb, line 37
def engine=(selected_engine)
  engine_class = solver_for_engine(selected_engine)
  if engine_class.nil?
    raise Errors::InvalidEngine, "Engine `#{selected_engine}` is not supported. Valid values are `:ruby`, `:gecode`"
  else
    engine_class.activate
  end

  @engine = selected_engine
end
it!(graph, demands, options = {}) click to toggle source

A quick solve. Given the “world” as we know it (the graph) and a list of requirements (demands) which must be met. Return me the best solution of artifacts and verisons that I should use.

If a ui object is passed in, the resolution will be traced

@param [Solve::Graph] graph @param [Array<Solve::Demand>, Array<String, String>] demands

@option options [Boolean] :sorted (false)

should the output be a sorted list rather than a Hash

@raise [NoSolutionError]

@return [Hash]

# File lib/solve.rb, line 63
def it!(graph, demands, options = {})
  solver_for_engine(engine).new(graph, demands, options).resolve(options)
end

Private Class Methods

solver_for_engine(engine_name) click to toggle source
# File lib/solve.rb, line 67
def solver_for_engine(engine_name)
  case engine_name
  when :ruby
    RubySolver
  when :gecode
    GecodeSolver
  end
end