Class: Quicopt::Result

Inherits:
Data
  • Object
show all
Defined in:
lib/quicopt/client.rb

Overview

A finished solve, parsed from the service's result JSON.

objective and feasible are nil where the outcome leaves them undefined — a model with nothing to feasibility-check, or a run that found no solution. display is the framed, ready-to-print summary the service renders the same way for every kind of model — print it rather than formatting your own.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#displayObject (readonly)

Returns the value of attribute display

Returns:

  • (Object)

    the current value of display



49
50
51
# File 'lib/quicopt/client.rb', line 49

def display
  @display
end

#feasibleObject (readonly)

Returns the value of attribute feasible

Returns:

  • (Object)

    the current value of feasible



49
50
51
# File 'lib/quicopt/client.rb', line 49

def feasible
  @feasible
end

#job_idObject (readonly)

Returns the value of attribute job_id

Returns:

  • (Object)

    the current value of job_id



49
50
51
# File 'lib/quicopt/client.rb', line 49

def job_id
  @job_id
end

#objectiveObject (readonly)

Returns the value of attribute objective

Returns:

  • (Object)

    the current value of objective



49
50
51
# File 'lib/quicopt/client.rb', line 49

def objective
  @objective
end

#solutionObject (readonly)

Returns the value of attribute solution

Returns:

  • (Object)

    the current value of solution



49
50
51
# File 'lib/quicopt/client.rb', line 49

def solution
  @solution
end

#solve_time_secondsObject (readonly)

Returns the value of attribute solve_time_seconds

Returns:

  • (Object)

    the current value of solve_time_seconds



49
50
51
# File 'lib/quicopt/client.rb', line 49

def solve_time_seconds
  @solve_time_seconds
end

#solver_dataObject (readonly)

Returns the value of attribute solver_data

Returns:

  • (Object)

    the current value of solver_data



49
50
51
# File 'lib/quicopt/client.rb', line 49

def solver_data
  @solver_data
end

#statusObject (readonly)

Returns the value of attribute status

Returns:

  • (Object)

    the current value of status



49
50
51
# File 'lib/quicopt/client.rb', line 49

def status
  @status
end

Class Method Details

.from_json(body) ⇒ Result

Build a Result from the service's decoded result JSON.

Missing optional keys default rather than raise, so a partial result (e.g. a heuristic backend that reports no objective) still parses.

Parameters:

  • body (Hash)

    the decoded result JSON object

Returns:



58
59
60
61
62
63
64
65
66
67
# File 'lib/quicopt/client.rb', line 58

def self.from_json(body)
  new(job_id: body["job_id"].to_s,
      status: body["status"].to_s,
      objective: body["objective"],
      feasible: body["feasible"],
      solution: body["solution"] || {},
      solve_time_seconds: body["solve_time_seconds"] || 0.0,
      solver_data: body["solver_data"] || {},
      display: body["display"].to_s)
end

Instance Method Details

#model_classString?

The kind of model the service recognised (+LP+/+MILP+/+QUBO+/…), or nil if it did not report one.

Returns:

  • (String, nil)


73
74
75
# File 'lib/quicopt/client.rb', line 73

def model_class
  solver_data["model_class"]
end