google / google/or-tools

ORtools solvers via cvxpy do not print out solve information at jupyter notebook

Open
#3,559 5 comments 0 reactions 2 assignees Claimed by @lperron View on GitHub
Feature Request Lang: Python
Dominant language
C++
Stars
14.1k
Forks
2.5k
Avg merge
8h 39m
Merged PRs (30d)
72

Description

**What version of OR-Tools and what language are you using?**
Version: main/v9.4
Language: Python

**Which solver are you using (e.g. CP-SAT, Routing Solver, GLOP, BOP, Gurobi)**
GLOP, PDLP

**What operating system (Linux, Windows, ...) and version?**
Mac

**What did you do?**

Open a jupyter notebook, and run the below code to call ortools solvers (i.e., GLOP or PDLP) via cvxpy using the code below:
```py
import cvxpy as cp
import numpy as np

m = 150
n = 100
np.random.seed(1)
s0 = np.random.randn(m)
lamb0 = np.maximum(-s0, 0)
s0 = np.maximum(s0, 0)
x0 = np.random.randn(n)
A = np.random.randn(m, n)
b = A @ x0 + s0
c = -A.T @ lamb0

x = cp.Variable(n)
prob = cp.Problem(cp.Minimize(c.T@x),
[A @ x <= b])
prob.solve(solver=cp.GLOP, verbose=True)
```
**What did you expect to see**
I expect to see the solving logs at the notebook.

**What did you see instead?**

The solving logs are printed out at the terminal not the notebook. Here are what shown at the notebook. The solving logs are not shown in the numerical solver section.
```
===============================================================================
CVXPY
v1.2.1
===============================================================================
(CVXPY) Nov 22 10:16:37 AM: Your problem has 1000 variables, 1 constraints, and 0 parameters.
(CVXPY) Nov 22 10:16:37 AM: It is compliant with the following grammars: DCP, DQCP
(CVXPY) Nov 22 10:16:37 AM: (If you need to solve this problem multiple times, but with different data, consider using parameters.)
(CVXPY) Nov 22 10:16:37 AM: CVXPY will first compile your problem; then, it will invoke a numerical solver to obtain a solution.
-------------------------------------------------------------------------------
Compilation
-------------------------------------------------------------------------------
(CVXPY) Nov 22 10:16:37 AM: Compiling problem (target solver=GLOP).
(CVXPY) Nov 22 10:16:37 AM: Reduction chain: Dcp2Cone -> CvxAttr2Constr -> ConeMatrixStuffing -> GLOP
(CVXPY) Nov 22 10:16:37 AM: Applying reduction Dcp2Cone
(CVXPY) Nov 22 10:16:37 AM: Applying reduction CvxAttr2Constr
(CVXPY) Nov 22 10:16:37 AM: Applying reduction ConeMatrixStuffing
(CVXPY) Nov 22 10:16:37 AM: Applying reduction GLOP
(CVXPY) Nov 22 10:16:43 AM: Finished problem compilation (took 5.485e+00 seconds).
-------------------------------------------------------------------------------
Numerical solver
-------------------------------------------------------------------------------
(CVXPY) Nov 22 10:16:43 AM: Invoking solver GLOP to obtain a solution.
-------------------------------------------------------------------------------
Summary
-------------------------------------------------------------------------------
(CVXPY) Nov 22 10:17:01 AM: Problem status: optimal
(CVXPY) Nov 22 10:17:01 AM: Optimal value: 3.907e+02
(CVXPY) Nov 22 10:17:01 AM: Compilation took 5.485e+00 seconds
(CVXPY) Nov 22 10:17:01 AM: Solver (including time spent in interface) took 1.824e+01 seconds
```

Make sure you include information that can help us debug (full error message, model Proto).

**Anything else we should know about your project / environment**

I am creating an education plan on using PDLP via cvxpy and jupyter notebook, and this issue raises up.

Could you please add dapplegate@google.com and miles.lubin@gmail.com for this issue?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.