psolve: Solve a DCP Problem

psolveR Documentation

Solve a DCP Problem

Description

Solve a DCP compliant optimization problem.

Usage

psolve(
  object,
  solver = NA,
  ignore_dcp = FALSE,
  warm_start = FALSE,
  verbose = FALSE,
  parallel = FALSE,
  gp = FALSE,
  feastol = NULL,
  reltol = NULL,
  abstol = NULL,
  num_iter = NULL,
  ...
)

## S4 method for signature 'Problem'
psolve(
  object,
  solver = NA,
  ignore_dcp = FALSE,
  warm_start = FALSE,
  verbose = FALSE,
  parallel = FALSE,
  gp = FALSE,
  feastol = NULL,
  reltol = NULL,
  abstol = NULL,
  num_iter = NULL,
  ...
)

## S4 method for signature 'Problem,ANY'
solve(a, b = NA, ...)

Arguments

object, a

A Problem object.

solver, b

(Optional) A string indicating the solver to use. Defaults to "ECOS".

ignore_dcp

(Optional) A logical value indicating whether to override the DCP check for a problem.

warm_start

(Optional) A logical value indicating whether the previous solver result should be used to warm start.

verbose

(Optional) A logical value indicating whether to print additional solver output.

parallel

(Optional) A logical value indicating whether to solve in parallel if the problem is separable.

gp

(Optional) A logical value indicating whether the problem is a geometric program. Defaults to FALSE.

feastol

The feasible tolerance on the primal and dual residual.

reltol

The relative tolerance on the duality gap.

abstol

The absolute tolerance on the duality gap.

num_iter

The maximum number of iterations.

...

Additional options that will be passed to the specific solver. In general, these options will override any default settings imposed by CVXR.

Value

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).

Examples

a <- Variable(name = "a")
prob <- Problem(Minimize(norm_inf(a)), list(a >= 2))
result <- psolve(prob, solver = "ECOS", verbose = TRUE)
result$status
result$value
result$getValue(a)
result$getDualValue(constraints(prob)[[1]])

CVXR documentation built on June 27, 2024, 5:11 p.m.