convexengineering / gpkit

Geometric programming for engineers
http://gpkit.readthedocs.org
MIT License
206 stars 40 forks source link

Partial vector substitution #1531

Closed bqpd closed 3 years ago

bqpd commented 3 years ago

allows substitutions like m.substitutions[v[0,2:]] = 1 # or np.ones(v[0,2:].shape)

bqpd commented 3 years ago

test models please

bqpd commented 3 years ago

@pgkirsch what do you think of this feature's utility? It seems to me like something that should Just Work, so I'm willing to take the performance hit...but that's easy for me to say.

pgkirsch commented 3 years ago

@bqpd that seems helpful! This seems like it would further simplify the proposed aero changes?

I assume that syntax carries over to the setup method form?

def setup(self):
...
    substitutions = {
        v[0,2:]: 1,
    ...
    }

    return constraints, substitutions

I know I'm sort of pushing the envelope on some of these vector variable subs, but do you have other users with anything similar in use case?

bqpd commented 3 years ago

yup, carries over!

I think this is one of those things where people might have tried to use it, it didn't work, they found an alternative without mentioning...

pgkirsch commented 3 years ago

Awesome!

Have you profiled what the performance hit is for a large model? I can't imagine it's too significant, right?

bqpd commented 3 years ago

it was ~4% of the time in that function...don't remember exactly the timing in my test run, but no more than a couple hundredths of a second.

pgkirsch commented 3 years ago

Seems very tolerable!

bqpd commented 3 years ago

I'm just so used to making things quicker when I make changes to core classes :p

pgkirsch commented 3 years ago

Ha sorry!

bqpd commented 3 years ago

test models please