Solves the problem and returns the optimal objective value. After solving,
variable values can be retrieved with value, constraint
dual values with dual_value, and solver information with
solver_stats.
psolve(
problem,
solver = NULL,
gp = FALSE,
qcp = FALSE,
verbose = FALSE,
warm_start = FALSE,
requires_grad = FALSE,
nlp = FALSE,
enforce_dpp = FALSE,
ignore_dpp = FALSE,
solver_path = NULL,
...
)The optimal objective value (numeric scalar), or Inf /
-Inf for infeasible / unbounded problems.
A Problem object.
Character string naming the solver to use (e.g.,
"CLARABEL", "SCS", "OSQP", "HIGHS"),
or NULL for automatic selection.
Logical; if TRUE, solve as a geometric program (DGP).
Logical; if TRUE, solve as a quasiconvex program (DQCP)
via bisection. Only needed for non-DCP DQCP problems.
Logical; if TRUE, print solver output.
Logical; if TRUE, use the current variable
values as a warm-start point for the solver.
Logical; if TRUE, route the solve through
the DIFFCP wrapper so backward() /
derivative() can recover gradients.
Logical; if TRUE, solve the problem as a disciplined
nonlinear program (DNLP) using the NLP reduction chain and an NLP solver
(e.g. "UNO"). The problem must satisfy is_dnlp().
Logical; if TRUE, raise an error when a
parametrized problem is not DPP instead of compiling it as non-DPP.
Logical; if TRUE, treat a DPP problem as non-DPP
(skip the DPP fast path).
Optional fallback chain. A character vector of
solver names or a list whose entries are either character names or
length-2 list(name, opts) pairs. Each solver is tried in
sequence; the first that succeeds returns its result. If every
solver fails, a SolverError-classed condition is raised
with the per-solver error messages. Cannot be combined with
solver. Mirrors CVXPY's solver_path argument.
Solver options passed to solver_opts().
Includes chain-construction options (use_quad_obj), standard
tolerances (feastol, reltol, abstol, num_iter),
and solver-specific parameters (e.g., eps_abs, scip_params).
See solver_opts for details.
For DQCP problems (qcp = TRUE), additional arguments include
low, high, eps, max_iters, and
max_iters_interval_search.
Problem, status,
solver_stats, solver_default_param
x <- Variable()
prob <- Problem(Minimize(x), list(x >= 5))
result <- psolve(prob, solver = "CLARABEL")
Run the code above in your browser using DataLab