Skip to content

Commit

Permalink
Fix most cost models
Browse files Browse the repository at this point in the history
  • Loading branch information
nielstron committed Jan 2, 2025
1 parent 883197e commit 67c7b21
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions uplc/cost_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def update_from_network_config(
f"{prefix}-arguments-constant", DEFAULT_COST_COEFF
)
self.model_above_equal_diagonal.update_from_network_config(
network_config, f"{prefix}-arguments-model"
network_config, f"{prefix}-arguments-model" if not isinstance(self.model_above_equal_diagonal, QuadraticInXAndY) else prefix
)

@dataclasses.dataclass
Expand Down Expand Up @@ -355,7 +355,8 @@ class QuadraticInXAndY(CostingFun):
minimum: int = 0

def cost(self, *memories: int, values=[]) -> int:
poly = self.c00 + self.c10 * memories[0] + self.c01 * memories[1] + + self.c20 * memories[0] ** 2 + self.c11 * memories[0] * memories[1] + self.c02 * memories[1] ** 2
x, y = memories[0], memories[1]
poly = self.c00 + self.c10 * x + self.c01 * y + + self.c20 * x * x + self.c11 * x * y + self.c02 * y * y
return max(poly, self.minimum)

@classmethod
Expand Down
2 changes: 1 addition & 1 deletion uplc/cost_model_files/base/builtinCostModel.json
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@
"type": "quadratic_in_x_and_y"
}
},
"type": "const_above_diagonal"
"type": "const_below_diagonal"
},
"memory": {
"arguments": {
Expand Down

0 comments on commit 67c7b21

Please sign in to comment.