convexengineering / gpkit

Geometric programming for engineers
http://gpkit.readthedocs.org
MIT License
206 stars 40 forks source link

Solution tables and diffs sorted by model sensitivity #1521

Closed pgkirsch closed 3 years ago

pgkirsch commented 4 years ago

When I look at a solution (or a diff of two solutions), I tend to look at the highest level variables first and work my way "down" the model. Obviously, this doesn't correspond to the alphabetical ordering of models so I end up bouncing around a very large file.

If I understand the recent Sankey functionality correctly, a solution already has the hierarchy I am looking for encoded by way of the model sensitivities. How difficult would it be to add a kwarg to SolutionArray.table and SolutionArray.diff that allows a user to see the models in order of "importance" (sensitivity).

Using the example from the docs Sankey gif, instead of a solution table that presumably looks like:

                | Aircraft
# variables
                | Climb
# variables
                | FlightSegment
# variables
                | Mission
# variables

it would be helpful to have the option to see the table as:

                | Mission
# variables
                | FlightSegment
# variables
                | Aircraft
# variables
                | Climb
# variables

I'm sure there are some complexities with achieving this that I'm not aware of but I think it could be a really useful feature if feasible.

I think there are some interesting tie-ins to #1512 here too (or maybe it's just tangentially related).

bqpd commented 4 years ago

This would be super easy! It seems to me like there's two ways to implement it: 1) looking at the overall sensitivity of a model (as I think your example is showing), and 2) looking at the sensitivity in constraints at its level.

I'd be comfortable not just implementing (1) but consider making it the default (with some threshold alphabetization to avoid too much flipflopping); is there any interest in (2)?