Nothing
#####
## DO NOT EDIT THIS FILE!! EDIT THE SOURCE INSTEAD: rsrc_tree/reductions/solvers/constant_solver.R
#####
## CVXPY SOURCE: reductions/solvers/constant_solver.py
## ConstantSolver -- handles problems with zero variables
##
## When a problem has no variables, we evaluate constraints directly
## without going through the full reduction pipeline.
CONSTANT_SOLVER <- "CONSTANT_SOLVER"
ConstantSolver <- new_class("ConstantSolver", parent = Solver, package = "CVXR",
constructor = function() {
new_object(S7_object(),
.cache = new.env(parent = emptyenv()),
MIP_CAPABLE = TRUE,
BOUNDED_VARIABLES = FALSE
)
}
)
method(solver_name, ConstantSolver) <- function(x) CONSTANT_SOLVER
method(reduction_accepts, ConstantSolver) <- function(x, problem, ...) {
length(variables(problem)) == 0L
}
## apply: pass the problem through unchanged
## CVXPY SOURCE: constant_solver.py lines 15-16
method(reduction_apply, ConstantSolver) <- function(x, problem, ...) {
list(problem, list())
}
## invert: return solution unchanged
## CVXPY SOURCE: constant_solver.py lines 18-19
method(reduction_invert, ConstantSolver) <- function(x, solution, inverse_data, ...) {
solution
}
## solve_via_data: evaluate constraints on the constant problem
## CVXPY SOURCE: constant_solver.py lines 30-37
method(solve_via_data, ConstantSolver) <- function(x, data, warm_start = FALSE, verbose = FALSE,
solver_opts = list(), ...) {
## data is the Problem object (passed through from apply())
problem <- data
feasible <- all(vapply(problem@constraints, function(c) value(c), logical(1L)))
if (feasible) {
opt_val <- value(problem@objective)
Solution(OPTIMAL, opt_val, list(), list(), list())
} else {
Solution(INFEASIBLE, NULL, list(), list(), list())
}
}
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.