Determine if a problem or expression complies with the disciplined convex programming rules.
is_dcp(object)
A Problem or Expression object.
A logical value indicating whether the problem or expression is DCP compliant, i.e. no unknown curvatures.
x <- Variable()
prob <- Problem(Minimize(x^2), list(x >= 5))
is_dcp(prob)
#> [1] TRUE
solve(prob)
#> $`2033`
#> [1] 5
#>
#> $`2038`
#> [1] 10
#>
#> $value
#> [1] 25
#>
#> $status
#> [1] "optimal"
#>
#> $getValue
#> function (objet)
#> {
#> if (is(objet, "Variable") || is(objet, "Constraint"))
#> return(result[[as.character(id(objet))]])
#> if (is_zero(objet)) {
#> dims <- dim(objet)
#> valResult <- matrix(0, nrow = dims[1], ncol = dims[2])
#> }
#> else {
#> arg_values <- list()
#> idx <- 1
#> for (arg in objet@args) {
#> arg_val <- if (is_constant(arg))
#> value(arg)
#> else {
#> getValue(arg)
#> }
#> if (is.null(arg_val) || (any(is.na(arg_val)) && !is_constant(objet)))
#> return(NA)
#> else {
#> arg_values[[idx]] <- arg_val
#> idx <- idx + 1
#> }
#> }
#> valResult <- to_numeric(objet, arg_values)
#> }
#> if (all(intf_dim(valResult) == c(1, 1)))
#> intf_scalar_value(valResult)
#> else valResult
#> }
#> <bytecode: 0x7fc303151cf0>
#> <environment: 0x7fc2e00bae90>
#>
#> $getDualValue
#> function (objet)
#> {
#> if (!is(objet, "Constraint"))
#> stop("getDualValue: argument should be a Constraint!")
#> getValue(objet)
#> }
#> <bytecode: 0x7fc30314a860>
#> <environment: 0x7fc2e00bae90>
#>
#> $solver
#> [1] "OSQP"
#>
#> $solve_time
#> [1] 3.7487e-05
#>
#> $setup_time
#> [1] NA
#>
#> $num_iters
#> [1] 50
#>