cvxgrp / CVXR

An R modeling language for convex optimization problems.

Home Page:https://cvxr.rbind.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

solver_error that shouldn't exist

btaute opened this issue · comments

When I try to execute the following example, I get a solver error. However, when I set the solver to the default ("ECOS"), it works. Obviously picking a solver isn't too cumbersome, but I wanted to bring this issue to attention as it appears to be a bug.

Thanks!

Example:

Set up data

n <- 7
r <- 1.05
m <- 200
V <- matrix(rep(0, m*n), m, n)
V[,1] <- r
V[,2] <- seq(.5, 2, (2-.5)/(m-1))
V[,3] <- pmax(0,(V[,2] - 1.1))
V[,4] <- pmax(0,(V[,2] - 1.2))
V[,5] <- pmax(0,(.8 - V[,2]))
V[,6] <- pmax(0,(.7 - V[,2]))
f <- .9
c<- 1.15
V[,7] <- pmin(pmax(V[,2]-1, f - 1), c - 1)
p <- rbind(1, 1, .06, .03, .02, .01)

CVXR Setup

p_collar <- Variable()
y <- Variable(m)
objective <- Maximize(p_collar)
constraints <- list(
y >= 0,
t(V) %*% y == rbind(p, p_collar)
)
problem <- Problem(objective, constraints)

solution <- solve(problem) #Solver returned with status solver_error

solution <- solve(problem, solver = 'ECOS') # Feasible Solution Found

Thanks for bringing this to our attention. The problem is not with CVXR, but with OSQP, the solver. For example, try:

solution <- solve(problem, adaptive_rho = FALSE, verbose = TRUE)

and OSQP will solve it.