Thanks for prompt reply Joel
I had tried to implement my cost function by dividing my curve into two pieces and implemented sort of piecewise regression of 2nd or 3rd order on both sides using if_else in casadi.
C2[0],C2[1],C[2] = Coeffecients of 2nd order regression for first part of curve
C2r[0],C2r[1],Cr[2] = Coeffecients of 2nd order regression for 2nd part of curve
f=if_else(x[A]>0,((C2[0]*x[A]**2)+(C2[1]*x[A])+C2[2]),((C2r[0]*x[A]**2)+(C2r[1]*x[A])+C2r[2]))
But spline itself make it piecewise between every two point which is working very efficiently in my situation. how can i implement this in casadi using if_else because i have only 29 pairs of data points and I can try to implement it
Kind regards