convexengineering / SPaircraft

Models for commercial aircraft design
http://spaircraft.readthedocs.org
25 stars 17 forks source link

Slicing State Model #12

Closed mayork closed 7 years ago

mayork commented 7 years ago

@bqpd this relates to https://github.com/hoburg/gpkit/issues/1038 and I'm wondering what your thoughts are. If you look at commit https://github.com/hoburg/d8/pull/11/commits/e2398511d7bf522874bdc701441fe7adfeb24084 you'll see I'm trying to slice the state model. However, there is no way to cleanly slice all of the constraints. It looks like (at line 362) state[0] returns the constraints but state[0][0] returns a single vectoized constraint not the first element of all the constraints. This seems counterintuitive to me and is presenting a pretty large problem. Is it possible we could change how the constraints are stored inside the vectorized model?

bqpd commented 7 years ago

Unfortunately we can't change this easily! It occurs because individual vectorized constraints are separate constraintsets. What you want can be accessed with

first constraints = [veccs[0] for veccs in state[0]]

and then you can modify the elements of first_constraints.

bqpd commented 7 years ago

If you're trying to access particular variables, you can also get m[varname][0] for each varname

mayork commented 7 years ago

ah gotcha. i was trying to access all the constraints at once. would it be difficult to write a small script that goes and pulls each constraint set out and slices that before repacking them into a single constraint set?

bqpd commented 7 years ago

transposed_constraints = [[veccs[i] for veccs in state[0]] for i in len(state[0][0])]

1ozturkbe commented 7 years ago

@mayork since the enginestate model works well now, are we done with this issue?

mayork commented 7 years ago

yep this can be closed, it's solved with the state linking method