Coverage for docs\source\examples\vectorize.py: 0%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"Vectorization demonstration"
2from gpkit import Model, Variable, Vectorize
4class Test(Model):
5 """A simple scalar model
7 Upper Unbounded
8 ---------------
9 x
10 """
11 def setup(self):
12 x = self.x = Variable("x")
13 return [x >= 1]
15print("SCALAR")
16m = Test()
17m.cost = m["x"]
18print(m.solve(verbosity=0).summary())
20print("__________\n")
21print("VECTORIZED")
22with Vectorize(3):
23 m = Test()
24m.cost = m["x"].prod()
25m.append(m["x"][1] >= 2)
26print(m.solve(verbosity=0).summary())