convexengineering / gpkit

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

Sort solution tables (that aren't already sorted by values) by model sensitivity, an print a model sensitivity table #1534

Closed bqpd closed 3 years ago

bqpd commented 3 years ago

Closes #1521

Example output:

Optimal Cost
------------
 [ 0.873     1.09      1.61      ]

Swept Variables
---------------
    | Aircraft.Wing
rho : [ 0.5       1         2        ]  [lbf/ft²] areal density

Model Sensitivities (sorts models in sections below)
-------------------
 +2.79 + [   -     -   +0.1 ] : Mission.FlightSegment.AircraftP.WingAero
 +2.51 + [   -     -     -  ] : Mission
 +2.43 + [ -0.2    -   +0.3 ] : Mission.FlightSegment.AircraftP
 +1.64 + [ -0.5    -   +0.6 ] : Aircraft.Wing
 +1.43 + [ -0.6    -   +0.7 ] : Mission.FlightSegment.FlightState
 +1.42 + [ -0.2    -   +0.3 ] : Aircraft
 +0.97 + [   -     -     -  ] : Aircraft.Fuselage

Free Variables
--------------
      | Mission.FlightSegment.AircraftP.WingAero
   CD : [ 0.014     0.014     0.0139    0.0139            drag coefficient
          0.019     0.0189    0.0189    0.0188
          0.0352    0.0351    0.0349    0.0348    ]
   CL : [ 0.797     0.796     0.795     0.793             lift coefficient
          1.01      1         1         1
          1.5       1.49      1.49      1.49      ]
    D : [ 2.19      2.19      2.18      2.18        [lbf] drag force
          2.74      2.73      2.72      2.72
          4.04      4.02      4.01      3.99      ]
   Re : [ 3.79e+05  3.79e+05  3.79e+05  3.79e+05          Reynold's number
          3.65e+05  3.65e+05  3.65e+05  3.65e+05
          3.25e+05  3.25e+05  3.25e+05  3.25e+05  ]

      | Mission.FlightSegment.AircraftP
Wburn : [ 0.219     0.219     0.218     0.218       [lbf] segment fuel burn
          0.274     0.273     0.272     0.272
          0.404     0.402     0.401     0.399     ]
Wfuel : [ 0.873     0.654     0.436     0.218       [lbf] fuel weight
          1.09      0.817     0.544     0.272
          1.61      1.2       0.8       0.399     ]

      | Aircraft.Wing
    S : [ 47.8      44.1      35.1     ]            [ft²] surface area
    W : [ 23.9      44.1      70.1     ]            [lbf] weight
    c : [ 1.33      1.28      1.14     ]            [ft]  mean chord

      | Aircraft
    W : [ 124       144       170      ]            [lbf] weight

Fixed Variables
---------------
    | Mission.FlightSegment.AircraftP.WingAero
  e : [ 0.9       0.9       0.9       0.9      ]           Oswald efficiency

    | Aircraft.Wing
  A : 27                                                   aspect ratio

    | Mission.FlightSegment.FlightState
  V : [ 40        40        40        40       ]  [kt]     true airspeed
 mu : [ 1.63e-05  1.63e-05  1.63e-05  1.63e-05 ]  [N·s/m²] dynamic viscosity
rho : [ 0.74      0.74      0.74      0.74     ]  [kg/m³]  air density

    | Aircraft.Fuselage
  W : 100                                         [lbf]    weight

Variable Sensitivities
----------------------
    | Aircraft.Fuselage
  W : [ +0.96     +0.97     +0.98    ]           weight

    | Aircraft.Wing
  A : [ -0.56     -0.67     -0.82    ]           aspect ratio
rho : [ +0.23     +0.43     +0.69    ]           areal density

    | Mission.FlightSegment.AircraftP.WingAero
  e : [ -0.15     -0.15     -0.15     -0.15      Oswald efficiency
        -0.18     -0.18     -0.18     -0.18
        -0.21     -0.21     -0.21     -0.21     ]

    | Mission.FlightSegment.FlightState
  V : [ -0.12     -0.12     -0.11     -0.11      true airspeed
        -0.22     -0.21     -0.21     -0.21
        -0.35     -0.34     -0.34     -0.34     ]
rho : [ -0.068    -0.068    -0.067    -0.067     air density
        -0.12     -0.11     -0.11     -0.11
        -0.18     -0.18     -0.18     -0.18     ]
 mu : [ +0.02     +0.02     +0.02     +0.02      dynamic viscosity
        +0.015    +0.015    +0.015    +0.015
        +0.0084   +0.0084   +0.0085   +0.0085   ]

Most Sensitive Constraints (in last sweep)
------------------------------------------
       | Aircraft
  +1.7 : .W ≥ .Fuselage.W + .Wing.W

       | Mission
    +1 : Wfuel[0] ≥ Wfuel[1] + Wburn[0]
 +0.75 : Wfuel[1] ≥ Wfuel[2] + Wburn[1]
  +0.5 : Wfuel[2] ≥ Wfuel[3] + Wburn[2]

       | Aircraft.Wing
 +0.69 : .W ≥ S·.rho
bqpd commented 3 years ago

@pgkirsch was this what you were thinking?

pgkirsch commented 3 years ago

@bqpd yes! Looks beautiful!