Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
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())