MATLAB Answers

0

Absolute Value in optimization expression

Asked by Vinayak Suresh on 1 Feb 2019
Latest activity Edited by Torsten
on 4 Feb 2019
How can I add an absolute value to an optimization expression I am trying to optimize? MATLAB shows the following error :
Undefined function 'abs' for input arguments of type 'optim.problemdef.OptimizationExpression'.
problem is :
minimize abs ( ax + by + cz - d )
subject to , x,y,z are integers in some range

  0 Comments

Sign in to comment.

2 Answers

Answer by Torsten
on 4 Feb 2019
Edited by Torsten
on 4 Feb 2019

min: eps
+ (a*x + b*y + c*z - d) - eps <= 0
- (a*x + b*y + c*z - d) - eps <= 0
subject to x,y,z are integers in some range with a new variable "eps".

  0 Comments

Sign in to comment.


Answer by Sean de Wolski
on 1 Feb 2019
Edited by Sean de Wolski
on 1 Feb 2019

Square it instead so as to not introduce a discontinuity
(expr).^2

  0 Comments

Sign in to comment.