Module: Solve

Defined in:
lib/solve.rb,
lib/solve/graph.rb,
lib/solve/demand.rb,
lib/solve/errors.rb,
lib/solve/version.rb,
lib/solve/artifact.rb,
lib/solve/constraint.rb,
lib/solve/dependency.rb,
lib/solve/ruby_solver.rb,
lib/solve/gecode_solver.rb,
lib/solve/solver/serializer.rb

Defined Under Namespace

Modules: Errors Classes: Artifact, Constraint, Demand, Dependency, GecodeSolver, Graph, Problem, RubySolver, Solver

Constant Summary collapse

VERSION =
"2.0.0"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.engineSymbol

Returns the currently configured engine.

Returns:

  • (Symbol)

See Also:

  • #engine=


22
23
24
# File 'lib/solve.rb', line 22

def engine
  @engine
end

.tracerSolve::Formatter (readonly)

Returns:

  • (Solve::Formatter)


15
16
17
# File 'lib/solve.rb', line 15

def tracer
  @tracer
end

Class Method Details

.it!(graph, demands, options = {}) ⇒ Hash

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

Parameters:

  • graph (Solve::Graph)
  • demands (Array<Solve::Demand>, Array<String, String>)
  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :sorted (Boolean) — default: false

    should the output be a sorted list rather than a Hash

Returns:

  • (Hash)

Raises:

  • (NoSolutionError)


61
62
63
# File 'lib/solve.rb', line 61

def it!(graph, demands, options = {})
  solver_for_engine(engine).new(graph, demands, options).resolve(options)
end

.solver_for_engine(engine_name) ⇒ Object



65
66
67
68
69
70
71
72
# File 'lib/solve.rb', line 65

def solver_for_engine(engine_name)
  case engine_name
  when :ruby
    RubySolver
  when :gecode
    GecodeSolver
  end
end