implement optimize_iteratively()

close #7