cvxgrp/cvxpy — pull request #8 by echu (2013-09-17 08:09:52+00:00)
Title: added nonlinear atom support.

I added some simple support for nonlinear functions (this is a bit of a misnomer, since square is a nonlinear atom; it's just nonlinear atoms that do not have cone representations). See cvxpy/atoms/nonlinear/log.py for an example. A simple problem using log is under examples/acent_eq.py.

There was also some weird cyclic dependency chain when I tried to install CVXPY (from scratch). You might want to remove your local CVXPY installation and run `sudo python setup.py install` and `nosetests` from scratch. I ran into various issues with `vstack` and whatnot. I tried to fix this, but I didn't get everything.

There are two major changes:

1. `canonicalize` is no longer backward compatible
2. the call to ECOS uses the new, numpy interface; feel free to comment this out and revert (as you did previously) to maintain compatibility with the old ECOS.

The main thing that breaks backward compatibility is that the `canonicalize` function now returns

`(objective, eq_constr, ineq_constr, nonlin_constr, dims)`

instead of just `(objective, eq_constr, ineq_constr, dims)`. The `nonlin_constr` is usually empty unless a logarithm is involved in the problem. When a logarithm is involved, we invoke `cvxopt.solvers.cpl` to solve the problem.

I added a `nonlinear_constraint_function` method to the Problem class; it mirrors the `constraints_matrix` method. It loops over the variables involved in the nonlinear constraint, builds a mapping and stores it, then uses this to evaluate the operator `F`, its gradient, and its Hessian in the nonlinear constraints. This is (for the most part) hacked together, so you might want to clean this up.

Feel free to go over the code and comment or suggest fixes.