There was an analyst here who explained Bakhmut. For however forlorn this battleground looks for the Ukrainian Army, they are still killing Russians in a 5-to-1 ratio (or better). They know they can grind away the Russians there; retreating has the risk of not finding a terrain with similar results.
Sorry to be so dour, but military analysts do look at things in this way. This analysis has logic as to why Ukraine is staying (for now). An emotional line in the sand is not the main reason.
If there was indeed a 10-to-1 ratio of some kind, the Russian army should be up to the Polish border by now. The Baltic countries would have been re-annexed in Russian provinces.
A political solution is not possible until there are few more battles.