construct optimizer with model