Skip to content

Commit

Permalink
ControlSignal: fix nonstateful cost function calls
Browse files Browse the repository at this point in the history
  • Loading branch information
kmantel committed Sep 11, 2019
1 parent cb7ad59 commit 422a679
Showing 1 changed file with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1069,24 +1069,27 @@ def compute_costs(self, intensity, execution_id=None):
intensity_cost = adjustment_cost = duration_cost = 0

if ControlSignalCosts.INTENSITY & cost_options:
intensity_cost = self.intensity_cost_function(intensity)
intensity_cost = self.intensity_cost_function(intensity, execution_id=execution_id)
self.parameters.intensity_cost._set(intensity_cost, execution_id)

if ControlSignalCosts.ADJUSTMENT & cost_options:
adjustment_cost = self.adjustment_cost_function(intensity_change)
adjustment_cost = self.adjustment_cost_function(intensity_change, execution_id=execution_id)
self.parameters.adjustment_cost._set(adjustment_cost, execution_id)

if ControlSignalCosts.DURATION & cost_options:
duration_cost = self.duration_cost_function(self.parameters.cost._get(execution_id))
duration_cost = self.duration_cost_function(self.parameters.cost._get(execution_id), execution_id=execution_id)
self.parameters.duration_cost._set(duration_cost, execution_id)

return max(
0.0,
self.combine_costs_function([
intensity_cost,
adjustment_cost,
duration_cost
])
self.combine_costs_function(
[
intensity_cost,
adjustment_cost,
duration_cost
],
execution_id=execution_id
)
)

@tc.typecheck
Expand Down

0 comments on commit 422a679

Please sign in to comment.