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's gravatar image

nardinebasta
613
accept rate: 0%

edited 06 Jan '18, 07:59

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

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.

link

answered 06 Jan '18, 16:14

Paul%20Rubin's gravatar image

Paul Rubin ♦♦
14.6k412
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
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • 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:

×65

Asked: 04 Jan '18, 08:07

Seen: 365 times

Last updated: 09 Jan '18, 07:28

OR-Exchange! Your site for questions, answers, and announcements about operations research.