# Coverage for docs/source/examples/simple_box.py: 100%

## 15 statements

, created at 2023-09-23 21:28 -0400

1"Maximizes box volume given area and aspect ratio constraints."

2from gpkit import Variable, Model

4# Parameters

5alpha = Variable("alpha", 2, "-", "lower limit, wall aspect ratio")

6beta = Variable("beta", 10, "-", "upper limit, wall aspect ratio")

7gamma = Variable("gamma", 2, "-", "lower limit, floor aspect ratio")

8delta = Variable("delta", 10, "-", "upper limit, floor aspect ratio")

9A_wall = Variable("A_{wall}", 200, "m^2", "upper limit, wall area")

10A_floor = Variable("A_{floor}", 50, "m^2", "upper limit, floor area")

12# Decision variables

13h = Variable("h", "m", "height")

14w = Variable("w", "m", "width")

15d = Variable("d", "m", "depth")

17# Constraints

18constraints = [A_wall >= 2*h*w + 2*h*d,

19 A_floor >= w*d,

20 h/w >= alpha,

21 h/w <= beta,

22 d/w >= gamma,

23 d/w <= delta]

25# Objective function

26V = h*w*d

27objective = 1/V # To maximize V, we minimize its reciprocal

29# Formulate the Model

30m = Model(objective, constraints)

32# Solve the Model and print the results table

33print(m.solve(verbosity=0).table())