Yesterday I posted this question on Mathematics Stack Exchange. Except for the one upvote it didn't receive any attention. What is the problem with my question? Is it too vague? Should I better include an example? I am hesitating whether I should have posted the question on MathOverflow instead of this SE. Should I change the location of the question?
The mere fact that a question does not get much attention does not in itself mean the question is lacking. The subject you ask about is not one that gets that much attention in general on this site.
However, I feel your question is also quite broad and possibly a bit hard to parse. The introduction of $t$ is not quite transparent, but as it is not my field and I still can sort of get the point it should be fine. But it is still quite broad a question.
To ask this question on MO does not strike me as a good idea, for one thing as this type of mathematics is not that well-represented on MO either.
If I had this type of question I would ask it on the site for Computational Science. The point that the question is a bit broad rests though.
If you want some specific advice: try to focus the question a bit more, and ask it on that site.
I think the question is rather vague and would be improved by including an example. Right now, the answer would appear to be "Well, it depends on what $f$, $t$ and $g$ are" - which isn't a very compelling answer. I'd bet it also depends on the method you're using for numerical optimization. In any case, being more specific would make the question substantially more answerable.
Also, it's worth noting that not receiving much attention isn't necessarily because there's anything wrong with the question. Sometimes that's just how it is.
(And, I'm not a regular on MO, but it doesn't look like a question about research level mathematics; it seems somewhat elementary, just vague)