Coverage for docs\source\examples\x_greaterthan_1.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

8 statements  

1"Very simple problem: minimize x while keeping x greater than 1." 

2from gpkit import Variable, Model 

3 

4# Decision variable 

5x = Variable("x") 

6 

7# Constraint 

8constraints = [x >= 1] 

9 

10# Objective (to minimize) 

11objective = x 

12 

13# Formulate the Model 

14m = Model(objective, constraints) 

15 

16# Solve the Model 

17sol = m.solve(verbosity=0) 

18 

19# print selected results 

20print("Optimal cost: %.4g" % sol["cost"]) 

21print("Optimal x val: %.4g" % sol["variables"][x])