Skip to content

Commit

Permalink
Merge pull request #18 from cmccomb/master
Browse files Browse the repository at this point in the history
Fixing bug where self.car is set directly from COTSCar
  • Loading branch information
cmccomb committed Jan 21, 2024
2 parents e0f0294 + 1783e72 commit 5b8325a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
11 changes: 6 additions & 5 deletions sae/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1055,10 +1055,10 @@ def set_param(self, i: int, val: int):
self.car.lia = attenuators.at[val, "length"]
elif i == 11:
self.cabin = val
self.car.hc = attenuators.at[val, "height"]
self.car.lc = attenuators.at[val, "width"]
self.car.wc = attenuators.at[val, "length"]
self.car.tc = attenuators.at[val, "thickness"]
self.car.hc = cabins.at[val, "height"]
self.car.lc = cabins.at[val, "width"]
self.car.wc = cabins.at[val, "length"]
self.car.tc = cabins.at[val, "thickness"]
elif i == 12:
self.front_tire_pressure = val
self.car.Pft = pressure.at[val, "pressure"]
Expand Down Expand Up @@ -1104,7 +1104,8 @@ def set_param(self, i: int, val: int):

def set_vec(self, vec: list[int]):
for i in range(17):
self.car.set_param(i, vec[i])
print(i, vec[i])
self.set_param(i, vec[i])

def get_param(self, i: int) -> int:
return self.vector[i]
Expand Down
12 changes: 12 additions & 0 deletions tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,18 @@ def test_feasible_generation_cots(self):
test_car.constraints_nonlin_ineq()
test_car.cost()

def test_hugh_bug(self):
carDesignVec = [12, 7, 6, 12, 9, 1, 0, 13, 9, 1, 39, 26, 2, 1, 33, 11, 4]
product = COTSCar()
print("COTSCar vec:", product.get_vec())
print("Car vec:", product.car.get_vec())
print("Cost: $", format(product.cost(), ",.2f"))
product.set_vec(carDesignVec)
print("COTSCar vec:", product.get_vec())
print("Car vec:", product.car.get_vec())
print("Cost: $", format(product.cost(), ",.2f"))
self.assertEqual(carDesignVec, product.get_vec())

def test_minimize_cots(self):
def round_x(x):
for i in range(len(x)):
Expand Down

0 comments on commit 5b8325a

Please sign in to comment.