convexengineering / gpkit

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

Signomial Programs don't return sensitivities correctly #457

Closed pgkirsch closed 8 years ago

pgkirsch commented 9 years ago

I don't think SPs are returning sensitivities correctly. I have always been surprised by how few sensitivities get returned for some of my SPs. I'm aware that there is a threshold above which values must fall to get printed in results table, but I don't think I actually believe that so many of these fall below threshold. Consider two pieces of code (long again, sorry). I have an SP that only has one somewhat dumb signomial constraint in it at the moment. This signomial can easily be removed. The reason I haven't is a topic for another time. Anyway, if I solve the SP version, my results table has no sensitivities (surprising considering I have 30+ constants). But if I eliminate the signomial constraint thus making the almost exact same problem a GP and resolve, I get > 20 sensitivities. See below.

The original SP

from gpkit import Variable, Model, SignomialsEnabled, units
import numpy as np
import numpy.testing as npt

class Fuselage(Model):
    """
    Fuselage model
    """
    def setup(self):

        # Variables
#        Acone =    Variable('Acone', 'm^2', 'Cone enclosed area')
        Afloor =    Variable('Afloor', 'm^2', 'Floor area')
        Afuse =     Variable('Afuse', 'm^2', 'Cross sectional area')
        Askin =     Variable('Askin', 'm^2', 'Cross sectional area of skin')
        dRfuse =    Variable('dRfuse', 'm', 'Offset of lower fuselage cylinder')
        hfloor =    Variable('hfloor', 'm', 'Floor I-beam height') # Value
#        Ihshell =  Variable('Ihshell', 'm^4', 'Bending inertia')
#        Ivshell =  Variable('Ivshell', 'm^4', 'Bending inertia')
        lfloor =    Variable('lfloor', 'm', 'Floor length')
        lcone =     Variable('lcone', 'm', 'Cone length') # added this 
        lnose =     Variable('lnose', 'm', 'Nose length')
        lshell =    Variable('lshell', 'm', 'Shell length')
        Mfloor =    Variable('Mfloor', 'N*m', 'Maximum bending moment in floor beams')
        nrows =     Variable('n_{rows}', '-', 'Number of rows')
        Pfloor =    Variable('Pfloor', 'N', 'Distributed floor load')
        plamcone =  Variable('plamcone', '-', 'Cone taper ratio + 1')
        plamv =     Variable('plamv', '-', '1 + 2*Tail taper ratio')
        qlamv =     Variable('qlamv', '-', '1 + Tail taper ratio')
        Qv =        Variable('Qv', 'N*m', 'Torsion moment imparted by vertical tail')
#        Rcone =    Variable('Rcone', 'm', 'Cone radius')
        Rfuse =     Variable('Rfuse', 'm', 'Fuselage radius')
        Sbulk =     Variable('Sbulk', 'm^2', 'Bulkhead surface area')
        Sfloor =    Variable('Sfloor', 'N', 'Maximum shear in floor beams')
        sigth =     Variable('sigth', 'N/m^2', 'Hoop stress in skin')
        sigx =      Variable('sigx', 'N/m^2', 'Axial stress in skin')
        Snose =     Variable('Snose', 'm^2', 'Nose surface area')
        taucone =   Variable('taucone', 'N/m^2', 'Shear stress in cone')
        tcone =     Variable('tcone', 'm', 'Cone thickness')
        tshell =    Variable('tshell', 'm', 'Shell thickness')
        tskin =     Variable('tskin', 'm', 'Skin thickness')
        Vbulk =     Variable('Vbulk', 'm^3', 'Bulkhead skin volume')
        Vcone =     Variable('Vcone', 'm^3', 'Volume of cone skin')
        Vcyl =      Variable('Vcyl', 'm^3', 'Cylinder skin volume')
        Vfloor =    Variable('Vfloor', 'm^3', 'Floor volume')
        Vnose =     Variable('Vnose', 'm^3', 'Nose skin volume')
        Wapu =      Variable('Wapu', 'N', 'Weight of APU')
        Wcone =     Variable('Wcone', 'N', 'Weight of cone')
        wfloor =    Variable('wfloor', 'm', 'Floor width')
        Wfloor =    Variable('Wfloor', 'N', 'Floor weight')
        Wfuse =     Variable('Wfuse', 'N', 'Fuselage weight')
        Winsul =    Variable('Winsul', 'N', 'Weight of insulation material')
        Wpadd =     Variable('Wpadd', 'N', 'Misc weights (attendants, food, galley, toilets, doors etc.)')
        Wseat =     Variable('Wseat', 'N', 'Weight of seats')
        Wshell =    Variable('Wshell', 'N', 'Shell weight')
        Wskin =     Variable('Wskin', 'N', 'Skin weight')
        Wwindow =   Variable('Wwindow', 'N', 'Weight of windows')
#        xapu =     Variable('xapu', 120*0.3048, 'm', 'x-location of APU')
#        xconend =   Variable('xconend', 'm', 'x-location of cone end')
        xshell1 =   Variable('xshell1', 'm', 'Start of cylinder section') # value subbed as constraint
#        xshell2 =   Variable('xshell2', 102*0.3048, 'm', 'End of cyinder section')
#        xVbulk =   Variable('xVbulk', 'm^4', 'Volume moment of bulkhead')
#        xVcyl =    Variable('xVcyl', 'm^4', 'Volume moment of cylinder')
#        xVnose =   Variable('xVnose', 'm^4', 'Volume moment of nose')
#        xWapu =    Variable('xWapu', 'N*m', 'Moment of APU')
#        xWcone =   Variable('xWcone', 'N*m', 'Moment of cone')
#        xWfix =    Variable('xWfix', 'N*m', 'Moment of fixed weights')
#        xWfloor =  Variable('xWfloor', 'N*m', 'Moment of floor weight')
#        xWfuse =   Variable('xWfuse', 'N*m', 'Fuselage moment')
#        xWinsul =  Variable('xWinsul', 'N*m', 'Mass moment of insulation material')
#        xWpadd =   Variable('xWpadd', 'N*m', 'Moment of misc weights')
#        xWseat =   Variable('xWseat', 'N*m', 'Moment of seats')
#        xWshell =  Variable('xWshell', 'N*m', 'Mass moment of shell')
#        xWskin =   Variable('xWskin', 'N*m', 'Mass moment of skin')
#        xWwindow = Variable('xWwindow', 'N*m', 'Mass moment of windows')

        # Constants ([TAS] means sourced from TASOPT)
        bv =        Variable('bv', 7, 'm', 'Vertical tail span')
#        CLvmax =   Variable('CLvmax', 2.6, '-', 'Tail max lift coefficient') # [TAS]
        dp =        Variable('\\Deltap', 76000-24000, 'Pa', 'Pressure difference across fuselage skin')
        fapu =      Variable('fapu', 0.035, '-', 'APU weight as fraction of payload weight') # [TAS]
        ffadd =     Variable('ffadd', 0.20, '-', 'Skin proportional added weight of local reinforcmenets') # [TAS]
        fframe =    Variable('fframe', 0.25, '-', 'Fractional weight of frame')
        fpadd =     Variable('fpadd', 0.35, '-', 'All other misc weight as fraction of payload weight') # [TAS]
        fseat =     Variable('fseat', 0.10, '-', 'Seat weight as fraction of payload weight')
        fstring =   Variable('fstring', 0.35, '-', 'Fraction of stringers?') # [TAS]
        g =         Variable('g', 9.81, 'm/s^2', 'Gravitational acceleration')
        Lvmax =     Variable('Lvmax', 35000, 'N', 'Tail max lift')
        Nland =     Variable('Nland', 6.0,  '-', 'Emergency landing load factor') # [TAS]
        nseats =    Variable('n_{seats}', 186, '-', 'Number of seats') # Must be multiple of SPR
        pitch =     Variable('pitch', 31 , 'in', 'Seat pitch') # Boeing doc
#        qNE =      Variable('qNE', 'Pa', 'Never exceed dynamic pressure')
        rE =        Variable('rE', 1.0, '-', 'Ratio of stringer/skin moduli') # [TAS]
        rhobend =   Variable('rhobend', 2700, 'kg/m^3', 'Stringer density') # [TAS]
        rhocone =   Variable('rhocone', 2700, 'kg/m^3', 'Density of cone material') # [TAS]
        rhofloor =  Variable('rhofloor', 2700, 'kg/m^3', 'Density of floor material') # [TAS]
        rhoskin =   Variable('rhoskin', 2700, 'kg/m^3', 'Skin density') # [TAS]
        sigfloor =  Variable('sigfloor', 30000/0.000145, 'N/m^2', 'Max allowable cap stress') # [TAS]
        sigskin =   Variable('sigskin', 15000/0.000145, 'N/m^2', 'Max allowable skin stress') # [TAS]
        SPR =       Variable('SPR', 6, '-', 'Number of seats per row')
#        Sv =       Variable('Sv', 20, 'm^2', 'Tail reference area')
        taufloor =  Variable('taufloor', 30000/0.000145, 'N/m^2', 'Max allowable shear web stress') # [TAS]
        waisle =    Variable('w_{aisle}', 0.51, 'm', 'Aisle width') # Boeing doc
        Wfix =      Variable('Wfix', 3000*4.45, 'N', 'Fixed weights (pilots, cockpit seats, instrumentation, navcom)')
        Wpay =      Variable('Wpay', 177000, 'N', 'Payload weight') # b737.org.uk
        Wppfloor =  Variable('Wppfloor', 60, 'N/m^2', 'Floor weight/area density') # [TAS]
        Wppinsul =  Variable('Wppinsul', 22, 'N/m^2', 'Weight/Area density of insulation material') # [TAS]
        Wpwindow =  Variable('Wpwindow', 145.*3, 'N/m', 'Weight/Length density of windows') # [TAS]
        wseat =     Variable('w_{seat}', 0.5, 'm', 'Seat width') # Boeing doc
#        xfix =     Variable('xfix', 7*0.3048, 'm', 'x-location of fixed weights')

#        Vcabin
#        rhocabin
#        rho0
#        R
#        Tcabin
#        pcabin
#        Wbuoy
#        Weff

        with SignomialsEnabled():
            objective = Wfuse

            constraints = [
                            # Geometry relations
                            lnose == xshell1,

                            # Cross section relations
                            Rfuse >= 77*0.0254*units.m, # TODO: this needs to be driven by something e.g. number of passengers
                            dRfuse >= 15*0.0254*units.m, # TODO: this needs to be driven by something e.g. cargo capacity
                            Askin >= 2*np.pi*Rfuse*tskin + 2*dRfuse*tskin,
                            Afuse >= np.pi*Rfuse**2,# + 2*Rfuse*dRfuse, # TODO Fix this
                            tshell >= tskin*(1 + rE*fstring*rhoskin/rhobend),
    #                            Ihshell >= (np.pi*Rfuse**2 + 2*np.pi*(dRfuse/2)**2)*Rfuse*tshell,
    #                            Ivshell >= np.pi*Rfuse**2 * Rfuse*tshell,

                            # Pressure shell loads
                            sigx == dp/2*Rfuse/tshell,
                            sigth == dp*Rfuse/tskin,
                            tskin == dp*Rfuse/sigskin,
                            Snose**(8./5) >= (2*np.pi*Rfuse**2)**(8./5) * (1./3 + (2./3)*(lnose/Rfuse)**(8./5)),
                            Sbulk == 2*np.pi*Rfuse**2,
                            Vcyl == Askin*lshell,
                            Vnose == Snose*tskin,
                            Vbulk == Sbulk*tskin,
    #                        xVcyl >= 0.5*(xshell1+xshell2)*Vcyl,
    #                        xVnose >= 0.5*(xshell1)*Vnose,
    #                        xVbulk >= (xshell2 + 0.5*dRfuse)*Vbulk,
                            Wskin >= rhoskin*g*(Vcyl + Vnose + Vbulk),
    #                        xWskin >= rhoskin*g*(xVcyl + xVnose + xVbulk),
                            Wshell >= Wskin*(1 + fstring + fframe + ffadd),
    #                        xWshell >= xWskin*(1 + fstring + fframe + ffadd),

                            # Cabin volume and buoyancy weight
    #                            rhocabin == (1/R*Tcabin)*pcabin,
    #                            Wbuoy >= (rhocabin - rho0)*g*Vcabin, # SP
    #                            Weff >= W + Wbuoy,

                           # Windows and insulation
                           Wwindow == Wpwindow * lshell,
    #                       xWwindow >= 0.5* (xshell1+xshell2)*Wwindow,
                           Winsul >= Wppinsul*(1.1*np.pi*Rfuse*lshell + 0.55*(Snose + Sbulk)),
    #                       xWinsul >= 0.5*(xshell1 + xshell2)*Winsul,

                           # Payload-proportional weights
                           Wapu == Wpay*fapu,
    #                       xWapu == xapu*Wapu,
                           Wseat == Wpay*fseat,
    #                       xWseat >= 0.5*(xshell1 + xshell2)*Wseat,
                           Wpadd == Wpay*fpadd,
    #                       xWpadd >= 0.5*(xshell1 + xshell2)*Wpadd,

                            # Fixed weight
    #                       xWfix == xfix*Wfix,

                            # Floor
                            Pfloor >= Nland*(Wpay + Wseat),
                            Sfloor == 0.5*Pfloor, # without support
                            Mfloor == 0.25*Pfloor*wfloor,
#                            lshell >= xshell2 - xshell1, # NOTE: [SP]
#                            xshell2 >= xshell1 + lshell, # NOTE: requires downward pressure on xshell2
                            lnose >= 5.18*units.m, # TODO: this needs to be driven by something e.g cockpit length
                            Afloor >= 2*Mfloor/(sigfloor*hfloor) + 1.5*Sfloor/taufloor,
                            hfloor <= 5*0.0254*units.m, # TODO: Get better upper bound on hfloor
                            Vfloor >= 2*Rfuse*Afloor,
                            lfloor >= lshell + 2*Rfuse,
                            Wfloor >= rhofloor*g*Vfloor + 2*wfloor*lfloor*Wppfloor,
   #                        xWfloor >= 0.5*(xshell1 + xshell2)*Wfloor,

                            # Tail cone
                            Qv == Lvmax*bv*plamv/(3*qlamv), # uses same p, q trick as GP for A/C design
                            2*qlamv <= 1 + plamv, # NOTE: [SP] (could be eliminated if necessary)
                            plamv >= 1.6,
                            taucone == sigskin,
                            Qv == 2*Afuse*taucone*tcone, # modified to match TASOPT code
    #                           Acone >= Afuse*(1 + plamcone*qlamcone*()/())
    #                           Rcone >= ....
    #                           tcone
                            Vcone*Rfuse*plamcone >= 2*Qv/taucone * lcone,
                            lcone >= 15*0.3048*units.m, # TODO: this needs to be driven by something (e.g. APU size)
    #                       xshell2 + lcone <= xconend,
                            plamcone <= 1.3,
                            Wcone >= rhocone*g*Vcone*(1 + fstring + fframe + ffadd),
    #                        xWcone >= 0.5*(xshell2 + xconend) * Wcone,

                            # Passenger requirements
                            nseats == nrows*SPR,
                            lshell >= nrows*pitch,
                            wfloor >= SPR*wseat + waisle,

                            # Total fuselage weight
                            Wfuse >= Wfix + Wapu + Wpadd + Wseat + Wshell + Wwindow + Winsul
                                     + Wcone + Wfloor,
    #                        xWfuse >= xWfix + xWapu + xWpadd + xWseat + xWshell + xWcone
    #                                 + xWwindow + xWinsul + xWfloor
                          ]
            return objective, constraints

    def test(self):
        sol = self.localsolve()

#        npt.assert_almost_equal(sol('lshell'), sol('xshell2') - sol('xshell1'), decimal=2)
        npt.assert_almost_equal(2*sol('qlamv'), 1 + sol('plamv'), decimal=5)

if __name__ == "__main__":
    Fuselage().test()

################
$ ipython fuselage.py

....

Sensitivities
-------------

The GP

from gpkit import Variable, Model, SignomialsEnabled, units
import numpy as np
import numpy.testing as npt

class Fuselage(Model):
    """
    Fuselage model
    """
    def setup(self):

        # Variables
#        Acone =    Variable('Acone', 'm^2', 'Cone enclosed area')
        Afloor =    Variable('Afloor', 'm^2', 'Floor area')
        Afuse =     Variable('Afuse', 'm^2', 'Cross sectional area')
        Askin =     Variable('Askin', 'm^2', 'Cross sectional area of skin')
        dRfuse =    Variable('dRfuse', 'm', 'Offset of lower fuselage cylinder')
        hfloor =    Variable('hfloor', 'm', 'Floor I-beam height') # Value
#        Ihshell =  Variable('Ihshell', 'm^4', 'Bending inertia')
#        Ivshell =  Variable('Ivshell', 'm^4', 'Bending inertia')
        lfloor =    Variable('lfloor', 'm', 'Floor length')
        lcone =     Variable('lcone', 'm', 'Cone length') # added this 
        lnose =     Variable('lnose', 'm', 'Nose length')
        lshell =    Variable('lshell', 'm', 'Shell length')
        Mfloor =    Variable('Mfloor', 'N*m', 'Maximum bending moment in floor beams')
        nrows =     Variable('n_{rows}', '-', 'Number of rows')
        Pfloor =    Variable('Pfloor', 'N', 'Distributed floor load')
        plamcone =  Variable('plamcone', '-', 'Cone taper ratio + 1')
        plamv =     Variable('plamv', '-', '1 + 2*Tail taper ratio')
        qlamv =     Variable('qlamv', '-', '1 + Tail taper ratio')
        Qv =        Variable('Qv', 'N*m', 'Torsion moment imparted by vertical tail')
#        Rcone =    Variable('Rcone', 'm', 'Cone radius')
        Rfuse =     Variable('Rfuse', 'm', 'Fuselage radius')
        Sbulk =     Variable('Sbulk', 'm^2', 'Bulkhead surface area')
        Sfloor =    Variable('Sfloor', 'N', 'Maximum shear in floor beams')
        sigth =     Variable('sigth', 'N/m^2', 'Hoop stress in skin')
        sigx =      Variable('sigx', 'N/m^2', 'Axial stress in skin')
        Snose =     Variable('Snose', 'm^2', 'Nose surface area')
        taucone =   Variable('taucone', 'N/m^2', 'Shear stress in cone')
        tcone =     Variable('tcone', 'm', 'Cone thickness')
        tshell =    Variable('tshell', 'm', 'Shell thickness')
        tskin =     Variable('tskin', 'm', 'Skin thickness')
        Vbulk =     Variable('Vbulk', 'm^3', 'Bulkhead skin volume')
        Vcone =     Variable('Vcone', 'm^3', 'Volume of cone skin')
        Vcyl =      Variable('Vcyl', 'm^3', 'Cylinder skin volume')
        Vfloor =    Variable('Vfloor', 'm^3', 'Floor volume')
        Vnose =     Variable('Vnose', 'm^3', 'Nose skin volume')
        Wapu =      Variable('Wapu', 'N', 'Weight of APU')
        Wcone =     Variable('Wcone', 'N', 'Weight of cone')
        wfloor =    Variable('wfloor', 'm', 'Floor width')
        Wfloor =    Variable('Wfloor', 'N', 'Floor weight')
        Wfuse =     Variable('Wfuse', 'N', 'Fuselage weight')
        Winsul =    Variable('Winsul', 'N', 'Weight of insulation material')
        Wpadd =     Variable('Wpadd', 'N', 'Misc weights (attendants, food, galley, toilets, doors etc.)')
        Wseat =     Variable('Wseat', 'N', 'Weight of seats')
        Wshell =    Variable('Wshell', 'N', 'Shell weight')
        Wskin =     Variable('Wskin', 'N', 'Skin weight')
        Wwindow =   Variable('Wwindow', 'N', 'Weight of windows')
#        xapu =     Variable('xapu', 120*0.3048, 'm', 'x-location of APU')
#        xconend =   Variable('xconend', 'm', 'x-location of cone end')
        xshell1 =   Variable('xshell1', 'm', 'Start of cylinder section') # value subbed as constraint
#        xshell2 =   Variable('xshell2', 102*0.3048, 'm', 'End of cyinder section')
#        xVbulk =   Variable('xVbulk', 'm^4', 'Volume moment of bulkhead')
#        xVcyl =    Variable('xVcyl', 'm^4', 'Volume moment of cylinder')
#        xVnose =   Variable('xVnose', 'm^4', 'Volume moment of nose')
#        xWapu =    Variable('xWapu', 'N*m', 'Moment of APU')
#        xWcone =   Variable('xWcone', 'N*m', 'Moment of cone')
#        xWfix =    Variable('xWfix', 'N*m', 'Moment of fixed weights')
#        xWfloor =  Variable('xWfloor', 'N*m', 'Moment of floor weight')
#        xWfuse =   Variable('xWfuse', 'N*m', 'Fuselage moment')
#        xWinsul =  Variable('xWinsul', 'N*m', 'Mass moment of insulation material')
#        xWpadd =   Variable('xWpadd', 'N*m', 'Moment of misc weights')
#        xWseat =   Variable('xWseat', 'N*m', 'Moment of seats')
#        xWshell =  Variable('xWshell', 'N*m', 'Mass moment of shell')
#        xWskin =   Variable('xWskin', 'N*m', 'Mass moment of skin')
#        xWwindow = Variable('xWwindow', 'N*m', 'Mass moment of windows')

        # Constants ([TAS] means sourced from TASOPT)
        bv =        Variable('bv', 7, 'm', 'Vertical tail span')
#        CLvmax =   Variable('CLvmax', 2.6, '-', 'Tail max lift coefficient') # [TAS]
        dp =        Variable('\\Deltap', 76000-24000, 'Pa', 'Pressure difference across fuselage skin')
        fapu =      Variable('fapu', 0.035, '-', 'APU weight as fraction of payload weight') # [TAS]
        ffadd =     Variable('ffadd', 0.20, '-', 'Skin proportional added weight of local reinforcmenets') # [TAS]
        fframe =    Variable('fframe', 0.25, '-', 'Fractional weight of frame')
        fpadd =     Variable('fpadd', 0.35, '-', 'All other misc weight as fraction of payload weight') # [TAS]
        fseat =     Variable('fseat', 0.10, '-', 'Seat weight as fraction of payload weight')
        fstring =   Variable('fstring', 0.35, '-', 'Fraction of stringers?') # [TAS]
        g =         Variable('g', 9.81, 'm/s^2', 'Gravitational acceleration')
        Lvmax =     Variable('Lvmax', 35000, 'N', 'Tail max lift')
        Nland =     Variable('Nland', 6.0,  '-', 'Emergency landing load factor') # [TAS]
        nseats =    Variable('n_{seats}', 186, '-', 'Number of seats') # Must be multiple of SPR
        pitch =     Variable('pitch', 31 , 'in', 'Seat pitch') # Boeing doc
#        qNE =      Variable('qNE', 'Pa', 'Never exceed dynamic pressure')
        rE =        Variable('rE', 1.0, '-', 'Ratio of stringer/skin moduli') # [TAS]
        rhobend =   Variable('rhobend', 2700, 'kg/m^3', 'Stringer density') # [TAS]
        rhocone =   Variable('rhocone', 2700, 'kg/m^3', 'Density of cone material') # [TAS]
        rhofloor =  Variable('rhofloor', 2700, 'kg/m^3', 'Density of floor material') # [TAS]
        rhoskin =   Variable('rhoskin', 2700, 'kg/m^3', 'Skin density') # [TAS]
        sigfloor =  Variable('sigfloor', 30000/0.000145, 'N/m^2', 'Max allowable cap stress') # [TAS]
        sigskin =   Variable('sigskin', 15000/0.000145, 'N/m^2', 'Max allowable skin stress') # [TAS]
        SPR =       Variable('SPR', 6, '-', 'Number of seats per row')
#        Sv =       Variable('Sv', 20, 'm^2', 'Tail reference area')
        taufloor =  Variable('taufloor', 30000/0.000145, 'N/m^2', 'Max allowable shear web stress') # [TAS]
        waisle =    Variable('w_{aisle}', 0.51, 'm', 'Aisle width') # Boeing doc
        Wfix =      Variable('Wfix', 3000*4.45, 'N', 'Fixed weights (pilots, cockpit seats, instrumentation, navcom)')
        Wpay =      Variable('Wpay', 177000, 'N', 'Payload weight') # b737.org.uk
        Wppfloor =  Variable('Wppfloor', 60, 'N/m^2', 'Floor weight/area density') # [TAS]
        Wppinsul =  Variable('Wppinsul', 22, 'N/m^2', 'Weight/Area density of insulation material') # [TAS]
        Wpwindow =  Variable('Wpwindow', 145.*3, 'N/m', 'Weight/Length density of windows') # [TAS]
        wseat =     Variable('w_{seat}', 0.5, 'm', 'Seat width') # Boeing doc
#        xfix =     Variable('xfix', 7*0.3048, 'm', 'x-location of fixed weights')

#        Vcabin
#        rhocabin
#        rho0
#        R
#        Tcabin
#        pcabin
#        Wbuoy
#        Weff

#        with SignomialsEnabled():
        if True == True:
            objective = Wfuse

            constraints = [
                            # Geometry relations
                            lnose == xshell1,

                            # Cross section relations
                            Rfuse >= 77*0.0254*units.m, # TODO: this needs to be driven by something e.g. number of passengers
                            dRfuse >= 15*0.0254*units.m, # TODO: this needs to be driven by something e.g. cargo capacity
                            Askin >= 2*np.pi*Rfuse*tskin + 2*dRfuse*tskin,
                            Afuse >= np.pi*Rfuse**2,# + 2*Rfuse*dRfuse, # TODO Fix this
                            tshell >= tskin*(1 + rE*fstring*rhoskin/rhobend),
    #                            Ihshell >= (np.pi*Rfuse**2 + 2*np.pi*(dRfuse/2)**2)*Rfuse*tshell,
    #                            Ivshell >= np.pi*Rfuse**2 * Rfuse*tshell,

                            # Pressure shell loads
                            sigx == dp/2*Rfuse/tshell,
                            sigth == dp*Rfuse/tskin,
                            tskin == dp*Rfuse/sigskin,
                            Snose**(8./5) >= (2*np.pi*Rfuse**2)**(8./5) * (1./3 + (2./3)*(lnose/Rfuse)**(8./5)),
                            Sbulk == 2*np.pi*Rfuse**2,
                            Vcyl == Askin*lshell,
                            Vnose == Snose*tskin,
                            Vbulk == Sbulk*tskin,
    #                        xVcyl >= 0.5*(xshell1+xshell2)*Vcyl,
    #                        xVnose >= 0.5*(xshell1)*Vnose,
    #                        xVbulk >= (xshell2 + 0.5*dRfuse)*Vbulk,
                            Wskin >= rhoskin*g*(Vcyl + Vnose + Vbulk),
    #                        xWskin >= rhoskin*g*(xVcyl + xVnose + xVbulk),
                            Wshell >= Wskin*(1 + fstring + fframe + ffadd),
    #                        xWshell >= xWskin*(1 + fstring + fframe + ffadd),

                            # Cabin volume and buoyancy weight
    #                            rhocabin == (1/R*Tcabin)*pcabin,
    #                            Wbuoy >= (rhocabin - rho0)*g*Vcabin, # SP
    #                            Weff >= W + Wbuoy,

                           # Windows and insulation
                           Wwindow == Wpwindow * lshell,
    #                       xWwindow >= 0.5* (xshell1+xshell2)*Wwindow,
                           Winsul >= Wppinsul*(1.1*np.pi*Rfuse*lshell + 0.55*(Snose + Sbulk)),
    #                       xWinsul >= 0.5*(xshell1 + xshell2)*Winsul,

                           # Payload-proportional weights
                           Wapu == Wpay*fapu,
    #                       xWapu == xapu*Wapu,
                           Wseat == Wpay*fseat,
    #                       xWseat >= 0.5*(xshell1 + xshell2)*Wseat,
                           Wpadd == Wpay*fpadd,
    #                       xWpadd >= 0.5*(xshell1 + xshell2)*Wpadd,

                            # Fixed weight
    #                       xWfix == xfix*Wfix,

                            # Floor
                            Pfloor >= Nland*(Wpay + Wseat),
                            Sfloor == 0.5*Pfloor, # without support
                            Mfloor == 0.25*Pfloor*wfloor,
#                            lshell >= xshell2 - xshell1, # NOTE: [SP]
#                            xshell2 >= xshell1 + lshell, # NOTE: requires downward pressure on xshell2
                            lnose >= 5.18*units.m, # TODO: this needs to be driven by something e.g cockpit length
                            Afloor >= 2*Mfloor/(sigfloor*hfloor) + 1.5*Sfloor/taufloor,
                            hfloor <= 5*0.0254*units.m, # TODO: Get better upper bound on hfloor
                            Vfloor >= 2*Rfuse*Afloor,
                            lfloor >= lshell + 2*Rfuse,
                            Wfloor >= rhofloor*g*Vfloor + 2*wfloor*lfloor*Wppfloor,
   #                        xWfloor >= 0.5*(xshell1 + xshell2)*Wfloor,

                            # Tail cone
                            Qv == Lvmax*bv*plamv/(3*qlamv), # uses same p, q trick as GP for A/C design
                       #     2*qlamv <= 1 + plamv, # NOTE: [SP] (could be eliminated if necessary)
                            qlamv == 1.3,
                            plamv == 1.6,
                            taucone == sigskin,
                            Qv == 2*Afuse*taucone*tcone, # modified to match TASOPT code
    #                           Acone >= Afuse*(1 + plamcone*qlamcone*()/())
    #                           Rcone >= ....
    #                           tcone
                            Vcone*Rfuse*plamcone >= 2*Qv/taucone * lcone,
                            lcone >= 15*0.3048*units.m, # TODO: this needs to be driven by something (e.g. APU size)
    #                       xshell2 + lcone <= xconend,
                            plamcone <= 1.3,
                            Wcone >= rhocone*g*Vcone*(1 + fstring + fframe + ffadd),
    #                        xWcone >= 0.5*(xshell2 + xconend) * Wcone,

                            # Passenger requirements
                            nseats == nrows*SPR,
                            lshell >= nrows*pitch,
                            wfloor >= SPR*wseat + waisle,

                            # Total fuselage weight
                            Wfuse >= Wfix + Wapu + Wpadd + Wseat + Wshell + Wwindow + Winsul
                                     + Wcone + Wfloor,
    #                        xWfuse >= xWfix + xWapu + xWpadd + xWseat + xWshell + xWcone
    #                                 + xWwindow + xWinsul + xWfloor
                          ]
            return objective, constraints

########################
> from gpkit import Model
> m = Model(m[0],m[1])
> sol = m.solve()

....

Sensitivities
-------------
    Nland : 0.05552  Emergency landing load factor                                 
      SPR : -0.1456  Number of seats per row                                       
     Wfix : 0.08696  Fixed weights (pilots, cockpit seats, instrumentation, navcom)
     Wpay : 0.6147   Payload weight                                                
 Wppfloor : 0.07771  Floor weight/area density                                     
 Wppinsul : 0.02968  Weight/Area density of insulation material                    
 Wpwindow : 0.06917  Weight/Length density of windows                              
  \Deltap : 0.1207   Pressure difference across fuselage skin                      
     fapu : 0.04036  APU weight as fraction of payload weight                      
    ffadd : 0.01353  Skin proportional added weight of local reinforcmenets        
   fframe : 0.01691  Fractional weight of frame                                    
    fpadd : 0.4036   All other misc weight as fraction of payload weight           
    fseat : 0.1203   Seat weight as fraction of payload weight                     
  fstring : 0.02367  Fraction of stringers?                                        
        g : 0.1773   Gravitational acceleration                                    
n_{seats} : 0.2571   Number of seats                                               
    pitch : 0.2571   Seat pitch                                                    
 rhofloor : 0.05552  Density of floor material                                     
  rhoskin : 0.1207   Skin density                                                  
 sigfloor : -0.05266 Max allowable cap stress                                      
  sigskin : -0.1217  Max allowable skin stress                                     
w_{aisle} : 0.01894  Aisle width                                                   
 w_{seat} : 0.1114   Seat width  
bqpd commented 9 years ago

Yeah, this is probably true. I thought I already had an issue for it, sorry. Current state is that they're occasionally correct.

bqpd commented 9 years ago

What is the sol["sensitivities"]["monomials"] in the SP example?

pgkirsch commented 9 years ago
In [8]: sol["sensitivities"]["monomials"]
Out[8]: 
array([ -6.43804454e-13,   0.00000000e+00,   0.00000000e+00,
        -1.19093776e-12,   0.00000000e+00,  -2.49435817e-43,
         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
         0.00000000e+00,   0.00000000e+00,   3.09892153e-30,
         3.09892153e-30,   5.88863184e-25,   0.00000000e+00,
        -5.16486921e-31,  -5.16486921e-31,   0.00000000e+00,
         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
         0.00000000e+00,   0.00000000e+00,  -1.46397018e-27,
        -6.48329649e-27,  -8.36554386e-28,  -4.18277193e-27,
         0.00000000e+00,   0.00000000e+00,   1.06393837e-41,
        -1.55418443e-26,   3.48969478e-32,   0.00000000e+00,
         0.00000000e+00,   1.38777878e-17,  -1.38777878e-17,
         0.00000000e+00,   0.00000000e+00,  -2.08166817e-17,
        -2.88889492e-34,   0.00000000e+00,   0.00000000e+00,
         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
         0.00000000e+00,   9.58599726e-26,   4.46815747e-30,
         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
         0.00000000e+00,   0.00000000e+00,  -1.00000000e+00,
        -5.42101086e-20,  -5.42101086e-20,   0.00000000e+00,
         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
         0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
         0.00000000e+00,   0.00000000e+00,   8.93458161e-30,
         0.00000000e+00,  -5.17848350e-26,   0.00000000e+00,
        -5.18205733e-26,  -1.03609876e-25,   6.43804454e-13])
bqpd commented 9 years ago

gosh those are small. What's m.program.gps[-1].result?

pgkirsch commented 9 years ago
{'cost': 154497.29714554103,
 'sensitivities': {'monomials': array([ -2.75749562e-12,  -0.00000000e+00,  -0.00000000e+00,
          -5.10049208e-12,  -0.00000000e+00,  -1.82947098e-41,
          -0.00000000e+00,  -0.00000000e+00,   0.00000000e+00,
          -0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          -0.00000000e+00,   5.30876601e-29,   5.30876601e-29,
           1.07999157e-23,   0.00000000e+00,  -6.63595751e-30,
          -6.63595751e-30,  -0.00000000e+00,   0.00000000e+00,
           0.00000000e+00,  -0.00000000e+00,  -0.00000000e+00,
           0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
           0.00000000e+00,  -1.18758274e-25,  -1.18758274e-25,
          -0.00000000e+00,  -0.00000000e+00,   0.00000000e+00,
          -2.85052145e-25,   4.48381317e-31,  -0.00000000e+00,
          -0.00000000e+00,  -0.00000000e+00,  -0.00000000e+00,
          -0.00000000e+00,  -0.00000000e+00,  -0.00000000e+00,
          -9.56339773e-30,  -0.00000000e+00,  -0.00000000e+00,
           0.00000000e+00,  -0.00000000e+00,  -0.00000000e+00,
          -0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
           0.00000000e+00,   0.00000000e+00,   1.75783860e-24,
          -0.00000000e+00,   0.00000000e+00,  -0.00000000e+00,
           0.00000000e+00,   0.00000000e+00,  -1.00000000e+00,
          -5.42101086e-20,  -5.42101086e-20,   0.00000000e+00,
          -0.00000000e+00,  -0.00000000e+00,  -0.00000000e+00,
           0.00000000e+00,  -0.00000000e+00,   0.00000000e+00,
          -0.00000000e+00,  -0.00000000e+00,   0.00000000e+00,
          -0.00000000e+00,  -0.00000000e+00,   0.00000000e+00,
          -0.00000000e+00,  -0.00000000e+00,  -6.89115431e-13,
          -0.00000000e+00,  -0.00000000e+00,   0.00000000e+00,
           0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
           2.75749562e-12,  -9.50269464e-25,   0.00000000e+00,
          -9.50154660e-25,  -1.90064416e-24]),
  'posynomials': array([  1.00000000e+00,   0.00000000e+00,   0.00000000e+00,
           3.40047213e-01,   5.64288237e-03,   9.66447560e-02,
           0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
           0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
           0.00000000e+00,   1.19892311e-01,   1.25469544e-02,
           0.00000000e+00,   9.17383230e-03,   0.00000000e+00,
           9.66447560e-02,   0.00000000e+00,   1.59560421e-02,
           0.00000000e+00,   7.29151331e-03,   1.19892311e-01,
           1.19892311e-01,   0.00000000e+00,   6.87266974e-02,
           2.94937234e-02,   0.00000000e+00,   4.05169001e-02,
           0.00000000e+00,   1.20829912e-01,   0.00000000e+00,
           4.05169001e-01,   5.57407427e-02,   0.00000000e+00,
           2.86950720e-03,   0.00000000e+00,   5.28712355e-02,
           1.81636677e-02,   5.57407427e-02,   5.28712355e-02,
           5.57407427e-02,   7.72104460e-02,   1.32951189e-01,
           0.00000000e+00,   1.07832831e-03,   1.07832831e-03,
           4.14741656e-04,   1.07832831e-03,   0.00000000e+00,
           0.00000000e+00,   0.00000000e+00,   1.07832831e-03,
           1.07832831e-03,   1.07832831e-03,   1.07832831e-03,
           2.55410175e-01,   0.00000000e+00,   2.55410175e-01,
           1.30081681e-01,   0.00000000e+00,   5.13926653e-01,
           6.87538077e-02,   6.17189215e-01,   1.00000000e+00])},
 'variables': {Sbulk: 24.034149154114779,
  Qv: 100512.82051282057,
  Rfuse: 1.9558000002263172,
  plamv: 1.6000000000000001,
  qlamv: 1.3,
  plamcone: 1.3,
  Pfloor: 1180410.2936709684,
  Mfloor: 1035810.0326962738,
  n_{rows}: 31.0,
  lnose: 5.1799999999999997,
  lshell: 24.409400000000002,
  lcone: 4.5720000000000001,
  lfloor: 28.32100002783033,
  dRfuse: 0.38100000000000001,
  hfloor: 0.12700000000000003,
  Afuse: 12.017074577057395,
  Askin: 0.012830299637153033,
  Afloor: 0.083120170973508739,
  xshell1: 5.1799999999999997,
  Wpadd: 62597.515513878796,
  W_{luggage}: 19923.584614751784,
  Winsul: 4556.7005528526806,
  Wfuse: 154497.29726983514,
  Wfloor: 20540.599307522163,
  Wwindow: 10618.089000000002,
  Wskin: 10290.576705148875,
  Wshell: 18523.038080683778,
  Wseat: 17885.004432536796,
  Wpay: 178850.04432536787,
  W_{pass}: 148926.45967892162,
  wfloor: 3.5099999999999993,
  Wcone: 166.59881310605837,
  Vnose: 0.051705981077816168,
  Wapu: 6259.7515513878725,
  Vcyl: 0.31317991596312328,
  Vfloor: 0.32513286081759979,
  Vcone: 0.0034943518016397638,
  tskin: 0.00098311546678042823,
  Vbulk: 0.023628343764317983,
  tshell: 0.0013272058801535778,
  tcone: 4.0426807930397913e-05,
  taucone: 103448275.86206895,
  sigx: 38314176.245210767,
  Snose: 52.594006324756897,
  sigth: 103448275.86206895,
  Sfloor: 590205.14683548419}}
bqpd commented 9 years ago

err lol. What's m.program.gps[-1]

pgkirsch commented 9 years ago
gpkit.GeometricProgram(
  # minimize
    Wfuse [N],
[ # subject to
    lnose*xshell1**-1 [-] <= 1,
    lnose**-1*xshell1 [-] <= 1,
    3.51*Rfuse**-1 [-] <= 1,
    0.381*dRfuse**-1 [-] <= 1,
    2*Askin**-1*dRfuse*tskin + 6.28*Askin**-1*Rfuse*tskin [-] <= 1,
    3.14*Afuse**-1*Rfuse**2 [-] <= 1,
    1.35*tshell**-1*tskin [-] <= 1,
    3.85e-05*Rfuse**-1*sigx*tshell [-] <= 1,
    2.6e+04*Rfuse*sigx**-1*tshell**-1 [-] <= 1,
    1.92e-05*Rfuse**-1*sigth*tskin [-] <= 1,
    5.2e+04*Rfuse*sigth**-1*tskin**-1 [-] <= 1,
    1.99e+03*Rfuse**-1*tskin [-] <= 1,
    0.000503*Rfuse*tskin**-1 [-] <= 1,
    12.6*Rfuse**1.6*Snose**-1.6*lnose**1.6 + 6.31*Rfuse**3.2*Snose**-1.6 [-] <= 1,
    0.159*Rfuse**-2*Sbulk [-] <= 1,
    6.28*Rfuse**2*Sbulk**-1 [-] <= 1,
    Askin**-1*Vcyl*lshell**-1 [-] <= 1,
    Askin*Vcyl**-1*lshell [-] <= 1,
    Snose**-1*Vnose*tskin**-1 [-] <= 1,
    Snose*Vnose**-1*tskin [-] <= 1,
    Sbulk**-1*Vbulk*tskin**-1 [-] <= 1,
    Sbulk*Vbulk**-1*tskin [-] <= 1,
    2.65e+04*Vbulk*Wskin**-1 + 2.65e+04*Vcyl*Wskin**-1 + 2.65e+04*Vnose*Wskin**-1 [-] <= 1,
    0.25*Wshell**-1*Wskin + 1.55*Wshell**-1*Wskin [-] <= 1,
    0.0023*Wwindow*lshell**-1 [-] <= 1,
    435*Wwindow**-1*lshell [-] <= 1,
    12.1*Sbulk*Winsul**-1 + 12.1*Snose*Winsul**-1 + 76*Rfuse*Winsul**-1*lshell [-] <= 1,
    28.6*Wapu*Wpay**-1 [-] <= 1,
    0.035*Wapu**-1*Wpay [-] <= 1,
    10*Wpay**-1*Wseat [-] <= 1,
    0.1*Wpay*Wseat**-1 [-] <= 1,
    2.86*Wpadd*Wpay**-1 [-] <= 1,
    0.35*Wpadd**-1*Wpay [-] <= 1,
    6*Pfloor**-1*Wpay + 6*Pfloor**-1*Wseat [-] <= 1,
    2*Pfloor**-1*Sfloor [-] <= 1,
    0.5*Pfloor*Sfloor**-1 [-] <= 1,
    4*Mfloor*Pfloor**-1*wfloor**-1 [-] <= 1,
    0.25*Mfloor**-1*Pfloor*wfloor [-] <= 1,
    5.18*lnose**-1 [-] <= 1,
    7.25e-09*Afloor**-1*Sfloor + 9.67e-09*Afloor**-1*Mfloor*hfloor**-1 [-] <= 1,
    7.87*hfloor [-] <= 1,
    2*Afloor*Rfuse*Vfloor**-1 [-] <= 1,
    2*Rfuse*lfloor**-1 + lfloor**-1*lshell [-] <= 1,
    120*Wfloor**-1*lfloor*wfloor + 2.65e+04*Vfloor*Wfloor**-1 [-] <= 1,
    1.22e-05*Qv*plamv**-1*qlamv [-] <= 1,
    8.17e+04*Qv**-1*plamv*qlamv**-1 [-] <= 1,
    1.03*plamv**-0.62*qlamv <= 1,
    1.6*plamv**-1 [-] <= 1,
    9.67e-09*taucone [-] <= 1,
    1.03e+08*taucone**-1 [-] <= 1,
    0.5*Afuse**-1*Qv*taucone**-1*tcone**-1 [-] <= 1,
    2*Afuse*Qv**-1*taucone*tcone [-] <= 1,
    2*Qv*Rfuse**-1*Vcone**-1*lcone*plamcone**-1*taucone**-1 [-] <= 1,
    4.57*lcone**-1 [-] <= 1,
    0.769*plamcone [-] <= 1,
    4.77e+04*Vcone*Wcone**-1 [-] <= 1,
    31*n_{rows}**-1 [-] <= 1,
    0.0323*n_{rows} [-] <= 1,
    0.787*lshell**-1*n_{rows} [-] <= 1,
    3.51*wfloor**-1 [-] <= 1,
    6.71e-06*W_{pass} [-] <= 1,
    1.49e+05*W_{pass}**-1 [-] <= 1,
    1.99e+04*W_{luggage}**-1 [-] <= 1,
    1e+04*Wpay**-1 + W_{luggage}*Wpay**-1 + W_{pass}*Wpay**-1 [-] <= 1,
    1.34e+04*Wfuse**-1 + Wapu*Wfuse**-1 + Wcone*Wfuse**-1 + Wfloor*Wfuse**-1 + Wfuse**-1*Winsul + Wfuse**-1*Wpadd + Wfuse**-1*Wseat + Wfuse**-1*Wshell + Wfuse**-1*Wwindow [-] <= 1,
])
bqpd commented 9 years ago

and the sensitivity to each of those is supposed to be 0? >:-/

what's that .solve()?

pgkirsch commented 9 years ago
{'cost': 210203.6311042389,
 'sensitivities': {'monomials': array([  1.00000000e+00,   0.00000000e+00,   0.00000000e+00,
           7.56483068e-01,   7.44327975e-03,   2.15425126e-01,
           7.44327975e-03,  -0.00000000e+00,  -0.00000000e+00,
           0.00000000e+00,  -0.00000000e+00,   0.00000000e+00,
          -0.00000000e+00,   0.00000000e+00,   2.95009589e-01,
           6.22431199e-03,   2.32037180e-02,   0.00000000e+00,
           3.54334393e-02,   0.00000000e+00,   2.22868406e-01,
           0.00000000e+00,   4.11636835e-02,   0.00000000e+00,
           3.09775001e-02,   4.11636835e-02,   3.09775001e-02,
           2.22868406e-01,   4.09735541e-02,   2.54036035e-01,
           0.00000000e+00,   5.05133472e-02,   3.09876931e-02,
           5.92116443e-03,   4.45593921e-03,   0.00000000e+00,
           2.97794644e-02,  -0.00000000e+00,   9.17682913e-02,
           0.00000000e+00,   2.97794644e-01,   6.68410728e-03,
           6.68410728e-02,   0.00000000e+00,   3.78504170e-03,
           0.00000000e+00,   6.97401384e-02,   3.71259488e-02,
           6.97401384e-02,   3.78504170e-03,   6.97401384e-02,
           7.35251801e-02,   4.89108548e-02,   1.40664744e-02,
           6.29773292e-02,   7.35251801e-02,   0.00000000e+00,
           4.41620286e-04,   4.41620286e-04,   1.69853956e-04,
           4.41620286e-04,   0.00000000e+00,   0.00000000e+00,
           0.00000000e+00,   4.41620286e-04,   4.41620286e-04,
           4.41620286e-04,   4.41620286e-04,   3.53280301e-01,
           0.00000000e+00,   3.53280301e-01,   1.32717468e-01,
           0.00000000e+00,   4.04839616e-01,   5.41599953e-02,
           2.71838609e-02,   5.41599953e-02,   4.04839616e-01,
           2.97794644e-02,   4.41620286e-04,   8.50841840e-02,
           5.05133472e-02,   6.35098449e-02,   1.36502509e-01,
           2.97794644e-01,   2.95009589e-01,   4.13647967e-02]),
  'posynomials': array([  1.00000000e+00,   0.00000000e+00,   0.00000000e+00,
           7.56483068e-01,   7.44327975e-03,   2.22868406e-01,
           0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
           0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
           0.00000000e+00,   2.95009589e-01,   2.94280300e-02,
           0.00000000e+00,   3.54334393e-02,   0.00000000e+00,
           2.22868406e-01,   0.00000000e+00,   4.11636835e-02,
           0.00000000e+00,   3.09775001e-02,   2.95009589e-01,
           2.95009589e-01,   0.00000000e+00,   5.05133472e-02,
           4.13647967e-02,   0.00000000e+00,   2.97794644e-02,
           0.00000000e+00,   9.17682913e-02,   0.00000000e+00,
           2.97794644e-01,   7.35251801e-02,   0.00000000e+00,
           3.78504170e-03,   0.00000000e+00,   6.97401384e-02,
           3.71259488e-02,   7.35251801e-02,   6.97401384e-02,
           7.35251801e-02,   6.29773292e-02,   1.36502509e-01,
           0.00000000e+00,   4.41620286e-04,   4.41620286e-04,
           1.69853956e-04,   4.41620286e-04,   0.00000000e+00,
           0.00000000e+00,   0.00000000e+00,   4.41620286e-04,
           4.41620286e-04,   4.41620286e-04,   4.41620286e-04,
           3.53280301e-01,   0.00000000e+00,   3.53280301e-01,
           1.32717468e-01,   0.00000000e+00,   4.04839616e-01,
           5.41599953e-02,   4.86183473e-01,   1.00000000e+00])},
 'variables': {Wskin: 34451.159365710191,
  Wshell: 62012.086858428796,
  Wseat: 17885.004429402448,
  Wpay: 178850.04429402438,
  W_{pass}: 148926.45967892162,
  Wpadd: 62597.51550290858,
  Winsul: 8695.0304668795889,
  W_{luggage}: 19923.584614751784,
  Wfuse: 210203.63110557903,
  Wfloor: 28693.323109543297,
  wfloor: 3.5099999999999993,
  Wcone: 92.830187666777633,
  Wapu: 6259.7515502908509,
  Vfloor: 0.58350359909608529,
  Vnose: 0.18148852373888313,
  Vcyl: 0.98261512144491103,
  Vcone: 0.0019470806992691935,
  Vbulk: 0.13657817478831194,
  tskin: 0.0017643600000007767,
  tshell: 0.0023818860000010479,
  tcone: 1.2551744835203809e-05,
  taucone: 103448275.86206895,
  Snose: 102.86365806230205,
  sigx: 38314176.245210767,
  Sfloor: 590205.14617484855,
  sigth: 103448275.86206895,
  Rfuse: 3.5100000000015465,
  Sbulk: 77.409471303051419,
  qlamv: 1.3,
  Qv: 100512.82051282057,
  plamcone: 1.3,
  plamv: 1.6000000000000001,
  n_{rows}: 31.0,
  Pfloor: 1180410.2923496971,
  lshell: 24.409400000000002,
  Mfloor: 1035810.0315368582,
  lcone: 4.5720000000000001,
  lnose: 5.1799999999999997,
  lfloor: 31.429400000358779,
  hfloor: 0.12700000000000003,
  dRfuse: 0.38100000000000001,
  Askin: 0.040255603228465713,
  Afuse: 38.704735651525709,
  Afloor: 0.083120170811371533,
  xshell1: 5.1799999999999997,
  Wwindow: 10618.089000000002}}
bqpd commented 9 years ago

Hmm, there's a few monomials with high sensitivities. Next step on this is to do the math to see what those variable sensitivities should be from that GP. (or which mmaps step the sensitivities go to 0 in; there's one in SP and one in SolutionArray, and I bet it's the one in SP)

bqpd commented 8 years ago

I think this is fixed in the newconstr_and_keydict branch

bqpd commented 8 years ago

Fixed in refactor, although note that the sensitivities returned are only guarantees about the shape of the local approximation, not about how much the value of the cost would change if the constant were changed. (these may be equivalent? @whoburg?)

whoburg commented 8 years ago

Good point @bqpd; we need to be careful and work out the math, but what I suspect we'll find is that these local sensitivities (which I assume @bqpd is pulling from the last GP approximation's sensitivities) ARE correct for the SP, but only locally. For small changes in the variable (for some value of small), the GP and SP are equivalent (for some value of equivalent), and so the sensitivities will be correct.

The size of the local area over which they are correct will depend on how strongly concave the function being locally-monomial-approximated is.

You can easily test with a simple example -- make an SP, find some sensitivity s in the output, multiply that constant by 1.001, and see if the new cost is approximately oldcost(1 + .001_s).

bqpd commented 8 years ago

577 is an interesting case here.