trial SQP code