An example household in Canada
A 65-year-old in Ontario with $900,000 saved, spending $56,000 a year to age 92, with investments earning 2% a year above inflation. The two results below differ only in which account each year's money comes out of, how much of the RRSP goes through a RRIF each year, and when CPP and OAS start.
The usual order is the rule of thumb you have probably read: spend the non-registered money first, then the RRSP, keep the TFSA for last, take the RRIF minimum, and start CPP and OAS at 65. On this household it leaves $98,483 less than the plan RetOpt found. Your result will differ.
Why the tax part is hard
Most retirement calculators apply an average tax rate to a projection. An average misses the income levels where one more dollar costs far more than the rate suggests. Above a threshold, every extra dollar of income costs a Canadian retiree 15 cents of their Old Age Security, on top of the tax on that dollar. A retiree on the Guaranteed Income Supplement can lose more than a dollar for every extra dollar they receive.
So RetOpt works out the actual tax return, every year, for your household: the federal and provincial tax, the credits you qualify for, the benefits that shrink as income rises, Ontario's extra tax on higher incomes, the health premiums and the other levies. Then it searches for the combination of choices that leaves the most after that tax, for every year of your plan, from your working years to the last year of retirement. How it works has the longer version.