Coverage for docs/source/examples/debug.py: 100%

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

17 statements  

1"Debug examples" 

2from gpkit import Variable, Model, units 

3 

4x = Variable("x", "ft") 

5x_min = Variable("x_min", 2, "ft") 

6x_max = Variable("x_max", 1, "ft") 

7y = Variable("y", "volts") 

8 

9m = Model(x/y, [x <= x_max, x >= x_min]) 

10m.debug() 

11 

12print("# Now let's try a model unsolvable with relaxed constants\n") 

13 

14m2 = Model(x, [x <= units("inch"), x >= units("yard")]) 

15m2.debug() 

16 

17print("# And one that's only unbounded\n") 

18 

19# the value of x_min was used up in the previous model! 

20x_min = Variable("x_min", 2, "ft") 

21m3 = Model(x/y, [x >= x_min]) 

22m3.debug() 

23 

24x_min = Variable("x_min", 2, "ft") 

25m4 = Model(x, [x >= x_min]) 

26m4.debug()