Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
haihaolu opened this issue Nov 22, 2022 · 5 comments
Assignees
Labels
Feature Request Missing Feature/Wrapper Lang: Python Python wrapper issue
Milestone

Comments

@haihaolu
Copy link

haihaolu commented Nov 22, 2022

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 Mizux added Feature Request Missing Feature/Wrapper Lang: Python Python wrapper issue labels Nov 23, 2022
@Mizux Mizux added this to the v9.6 milestone Nov 23, 2022
@Mizux
Copy link
Collaborator

Mizux commented Nov 23, 2022

devNote:

  • We currently use a custom "GLOG" implem written on top of absl::flags.
  • By the end of this year, abseil-cpp should publish a new release with absl::log so we'll need to migrate to it (i.e. drop our custom glog/absl::flags implem).
  • Absl::log should give us the possibility to send log to a callback instead of stderr so logs could be redirected to a python logging system...

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.

@Mizux Mizux added this to To do in Feature Requests via automation Nov 23, 2022
@Mizux Mizux moved this from To do to stall in Feature Requests Nov 23, 2022
@mlubin
Copy link
Contributor

mlubin commented Nov 23, 2022

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

@lperron
Copy link
Collaborator

lperron commented Nov 23, 2022 via email

@Mizux
Copy link
Collaborator

Mizux commented Nov 23, 2022

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 Mizux modified the milestones: v9.6, v10.0 Feb 3, 2023
@Mizux
Copy link
Collaborator

Mizux commented Feb 3, 2023

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)

@Mizux Mizux modified the milestones: v10.0, v9.7 Feb 3, 2023
@Mizux Mizux modified the milestones: v9.7, v9.8 Jun 6, 2023
@Mizux Mizux modified the milestones: v9.8, v9.9 Oct 13, 2023
@Mizux Mizux modified the milestones: v9.9, v10.0 Feb 14, 2024
@Mizux Mizux modified the milestones: v10.0, Backlog Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request Missing Feature/Wrapper Lang: Python Python wrapper issue
4 participants