Here’s a thread which explains one way to get negative cost values in this assignment. But you are saying you don’t get a negative cost, so maybe that is not relevant.
But what do you mean by “this error” in that case then? Please show us the exception trace that you are actually getting.