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

IndexError during SGP A-matrix modification #1480

Closed
1ozturkbe opened this issue Mar 7, 2020 · 16 comments · Fixed by #1482
Closed

IndexError during SGP A-matrix modification #1480

1ozturkbe opened this issue Mar 7, 2020 · 16 comments · Fixed by #1482

Comments

@1ozturkbe
Copy link
Contributor

This is breaking SPaircraft atm. Why * before the args=None?

@1ozturkbe
Copy link
Contributor Author

oy, everything is breaking now @bqpd, even localsolve.

C:\Users\Berk\Dropbox (MIT)\MIT Graduate School\Code\SPaircraft>python3 SPaircraft.py
Starting a sequence of GP solves
 for 317 free variables
  in 136 locally-GP constraints
  and for 1208 free variables
       in 4725 posynomial inequalities.

GP Solve 1
Using solver 'mosek_cli'
 for 1208 free variables
  in 4725 posynomial inequalities.
Solving took 0.641 seconds.
Solved cost was 3.774e+40.
Traceback (most recent call last):
  File "SPaircraft.py", line 97, in <module>
    sol = test()
  File "SPaircraft.py", line 89, in test
    sol = optimize_aircraft(m, substitutions, fixedBPR, pRatOpt, mutategparg)
  File "SPaircraft.py", line 65, in optimize_aircraft
    sol = m_relax.localsolve(verbosity=2, iteration_limit=200, reltol=0.01, mutategp=mutategparg)#, x0 = x0)
  File "c:\users\berk\dropbox (mit)\mit graduate school\code\gpkit\gpkit\constraints\prog_factories.py", line 126, in solvefn
    result = progsolve(solver, verbosity=verbosity, **solveargs)
  File "c:\users\berk\dropbox (mit)\mit graduate school\code\gpkit\gpkit\constraints\sgp.py", line 151, in localsolve
    gp = self.gp(x0, cleanx0=True)
  File "c:\users\berk\dropbox (mit)\mit graduate school\code\gpkit\gpkit\constraints\sgp.py", line 232, in gp
    row_idx = a_idxs.pop()  # modify a particular A entry
IndexError: pop from empty list

@bqpd
Copy link
Contributor

bqpd commented Mar 7, 2020

it passes tests! :p

@bqpd
Copy link
Contributor

bqpd commented Mar 7, 2020

oops no it doesn't. Forgot it got removed from tests in gpkitmodels

@1ozturkbe
Copy link
Contributor Author

lol yes, good catch.

@bqpd
Copy link
Contributor

bqpd commented Mar 7, 2020

New commit sets the A matrix directly; looks like there's a constraint which changes its number of variables/monomials during run. Will find out which...

@1ozturkbe
Copy link
Contributor Author

tbh, that was my fault for not fixing SPaircraft sooner.

@1ozturkbe
Copy link
Contributor Author

Interesting... I wonder which constraint it is...

@bqpd
Copy link
Contributor

bqpd commented Mar 7, 2020

it's in gpkit.SignomialInequality((π + 2·Mission.Aircraft.Fuselage.\theta_{db} + 2·Mission.Aircraft.Fuselage.\theta_{db}·(1 - Mission.Aircraft.Fuselage.\theta_{db}²/2))·Mission.Aircraft.Fuselage.R_{fuse}² + 2·Mission.Aircraft.Fuselage.\Delta R_{fuse}·Mission.Aircraft.Fuselage.R_{fuse} <= Mission.Aircraft.Fuselage.A_{fuse} that the error occurs

@bqpd
Copy link
Contributor

bqpd commented Mar 7, 2020

on the second local gp

@bqpd
Copy link
Contributor

bqpd commented Mar 7, 2020

for the 1st GP it's

gpkit.PosynomialInequality(2·Mission.Aircraft.Fuselage.R_{fuse}·Mission.Aircraft.Fuselage.\Delta R_{fuse} + 3.14·Mission.Aircraft.Fuselage.R_{fuse}² + 4·Mission.Aircraft.Fuselage.R_{fuse}²·Mission.Aircraft.Fuselage.\theta_{db} <= 2·Mission.Aircraft.Fuselage.A_{fuse}^0.5·Mission.Aircraft.Fuselage.R_{fuse}·Mission.Aircraft.Fuselage.\theta_{db}^1.5
for the 2nd:

gpkit.PosynomialInequality(2·Mission.Aircraft.Fuselage.R_{fuse}·Mission.Aircraft.Fuselage.\Delta R_{fuse} + 3.14·Mission.Aircraft.Fuselage.R_{fuse}² + 4·Mission.Aircraft.Fuselage.R_{fuse}²·Mission.Aircraft.Fuselage.\theta_{db} <= 1.01·Mission.Aircraft.Fuselage.A_{fuse}^1·Mission.Aircraft.Fuselage.R_{fuse}^0.0016·Mission.Aircraft.Fuselage.\theta_{db}^0.0024)

@bqpd
Copy link
Contributor

bqpd commented Mar 7, 2020

It appears the problem is that R_{fuse} has no exponent in the posylt1 of the first version, because it divides out between the first two sides (lt exp: 1, gt exp: 1), but it does not divide out in the second (lt exp: 1, gt exp: 0.0016)

@1ozturkbe
Copy link
Contributor Author

Oy, seems like a small bug. Also, I wonder why this is not a valid thing to ask GPkit.

m_gpapprox = m.gp(None)

gives me an error. Is this expected behavior?

@bqpd
Copy link
Contributor

bqpd commented Mar 7, 2020

uh, that should work. MWE?

@1ozturkbe
Copy link
Contributor Author

Sure, I'll make a new issue.

@bqpd
Copy link
Contributor

bqpd commented Mar 7, 2020

fixed! will put up PR soon. SPaircraft is soooo much faster and seems to solve with mosek_conif now

@1ozturkbe
Copy link
Contributor Author

I fixed it on Monday :P

@bqpd bqpd changed the title * in ConstantsRelaxed should be after include_only and exclude. IndexError during SGP A-matrix modification Mar 7, 2020
@bqpd bqpd closed this as completed in #1482 Mar 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants