Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix exponents appearing and disappearing from the A matrix #1482

Merged
merged 1 commit into from
Mar 7, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions gpkit/constraints/sgp.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,18 @@ def gp(self, x0=None, *, cleanx0=False):
self._gp.exps[m_idx + i] = exp
self._gp.cs[m_idx + i] = c
for var, x in exp.items():
row_idx = a_idxs.pop() # modify a particular A entry
self._gp.A.row[row_idx] = m_idx + i
self._gp.A.col[row_idx] = self._gp.varidxs[var]
self._gp.A.data[row_idx] = x
try: # modify a particular A entry
row_idx = a_idxs.pop()
self._gp.A.row[row_idx] = m_idx + i
self._gp.A.col[row_idx] = self._gp.varidxs[var]
self._gp.A.data[row_idx] = x
except IndexError: # numbers of exps increased
self.a_idxs[p_idx].append(len(self._gp.A.row))
self._gp.A.row.append(m_idx + i)
self._gp.A.col.append(self._gp.varidxs[var])
self._gp.A.data.append(x)
for row_idx in a_idxs: # number of exps decreased
self._gp.A.row[row_idx] = 0 # zero out this entry
self._gp.A.col[row_idx] = 0
self._gp.A.data[row_idx] = 0
return self._gp