how to linearize:

if (m > 0)
  then c = 1
  else c = 0

thank you

c is binary
m is in [0,inf)

asked 21 Apr '16, 12:56

nardinebasta's gravatar image

nardinebasta
613
accept rate: 0%

edited 21 Apr '16, 13:54

fbahr's gravatar image

fbahr ♦
4.6k716

I kindly seek help for linearizing the following:

if(R>0) then T=aR+bL else T=L

where T,R,L are continuous in[0,1] a and b are variables to be optimized, where a+b=1

(24 Apr '17, 04:25) nardinebasta

It is not possible to do this exactly (at least not within a mixed integer linear program). The first problem is the feasible region corresponding to \(c=1\) is open, due to the strict inequality \(m>0\). So you must settle for either \(c\) being ambiguous (0 and 1 both feasible values) when \(m=0\) or \(c=1\) when \(m\ge \epsilon\) for some small but strictly positive \(\epsilon\).

The second problem is that the only way I know to linearize this requires a finite upper bound for \(m\). Moreover, if the upper bound is too large, the model can become numerically unstable. (How large is "too large" depends on the rest of the model, the precision of the solver, and to some extent just luck.)

To linearize "if \(m\ge\epsilon\) then \(c=1\) else \(c=0\)" when \(m\in [0, U]\) for some finite \(U\), follow the last part of my answer to your previous question ("converting composite conditional constraint to linear progrmming"), with the \(c_2\) there being your \(c\) here and the value 100 there being the upper bound \(U\) here.

link

answered 21 Apr '16, 15:45

Paul%20Rubin's gravatar image

Paul Rubin ♦♦
14.6k412
accept rate: 19%

edited 21 Apr '16, 15:46

here the other way around. when m(v,t) is 0, c(v,s,t) is for sure 0. when m >0 then if r(v,s,t)=m(v,t) then c(v,s,t)=1 else c(v,s,t)=0

m(v,t) is the maximum attraction a vehicle v could achieve at this time slot c(v,s,t) is a binary value signifying the attraction between a vehicle v and a location s is matching the maximum attraction the vehicle could achieve. r(v,s,t)is the relation attraction between a vehicle v and a location s at time t.

so i am not sure what I did is correct.

I treated the compound condition into two separate ones without any conjunction. i replaced the

if m(v,t) =0 then c(v,s,t) = 0.

by :

100*maximumAttraction(v,t)>=chosenLocation(v,s,t)

and

if r(v,s,t)=m(v,t) then c(v,s,t)=1.

by:

relationAttraction(v,s,t) - maximumAttraction(v,t) <= 100*(1-chosenLocation(v,s,t))
relationAttraction(v,s,t) - maximumAttraction(v,t) >=-100*(1-chosenLocation(v,s,t))

however I have noticed that the values of the variables to be optimized are highly affected by the lower and upper bounds values, the smaller the range, the more realistic the optimized values are, despite the fact that the value of the objective function does not change. i did not put and limit on the number of iterations for the solver.

link

answered 23 Apr '16, 15:30

nardinebasta's gravatar image

nardinebasta
613
accept rate: 0%

edited 23 Apr '16, 15:41

Your first constraint is correct (assuming that 100 is a large enough constant). Your second and third constraints actually enforce the converse of what you say you want: if c = 1 then r = m. Observe that r = m and c = 0 satisfies both of them.

(28 Apr '16, 16:09) Paul Rubin ♦♦

how to represent if (m=0) then c=0 where m in [0,1] and c is binary

(04 May '16, 11:17) nardinebasta
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:

×231
×190

Asked: 21 Apr '16, 12:56

Seen: 1,304 times

Last updated: 24 Apr '17, 04:25

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