Switched scipy optimize functions