Hello, @s-dorsher,
With the fact that you were getting a previous cost value, I am afraid you might just have been assigning that value to d['costs']. Check for the spelling of the variable names returned by optimize in your model().
d['costs'] takes costs.
Cheers!
Raymond