Hello,

I am trying to code in the following line which I want to minimize as the objective of the model

A:=sum(i in points,j in placement) (MAX((xij(i,j)*x(i)-xij(i,j+1)*x(i)),(xij(i,j)*y(i)-xij(i,j+1)*y(i))+MAX(abs(xij(i,1)*x(i)-Fx),abs(xij(i,1)*y(i)-Fy)))+MAX(abs(xij(i,16)*x(i)-Fx),abs(xij(i,16)*y(i)-Fy)))

However I am running into some problems with MAX and abs. These functions do not appear to allow me to have decision variables as part of the elements they are evaluating.

If anyone can confirm this that would be helpful. Any help in implementign the desired code as well would be great.

Thank you.

Hi,

The expression in its current form is highly nonlinear, for which you would in general need to use mmxnlp instead of mmxprs.

However 'A' looks like the combination of expressions that can be expressed in a linear from.

As you are minimizing, the MAX and ABS functions can be rewritten following these ideas:

Minimize abs(expression)is the same as

Minimize zexpression <= z- expression <= zMinimize Max( expression_1, …, expression_k )Is the same as

Minimize zexpression_1 <= z…expression_k <= zand z is free.

The critical question is the product of variables xij(I,j)*x(i), assuming they are indeed variables. Speculating from the expression, is it correct that xij are binary?

If so, the product can be rewritten (showing the xi >= 0 case) as

Replace xij(i,j)*x(i) with variable z >= 0 and add the following constraints:

z <= M*xij(i,j)z <= xi(i) + M (1- xij(i,j))z >= xi(i) - M (1- xij(i,j))Where M is sufficiently large. Now if xij(i,j) = 0 then the 3 equations become

z <= 0 (z = 0)z <= xi + M (redundant if M is large)z >= xi - M (redundant if M is large)On the other hand if xij(I,j) = 1 then the 3 equations become

z <= M (redundant if M is large)z <= xiz >= xi (together implying that z = xi)If the assumptions do not hold and the variables are general variables, the problem is a non-convex quadratic one and you would need a non-linear solver like Xpress-Nonlinear to solve it.