Set up objective function