Determine if a problem or expression complies with the disciplined geometric programming rules.

is_dgp(object)

Arguments

object

A Problem or Expression object.

Value

A logical value indicating whether the problem or expression is DCP compliant, i.e. no unknown curvatures.

Examples

x <- Variable(pos = TRUE)
y <- Variable(pos = TRUE)
prob <- Problem(Minimize(x*y), list(x >= 5, y >= 5))
is_dgp(prob)
#> [1] TRUE
solve(prob, gp = TRUE)
#> $`2073`
#> [1] 5
#> 
#> $`2074`
#> [1] 5
#> 
#> $`2079`
#> [1] 1
#> 
#> $`2085`
#> [1] 1
#> 
#> $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: 0x7fa5784c5540>
#> <environment: 0x7fa56b6de320>
#> 
#> $getDualValue
#> function (objet) 
#> {
#>     if (!is(objet, "Constraint")) 
#>         stop("getDualValue: argument should be a Constraint!")
#>     getValue(objet)
#> }
#> <bytecode: 0x7fa5784c92f8>
#> <environment: 0x7fa56b6de320>
#> 
#> $solver
#> [1] "ECOS"
#> 
#> $solve_time
#> [1] 1.2557e-05
#> 
#> $setup_time
#> [1] 9.351e-06
#> 
#> $num_iters
#> [1] 4
#>