Skip to content

Commit

Permalink
add readme edit
Browse files Browse the repository at this point in the history
  • Loading branch information
LiamSwayne committed Nov 21, 2023
1 parent 4765da6 commit 285cfbf
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions linear_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

# 1000 is used a placeholder throughout the document for unknown values

# info for README.md
logs = []

# solve linear system
def calculate(floors=1, xLength=1, yLength=1):
# floors is the number of floors of the building
Expand Down Expand Up @@ -49,13 +52,13 @@ def calculate(floors=1, xLength=1, yLength=1):
problem = cp.Problem(cp.Maximize(cost), constraints)
problem.solve(solver=cp.GUROBI,verbose = True)

print("cost (measured in USD):")
print(cost.value)
print("\ncolumns (measured in quantity):")
print(woodColumns.value)
print(steelReinforcedColumns.value)
print("\ncarbon offsets (measured in acres):")
print(slashPineAcres.value)
logs.append("cost (measured in USD):")
logs.append(cost.value)
logs.append("\ncolumns (measured in quantity):")
logs.append(woodColumns.value)
logs.append(steelReinforcedColumns.value)
logs.append("\ncarbon offsets (measured in acres):")
logs.append(slashPineAcres.value)

# get arguments from command line
if len(sys.argv) == 4:
Expand All @@ -70,4 +73,19 @@ def calculate(floors=1, xLength=1, yLength=1):
randomXLength = random.randint(1, 10)
randomYLength = random.randint(1, 10)
print("Running randomized values: floors=" + str(randomFloors) + " xLength=" + str(randomXLength) + " yLength=" + str(randomYLength))
calculate(randomFloors, randomXLength, randomYLength)
calculate(randomFloors, randomXLength, randomYLength)

# only run if it is a test case
if len(sys.argv) == 5:
testCaseNum = int(sys.argv[4])

# open the README.md file
file = open("./README.md", "r")
fileContents = file.read()

# locate case
startCaseIndex = fileContents.index("<!-- TEST CASE " + str(testCaseNum) + " -->")
endCaseIndex = fileContents.index("<!-- END TEST CASE -->")

newContents = fileContents[:startCaseIndex]
print(newContents)

0 comments on commit 285cfbf

Please sign in to comment.