diff --git a/gpkit/constraints/gp.py b/gpkit/constraints/gp.py index 9edab6e91..9a2c3e2c7 100644 --- a/gpkit/constraints/gp.py +++ b/gpkit/constraints/gp.py @@ -290,8 +290,12 @@ def _generate_nula(self, solver_out): nu_by_posy = [nu[mi] for mi in self.m_idxs] solver_out["la"] = la = np.array([sum(nup) for nup in nu_by_posy]) elif "la" in solver_out: + la = np.ravel(solver_out["la"]) + if len(la) == len(self.hmaps) - 1: + # assume solver dropped the cost's sensitivity (always 1.0) + la = np.hstack(([1.0], la)) # solver gave us posynomial sensitivities, generate monomial ones - solver_out["la"] = la = np.ravel(solver_out["la"]) + solver_out["la"] = la z = np.log(self.cs) + self.A.dot(solver_out["primal"]) m_iss = [self.p_idxs == i for i in range(len(la))] nu_by_posy = [la[p_i]*np.exp(z[m_is])/sum(np.exp(z[m_is])) diff --git a/gpkit/nomials/math.py b/gpkit/nomials/math.py index 8ee42d36c..df54ebeeb 100644 --- a/gpkit/nomials/math.py +++ b/gpkit/nomials/math.py @@ -523,7 +523,7 @@ def __init__(self, left, right): self.meq_bounded = {} self._las = [] if self.unsubbed and len(self.varkeys) > 1: - exp, = list(self.unsubbed[0].hmap) + exp, = self.unsubbed[0].hmap for key, e in exp.items(): s_e = np.sign(e) ubs = frozenset((k, "upper" if np.sign(e) != s_e else "lower")