# linearize the absolute value of a difference

 0 I would like to linearize the following : d=abs(c-r)  where c and r are continuous variables in [0,1] the objective function is to minimize d I tired d >=c-r d >= r - c  it doesn't seem to work properly. I get a lot of non basic values. what am i doing wrong asked 04 Jan '18, 08:07 nardinebasta 6●1●4 accept rate: 0% Have you tried typing "absolute value" in the search box? (04 Jan '18, 09:34) Paul Rubin ♦♦ thank you for your reply :) yes i did but wasn't successful in finding the solution (06 Jan '18, 08:00) nardinebasta Maybe this will work: $\begin{array}{l} \text{minimize} & d_1+d_2\\ \text{subject to:} \, & \left\{ \begin{array}{l} d_1-d_2+c-r=0 \\ d_1 \geq 0 \\ d_2 \geq 0 \end{array} \right. \end{array}$ (08 Jan '18, 15:44) Slavko

 0 I don't know what you mean by "get a lot of non-basic values". If minimizing $$d$$ is the full objective function (i.e., the objective function does not contain any other variables), your two constraints should suffice. answered 06 Jan '18, 16:14 Paul Rubin ♦♦ 14.6k●5●13 accept rate: 19% If $$c=0.1$$ & $$r=0.4$$ then $$d=0.3$$. And obviously If $$c=0.4$$ & $$r=0.1$$ then also $$d=0.3$$. All is OK. (09 Jan '18, 07:28) Slavko
 toggle preview community wiki

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "Title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported

Tags: