google / or-tools

Google's Operations Research tools:
https://developers.google.com/optimization/
Apache License 2.0
11.1k stars 2.11k forks source link

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

Open haihaolu opened 1 year ago

haihaolu commented 1 year ago

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:

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?

Mizux commented 1 year ago

devNote:

note: absl-py has nothing to do with abseil-cpp and the team don't bother (i.e. out of the scope, no ressources to do it...) to implement some cross language log support, e.g. swig/pybind11's absl::log wrapper so we'll have to do some PoC to investigate this issue/feature.

mlubin commented 1 year ago

It looks like absl logging was released recently: https://abseil.io/blog/20220908-logging

lperron commented 1 year ago

Yes and no.

There are no release with logging

VLOG is not implemented. So our code will not compile. Laurent Perron | Operations Research | @.*** | (33) 1 42 68 53 00

Le mer. 23 nov. 2022 à 15:17, Miles Lubin @.***> a écrit :

It looks like absl logging was released recently: https://abseil.io/blog/20220908-logging

— Reply to this email directly, view it on GitHub https://github.com/google/or-tools/issues/3559#issuecomment-1325138985, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUPL3IGNL35Q5K3CRYBL6TWJYRPDANCNFSM6AAAAAASICJODA . You are receiving this because you were assigned.Message ID: @.***>

Mizux commented 1 year ago

last release is still 20220623.1 (without absl::log) ref https://github.com/abseil/abseil-cpp/releases

As Laurent said, this is a partial export so we still need half of our hack to fix the missing macros...

Mizux commented 1 year ago

We've just integrate abseil-cpp 20230125.0 in main branch, BUT we will need time to have support from python wrapper (if it's possible)