Profiling CVXPY Vs Solver

150 views
Skip to first unread message

Hong Wong

unread,
Oct 26, 2016, 8:10:38 PM10/26/16
to cvxpy
Hi

Is there a way to view how much time is spend within the solver Vs CVXPY please?

Many Thanks, Hong...

Steven Diamond

unread,
Oct 27, 2016, 11:45:17 AM10/27/16
to cvxpy
You can time "prob.get_problem_data(solver=XXX)" to get the time spent in cvxpy. Generally the solvers show their solve time if you do prob.solve with verbose=True.

Hong Wong

unread,
Oct 27, 2016, 6:09:36 PM10/27/16
to cvxpy
Hi Steven

Thanks very much for the answer - I'm currently using CVXPY, specifically with the ECOS solver for a SOCP.

Everything works fine, although I am seeing that a huge majority of the runtime is being spent creating the C++ CVXCanon LinOp tree i.e. specifically when canonInterface.get_problem_matrix calls canonInterface.build_lin_op_tree to create the C++ Lin Op tree from the Python LinOp tree (this happens on instantiation of cvxpy.problems.problem_data.matrix_data.MatrixData).

i.e. as a rough guide of time consumption (using around 14 constraints), the key steps in problem.solve() are:
1. [27%] Define problem & create objection/constrains
2. [29%] Check the problem is DCP
3. [13%] Canonicalize
3. [30%] Create CVXCanon C++ tree & matrix for use by solver
4. Solve e.g. using ECOS/CVXOPT etc

I'm seeing total calculation wall clock time of around 0.2 secs from problem definition to solve.

By way of background, I'm looking to solve around hundreds of thousands datasets, which is why I'm performance sensitive - my observations show me that the actual solve time is minimal i.e. around 0.0015 secs i.e. the vast majority of time is spend creating constraint representation, checking DCP conformity and then CVXCanon/C++ LinOps tree creation.

I understand the rationale for using CVXCanon, but is there any way to speed up the C++ LinOps tree creation?

Or could you kindly recommend anything to help speed other areas up anymore please? I've gone as far as trying to minimise the number LinOp tree nodes as far as I can - I don't really need the is_dcp check enabled although I can't see anyway of turning it off (I did comment it out for testing though).

Many thanks, Hong...

Steven Diamond

unread,
Oct 27, 2016, 9:06:01 PM10/27/16
to cvxpy
This is a use case where cvxpy doesn't perform super well. You could try using parameters. A better option would be CVXGEN (http://cvxgen.com/docs/index.html) if your problem is a QP. 
 
Can you group your problems into larger separable problems? That's another idea.

Hong Wong

unread,
Oct 29, 2016, 8:50:30 AM10/29/16
to cvxpy
Hi Steven

Okay, will take a look, thanks for the pointers.

Hong...
Reply all
Reply to author
Forward
0 new messages