That is a bad idea.
You want to adjust your objective function in an optimization, based on iteration count, or some other information? Essentially, this creates an objective function that is not a continuous function. Worse, it is not even repeatable, so called a second time at the same location, you won't even return the same value? A really bad idea. And it invalidates the assumptions in essentially any optimization tool.