Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
AidenSwayne committed Nov 26, 2023
2 parents 2b5c5e3 + 7244db6 commit 718a519
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 77 deletions.
84 changes: 34 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,76 +5,60 @@ The test cases below are auto-generated by GitHub Actions every time a commit is
<!-- TEST CASE 1 -->
```python
Parameters given: 3 floor, 4 tile x length, 10 tile y length.
cost (measured in USD):
177831.9783197832

Cost (measured in USD): $296854.5

columns (measured in quantity):
Wood columns:
[[-0. -0. -0. -0. -0. -0. -0. -0. -0. -0.]
[-0. -0. -0. -0. -0. -0. -0. -0. -0. -0.]
[-0. -0. -0. -0. -0. -0. -0. -0. -0. -0.]
[-0. -0. -0. -0. -0. -0. -0. -0. -0. -0.]]
Steel columns:
[[3. 3. 3. 3. 3. 3. 3. 3. 3. 3.]
[3. 3. 3. 3. 3. 3. 3. 3. 3. 3.]
[3. 3. 3. 3. 3. 3. 3. 3. 3. 3.]
[3. 3. 3. 3. 3. 3. 3. 3. 3. 3.]]
aluminum columns needed: Sum([[-0.00 -0.00 ... -0.00 -0.00]
[-0.00 -0.00 ... -0.00 -0.00]
[-0.00 -0.00 ... -0.00 -0.00]
[-0.00 -0.00 ... -0.00 -0.00]], None, False)
Steel columns needed: Sum([[591.00 -0.00 ... -0.00 -0.00]
[-0.00 -0.00 ... -0.00 -0.00]
[-0.00 -0.00 ... -0.00 -0.00]
[-0.00 -0.00 ... -0.00 -0.00]], None, False)

carbon offsets (measured in acres):
350.4968383017163
Carbon offsets (measured in acres):
Slash pine acres: 1.0
```
<!-- END TEST CASE -->

<!-- TEST CASE 2 -->
```python
Parameters given: 5 floor, 2 tile x length, 3 tile y length.
cost (measured in USD):
44457.9945799458

Cost (measured in USD): $128674.9

columns (measured in quantity):
Wood columns:
[[-0. -0. -0.]
[-0. -0. -0.]]
Steel columns:
[[5. 5. 5.]
[5. 5. 5.]]
aluminum columns needed: Sum([[-0.00 -0.00 -0.00]
[-0.00 -0.00 -0.00]], None, False)
Steel columns needed: Sum([[985.00 -0.00 -0.00]
[-0.00 -0.00 -0.00]], None, False)

carbon offsets (measured in acres):
87.62420957542908
Carbon offsets (measured in acres):
Slash pine acres: 1.0
```
<!-- END TEST CASE -->

<!-- TEST CASE 3 -->
```python
Parameters given: 1 floor, 10 tile x length, 10 tile y length.
cost (measured in USD):
148193.315266486

Cost (measured in USD): $228228.3

columns (measured in quantity):
Wood columns:
[[-0. -0. -0. -0. -0. -0. -0. -0. -0. -0.]
[-0. -0. -0. -0. -0. -0. -0. -0. -0. -0.]
[-0. -0. -0. -0. -0. -0. -0. -0. -0. -0.]
[-0. -0. -0. -0. -0. -0. -0. -0. -0. -0.]
[-0. -0. -0. -0. -0. -0. -0. -0. -0. -0.]
[-0. -0. -0. -0. -0. -0. -0. -0. -0. -0.]
[-0. -0. -0. -0. -0. -0. -0. -0. -0. -0.]
[-0. -0. -0. -0. -0. -0. -0. -0. -0. -0.]
[-0. -0. -0. -0. -0. -0. -0. -0. -0. -0.]
[-0. -0. -0. -0. -0. -0. -0. -0. -0. -0.]]
Steel columns:
[[1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]
[1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]
[1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]
[1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]
[1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]
[1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]
[1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]
[1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]
[1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]
[1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]]
aluminum columns needed: Sum([[-0.00 -0.00 ... -0.00 -0.00]
[-0.00 -0.00 ... -0.00 -0.00]
...
[-0.00 -0.00 ... -0.00 -0.00]
[-0.00 -0.00 ... -0.00 -0.00]], None, False)
Steel columns needed: Sum([[197.00 -0.00 ... -0.00 -0.00]
[-0.00 -0.00 ... -0.00 -0.00]
...
[-0.00 -0.00 ... -0.00 -0.00]
[-0.00 -0.00 ... -0.00 -0.00]], None, False)

carbon offsets (measured in acres):
292.0806985847636
Carbon offsets (measured in acres):
Slash pine acres: 1.0
```
<!-- END TEST CASE -->
63 changes: 36 additions & 27 deletions linear_program.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# import built-in
import sys
import random

# import external libraries
import cvxpy as cp

# 1000 is used a placeholder throughout the document for unknown values
Expand All @@ -10,60 +13,66 @@
# solve linear system
def calculate(floors=1, xLength=1, yLength=1):
# floors is the number of floors of the building
# xLength is the length of the building in tiles
# yLength is the width of the building in tiles
# xLength is the length of the building in square-meter tiles
# yLength is the width of the building in square-meter tiles

# create building layout
tiles = cp.Variable((xLength,yLength), integer = True)

# weight of each tile ceiling
# weight of each tile used on each floor
tileWeight = 1000

# create columns
woodColumns = cp.Variable((xLength,yLength), integer = True)
steelReinforcedColumns = cp.Variable((xLength,yLength), integer = True)
aluminumColumns = cp.Variable((xLength,yLength), integer = True)
steelColumns = cp.Variable((xLength,yLength), integer = True)

# create trees
# TODO: add more trees
slashPineAcres = cp.Variable(nonneg = True)
slashPineAcres = cp.Variable(integer = True)

# cost calculation
# page 3 of https://bugwoodcloud.org/bugwood/productivity/pdfs/SeriesPaper5.pdf for slash pine cost per acre
# cost calculation (measured in USD)
# page 3 of https://bugaluminumcloud.org/bugaluminum/productivity/pdfs/SeriesPaper5.pdf for slash pine cost per acre
cost = slashPineAcres*(55+110)
# cost of wood columns
cost += cp.sum(woodColumns)*1000
# cost of each tile
cost += 1000*xLength*yLength*floors
# cost of aluminum columns from https://www.homedepot.com/p/Afco-8-x-7-5-8-Endura-Aluminum-Column-Round-Shaft-Load-Bearing-21-000-lbs-Non-Tapered-Fluted-Gloss-White-EA0808ANFSATUTU/301315907
cost += cp.sum(aluminumColumns)*278
# cost of steel columns from https://web.archive.org/web/20161210125922/http://www.homedepot.com:80/p/Tiger-Brand-8-ft-to-8-ft-4-in-Adjustable-Steel-Building-Support-Column-3-in-O-D-3A-8084/202086528
cost += cp.sum(steelColumns)*64.90
# cost of each square-meter tile from https://www.forbes.com/home-improvement/home/cost-to-add-second-story/#:~:text=average%20of%20%24100%20to%20%24300%20per%20square%20foot
# middle figure of 200/square-foot taken, 200*10.7639 is the cost for a square-meter tile
cost += 2152.78*xLength*yLength*floors

# constraints
constraints = []

# CO2 constraint measured in metric tons
# slash pine figure from https://extension.psu.edu/carbon-accounting-in-forest-management#:~:text=100%2C000%20pounds%20carbon%20per%20acre%20%C3%B7%2045,tons%20of%20CO2%20emissions%20avoided
# steel-reinforced column figure from https://www.mdpi.com/1996-1073/6/11/5609#:~:text=As%20shown%20in%20Figure%205%2C%20the,in%20Yeo%20and%20Potra%20%5B18%5D.
constraints.append(cp.sum(steelReinforcedColumns)*485 + cp.sum(woodColumns)*1000 - slashPineAcres*166.05 <= 0)
# aluminum and steel column figures from https://www.wesa.fm/development-transportation/2017-08-31/aluminum-production-leaves-a-big-carbon-footprint-so-alcoa-is-adapting-with-sustainable-products#:~:text=For%20each%20ton%20of%20steel%20produced%2C%202%20tons%20of%20carbon%20is%20emitted.%20And%20for%20each%20ton%20of%20aluminum%2C%20the%20worldwide%20average%20is%2011.7%20tons%20of%20carbon%20emitted
# each aluminum column is 30 pounds, equivalent to 0.0136078, and 0.0136078*11.7 = 0.15921126
# each steel column is 35 pounds, equivalent to 0.0158757, and 0.0158757*2 = 0.0317514
constraints.append(cp.sum(steelColumns)*0.0317514 + cp.sum(aluminumColumns)*0.15921126 - slashPineAcres*166.05 <= 0)

# columns supporting each tile
for i in range(xLength):
for j in range(yLength):
constraints.append(woodColumns[i][j]*1000 + steelReinforcedColumns[i][j]*1000 >= floors*tileWeight)
# columns supporting each floor
# aluminum column support figure from https://www.homedepot.com/p/Afco-8-x-7-5-8-Endura-Aluminum-Column-Round-Shaft-Load-Bearing-21-000-lbs-Non-Tapered-Fluted-Gloss-White-EA0808ANFSATUTU/301315907#:~:text=bearing%20limit%20(lb.)-,21000,-Material
# 21000 pounds has been converted to metric tons
# steel column support figure from https://www.homedepot.com/p/Tiger-Brand-8-ft-to-8-ft-4-in-Adjustable-Steel-Building-Support-Column-3-in-O-D-3A-8084/202086528#:~:text=maximum%20extension%20(lb.)-,11200%20lb,-Maximum%20load%20at
# 11200 pounds has been converted to metric tons
constraints.append(cp.sum(aluminumColumns)*0.0317514 + cp.sum(steelColumns)*5.0802345 >= floors*tileWeight)

# nonnegativity
constraints.append(woodColumns >= 0)
constraints.append(steelReinforcedColumns >= 0)
constraints.append(aluminumColumns >= 0)
constraints.append(steelColumns >= 0)
constraints.append(slashPineAcres >= 0)

# create and solve problem
problem = cp.Problem(cp.Minimize(cost), constraints)
problem.solve(verbose = True)

logs.append("Parameters given: " + str(floors) + " floor, " + str(xLength) + " tile x length, " + str(yLength) + " tile y length.")
logs.append("cost (measured in USD):")
logs.append(cost.value)
logs.append("\nCost (measured in USD): $" + str(round(cost.value, 2)))
logs.append("\ncolumns (measured in quantity):")
logs.append("Wood columns:\n"+str(woodColumns.value))
logs.append("Steel columns:\n"+str(steelReinforcedColumns.value))
logs.append("\ncarbon offsets (measured in acres):")
logs.append(slashPineAcres.value)
logs.append("aluminum columns needed: "+str(cp.sum(aluminumColumns.value)))
logs.append("Steel columns needed: "+str(cp.sum(steelColumns.value)))
logs.append("\nCarbon offsets (measured in acres):")
logs.append("Slash pine acres: " + str(slashPineAcres.value))

# get arguments from command line
if len(sys.argv) == 4 or len(sys.argv) == 5:
Expand Down

0 comments on commit 718a519

Please sign in to comment.