Absolute Value in optimization expression

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

Antworten (2)

Torsten
Torsten am 4 Feb. 2019
Bearbeitet: Torsten am 4 Feb. 2019

1 Stimme

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".
Sean de Wolski
Sean de Wolski am 1 Feb. 2019
Bearbeitet: Sean de Wolski am 1 Feb. 2019

0 Stimmen

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

Kategorien

Gefragt:

am 1 Feb. 2019

Bearbeitet:

am 4 Feb. 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by