Class: SCS::Solver
- Inherits:
-
Object
- Object
- SCS::Solver
- Defined in:
- lib/scs/solver.rb
Instance Method Summary collapse
-
#initialize(indirect: false) ⇒ Solver
constructor
A new instance of Solver.
- #solve(data, cone, **settings) ⇒ Object
Constructor Details
Instance Method Details
#solve(data, cone, **settings) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/scs/solver.rb', line 7 def solve(data, cone, **settings) cdata = create_data(data) set_settings(cdata, settings) ccone = create_cone(cone) solution = calloc(ffi::Solution.size) # alloc clear memory info = ffi::Info.malloc ffi.scs(cdata, ccone, solution, info) solution = ffi::Solution.new(solution) x = read_float_array(solution.x, cdata.n) y = read_float_array(solution.y, cdata.m) s = read_float_array(solution.s, cdata.m) { x: x, y: y, s: s, iter: info.iter, status: read_string(info.status), status_val: info.status_val, pobj: info.pobj, dobj: info.dobj, res_pri: info.res_pri, res_dual: info.res_dual, res_infeas: info.res_infeas, res_unbdd: info.res_unbdd, rel_gap: info.rel_gap, setup_time: info.setup_time, solve_time: info.solve_time } end |