unpack_results {CVXR} | R Documentation |
Updates problem status, problem value, and primal and dual variable values
unpack_results(object, solution, chain, inverse_data)
object |
A Problem object. |
solution |
A Solution object. |
chain |
The corresponding solving Chain. |
inverse_data |
A InverseData object or list containing data necessary for the inversion. |
A list containing the solution to the problem:
status
The status of the solution. Can be "optimal", "optimal_inaccurate", "infeasible", "infeasible_inaccurate", "unbounded", "unbounded_inaccurate", or "solver_error".
value
The optimal value of the objective function.
solver
The name of the solver.
solve_time
The time (in seconds) it took for the solver to solve the problem.
setup_time
The time (in seconds) it took for the solver to set up the problem.
num_iters
The number of iterations the solver had to go through to find a solution.
getValue
A function that takes a Variable object and retrieves its primal value.
getDualValue
A function that takes a Constraint object and retrieves its dual value(s).
## Not run: x <- Variable(2) obj <- Minimize(x[1] + cvxr_norm(x, 1)) constraints <- list(x >= 2) prob1 <- Problem(obj, constraints) # Solve with ECOS. ecos_data <- get_problem_data(prob1, "ECOS") # Call ECOS solver interface directly ecos_output <- ECOSolveR::ECOS_csolve( c = ecos_data[["c"]], G = ecos_data[["G"]], h = ecos_data[["h"]], dims = ecos_data[["dims"]], A = ecos_data[["A"]], b = ecos_data[["b"]] ) # Unpack raw solver output. res1 <- unpack_results(prob1, "ECOS", ecos_output) # Without DCP validation (so be sure of your math), above is equivalent to: # res1 <- solve(prob1, solver = "ECOS") X <- Variable(2,2, PSD = TRUE) Fmat <- rbind(c(1,0), c(0,-1)) obj <- Minimize(sum_squares(X - Fmat)) prob2 <- Problem(obj) scs_data <- get_problem_data(prob2, "SCS") scs_output <- scs::scs( A = scs_data[['A']], b = scs_data[['b']], obj = scs_data[['c']], cone = scs_data[['dims']] ) res2 <- unpack_results(prob2, "SCS", scs_output) # Without DCP validation (so be sure of your math), above is equivalent to: # res2 <- solve(prob2, solver = "SCS") ## End(Not run)