An object of name x is already attached to this model. If this is intended, consider using the anonymous construction syntax

Because your solution never satisfies your termination condition for the loop.

I suggest you take another look at the formulation, on paper, and think about your objective.