Changing the cost function

If you want to change the cost function without solver parameters, you have to use either LINEAR_LS or NONLINEAR_LS cost formulations.
Then you can update the weight matrix W and the reference vector y_ref at each shooting node individually.