Problem Description: I am using CVXPY on Google Colab and trying to use MOSEK as the solver for a Second-Order Cone Program (SOCP). However, when I run the following command:
prob.solve(solver=cp.MOSEK, verbose=True)
I get the error: MOSEK solver is not installed or failed. What I've Tried:
- Checking Installed Solvers I checked the available solvers in CVXPY using:
import cvxpy as cp
print(cp.installed_solvers())
Output:
['CLARABEL', 'CVXOPT', 'GLPK', 'GLPK_MI', 'HIGHS', 'MOSEK', 'OSQP', 'SCIPY', 'SCS'] MOSEK appears in the installed solvers list, but I still cannot use it.
- Testing a Simple SOCP Problem I ran a simple Second-Order Cone Problem (SOCP) to check if MOSEK works:
import cvxpy as cp
# Define variables
x = cp.Variable(2)
# Objective function
objective = cp.Minimize(x[0] + x[1])
# Constraints
constraints = [
cp.SOC(1, x), # Second-order cone constraint: sqrt(x1² + x2²) <= 1
x >= 0 # Non-negativity constraint: x1 >= 0, x2 >= 0
]
# Create and solve the problem
prob = cp.Problem(objective, constraints)
# Solve with MOSEK
try:
prob.solve(solver=cp.MOSEK, verbose=True)
print(f"Optimal value: {prob.value}")
print(f"Optimal solution: x1 = {x.value[0]}, x2 = {x.value[1]}")
except cp.error.SolverError:
print("MOSEK solver failed.")
Error Message:
MOSEK solver is not installed or failed. Questions: MOSEK appears in cp.installed_solvers(), so why is it still not working? Do I need additional configurations (e.g., environment variables, license setup) to activate MOSEK? How can I correctly set up CVXPY to use MOSEK on Google Colab?