cvxgrp/qcml — pull request #30 by chinasaur (2013-09-16 04:08:03+00:00)
Title: Flexdims/4

See abstract_dim for main changes. I implemented the arithmetic operators that I needed to get the CBP example to work, but I haven't tested other examples, so there are probably things missing. E.g. AD.__mul__ assumes the other is also an AD, but may need to be willing to handle an int. Most of the other operators handle ints.

Changes to codegens and encoders was mostly just changing %d to %s in a bunch of places.

The ugly part was trying to get the abstract dim variable names properly wrapped (dims.m for Matlab, dims['m'] for Python, dims->m for C). It might have been easier if I hadn't already hacked out the old dimension_dictionary stuff, but still I think the new way is cleaner. Codegen's now must implement abstract base method abstractdim_rewriter. When shape.size() is called in Codegen, this rewriting function is passed in to translate m to dims.m, etc.

Matlab codegen gets correct optval. C codegen compiles and Python looks good, but I haven't tested those. All codegen prob2socp now take a dims argument as second argument; I didn't add any logic to test whether the dims argument is really needed, i.e. whether there are any dims that aren't set to straight integers.

A future possibility would be to pull dims out of the function arguments and use the size of one of the params to determine dims. Requires walking through the params and finding one whose shape reflects each of the abstract dims.

I changed the name of the dims.l dims.q dims.s variable to cones.l cones.q cones.s to avoid clashing with the input dims variable. When 'cones' is loaded into 'data' at the end though, it goes in as 'dims' to be compatible with ECOS.

Shape no longer pays much attention to whether it is "instantiated" as the rest of the code can now handle concrete int dims or abstract dims. But I left the instantiated logic in there as it was used by the future slice method and I didn't think through how that would play out.

I think that sums it up; hope it's not a bear to merge with your changes!