Question: how to jacobian this function which has max when meet error

got an error when try to jacobian this

with(VectorCalculus):
f1 := -2*x1-x2; f2 := -x1-4*x2; g1 := 2*x1+3*x2-6; g2 := -x1; g3 := -x2;
penalty := lambda1*max(f1-M,0) + lambda2*max(f2-M,0) + (M^2)*(max(g1,0) + max(g2,0) + max(g3,0)):
obj := eval(penalty,[lambda1=3,lambda2=0.645,M=1]);
Hf := Jacobian(Jacobian(obj, [x1, x2, x3]), [x1, x2, x3]);

Error, invalid input: VectorCalculus:-Jacobian expects its 1st argument, f,
to be of type {Vector(algebraic), list(algebraic)}, but received 3*max(0, -2*x1-x2-1)+.645*max(0, -x1-4*x2-1)+max(0, 2*x1+3*x2-6)+max(0, -x1)+max(0, -x2)

 

Please Wait...