Class: Quicopt::Result
- Inherits:
-
Data
- Object
- Data
- Quicopt::Result
- Defined in:
- lib/quicopt/client.rb
Overview
A finished solve, parsed from the service's result JSON.
objective and feasible are nil when the class or outcome leaves them
undefined (an unconstrained heuristic, or no incumbent). display is the
framed, ready-to-print summary the service renders for every backend alike —
print it rather than formatting your own.
Instance Attribute Summary collapse
-
#display ⇒ Object
readonly
Returns the value of attribute display.
-
#feasible ⇒ Object
readonly
Returns the value of attribute feasible.
-
#job_id ⇒ Object
readonly
Returns the value of attribute job_id.
-
#objective ⇒ Object
readonly
Returns the value of attribute objective.
-
#solution ⇒ Object
readonly
Returns the value of attribute solution.
-
#solve_time_seconds ⇒ Object
readonly
Returns the value of attribute solve_time_seconds.
-
#solver_data ⇒ Object
readonly
Returns the value of attribute solver_data.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Class Method Summary collapse
-
.from_json(body) ⇒ Result
Build a
Resultfrom the service's decoded result JSON.
Instance Method Summary collapse
-
#model_class ⇒ String?
The class the service routed the model to (+LP+/+MILP+/+QUBO+/…), or
nilif it did not report one.
Instance Attribute Details
#display ⇒ Object (readonly)
Returns the value of attribute display
49 50 51 |
# File 'lib/quicopt/client.rb', line 49 def display @display end |
#feasible ⇒ Object (readonly)
Returns the value of attribute feasible
49 50 51 |
# File 'lib/quicopt/client.rb', line 49 def feasible @feasible end |
#job_id ⇒ Object (readonly)
Returns the value of attribute job_id
49 50 51 |
# File 'lib/quicopt/client.rb', line 49 def job_id @job_id end |
#objective ⇒ Object (readonly)
Returns the value of attribute objective
49 50 51 |
# File 'lib/quicopt/client.rb', line 49 def objective @objective end |
#solution ⇒ Object (readonly)
Returns the value of attribute solution
49 50 51 |
# File 'lib/quicopt/client.rb', line 49 def solution @solution end |
#solve_time_seconds ⇒ Object (readonly)
Returns the value of attribute solve_time_seconds
49 50 51 |
# File 'lib/quicopt/client.rb', line 49 def solve_time_seconds @solve_time_seconds end |
#solver_data ⇒ Object (readonly)
Returns the value of attribute solver_data
49 50 51 |
# File 'lib/quicopt/client.rb', line 49 def solver_data @solver_data end |
#status ⇒ Object (readonly)
Returns the value of attribute 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.
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_class ⇒ String?
The class the service routed the model to (+LP+/+MILP+/+QUBO+/…), or nil
if it did not report one.
73 74 75 |
# File 'lib/quicopt/client.rb', line 73 def model_class solver_data["model_class"] end |