Closed pgkirsch closed 8 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.
What is the sol["sensitivities"]["monomials"]
in the SP example?
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])
gosh those are small. What's m.program.gps[-1].result?
{'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}}
err lol. What's m.program.gps[-1]
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,
])
and the sensitivity to each of those is supposed to be 0? >:-/
what's that .solve()?
{'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}}
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)
I think this is fixed in the newconstr_and_keydict branch
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?)
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).
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
The GP